index.vue 5.0 KB

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