index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="main">
  3. <view class="one" v-if="info.file.length>0">
  4. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
  5. indicator-active-color="#ffffff" :autoplay="true" :interval="3000" :duration="1000">
  6. <swiper-item class="list" v-for="(item,index) in info.file" :key="index">
  7. <image class="image" :src="item.url" mode="">
  8. </image>
  9. </swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="bottom">
  13. <view class="two">
  14. <view class="two_1">{{info.name||'暂无'}}</view>
  15. <view class="two_2">{{info.open_time||'暂无'}}</view>
  16. </view>
  17. <view class="thr">
  18. <view class="thr_1">
  19. <view class="left">地址:</view>
  20. <view class="right"><text :user-select='true'>{{info.address||'暂无'}}</text></view>
  21. </view>
  22. <view class="thr_1">
  23. <view class="left">状态:</view>
  24. <view class="right">
  25. <text :class="[info.status=='0'?'text_1':'text_2']">{{info.zhStatus}}</text>
  26. </view>
  27. </view>
  28. <view class="thr_1">
  29. <view class="left">官方电话:</view>
  30. <view class="right"><text :user-select='true'>{{info.phone||'暂无'}}</text></view>
  31. </view>
  32. </view>
  33. <view class="four" v-if="info.policy">
  34. <view class="four_1">优待政策</view>
  35. <rich-text :nodes="formatRichText(info.policy)"></rich-text>
  36. </view>
  37. <view class="four">
  38. <view class="four_1">简介</view>
  39. <rich-text :nodes="formatRichText(info.brief)"></rich-text>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. user: {},
  49. info: {
  50. file: []
  51. },
  52. // 字典表
  53. statusList: []
  54. }
  55. },
  56. onLoad: async function(e) {
  57. const that = this;
  58. uni.setNavigationBarTitle({
  59. title: e && e.title || '分类'
  60. });
  61. await that.searchOther();
  62. that.searchToken();
  63. that.search();
  64. },
  65. methods: {
  66. searchToken() {
  67. const that = this;
  68. try {
  69. const res = uni.getStorageSync('token');
  70. if (res) {
  71. that.$set(that, `user`, res);
  72. }
  73. } catch (e) {
  74. uni.showToast({
  75. title: err.errmsg,
  76. icon: 'error',
  77. duration: 2000
  78. });
  79. }
  80. },
  81. async search() {
  82. const that = this;
  83. const res = await that.$api(`/config`, 'GET', {})
  84. if (res.errcode == '0') {
  85. const status = that.statusList.find(i => i.value == res.data.status)
  86. if (status) res.data.zhStatus = status.label
  87. that.$set(that, `info`, res.data)
  88. } else {
  89. uni.showToast({
  90. title: res.errmsg,
  91. });
  92. }
  93. },
  94. // 处理富文本
  95. formatRichText(html) {
  96. // 富文本内容格式化
  97. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  98. // 查找所有的 img 元素
  99. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  100. '')
  101. // 删除找到的所有 img 元素中的 style 属性
  102. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  103. },
  104. // 查询其他信息
  105. async searchOther() {
  106. const that = this;
  107. let res;
  108. // 查询类型
  109. res = await that.$api(`/dictData`, 'GET', {
  110. type: 'config_status',
  111. is_use: '0',
  112. })
  113. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  114. },
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .main {
  120. .one {
  121. .swiper {
  122. height: 70vw;
  123. .list {
  124. .image {
  125. width: 100%;
  126. height: 100%;
  127. }
  128. }
  129. }
  130. }
  131. .bottom {
  132. position: absolute;
  133. top: 65vw;
  134. left: 0;
  135. right: 0;
  136. background-color: var(--mainColor);
  137. border-radius: 20px;
  138. padding: 2vw 0 0 0;
  139. .two {
  140. padding: 4vw 2vw;
  141. text-align: center;
  142. .two_1 {
  143. padding: 1vw 0;
  144. font-weight: bold;
  145. font-size: var(--font16Size);
  146. }
  147. .two_2 {
  148. color: var(--f85Color);
  149. font-size: var(--font12Size);
  150. }
  151. }
  152. .thr {
  153. padding: 2vw;
  154. .thr_1 {
  155. display: flex;
  156. font-size: var(--font14Size);
  157. padding: 0 0 1vw 0;
  158. .left {
  159. padding: 0 1vw 0 0;
  160. font-weight: bold;
  161. }
  162. .right {
  163. color: var(--f85Color);
  164. .text_1 {
  165. font-size: var(--font12Size);
  166. padding: 3px 5px;
  167. color: var(--mainColor);
  168. background-color: mediumseagreen;
  169. }
  170. .text_2 {
  171. font-size: var(--font12Size);
  172. padding: 3px 5px;
  173. color: var(--mainColor);
  174. background-color: red;
  175. }
  176. }
  177. }
  178. }
  179. .four {
  180. padding: 2vw;
  181. .four_1 {
  182. font-weight: bold;
  183. font-size: var(--font16Size);
  184. padding: 0 0 1vw 0;
  185. }
  186. }
  187. }
  188. }
  189. </style>