reportDetail.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="container">
  3. <view class="pay-wall">
  4. <view class="title">
  5. {{ report.title }}
  6. </view>
  7. <!-- <text>需要付款才能看</text> -->
  8. </view>
  9. <!-- <web-view id="webview" :src="report.sourceFile">
  10. <cover-view class="close-view">
  11. <button>22222</button>
  12. </cover-view>
  13. </web-view> -->
  14. <view class="bottom-box">
  15. <view class="menu-box">
  16. <button class="menu-item" @click="changeApplaud">
  17. <i class="iconfont icon-dianzan" :class="report.hasApplaud?'active':''"></i>
  18. </button>
  19. <button class="menu-item" @click="changeFavi">
  20. <i class="iconfont icon-shoucang1" :class="report.hasFavi?'active':''"></i>
  21. </button>
  22. <button class="menu-item" open-type="share">
  23. <i class="iconfont icon-zhuanfa"></i>
  24. </button>
  25. <button class="menu-item">
  26. <i class="iconfont icon-pengyouquan"></i>
  27. </button>
  28. <button class="menu-item">
  29. <i class="iconfont icon-xiaoxi"></i>
  30. </button>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup>
  36. import {
  37. ref,
  38. computed,
  39. onMounted
  40. } from 'vue'
  41. import {
  42. onLoad,
  43. onShareAppMessage,
  44. onShareTimeline
  45. } from '@dcloudio/uni-app'
  46. import {
  47. getToken
  48. } from '@/utils/auth.js'
  49. import {
  50. getReportDetail,
  51. reportFavi,
  52. cancelReportFavi,
  53. reportApplaud,
  54. cancelReportApplaud
  55. } from '@/api/report.js'
  56. // import VueOfficePdf from '@vue-office/pdf'
  57. // const modelValue = ref('http://www.gzrea.org.cn/upload/news/2025/03/4128b87c1b0535772f345cf82fa04084431c17f2561a6fb3.pdf')
  58. // let previewOtherUpload = ref(false);
  59. const webview = ref();
  60. const id = ref()
  61. const title = ref()
  62. const hasPermission = ref(false);
  63. const imgurl = '/static/images/avator-img/1.png'
  64. const report = ref({
  65. id: '01',
  66. title: '2025年2月从化区二手住宅市场交易简报',
  67. summary: "2025年2月从化区二手住宅市场交易简报",
  68. price: '9.9',
  69. memberFree: 1,
  70. free: 0,
  71. status: 0,
  72. markdown: ``
  73. })
  74. const compileMarkDown = computed(() => {
  75. if (!report.value.markdown) {
  76. return;
  77. }
  78. let htmlString = "";
  79. // 判断markdown中代码块标识符的数量是否为偶数
  80. if (report.value.markdown.split("```").length % 2) {
  81. let content = report.value.markdown;
  82. if (content[content.length - 1] != "\n") {
  83. content += "\n";
  84. }
  85. htmlString = content;
  86. } else {
  87. htmlString = report.value.markdown;
  88. }
  89. return htmlString;
  90. })
  91. // 是否登录
  92. const isLogin = computed(() => {
  93. return false
  94. // return getToken() ? true : false
  95. })
  96. // 是否购买/免费
  97. const free = computed(() => {
  98. return false
  99. })
  100. const showMask = computed(() => {
  101. // 是否登录
  102. // 是否已购买或者免费
  103. if (report.value.status || report.value.free) {
  104. return false
  105. }
  106. // 判断用户是否为会员免费
  107. if (report.value.memberFree) {
  108. //
  109. }
  110. return false
  111. })
  112. function changeFavi() {
  113. if(report.value.hasFavi){
  114. cancelReportFavi(id.value).then(res=>{
  115. if(res?.code==0){
  116. report.value.hasFavi = false
  117. }
  118. })
  119. }else{
  120. reportFavi(id.value).then(res => {
  121. if(res?.code==0){
  122. report.value.hasFavi = true
  123. }
  124. })
  125. }
  126. }
  127. function changeApplaud(){
  128. if(report.value.hasApplaud){
  129. cancelReportApplaud(id.value).then(res=>{
  130. if(res?.code==0){
  131. report.value.hasApplaud = false
  132. }
  133. })
  134. }else{
  135. reportApplaud(id.value).then(res => {
  136. if(res?.code==0){
  137. report.value.hasApplaud = true
  138. }
  139. })
  140. }
  141. }
  142. onLoad((load) => {
  143. if(load.id){
  144. console.log(load.id)
  145. id.value = load.id
  146. title.value = load.title
  147. }
  148. getReportDetail(66).then(res => {
  149. // console.log(res, "报告详情")
  150. if (res.code === 0) {
  151. report.value = res.data
  152. }
  153. })
  154. uni.setNavigationBarTitle({
  155. title: title.value
  156. })
  157. })
  158. onMounted(()=>{
  159. console.log(uni.createSelectorQuery().select("#webview"))
  160. })
  161. onShareAppMessage((res) => {
  162. if (res.from === 'button') {
  163. console.log('来自按钮分享');
  164. }
  165. return {
  166. title: '研究报告',
  167. path: `/pages/reportDetail/reportDetail?id=${id.value}`,
  168. imageUrl: imgurl.value
  169. };
  170. })
  171. onShareTimeline(() => {
  172. return {
  173. title: '朋友圈标题-研究报告',
  174. query: `id=${id.value}`,
  175. imageUrl: imgurl.value
  176. };
  177. })
  178. </script>
  179. <style lang="scss" scoped>
  180. .container {
  181. height: 100vh;
  182. width: 100vw;
  183. background-color: $uni-bg-color;
  184. .title {
  185. font-size: 38rpx;
  186. text-align: center;
  187. width: 60%;
  188. margin: 0 auto;
  189. padding: 20rpx 0;
  190. }
  191. .content {
  192. padding: 0 20rpx;
  193. }
  194. .mask {
  195. height: 75vh;
  196. padding: 0 20rpx;
  197. background-color: $uni-bg-color-grey;
  198. -webkit-box-shadow: 0px -1rpx 5rpx 0px rgba(50, 50, 50, 0.25);
  199. -moz-box-shadow: 0px -1rpx 5rpx 0px rgba(50, 50, 50, 0.25);
  200. box-shadow: 0px -1rpx 5rpx 0px rgba(50, 50, 50, 0.25);
  201. border-radius: 20rpx 20rpx 0 0;
  202. @include bottomMagnet();
  203. .mask-box {
  204. height: 100%;
  205. width: 100%;
  206. position: relative;
  207. .button {
  208. margin: 0 auto;
  209. width: 45%;
  210. }
  211. }
  212. .member-box {
  213. padding-top: 210rpx;
  214. .remark {
  215. height: 90rpx;
  216. text-align: center;
  217. letter-spacing: 3rpx;
  218. font-size: 32rpx;
  219. color: $uni-text-color-grey;
  220. }
  221. .link {
  222. position: absolute;
  223. top: 70%;
  224. width: 100%;
  225. font-size: 32rpx;
  226. color: $uni-color-error;
  227. font-size: $uni-title-font-size-2;
  228. font-weight: bold;
  229. .text {
  230. text-align: center;
  231. letter-spacing: 5rpx;
  232. &:active {
  233. text-decoration: underline;
  234. }
  235. }
  236. }
  237. }
  238. .login-box {
  239. padding-top: 300rpx;
  240. }
  241. }
  242. .disable-scroll {
  243. position: fixed;
  244. top: 0;
  245. left: 0;
  246. width: 100%;
  247. height: 100%;
  248. }
  249. .bottom-block {
  250. height: 110rpx;
  251. }
  252. .bottom-box {
  253. padding: 5rpx 25rpx;
  254. background-color: $uni-bg-color-grey;
  255. @include bottomMagnet();
  256. -webkit-box-shadow: 0px -1rpx 5rpx 0px rgba(50, 50, 50, 0.25);
  257. -moz-box-shadow: 0px -1rpx 5rpx 0px rgba(50, 50, 50, 0.25);
  258. box-shadow: 0px -1rpx 5rpx 0px rgba(50, 50, 50, 0.25);
  259. .menu-box {
  260. height: 100rpx;
  261. display: flex;
  262. align-items: center;
  263. justify-content: flex-end;
  264. gap: 50rpx;
  265. .menu-item{
  266. background-color: transparent;
  267. margin: 0;
  268. border: none;
  269. padding: 0;
  270. }
  271. .menu-item::after{
  272. border: none !important;
  273. }
  274. .iconfont {
  275. font-size: 42rpx;
  276. color: $uni-text-color-grey;
  277. }
  278. .active {
  279. color: yellow;
  280. }
  281. }
  282. }
  283. }
  284. </style>