articleDetails.vue 4.4 KB

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