detail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="content" :style="$store.state.theme.currentMoban">
  3. <u-navbar
  4. :title="item.title.length>12?item.title.slice(0,12)+'...':item.title"
  5. :autoBack="true"
  6. >
  7. </u-navbar>
  8. <view class="h140"></view>
  9. <view class="detail-cont">
  10. <view class="title">{{item.title}}</view>
  11. <view class="info">
  12. <view class="reads">阅读数:{{item.views}}</view>
  13. <view class="time">{{item.publishTime}}</view>
  14. </view>
  15. <!-- 正文 -->
  16. <view class="full-text">
  17. <view v-html="item.contents"></view>
  18. </view>
  19. </view>
  20. <!-- 最近阅读 -->
  21. <view class="recent-reads">
  22. <view class="left">
  23. <text class="label">最近阅读</text>
  24. <view class="peop-box" @click="showUsers">
  25. <view class="head-box">
  26. <view class="head" v-for="(subitem,j) in views" :key="j">
  27. <image :src="subitem.avatar==null?'../../static/images/detault_head.jpg':subitem.avatar" mode=""></image>
  28. </view>
  29. </view>
  30. <image class="arrow" src="../../static/images/arrow_gray.png" mode=""></image>
  31. </view>
  32. </view>
  33. <view class="share-btn">
  34. <image src="../../static/images/share.png" mode=""></image>
  35. <text>分享</text>
  36. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  37. </view>
  38. </view>
  39. <!-- 咨询按钮 -->
  40. <view class="inquiry">
  41. <view class="content">
  42. <image src="../../static/images/consult.png" mode=""></image>
  43. <text class="text">咨询</text>
  44. <button class="contact-btn" open-type="contact"></button>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {getArticleByArticleId,updateView} from '@/api/article'
  51. export default {
  52. data() {
  53. return {
  54. articleId:null,
  55. item:{},
  56. views:[],
  57. };
  58. },
  59. onLoad(option) {
  60. this.articleId=option.articleId;
  61. this.utils.isLogin().then(res => {
  62. if(res){
  63. this.updateView();
  64. }
  65. })
  66. uni.showShareMenu({
  67. withShareTicket:true,
  68. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  69. menus:["shareAppMessage","shareTimeline"] //不设置默认发送给朋友
  70. })
  71. },
  72. onShow() {
  73. this.getArticleByArticleId();
  74. },
  75. //发送给朋友
  76. onShareAppMessage(res) {
  77. return {
  78. title: this.item.title,
  79. path: '/pages/healthy/detail?articleId='+this.item.productId,
  80. imageUrl: this.item.imageUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  81. }
  82. },
  83. //分享到朋友圈
  84. onShareTimeline(res) {
  85. return {
  86. title: this.item.title,
  87. query:'articleId='+this.item.articleId,
  88. imageUrl: this.item.imageUrl //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  89. }
  90. },
  91. methods:{
  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. showUsers() {
  118. uni.navigateTo({
  119. url: './readUsers?articleId='+this.articleId
  120. })
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. page{
  127. height: 100%;
  128. }
  129. .content{
  130. height: 100%;
  131. display: flex;
  132. flex-direction: column;
  133. }
  134. .detail-cont{
  135. flex: 1;
  136. padding: 40upx;
  137. overflow-y: auto;
  138. .title{
  139. font-size: 40upx;
  140. font-family: PingFang SC;
  141. // font-weight: bold;
  142. color: #222222;
  143. line-height: 70upx;
  144. }
  145. .info{
  146. display: flex;
  147. align-items: center;
  148. font-size: 24upx;
  149. font-family: PingFang SC;
  150. font-weight: 500;
  151. color: #999999;
  152. line-height: 48upx;
  153. margin: 23upx 0;
  154. .reads{
  155. margin-right: 30upx;
  156. }
  157. }
  158. .full-text{
  159. font-size: 36upx;
  160. font-family: PingFang SC;
  161. // font-weight: 500;
  162. color: #222222;
  163. line-height: 60upx;
  164. }
  165. }
  166. .recent-reads{
  167. flex-shrink: 0;
  168. box-sizing: border-box;
  169. height: 121upx;
  170. background: #FFFFFF;
  171. border-top: 1px solid #F0F0F0;
  172. padding: 0 40upx 0 37upx;
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. .left{
  177. display: flex;
  178. align-items: center;
  179. .label{
  180. font-size: 28upx;
  181. font-family: PingFang SC;
  182. font-weight: 500;
  183. color: #666666;
  184. line-height: 1;
  185. margin-right: 20upx;
  186. }
  187. .peop-box{
  188. display: flex;
  189. align-items: center;
  190. .head-box{
  191. margin-right: 28upx;
  192. display: flex;
  193. align-items: center;
  194. .head{
  195. width: 48upx;
  196. height: 48upx;
  197. border-radius: 50%;
  198. overflow: hidden;
  199. box-shadow: 0 0 0 1px #fff;
  200. margin-right: -10upx;
  201. image{
  202. width: 100%;
  203. height: 100%;
  204. }
  205. }
  206. }
  207. .arrow{
  208. width: 13upx;
  209. height: 23upx;
  210. }
  211. }
  212. }
  213. .share-btn{
  214. position: relative;
  215. width: 240upx;
  216. height: 80upx;
  217. line-height: 80upx;
  218. font-size: 30upx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #FFFFFF;
  222. background: var(--base-color);
  223. border-radius: 40upx;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. image{
  228. width: 32upx;
  229. height: 32upx;
  230. margin-right: 15upx;
  231. }
  232. .share{
  233. position: absolute;
  234. width: 100%;
  235. height: 100%;
  236. opacity: 0;
  237. }
  238. }
  239. }
  240. .inquiry{
  241. width: 131upx;
  242. height: 131upx;
  243. position: fixed;
  244. right: 22upx;
  245. bottom: 193upx;
  246. z-index: 99;
  247. .content{
  248. position: relative;
  249. image{
  250. width: 100%;
  251. height: 100%;
  252. position: absolute;
  253. top: 0;
  254. left: 0;
  255. z-index: 9;
  256. }
  257. .text{
  258. position: absolute;
  259. top: 70upx;
  260. left: 50%;
  261. transform: translateX(-50%);
  262. z-index: 10;
  263. font-size: 22upx;
  264. font-family: PingFang SC;
  265. font-weight: bold;
  266. color: var(--base-color);
  267. line-height: 1;
  268. }
  269. }
  270. }
  271. .contact-btn{
  272. display: inline-block;
  273. position: absolute;
  274. top: 0;
  275. left: 0;
  276. width: 100%;
  277. height: 100%;
  278. opacity: 0;
  279. z-index: 9999;
  280. }
  281. </style>