articleDetail.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view>
  3. <u-navbar back-text="文章详情" :share="share" back-icon-size="28" back-icon-color="#ffffff"
  4. :background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
  5. <view class="main">
  6. <!-- 标题 -->
  7. <view class="title">
  8. {{form.title}}
  9. </view>
  10. <!-- 其他信息 -->
  11. <view class="infos">
  12. <view class="photo">
  13. <u-avatar class="avatar"
  14. :src="photo != null ? photo : '@/assets/img/headPortrait.png'" size="48">
  15. </u-avatar>
  16. </view>
  17. <view class="name">
  18. {{form.author}}
  19. </view>
  20. <view class="date" v-if="form.createTime != null">
  21. {{form.createTime.slice(0,10)}}
  22. </view>
  23. <view class="tag1" v-if="form.type == '1'">
  24. 急需用工
  25. </view>
  26. <view class="tag2" v-if="form.type == '2'">
  27. 资源共享
  28. </view>
  29. </view>
  30. <u-line color="#CFD2D5" />
  31. <!-- 文章内容 -->
  32. <view class="content news-content" v-html="form.content">
  33. </view>
  34. <!-- 图片 -->
  35. <view class="picture">
  36. <!-- <img src="@/assets/img/articlePicture.png" alt=""> -->
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import * as API_packages from '@/apis/pagejs/packages.js'
  43. export default {
  44. data() {
  45. return {
  46. form: {
  47. id: ''
  48. },
  49. photo: '',
  50. share:0,
  51. }
  52. },
  53. onShareTimeline(){
  54. return {
  55. title: this.form.title,
  56. path: '/pages/packages/shareEmployment/articleDetail?shareMP=1&id=' + this.form.id
  57. }
  58. },
  59. onShareAppMessage(res) {
  60. if (res.from === 'button') { // 来自页面内分享按钮
  61. //.log(res.target)
  62. }
  63. return {
  64. title: this.form.title,
  65. path: '/pages/packages/shareEmployment/articleDetail?shareMP=1&id=' + this.form.id
  66. }
  67. },
  68. onLoad(op) {
  69. if (op.shareMP) {
  70. this.share = op.shareMP
  71. }
  72. if(op.id) {
  73. this.form.id = op.id;
  74. this.getShareWorksDetail();
  75. }
  76. },
  77. methods: {
  78. getShareWorksDetail() {
  79. uni.showLoading({
  80. title: "加载中",
  81. mask: true,
  82. })
  83. API_packages.shareWorksDetail({id: this.form.id}).then((res) => {
  84. var newsDetail=res.data.shareWorksInfo;
  85. if(newsDetail.content){
  86. var reg=new RegExp('alt','gi');
  87. newsDetail.content=newsDetail.content.replace(reg,'width="100%" height="100%" /> <p')
  88. }
  89. this.form=newsDetail
  90. if(res.data.personInfo) {
  91. this.photo = res.data.personInfo.photo;
  92. }
  93. uni.hideLoading();
  94. }).catch(error => {
  95. uni.showToast({icon: 'none',
  96. title: error,
  97. icon: "none"
  98. })
  99. })
  100. },
  101. }
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .main {
  106. padding: 40rpx 32rpx;
  107. // 标题
  108. .title {
  109. color: rgba(16, 16, 16, 1);
  110. font-size: 36rpx;
  111. }
  112. // 其他信息
  113. .infos {
  114. display: flex;
  115. align-items: center;
  116. margin-top: 24rpx;
  117. margin-bottom: 36rpx;
  118. .photo {
  119. width: 48rpx;
  120. height: 48rpx;
  121. border-radius: 50px;
  122. img {
  123. width: 48rpx;
  124. height: 48rpx;
  125. }
  126. }
  127. .name {
  128. color: rgba(16, 16, 16, 1);
  129. margin-left: 8rpx;
  130. }
  131. .date {
  132. color: rgba(119, 119, 119, 1);
  133. margin-left: 32rpx;
  134. }
  135. .tag1 {
  136. flex: 1;
  137. color: rgba(39, 149, 253, 1);
  138. text-align: right;
  139. }
  140. .tag2 {
  141. flex: 1;
  142. color: rgba(0, 185, 98, 1);
  143. text-align: right;
  144. }
  145. }
  146. // 文章内容
  147. .content{
  148. color: rgba(16, 16, 16, 1);
  149. line-height: 56rpx;
  150. img{
  151. width: 100%;
  152. height: 100%;
  153. }
  154. // text-align: j;
  155. }
  156. // 图片
  157. .picture{
  158. margin-top: 24rpx;
  159. border-radius: 4px;
  160. width: 100%;
  161. height: 400rpx;
  162. img{
  163. width: 100%;
  164. height: 100%;
  165. }
  166. }
  167. }
  168. </style>
  169. r