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 v-else
  11. :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) that.$set(that, `user`, res);
  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, `imgList`, [...res.data.video, ...res.data.file]);
  88. that.$set(that, `info`, res.data)
  89. } else {
  90. uni.showToast({
  91. title: res.errmsg,
  92. });
  93. }
  94. },
  95. // 处理富文本
  96. formatRichText(html) {
  97. if (html) {
  98. // 富文本内容格式化
  99. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  100. // 查找所有的 img 元素
  101. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  102. '')
  103. // 删除找到的所有 img 元素中的 style 属性
  104. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  105. }
  106. },
  107. // 查询其他信息
  108. async searchOther() {
  109. const that = this;
  110. let res;
  111. // 查询类型
  112. res = await that.$api(`/dictData`, 'GET', {
  113. type: 'config_status',
  114. is_use: '0',
  115. })
  116. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .main {
  123. .one {
  124. .swiper {
  125. height: 70vw;
  126. .list {
  127. .image {
  128. width: 100%;
  129. height: 100%;
  130. }
  131. }
  132. }
  133. }
  134. .bottom {
  135. position: absolute;
  136. top: 65vw;
  137. left: 0;
  138. right: 0;
  139. background-color: var(--mainColor);
  140. border-radius: 20px;
  141. padding: 2vw 0 0 0;
  142. .two {
  143. padding: 4vw 2vw;
  144. text-align: center;
  145. .two_1 {
  146. padding: 1vw 0;
  147. font-weight: bold;
  148. font-size: var(--font16Size);
  149. }
  150. .two_2 {
  151. color: var(--f85Color);
  152. font-size: var(--font12Size);
  153. }
  154. }
  155. .thr {
  156. padding: 2vw;
  157. .thr_1 {
  158. display: flex;
  159. font-size: var(--font14Size);
  160. padding: 0 0 1vw 0;
  161. .left {
  162. padding: 0 1vw 0 0;
  163. font-weight: bold;
  164. }
  165. .right {
  166. color: var(--f85Color);
  167. .text_1 {
  168. font-size: var(--font12Size);
  169. padding: 3px 5px;
  170. color: var(--mainColor);
  171. border-radius: 5px;
  172. background-color: mediumseagreen;
  173. }
  174. .text_2 {
  175. font-size: var(--font12Size);
  176. padding: 3px 5px;
  177. color: var(--mainColor);
  178. border-radius: 5px;
  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>