info.vue 4.6 KB

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