noteAndViewpoint.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 global_title"> {{ 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 text_oneLine" v-for="(item, index) in detailDataForm.Docs" :key="index">
  20. <image :src="item.DocIcon"></image>
  21. {{ item.DocName }}
  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: $uni-bg-color;
  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. line-height: 46rpx;
  144. }
  145. .file-item {
  146. width: 100%;
  147. height: 42rpx;
  148. margin: 20rpx 0;
  149. display: flex;
  150. align-items: center;
  151. background-color: #f8f8fa;
  152. color: #376cbb;
  153. image {
  154. margin-right: 15rpx;
  155. width: 27rpx;
  156. height: 27rpx;
  157. }
  158. }
  159. .text-conten {
  160. font-size: 32rpx;
  161. line-height: 44rpx;
  162. }
  163. .image-conten {
  164. display: flex;
  165. flex-wrap: wrap;
  166. image {
  167. width: 144rpx;
  168. height: 144rpx;
  169. margin-right: 20rpx;
  170. }
  171. }
  172. .lable-conten {
  173. display: flex;
  174. flex-wrap: wrap;
  175. margin: 20rpx 0;
  176. font-size: 24rpx;
  177. .item {
  178. display: flex;
  179. align-items: center;
  180. height: 34rpx;
  181. border-radius: 44rpx;
  182. padding: 0 35rpx;
  183. background-color: #f0f1f3;
  184. margin: 0 20rpx 20rpx 0;
  185. }
  186. }
  187. .collect-conten {
  188. display: flex;
  189. justify-content: flex-end;
  190. align-items: center;
  191. color: #666666;
  192. image {
  193. width: 27rpx;
  194. height: 26rpx;
  195. padding: 10rpx;
  196. }
  197. }
  198. .author-name {
  199. display: flex;
  200. align-items: center;
  201. margin-bottom: 50rpx;
  202. .img-box {
  203. width: 48rpx;
  204. height: 48rpx;
  205. overflow: hidden;
  206. font-size: 28rpx;
  207. color: #333;
  208. image {
  209. width: 100%;
  210. height: 100%;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. </style>