detail.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="content">
  3. <view class="detail-cont">
  4. <view class="title">{{item.title}}</view>
  5. <view class="info">
  6. <view class="reads">阅读数:{{item.views}}</view>
  7. <view class="time">{{item.publishTime}}</view>
  8. </view>
  9. <!-- 正文 -->
  10. <view class="full-text">
  11. <view v-html="item.contents"></view>
  12. </view>
  13. </view>
  14. <!-- 最近阅读 -->
  15. <view class="recent-reads">
  16. <view class="left">
  17. <text class="label">最近阅读</text>
  18. <view class="peop-box" >
  19. <view class="head-box">
  20. <view class="head" v-for="(subitem,j) in views" :key="j">
  21. <image :src="subitem.avatar==null?'/static/images/detault_head.jpg':subitem.avatar" mode=""></image>
  22. </view>
  23. </view>
  24. <image class="arrow" src="/static/images/arrow_gray.png" mode=""></image>
  25. </view>
  26. </view>
  27. <view class="share-btn" @click="openShare()">
  28. <image src="/static/images/share.png" mode=""></image>
  29. <text>分享</text>
  30. </view>
  31. </view>
  32. <u-popup :show="show" @close="closeShare" >
  33. <view class="share-content">
  34. <view class="share-inner">
  35. <view class="share-item">
  36. <image src="/static/images/icon_wx.png" mode=""></image>
  37. <text class="text">微信</text>
  38. </view>
  39. <view class="share-item">
  40. <image src="/static/images/icon_pyq.png" mode=""></image>
  41. <text class="text">朋友圈</text>
  42. </view>
  43. <view class="share-item">
  44. <image src="/static/images/icon_xcxhb.png" mode=""></image>
  45. <text class="text">小程序海报</text>
  46. </view>
  47. <view class="share-item">
  48. <image src="/static/images/icon_xccard.png" mode=""></image>
  49. <text class="text">小程序卡片</text>
  50. </view>
  51. <view class="share-item">
  52. <image src="/static/images/icon_code.png" mode=""></image>
  53. <text class="text">二维码</text>
  54. </view>
  55. <view class="share-item">
  56. <image src="/static/images/icon_copy_link.png" mode=""></image>
  57. <text class="text">复制链接</text>
  58. </view>
  59. </view>
  60. <view class="cancel-btn" @click="closeShare">取消</view>
  61. </view>
  62. </u-popup>
  63. </view>
  64. </template>
  65. <script>
  66. import {getArticleByArticleId,updateView} from '@/api/article'
  67. export default {
  68. data() {
  69. return {
  70. show:false,
  71. articleId:null,
  72. item:{},
  73. views:[],
  74. };
  75. },
  76. onLoad(option) {
  77. this.articleId=option.articleId;
  78. if(this.$isLogin()){
  79. this.updateView();
  80. }
  81. },
  82. onShow() {
  83. this.getArticleByArticleId();
  84. },
  85. methods:{
  86. openShare() {
  87. this.show = true
  88. },
  89. closeShare() {
  90. this.show = false
  91. },
  92. updateView(){
  93. updateView(this.articleId).then(
  94. res => {
  95. },
  96. rej => { }
  97. );
  98. },
  99. getArticleByArticleId(){
  100. let data = {articleId:this.articleId};
  101. getArticleByArticleId(data).then(
  102. res => {
  103. if(res.code==200){
  104. this.item=res.data;
  105. this.views=res.views;
  106. }else{
  107. uni.showToast({
  108. icon:'none',
  109. title: "请求失败",
  110. });
  111. }
  112. },
  113. rej => {}
  114. );
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. page{
  121. height: 100%;
  122. }
  123. .content{
  124. height: 100%;
  125. width: 100%;
  126. }
  127. .detail-cont{
  128. padding: 40upx 40upx 161rpx;
  129. overflow-y: auto;
  130. .title{
  131. font-size: 40upx;
  132. font-family: PingFang SC;
  133. // font-weight: bold;
  134. color: #222222;
  135. line-height: 70upx;
  136. }
  137. .info{
  138. display: flex;
  139. align-items: center;
  140. font-size: 24upx;
  141. font-family: PingFang SC;
  142. font-weight: 500;
  143. color: #999999;
  144. line-height: 48upx;
  145. margin: 23upx 0;
  146. .reads{
  147. margin-right: 30upx;
  148. }
  149. }
  150. .full-text{
  151. font-size: 36upx;
  152. font-family: PingFang SC;
  153. // font-weight: 500;
  154. color: #222222;
  155. line-height: 60upx;
  156. }
  157. }
  158. .recent-reads{
  159. width: 100%;
  160. position: fixed;
  161. bottom:0upx;
  162. left:0rpx;
  163. box-sizing: border-box;
  164. height: 121upx;
  165. background: #FFFFFF;
  166. border-top: 1px solid #F0F0F0;
  167. padding: 0 40upx 0 37upx;
  168. display: flex;
  169. align-items: center;
  170. justify-content: space-between;
  171. .left{
  172. display: flex;
  173. align-items: center;
  174. .label{
  175. font-size: 28upx;
  176. font-family: PingFang SC;
  177. font-weight: 500;
  178. color: #666666;
  179. line-height: 1;
  180. margin-right: 20upx;
  181. }
  182. .peop-box{
  183. display: flex;
  184. align-items: center;
  185. .head-box{
  186. margin-right: 28upx;
  187. display: flex;
  188. align-items: center;
  189. .head{
  190. width: 48upx;
  191. height: 48upx;
  192. border-radius: 50%;
  193. overflow: hidden;
  194. box-shadow: 0 0 0 1px #fff;
  195. margin-right: -10upx;
  196. image{
  197. width: 100%;
  198. height: 100%;
  199. }
  200. }
  201. }
  202. .arrow{
  203. width: 13upx;
  204. height: 23upx;
  205. }
  206. }
  207. }
  208. .share-btn{
  209. width: 240upx;
  210. height: 80upx;
  211. line-height: 80upx;
  212. font-size: 30upx;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. color: #FFFFFF;
  216. background: #2BC7B9;
  217. border-radius: 40upx;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. image{
  222. width: 32upx;
  223. height: 32upx;
  224. margin-right: 15upx;
  225. }
  226. .share{
  227. position: absolute;
  228. width: 100%;
  229. height: 100%;
  230. opacity: 0;
  231. }
  232. }
  233. }
  234. .share-content{
  235. background-color: #FFF;
  236. border-radius: 40upx 40upx 0px 0px;
  237. .share-inner{
  238. padding: 70upx 0 0 0;
  239. display: flex;
  240. flex-wrap: wrap;
  241. .share-item{
  242. width: 25%;
  243. display: flex;
  244. flex-direction: column;
  245. align-items: center;
  246. justify-content: center;
  247. margin-bottom: 66upx;
  248. image{
  249. width: 80upx;
  250. height: 80upx;
  251. margin-bottom: 20upx;
  252. }
  253. .text{
  254. font-size: 28upx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #111111;
  258. line-height: 1;
  259. }
  260. }
  261. }
  262. .cancel-btn{
  263. height: 96upx;
  264. line-height: 96upx;
  265. text-align: center;
  266. font-size: 32upx;
  267. font-family: PingFang SC;
  268. font-weight: 500;
  269. color: #111111;
  270. border-top: 2upx solid #E8E8E8;
  271. background-color: #FFF;
  272. }
  273. }
  274. </style>