articleDetail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view>
  3. <u-navbar back-text="文章详情" 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. }
  51. },
  52. onLoad(op) {
  53. if(op.id) {
  54. this.form.id = op.id;
  55. this.getShareWorksDetail();
  56. }
  57. },
  58. methods: {
  59. getShareWorksDetail() {
  60. uni.showLoading({
  61. title: "加载中",
  62. mask: true,
  63. })
  64. API_packages.shareWorksDetail({id: this.form.id}).then((res) => {
  65. var newsDetail=res.data.shareWorksInfo;
  66. if(newsDetail.content){
  67. var reg=new RegExp('alt','gi');
  68. newsDetail.content=newsDetail.content.replace(reg,'width="100%" height="100%" /> <p')
  69. }
  70. this.form=newsDetail
  71. if(res.data.personInfo) {
  72. this.photo = res.data.personInfo.photo;
  73. }
  74. uni.hideLoading();
  75. }).catch(error => {
  76. uni.showToast({icon: 'none',
  77. title: error,
  78. icon: "none"
  79. })
  80. })
  81. },
  82. }
  83. }
  84. </script>
  85. <style scoped lang="scss">
  86. .main {
  87. padding: 40rpx 32rpx;
  88. // 标题
  89. .title {
  90. color: rgba(16, 16, 16, 1);
  91. font-size: 36rpx;
  92. }
  93. // 其他信息
  94. .infos {
  95. display: flex;
  96. align-items: center;
  97. margin-top: 24rpx;
  98. margin-bottom: 36rpx;
  99. .photo {
  100. width: 48rpx;
  101. height: 48rpx;
  102. border-radius: 50px;
  103. img {
  104. width: 48rpx;
  105. height: 48rpx;
  106. }
  107. }
  108. .name {
  109. color: rgba(16, 16, 16, 1);
  110. margin-left: 8rpx;
  111. }
  112. .date {
  113. color: rgba(119, 119, 119, 1);
  114. margin-left: 32rpx;
  115. }
  116. .tag1 {
  117. flex: 1;
  118. color: rgba(39, 149, 253, 1);
  119. text-align: right;
  120. }
  121. .tag2 {
  122. flex: 1;
  123. color: rgba(0, 185, 98, 1);
  124. text-align: right;
  125. }
  126. }
  127. // 文章内容
  128. .content{
  129. color: rgba(16, 16, 16, 1);
  130. line-height: 56rpx;
  131. img{
  132. width: 100%;
  133. height: 100%;
  134. }
  135. // text-align: j;
  136. }
  137. // 图片
  138. .picture{
  139. margin-top: 24rpx;
  140. border-radius: 4px;
  141. width: 100%;
  142. height: 400rpx;
  143. img{
  144. width: 100%;
  145. height: 100%;
  146. }
  147. }
  148. }
  149. </style>
  150. r