info.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="main">
  3. <view class="top">
  4. <view class="left">
  5. <image class="image" :src="info.file&&info.file.length>0?info.file[0].url:''" mode="aspectFill">
  6. </view>
  7. <view class="right">
  8. <view class="right_1 textOver">{{info.name||'暂无'}}</view>
  9. <view class="right_2">已售 {{info.buy_num||0}}</view>
  10. </view>
  11. </view>
  12. <view class="center">
  13. <scroll-view scroll-y="true" class="scroll-view">
  14. <view class="list-scroll-view">
  15. <view class="center_1" v-if="info.buy_explain">
  16. <view class="name">购买须知</view>
  17. <view class="cotent">
  18. <rich-text :nodes="formatRichText(info.buy_explain)"></rich-text>
  19. </view>
  20. </view>
  21. <view class="center_1" v-if="info.use_explain">
  22. <view class="name">使用说明</view>
  23. <view class="cotent">
  24. <rich-text :nodes="formatRichText(info.use_explain)"></rich-text>
  25. </view>
  26. </view>
  27. <view class="center_1" v-if="info.money_explain">
  28. <view class="name">费用说明</view>
  29. <view class="cotent">
  30. <rich-text :nodes="formatRichText(info.money_explain)"></rich-text>
  31. </view>
  32. </view>
  33. <view class="center_1" v-if="info.other_explain">
  34. <view class="name">其他说明</view>
  35. <view class="cotent">
  36. <rich-text :nodes="formatRichText(info.other_explain)"></rich-text>
  37. </view>
  38. </view>
  39. </view>
  40. </scroll-view>
  41. </view>
  42. <view class="foot">
  43. <view class="money">
  44. <text>¥{{info.original_price||'暂无'}}</text>
  45. <text>¥{{info.money||'暂无'}}起</text>
  46. </view>
  47. <view class="button">
  48. <button type="warn" @tap.stop="toBuy(item)">预订</button>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. id: '',
  58. user: {},
  59. info: {
  60. file: []
  61. },
  62. // 字典表
  63. typeList: []
  64. }
  65. },
  66. onLoad: async function(e) {
  67. const that = this;
  68. that.$set(that, `id`, e && e.id || '');
  69. await that.searchOther();
  70. await that.search();
  71. },
  72. onShow: async function(e) {
  73. const that = this;
  74. that.searchToken();
  75. },
  76. methods: {
  77. searchToken() {
  78. const that = this;
  79. try {
  80. const res = uni.getStorageSync('token');
  81. if (res) {
  82. that.$set(that, `user`, res);
  83. }
  84. } catch (e) {
  85. uni.showToast({
  86. title: err.errmsg,
  87. icon: 'error',
  88. duration: 2000
  89. });
  90. }
  91. },
  92. async search() {
  93. const that = this;
  94. if (that.id) {
  95. const res = await that.$api(`/ticket/${that.id}`, 'GET', {})
  96. if (res.errcode == '0') {
  97. const type = that.typeList.find(i => i.value == res.data.type)
  98. if (type) res.data.zhType = type.label
  99. that.$set(that, `info`, res.data)
  100. } else {
  101. uni.showToast({
  102. title: res.errmsg,
  103. });
  104. }
  105. }
  106. },
  107. // 处理富文本
  108. formatRichText(html) {
  109. if (html) {
  110. // 富文本内容格式化
  111. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  112. // 查找所有的 img 元素
  113. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  114. '')
  115. // 删除找到的所有 img 元素中的 style 属性
  116. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  117. }
  118. },
  119. // 预订
  120. toBuy(item) {
  121. const that = this;
  122. if (that.user && that.user._id) {
  123. console.log("预订");
  124. } else {
  125. uni.navigateTo({
  126. url: `/pagesIndex/login/index`
  127. })
  128. }
  129. },
  130. // 查询其他信息
  131. async searchOther() {
  132. const that = this;
  133. let res;
  134. // 查询类型
  135. res = await that.$api(`/dictData`, 'GET', {
  136. type: 'project_type',
  137. is_use: '0',
  138. })
  139. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .main {
  146. display: flex;
  147. flex-direction: column;
  148. width: 100vw;
  149. height: 100vh;
  150. .top {
  151. display: flex;
  152. padding: 1vw;
  153. border-radius: 5px;
  154. border: 1px solid var(--f9Color);
  155. .left {
  156. width: 25vw;
  157. .image {
  158. width: 100%;
  159. height: 25vw;
  160. }
  161. }
  162. .right {
  163. padding: 2vw;
  164. width: 65vw;
  165. margin: 0 0 0 2vw;
  166. .right_1 {
  167. font-size: var(--font18Size);
  168. font-weight: bold;
  169. padding: 0 0 2px 0;
  170. }
  171. .right_2 {
  172. padding: 0 0 2px 0;
  173. font-size: var(--font14Size);
  174. color: var(--f85Color);
  175. }
  176. }
  177. }
  178. .center {
  179. position: relative;
  180. flex-grow: 1;
  181. .center_1 {
  182. padding: 2vw;
  183. .name {
  184. padding: 3vw 0;
  185. font-size: var(--font18Size);
  186. font-weight: bold;
  187. }
  188. .content {
  189. padding: 2vw;
  190. }
  191. }
  192. }
  193. .foot {
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. padding: 2vw;
  198. background-color: var(--mainColor);
  199. .money {
  200. text-align: right;
  201. color: var(--fF0Color);
  202. font-size: var(--font16Size);
  203. font-weight: bold;
  204. text:first-child {
  205. text-decoration: line-through;
  206. color: var(--f69Color);
  207. font-size: var(--font12Size);
  208. font-weight: 400;
  209. }
  210. }
  211. .button {
  212. button {
  213. width: 30vw;
  214. font-size: var(--font14Size);
  215. border-radius: 40px;
  216. background: linear-gradient(to right, #00BFFF, #007AFF);
  217. }
  218. }
  219. }
  220. }
  221. .scroll-view {
  222. position: absolute;
  223. top: 0;
  224. left: 0;
  225. right: 0;
  226. bottom: 0;
  227. .list-scroll-view {
  228. display: flex;
  229. flex-direction: column;
  230. }
  231. }
  232. .is_bottom {
  233. width: 100%;
  234. text-align: center;
  235. text {
  236. padding: 2vw 0;
  237. display: inline-block;
  238. color: var(--f85Color);
  239. font-size: var(--font14Size);
  240. }
  241. }
  242. </style>