articleDetails.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="detail-cont">
  5. <view class="title">{{item.title}}</view>
  6. <view class="info">
  7. <view class="reads">阅读数:{{item.views}}</view>
  8. <view class="time">{{item.publishTime}}</view>
  9. </view>
  10. <!-- 正文 -->
  11. <view class="full-text">
  12. <view v-html="item.contents"></view>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 分享弹窗 -->
  17. <u-popup :show="showShare" @close="showShare = false">
  18. <share-box :shareItem="shareItem" @closeShare='showShare = false'></share-box>
  19. </u-popup>
  20. <h5-down-app-tip :pageUrl="pageUrl" v-if="pageUrl" />
  21. </view>
  22. </template>
  23. <script>
  24. import {
  25. getArticleById
  26. } from '@/api/article'
  27. export default {
  28. data() {
  29. return {
  30. baseUrl: uni.getStorageSync('requestPath'),
  31. articleId: null,
  32. item: {},
  33. showShare: false,
  34. shareItem: {
  35. imageUrl: "",
  36. title: "",
  37. path: "",
  38. isMini: true,
  39. yyb: true
  40. },
  41. };
  42. },
  43. onLoad(option) {
  44. this.articleId = option.articleId;
  45. },
  46. onShow() {
  47. this.getArticleById();
  48. },
  49. //发送给朋友
  50. onShareAppMessage(res) {
  51. return {
  52. title: this.item.title,
  53. path: '/pages_index/articleDetails?articleId=' + this.articleId,
  54. }
  55. },
  56. //分享到朋友圈
  57. onShareTimeline(res) {
  58. return {
  59. title: this.item.title,
  60. query: 'articleId=' + this.articleId, //页面参数
  61. }
  62. },
  63. onNavigationBarButtonTap(e) {
  64. //#ifdef APP-PLUS
  65. this.shareItem.healthId = this.articleId;
  66. this.shareItem.title = this.item.title;
  67. this.shareItem.imageUrl = "../../static/logo.png";
  68. this.shareItem.isMini = true;
  69. this.shareItem.path = '/pages/article/articleDetails?articleId=' + this.articleId;
  70. let cdn = uni.getStorageSync('h5Path');
  71. this.showShare = true;
  72. //#endif
  73. },
  74. methods: {
  75. getArticleById() {
  76. let data = {
  77. articleId: this.articleId
  78. };
  79. getArticleById(data).then(
  80. res => {
  81. if (res.code == 200) {
  82. this.item = res.data;
  83. } else {
  84. uni.showToast({
  85. icon: 'none',
  86. title: "请求失败",
  87. });
  88. }
  89. },
  90. rej => {}
  91. );
  92. },
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. page {
  98. height: 100%;
  99. }
  100. .content {
  101. height: 100%;
  102. display: flex;
  103. flex-direction: column;
  104. }
  105. .detail-cont {
  106. flex: 1;
  107. padding: 40upx;
  108. overflow-y: auto;
  109. .title {
  110. font-size: 40upx;
  111. font-family: PingFang SC;
  112. // font-weight: bold;
  113. color: #222222;
  114. line-height: 70upx;
  115. }
  116. .info {
  117. display: flex;
  118. align-items: center;
  119. font-size: 24upx;
  120. font-family: PingFang SC;
  121. font-weight: 500;
  122. color: #999999;
  123. line-height: 48upx;
  124. margin: 23upx 0;
  125. .reads {
  126. margin-right: 30upx;
  127. }
  128. }
  129. .full-text {
  130. font-size: 36upx;
  131. font-family: PingFang SC;
  132. // font-weight: 500;
  133. color: #222222;
  134. line-height: 60upx;
  135. }
  136. }
  137. .recent-reads {
  138. flex-shrink: 0;
  139. box-sizing: border-box;
  140. height: 121upx;
  141. background: #FFFFFF;
  142. border-top: 1px solid #F0F0F0;
  143. padding: 0 40upx 0 37upx;
  144. display: flex;
  145. align-items: center;
  146. justify-content: space-between;
  147. .left {
  148. display: flex;
  149. align-items: center;
  150. .label {
  151. font-size: 28upx;
  152. font-family: PingFang SC;
  153. font-weight: 500;
  154. color: #666666;
  155. line-height: 1;
  156. margin-right: 20upx;
  157. }
  158. .peop-box {
  159. display: flex;
  160. align-items: center;
  161. .head-box {
  162. margin-right: 28upx;
  163. display: flex;
  164. align-items: center;
  165. .head {
  166. width: 48upx;
  167. height: 48upx;
  168. border-radius: 50%;
  169. overflow: hidden;
  170. box-shadow: 0 0 0 1px #fff;
  171. margin-right: -10upx;
  172. image {
  173. width: 100%;
  174. height: 100%;
  175. }
  176. }
  177. }
  178. .arrow {
  179. width: 13upx;
  180. height: 23upx;
  181. }
  182. }
  183. }
  184. .share-btn {
  185. position: relative;
  186. width: 240upx;
  187. height: 80upx;
  188. line-height: 80upx;
  189. font-size: 30upx;
  190. font-family: PingFang SC;
  191. font-weight: 500;
  192. color: #FFFFFF;
  193. background: #2583EB;
  194. border-radius: 40upx;
  195. display: flex;
  196. align-items: center;
  197. justify-content: center;
  198. image {
  199. width: 32upx;
  200. height: 32upx;
  201. margin-right: 15upx;
  202. }
  203. .share {
  204. position: absolute;
  205. width: 100%;
  206. height: 100%;
  207. opacity: 0;
  208. }
  209. }
  210. }
  211. </style>