detail.vue 6.4 KB

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