detail.vue 4.2 KB

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