detail.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="content" :style="$store.state.theme.currentMoban">
  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. uni.showShareMenu({
  61. withShareTicket:true,
  62. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  63. menus:["shareAppMessage","shareTimeline"] //不设置默认发送给朋友
  64. })
  65. },
  66. onShow() {
  67. this.getArticleByArticleId();
  68. },
  69. //发送给朋友
  70. onShareAppMessage(res) {
  71. return {
  72. title: this.item.title,
  73. path: '/pages/healthy/detail?articleId='+this.item.productId,
  74. imageUrl: this.item.imageUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  75. }
  76. },
  77. //分享到朋友圈
  78. onShareTimeline(res) {
  79. return {
  80. title: this.item.title,
  81. query:'articleId='+this.item.articleId,
  82. imageUrl: this.item.imageUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  83. }
  84. },
  85. methods:{
  86. updateView(){
  87. updateView(this.articleId).then(
  88. res => {
  89. },
  90. rej => {}
  91. );
  92. },
  93. getArticleByArticleId(){
  94. let data = {articleId:this.articleId};
  95. getArticleByArticleId(data).then(
  96. res => {
  97. if(res.code==200){
  98. this.item=res.data;
  99. this.views=res.views;
  100. }else{
  101. uni.showToast({
  102. icon:'none',
  103. title: "请求失败",
  104. });
  105. }
  106. },
  107. rej => {}
  108. );
  109. },
  110. // 查看阅读用户
  111. showUsers() {
  112. uni.navigateTo({
  113. url: './readUsers?articleId='+this.articleId
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. page{
  121. height: 100%;
  122. }
  123. .content{
  124. height: 100%;
  125. display: flex;
  126. flex-direction: column;
  127. }
  128. .detail-cont{
  129. flex: 1;
  130. padding: 40upx;
  131. overflow-y: auto;
  132. .title{
  133. font-size: 40upx;
  134. font-family: PingFang SC;
  135. // font-weight: bold;
  136. color: #222222;
  137. line-height: 70upx;
  138. }
  139. .info{
  140. display: flex;
  141. align-items: center;
  142. font-size: 24upx;
  143. font-family: PingFang SC;
  144. font-weight: 500;
  145. color: #999999;
  146. line-height: 48upx;
  147. margin: 23upx 0;
  148. .reads{
  149. margin-right: 30upx;
  150. }
  151. }
  152. .full-text{
  153. font-size: 36upx;
  154. font-family: PingFang SC;
  155. // font-weight: 500;
  156. color: #222222;
  157. line-height: 60upx;
  158. }
  159. }
  160. .recent-reads{
  161. flex-shrink: 0;
  162. box-sizing: border-box;
  163. height: 121upx;
  164. background: #FFFFFF;
  165. border-top: 1px solid #F0F0F0;
  166. padding: 0 40upx 0 37upx;
  167. display: flex;
  168. align-items: center;
  169. justify-content: space-between;
  170. .left{
  171. display: flex;
  172. align-items: center;
  173. .label{
  174. font-size: 28upx;
  175. font-family: PingFang SC;
  176. font-weight: 500;
  177. color: #666666;
  178. line-height: 1;
  179. margin-right: 20upx;
  180. }
  181. .peop-box{
  182. display: flex;
  183. align-items: center;
  184. .head-box{
  185. margin-right: 28upx;
  186. display: flex;
  187. align-items: center;
  188. .head{
  189. width: 48upx;
  190. height: 48upx;
  191. border-radius: 50%;
  192. overflow: hidden;
  193. box-shadow: 0 0 0 1px #fff;
  194. margin-right: -10upx;
  195. image{
  196. width: 100%;
  197. height: 100%;
  198. }
  199. }
  200. }
  201. .arrow{
  202. width: 13upx;
  203. height: 23upx;
  204. }
  205. }
  206. }
  207. .share-btn{
  208. position: relative;
  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: var(--base-color);
  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. .inquiry{
  235. width: 131upx;
  236. height: 131upx;
  237. position: fixed;
  238. right: 22upx;
  239. bottom: 193upx;
  240. z-index: 99;
  241. .content{
  242. position: relative;
  243. image{
  244. width: 100%;
  245. height: 100%;
  246. position: absolute;
  247. top: 0;
  248. left: 0;
  249. z-index: 9;
  250. }
  251. .text{
  252. position: absolute;
  253. top: 70upx;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. z-index: 10;
  257. font-size: 22upx;
  258. font-family: PingFang SC;
  259. font-weight: bold;
  260. color: var(--base-color);
  261. line-height: 1;
  262. }
  263. }
  264. }
  265. .contact-btn{
  266. display: inline-block;
  267. position: absolute;
  268. top: 0;
  269. left: 0;
  270. width: 100%;
  271. height: 100%;
  272. opacity: 0;
  273. z-index: 9999;
  274. }
  275. </style>