articleDetail.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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: "荆州经开区共享用工平台",
  56. }
  57. },
  58. onShareAppMessage(res) {
  59. if (res.from === 'button') { // 来自页面内分享按钮
  60. //.log(res.target)
  61. }
  62. return {
  63. title: this.form.title,
  64. path: '/pages/packages/shareEmployment/articleDetail?shareMP=1&id=' + this.form.id
  65. }
  66. },
  67. onLoad(op) {
  68. if (op.shareMP) {
  69. this.share = op.shareMP
  70. }
  71. if(op.id) {
  72. this.form.id = op.id;
  73. this.getShareWorksDetail();
  74. }
  75. },
  76. methods: {
  77. getShareWorksDetail() {
  78. uni.showLoading({
  79. title: "加载中",
  80. mask: true,
  81. })
  82. API_packages.shareWorksDetail({id: this.form.id}).then((res) => {
  83. var newsDetail=res.data.shareWorksInfo;
  84. if(newsDetail.content){
  85. var reg=new RegExp('alt','gi');
  86. newsDetail.content=newsDetail.content.replace(reg,'width="100%" height="100%" /> <p')
  87. }
  88. this.form=newsDetail
  89. if(res.data.personInfo) {
  90. this.photo = res.data.personInfo.photo;
  91. }
  92. uni.hideLoading();
  93. }).catch(error => {
  94. uni.showToast({icon: 'none',
  95. title: error,
  96. icon: "none"
  97. })
  98. })
  99. },
  100. }
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .main {
  105. padding: 40rpx 32rpx;
  106. // 标题
  107. .title {
  108. color: rgba(16, 16, 16, 1);
  109. font-size: 36rpx;
  110. }
  111. // 其他信息
  112. .infos {
  113. display: flex;
  114. align-items: center;
  115. margin-top: 24rpx;
  116. margin-bottom: 36rpx;
  117. .photo {
  118. width: 48rpx;
  119. height: 48rpx;
  120. border-radius: 50px;
  121. img {
  122. width: 48rpx;
  123. height: 48rpx;
  124. }
  125. }
  126. .name {
  127. color: rgba(16, 16, 16, 1);
  128. margin-left: 8rpx;
  129. }
  130. .date {
  131. color: rgba(119, 119, 119, 1);
  132. margin-left: 32rpx;
  133. }
  134. .tag1 {
  135. flex: 1;
  136. color: rgba(39, 149, 253, 1);
  137. text-align: right;
  138. }
  139. .tag2 {
  140. flex: 1;
  141. color: rgba(0, 185, 98, 1);
  142. text-align: right;
  143. }
  144. }
  145. // 文章内容
  146. .content{
  147. color: rgba(16, 16, 16, 1);
  148. line-height: 56rpx;
  149. img{
  150. width: 100%;
  151. height: 100%;
  152. }
  153. // text-align: j;
  154. }
  155. // 图片
  156. .picture{
  157. margin-top: 24rpx;
  158. border-radius: 4px;
  159. width: 100%;
  160. height: 400rpx;
  161. img{
  162. width: 100%;
  163. height: 100%;
  164. }
  165. }
  166. }
  167. </style>
  168. r