noteAndViewpoint.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="container note-and-viewpoint">
  3. <view class="content-item">
  4. <view class="author-name">
  5. <view class="img-box">
  6. <image :src="detailDataForm.HeadImg" @click="goDetailPages"></image>
  7. </view>
  8. <text style="margin-left: 10rpx">{{ detailDataForm.NickName }}</text>
  9. </view>
  10. <view class="type-time">
  11. <view class="type"> {{ detailDataForm.Type == 1 ? "笔 记" : "观 点" }} </view>
  12. <view class="time">{{ detailDataForm.PublishTime }}</view>
  13. </view>
  14. <view class="title-item"> {{ detailDataForm.Title }}</view>
  15. <view class="text-conten">
  16. <mp-html :content="detailDataForm.Content" />
  17. </view>
  18. <block v-if="detailDataForm.Docs && detailDataForm.Docs.length > 0">
  19. <view @click="goFilePages(item)" class="file-item" v-for="(item, index) in detailDataForm.Docs" :key="index">
  20. <image :src="item.DocIcon"></image>
  21. {{ item.DocName }}.{{ item.DocSuffix }}
  22. </view>
  23. </block>
  24. <view class="image-conten">
  25. <image v-for="key in dataProcessing(detailDataForm.ImgUrl)" :key="key" :src="key" @click="previewImageMediahandler(key)"></image>
  26. </view>
  27. <view class="lable-conten">
  28. <view class="item" v-for="key in dataProcessing(detailDataForm.Tags)" :key="key">{{ key }}</view>
  29. </view>
  30. <view class="collect-conten">
  31. <image @click="collectHandler(2)" v-if="detailDataForm.IsCollect == 1" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_act.png"></image>
  32. <image @click="collectHandler(1)" v-else src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/collect_icon.png"></image>
  33. {{ detailDataForm.CollectNum }}
  34. </view>
  35. </view>
  36. <Loading />
  37. </view>
  38. </template>
  39. <script>
  40. import { purchaserApi } from "@/config/api";
  41. export default {
  42. data() {
  43. return {
  44. detailDataForm: "",
  45. detailId: 0,
  46. };
  47. },
  48. methods: {
  49. previewImageMediahandler(key) {
  50. uni.previewImage({
  51. urls: [key], //查看图片的数组
  52. });
  53. },
  54. // 获取专栏详情
  55. async getDetaliData() {
  56. const res = await purchaserApi.yanxuanSpecialDetail({
  57. Id: this.detailId,
  58. });
  59. if (res.Ret === 200) {
  60. this.detailDataForm = res.Data;
  61. let str = this.detailDataForm.Type == 1 ? "笔记" : "观点";
  62. wx.setNavigationBarTitle({
  63. title: `${str}详情`,
  64. });
  65. }
  66. },
  67. // 数据处理
  68. dataProcessing(item) {
  69. return item ? item.split(",") : [];
  70. },
  71. // 收藏
  72. async collectHandler(type) {
  73. await this.$store.dispatch("checkHandle");
  74. if (!this.$store.state.isAuth && !this.$store.state.isBind) {
  75. const res = await purchaserApi.yanxuanSpecialCollect({
  76. Id: this.detailDataForm.Id,
  77. Status: type,
  78. });
  79. if (res.Ret === 200) {
  80. this.$util.toast(res.Msg);
  81. this.getDetaliData();
  82. }
  83. }
  84. },
  85. // 去往预览文件
  86. goFilePages(item) {
  87. wx.downloadFile({
  88. // 示例 url,并非真实存在
  89. url: item.DocUrl,
  90. success: function (res) {
  91. const filePath = res.tempFilePath;
  92. wx.openDocument({
  93. filePath: filePath,
  94. success: function (res) {
  95. console.log("打开文档成功");
  96. },
  97. });
  98. },
  99. });
  100. },
  101. goDetailPages() {
  102. uni.navigateTo({ url: "/pages-purchaser/columnDetail/columnDetail?id=" + this.detailDataForm.UserId });
  103. },
  104. },
  105. onLoad(options) {
  106. this.detailId = Number(options.id) || 0;
  107. this.detailId > 0 && this.getDetaliData();
  108. },
  109. /** 用户点击分享 */
  110. onShareAppMessage: function (res) {
  111. return {
  112. title: (this.detailDataForm.Type == 1 ? "笔记" : "观点") + "详情",
  113. path: "/pages-purchaser/noteAndViewpoint/noteAndViewpoint?id=" + this.detailId,
  114. };
  115. },
  116. };
  117. </script>
  118. <style lang="scss" scope>
  119. .note-and-viewpoint {
  120. padding: 30rpx;
  121. background: #f3f5f9;
  122. .content-item {
  123. padding: 40rpx;
  124. background-color: #fff;
  125. .type-time {
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. color: #666666;
  130. .type {
  131. width: 110rpx;
  132. height: 42rpx;
  133. line-height: 42rpx;
  134. text-align: center;
  135. border-radius: 38rpx;
  136. color: #928563;
  137. background-color: #fff6de;
  138. font-weight: 500;
  139. }
  140. }
  141. .title-item {
  142. margin: 10rpx 0 20rpx;
  143. color: #333;
  144. font-size: 32rpx;
  145. font-weight: 500;
  146. line-height: 46rpx;
  147. }
  148. .file-item {
  149. width: 100%;
  150. height: 42rpx;
  151. margin: 20rpx 0;
  152. display: flex;
  153. align-items: center;
  154. background-color: #f8f8fa;
  155. color: #376cbb;
  156. image {
  157. margin-right: 15rpx;
  158. width: 27rpx;
  159. height: 27rpx;
  160. }
  161. }
  162. .image-conten {
  163. display: flex;
  164. flex-wrap: wrap;
  165. image {
  166. width: 144rpx;
  167. height: 144rpx;
  168. margin-right: 20rpx;
  169. }
  170. }
  171. .lable-conten {
  172. display: flex;
  173. flex-wrap: wrap;
  174. margin: 20rpx 0;
  175. font-size: 24rpx;
  176. .item {
  177. display: flex;
  178. align-items: center;
  179. height: 34rpx;
  180. border-radius: 44rpx;
  181. padding: 0 35rpx;
  182. background-color: #f0f1f3;
  183. margin: 0 20rpx 20rpx 0;
  184. }
  185. }
  186. .collect-conten {
  187. display: flex;
  188. justify-content: flex-end;
  189. align-items: center;
  190. color: #666666;
  191. image {
  192. width: 27rpx;
  193. height: 26rpx;
  194. padding: 10rpx;
  195. }
  196. }
  197. .author-name {
  198. display: flex;
  199. align-items: center;
  200. margin-bottom: 50rpx;
  201. .img-box {
  202. width: 48rpx;
  203. height: 48rpx;
  204. overflow: hidden;
  205. font-size: 28rpx;
  206. color: #333;
  207. image {
  208. width: 100%;
  209. height: 100%;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. </style>