articleDetails.vue 4.2 KB

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