articleDetails.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. }
  77. .content{
  78. height: 100%;
  79. display: flex;
  80. flex-direction: column;
  81. }
  82. .detail-cont{
  83. flex: 1;
  84. padding: 40upx;
  85. overflow-y: auto;
  86. .title{
  87. font-size: 40upx;
  88. font-family: PingFang SC;
  89. // font-weight: bold;
  90. color: #222222;
  91. line-height: 70upx;
  92. }
  93. .info{
  94. display: flex;
  95. align-items: center;
  96. font-size: 24upx;
  97. font-family: PingFang SC;
  98. font-weight: 500;
  99. color: #999999;
  100. line-height: 48upx;
  101. margin: 23upx 0;
  102. .reads{
  103. margin-right: 30upx;
  104. }
  105. }
  106. .full-text{
  107. font-size: 36upx;
  108. font-family: PingFang SC;
  109. // font-weight: 500;
  110. color: #222222;
  111. line-height: 60upx;
  112. }
  113. }
  114. .recent-reads{
  115. flex-shrink: 0;
  116. box-sizing: border-box;
  117. height: 121upx;
  118. background: #FFFFFF;
  119. border-top: 1px solid #F0F0F0;
  120. padding: 0 40upx 0 37upx;
  121. display: flex;
  122. align-items: center;
  123. justify-content: space-between;
  124. .left{
  125. display: flex;
  126. align-items: center;
  127. .label{
  128. font-size: 28upx;
  129. font-family: PingFang SC;
  130. font-weight: 500;
  131. color: #666666;
  132. line-height: 1;
  133. margin-right: 20upx;
  134. }
  135. .peop-box{
  136. display: flex;
  137. align-items: center;
  138. .head-box{
  139. margin-right: 28upx;
  140. display: flex;
  141. align-items: center;
  142. .head{
  143. width: 48upx;
  144. height: 48upx;
  145. border-radius: 50%;
  146. overflow: hidden;
  147. box-shadow: 0 0 0 1px #fff;
  148. margin-right: -10upx;
  149. image{
  150. width: 100%;
  151. height: 100%;
  152. }
  153. }
  154. }
  155. .arrow{
  156. width: 13upx;
  157. height: 23upx;
  158. }
  159. }
  160. }
  161. .share-btn{
  162. position: relative;
  163. width: 240upx;
  164. height: 80upx;
  165. line-height: 80upx;
  166. font-size: 30upx;
  167. font-family: PingFang SC;
  168. font-weight: 500;
  169. color: #FFFFFF;
  170. background: #018C39;
  171. border-radius: 40upx;
  172. display: flex;
  173. align-items: center;
  174. justify-content: center;
  175. image{
  176. width: 32upx;
  177. height: 32upx;
  178. margin-right: 15upx;
  179. }
  180. .share{
  181. position: absolute;
  182. width: 100%;
  183. height: 100%;
  184. opacity: 0;
  185. }
  186. }
  187. }
  188. .inquiry{
  189. width: 131upx;
  190. height: 131upx;
  191. position: fixed;
  192. right: 22upx;
  193. bottom: 193upx;
  194. z-index: 99;
  195. .content{
  196. position: relative;
  197. image{
  198. width: 100%;
  199. height: 100%;
  200. position: absolute;
  201. top: 0;
  202. left: 0;
  203. z-index: 9;
  204. }
  205. .text{
  206. position: absolute;
  207. top: 70upx;
  208. left: 50%;
  209. transform: translateX(-50%);
  210. z-index: 10;
  211. font-size: 22upx;
  212. font-family: PingFang SC;
  213. font-weight: bold;
  214. color: #018C39;
  215. line-height: 1;
  216. }
  217. }
  218. }
  219. .contact-btn{
  220. display: inline-block;
  221. position: absolute;
  222. top: 0;
  223. left: 0;
  224. width: 100%;
  225. height: 100%;
  226. opacity: 0;
  227. z-index: 9999;
  228. }
  229. </style>