accompanyingCampDetail.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view>
  3. <view class="shopping-wrapper">
  4. <view class="list-item">
  5. <view class="list-item-title">
  6. {{ item.name }}
  7. </view>
  8. <view class="list-item-read mt10 display-flex-between">
  9. <view class="display-flex">
  10. <image :src="shop_logo" class="list-item-read-img mr8" ></image>
  11. <view class="list-item-read-text">
  12. {{shopName}}
  13. </view>
  14. </view>
  15. <view class="display-flex">
  16. <view>
  17. <u-icon
  18. size="14"
  19. name="eye"
  20. ></u-icon>
  21. </view>
  22. <view class="list-item-read-text2 ml8">
  23. {{ item.num_read }}
  24. </view>
  25. </view>
  26. </view>
  27. <u-divider ></u-divider>
  28. <view class="list-item-remark ">
  29. {{ item.remark }}
  30. </view>
  31. </view>
  32. <view class="list-item mt10">
  33. <view class="list-item-content ">
  34. <u-parse :content="item.content" :tagStyle="contentStyle"></u-parse>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {getNewsRead} from "@/common/api/news";
  42. export default {
  43. data() {
  44. return {
  45. item: {},
  46. itemId: 0,
  47. shopName: '',
  48. shop_logo: '',
  49. contentStyle:{
  50. p: "font-size:24rpx; background-color: #FFFFFF;",
  51. span: "font-size: 24rpx; background-color: #FFFFFF;",
  52. text:"font-size: 24rpx; background-color: #FFFFFF;"
  53. }
  54. };
  55. },
  56. created() {
  57. const configs = uni.getStorageSync("configs");
  58. if (configs) {
  59. console.log(configs)
  60. this.shopName = configs.shop_name
  61. this.shop_logo = configs.shop_logo
  62. }
  63. },
  64. onLoad(options) {
  65. console.log(options)
  66. this.itemId = options.id
  67. },
  68. onShow() {
  69. this.getData(this.itemId)
  70. },
  71. methods: {
  72. setContent: function () {
  73. if (this.item.content) {
  74. this.item.content = this.item.content.replace(/\/apihttps:/g, 'https:');
  75. // 使用正则表达式匹配和修改 img 标签的 style 属性
  76. this.item.content = this.item.content.replace(/<img([^>]*)>/gi, (match, attributes) => {
  77. // 检查是否已经存在 style 属性
  78. if (attributes.includes('style')) {
  79. // 如果存在 style 属性,添加 width: 100%;
  80. return match.replace(/style="([^"]*)"/i, (styleMatch, styleContent) => {
  81. if (!styleContent.includes('width: 100%')) {
  82. return `style="${styleContent}; width: 100%;"`;
  83. }
  84. return styleMatch;
  85. });
  86. } else {
  87. // 如果不存在 style 属性,添加 style="width: 100%;"
  88. return match.replace(/<img/i, '<img style="width: 100%;"');
  89. }
  90. });
  91. }
  92. }, getData(id) {
  93. getNewsRead(
  94. {
  95. "id": id,
  96. }).then(({data}) => {
  97. if (data) {
  98. this.item = data
  99. this.setContent();
  100. }
  101. })
  102. },
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .shopping-wrapper {
  108. width: calc(100% - 40rpx);
  109. margin: 20rpx auto 0rpx;
  110. padding: 0rpx 20rpx 60rpx;
  111. .list-item {
  112. background: #FFFFFF;
  113. border-radius: 16rpx 16rpx 16rpx 16rpx;
  114. width: calc(100% - 60rpx);
  115. padding:30rpx;
  116. &-title {
  117. font-family: PingFang SC, PingFang SC;
  118. font-weight: 600;
  119. font-size: 32rpx;
  120. color: #333333;
  121. line-height: 40rpx;
  122. text-align: left;
  123. font-style: normal;
  124. text-transform: none;
  125. }
  126. &-read{
  127. &-img{
  128. width: 36rpx;
  129. height: 36rpx;
  130. }
  131. &-text{
  132. font-family: PingFang SC-Medium, PingFang SC;
  133. font-weight: 400;
  134. font-size: 24rpx;
  135. color: #333333;
  136. line-height: 36rpx;
  137. text-align: left;
  138. font-style: normal;
  139. text-transform: none;
  140. }
  141. &-text2{
  142. font-family: PingFang SC-Medium, PingFang SC;
  143. font-weight: 400;
  144. font-size: 22rpx;
  145. color: #666666;
  146. line-height: 40rpx;
  147. text-align: left;
  148. font-style: normal;
  149. text-transform: none;
  150. }
  151. }
  152. &-remark{
  153. font-weight: 400;
  154. font-size: 24rpx;
  155. color: #666666;
  156. line-height: 40rpx;
  157. text-align: justify;
  158. font-style: normal;
  159. text-transform: none;
  160. }
  161. }
  162. .list-item-content{
  163. background-color: #FFFFFF;
  164. }
  165. }
  166. </style>