index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. await that.searchOther();
  59. that.searchToken();
  60. that.search();
  61. },
  62. methods: {
  63. searchToken() {
  64. const that = this;
  65. try {
  66. const res = uni.getStorageSync('token');
  67. if (res) {
  68. that.$set(that, `user`, res);
  69. }
  70. } catch (e) {
  71. uni.showToast({
  72. title: err.errmsg,
  73. icon: 'error',
  74. duration: 2000
  75. });
  76. }
  77. },
  78. async search() {
  79. const that = this;
  80. const res = await that.$api(`/config`, 'GET', {})
  81. if (res.errcode == '0') {
  82. const status = that.statusList.find(i => i.value == res.data.status)
  83. if (status) res.data.zhStatus = status.label
  84. that.$set(that, `info`, res.data)
  85. } else {
  86. uni.showToast({
  87. title: res.errmsg,
  88. });
  89. }
  90. },
  91. // 处理富文本
  92. formatRichText(html) {
  93. if (html) {
  94. // 富文本内容格式化
  95. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  96. // 查找所有的 img 元素
  97. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  98. '')
  99. // 删除找到的所有 img 元素中的 style 属性
  100. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  101. }
  102. },
  103. // 查询其他信息
  104. async searchOther() {
  105. const that = this;
  106. let res;
  107. // 查询类型
  108. res = await that.$api(`/dictData`, 'GET', {
  109. type: 'config_status',
  110. is_use: '0',
  111. })
  112. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  113. },
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .main {
  119. .one {
  120. .swiper {
  121. height: 70vw;
  122. .list {
  123. .image {
  124. width: 100%;
  125. height: 100%;
  126. }
  127. }
  128. }
  129. }
  130. .bottom {
  131. position: absolute;
  132. top: 65vw;
  133. left: 0;
  134. right: 0;
  135. background-color: var(--mainColor);
  136. border-radius: 20px;
  137. padding: 2vw 0 0 0;
  138. .two {
  139. padding: 4vw 2vw;
  140. text-align: center;
  141. .two_1 {
  142. padding: 1vw 0;
  143. font-weight: bold;
  144. font-size: var(--font16Size);
  145. }
  146. .two_2 {
  147. color: var(--f85Color);
  148. font-size: var(--font12Size);
  149. }
  150. }
  151. .thr {
  152. padding: 2vw;
  153. .thr_1 {
  154. display: flex;
  155. font-size: var(--font14Size);
  156. padding: 0 0 1vw 0;
  157. .left {
  158. padding: 0 1vw 0 0;
  159. font-weight: bold;
  160. }
  161. .right {
  162. color: var(--f85Color);
  163. .text_1 {
  164. font-size: var(--font12Size);
  165. padding: 3px 5px;
  166. color: var(--mainColor);
  167. background-color: mediumseagreen;
  168. }
  169. .text_2 {
  170. font-size: var(--font12Size);
  171. padding: 3px 5px;
  172. color: var(--mainColor);
  173. background-color: red;
  174. }
  175. }
  176. }
  177. }
  178. .four {
  179. padding: 2vw;
  180. .four_1 {
  181. font-weight: bold;
  182. font-size: var(--font16Size);
  183. padding: 0 0 1vw 0;
  184. }
  185. }
  186. }
  187. }
  188. </style>