detail.vue 4.1 KB

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