articleDetail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. this.photo = res.data.personInfo.photo;
  72. uni.hideLoading();
  73. }).catch(error => {
  74. uni.showToast({icon: 'none',
  75. title: error,
  76. icon: "none"
  77. })
  78. })
  79. },
  80. }
  81. }
  82. </script>
  83. <style scoped lang="scss">
  84. .main {
  85. padding: 40rpx 32rpx;
  86. // 标题
  87. .title {
  88. color: rgba(16, 16, 16, 1);
  89. font-size: 36rpx;
  90. }
  91. // 其他信息
  92. .infos {
  93. display: flex;
  94. align-items: center;
  95. margin-top: 24rpx;
  96. margin-bottom: 36rpx;
  97. .photo {
  98. width: 48rpx;
  99. height: 48rpx;
  100. border-radius: 50px;
  101. img {
  102. width: 48rpx;
  103. height: 48rpx;
  104. }
  105. }
  106. .name {
  107. color: rgba(16, 16, 16, 1);
  108. margin-left: 8rpx;
  109. }
  110. .date {
  111. color: rgba(119, 119, 119, 1);
  112. margin-left: 32rpx;
  113. }
  114. .tag1 {
  115. flex: 1;
  116. color: rgba(39, 149, 253, 1);
  117. text-align: right;
  118. }
  119. .tag2 {
  120. flex: 1;
  121. color: rgba(0, 185, 98, 1);
  122. text-align: right;
  123. }
  124. }
  125. // 文章内容
  126. .content{
  127. color: rgba(16, 16, 16, 1);
  128. line-height: 56rpx;
  129. img{
  130. width: 100%;
  131. height: 100%;
  132. }
  133. // text-align: j;
  134. }
  135. // 图片
  136. .picture{
  137. margin-top: 24rpx;
  138. border-radius: 4px;
  139. width: 100%;
  140. height: 400rpx;
  141. img{
  142. width: 100%;
  143. height: 100%;
  144. }
  145. }
  146. }
  147. </style>
  148. r