detail.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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" @click="showUsers">
  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">
  28. <image src="../../static/images/share.png" mode=""></image>
  29. <text>分享</text>
  30. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  31. </view>
  32. </view>
  33. <!-- 咨询按钮 -->
  34. <view class="inquiry">
  35. <view class="content">
  36. <image src="../../static/images/consult.png" mode=""></image>
  37. <text class="text">咨询</text>
  38. <button class="contact-btn" open-type="contact"></button>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {getArticleByArticleId,updateView} from '@/api/article'
  45. export default {
  46. data() {
  47. return {
  48. articleId:null,
  49. item:{},
  50. views:[],
  51. };
  52. },
  53. onLoad(option) {
  54. this.articleId=option.articleId;
  55. this.utils.isLogin().then(res => {
  56. if(res){
  57. this.updateView();
  58. }
  59. })
  60. },
  61. onShow() {
  62. this.getArticleByArticleId();
  63. },
  64. methods:{
  65. updateView(){
  66. updateView(this.articleId).then(
  67. res => {
  68. },
  69. rej => {}
  70. );
  71. },
  72. getArticleByArticleId(){
  73. let data = {articleId:this.articleId};
  74. getArticleByArticleId(data).then(
  75. res => {
  76. if(res.code==200){
  77. this.item=res.data;
  78. this.views=res.views;
  79. }else{
  80. uni.showToast({
  81. icon:'none',
  82. title: "请求失败",
  83. });
  84. }
  85. },
  86. rej => {}
  87. );
  88. },
  89. // 查看阅读用户
  90. showUsers() {
  91. uni.navigateTo({
  92. url: './readUsers?articleId='+this.articleId
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. page{
  100. height: 100%;
  101. }
  102. .content{
  103. height: 100%;
  104. display: flex;
  105. flex-direction: column;
  106. }
  107. .detail-cont{
  108. flex: 1;
  109. padding: 40upx;
  110. overflow-y: auto;
  111. .title{
  112. font-size: 40upx;
  113. font-family: PingFang SC;
  114. // font-weight: bold;
  115. color: #222222;
  116. line-height: 70upx;
  117. }
  118. .info{
  119. display: flex;
  120. align-items: center;
  121. font-size: 24upx;
  122. font-family: PingFang SC;
  123. font-weight: 500;
  124. color: #999999;
  125. line-height: 48upx;
  126. margin: 23upx 0;
  127. .reads{
  128. margin-right: 30upx;
  129. }
  130. }
  131. .full-text{
  132. font-size: 36upx;
  133. font-family: PingFang SC;
  134. // font-weight: 500;
  135. color: #222222;
  136. line-height: 60upx;
  137. }
  138. }
  139. .recent-reads{
  140. flex-shrink: 0;
  141. box-sizing: border-box;
  142. height: 121upx;
  143. background: #FFFFFF;
  144. border-top: 1px solid #F0F0F0;
  145. padding: 0 40upx 0 37upx;
  146. display: flex;
  147. align-items: center;
  148. justify-content: space-between;
  149. .left{
  150. display: flex;
  151. align-items: center;
  152. .label{
  153. font-size: 28upx;
  154. font-family: PingFang SC;
  155. font-weight: 500;
  156. color: #666666;
  157. line-height: 1;
  158. margin-right: 20upx;
  159. }
  160. .peop-box{
  161. display: flex;
  162. align-items: center;
  163. .head-box{
  164. margin-right: 28upx;
  165. display: flex;
  166. align-items: center;
  167. .head{
  168. width: 48upx;
  169. height: 48upx;
  170. border-radius: 50%;
  171. overflow: hidden;
  172. box-shadow: 0 0 0 1px #fff;
  173. margin-right: -10upx;
  174. image{
  175. width: 100%;
  176. height: 100%;
  177. }
  178. }
  179. }
  180. .arrow{
  181. width: 13upx;
  182. height: 23upx;
  183. }
  184. }
  185. }
  186. .share-btn{
  187. position: relative;
  188. width: 240upx;
  189. height: 80upx;
  190. line-height: 80upx;
  191. font-size: 30upx;
  192. font-family: PingFang SC;
  193. font-weight: 500;
  194. color: #FFFFFF;
  195. background: #2BC7B9;
  196. border-radius: 40upx;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. image{
  201. width: 32upx;
  202. height: 32upx;
  203. margin-right: 15upx;
  204. }
  205. .share{
  206. position: absolute;
  207. width: 100%;
  208. height: 100%;
  209. opacity: 0;
  210. }
  211. }
  212. }
  213. .inquiry{
  214. width: 131upx;
  215. height: 131upx;
  216. position: fixed;
  217. right: 22upx;
  218. bottom: 193upx;
  219. z-index: 99;
  220. .content{
  221. position: relative;
  222. image{
  223. width: 100%;
  224. height: 100%;
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. z-index: 9;
  229. }
  230. .text{
  231. position: absolute;
  232. top: 70upx;
  233. left: 50%;
  234. transform: translateX(-50%);
  235. z-index: 10;
  236. font-size: 22upx;
  237. font-family: PingFang SC;
  238. font-weight: bold;
  239. color: #2BC7B9;
  240. line-height: 1;
  241. }
  242. }
  243. }
  244. .contact-btn{
  245. display: inline-block;
  246. position: absolute;
  247. top: 0;
  248. left: 0;
  249. width: 100%;
  250. height: 100%;
  251. opacity: 0;
  252. z-index: 9999;
  253. }
  254. </style>