info.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. <template>
  2. <!-- 禁止滚动穿透 -->
  3. <page-meta :page-style="'overflow:'+(show?'hidden':'visible')"></page-meta>
  4. <view class="main">
  5. <view class="one" v-if="info.file.length>0">
  6. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
  7. indicator-active-color="#ffffff" :autoplay="true" :interval="3000" :duration="1000">
  8. <swiper-item class="list" v-for="(item,index) in info.file" :key="index">
  9. <image class="image" :src="item.url" mode="">
  10. </image>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. <view class="bottom">
  15. <view class="two">
  16. <view class="two_1">
  17. <view class="name textOne">{{info.name||'暂无'}}</view>
  18. <view class="collect">
  19. <uni-fav :checked="info.is_collect" @click="onClick(info)" />
  20. </view>
  21. </view>
  22. <view class="two_2">入住时间:{{info.start_time||'暂无'}}</view>
  23. <view class="two_2">退房时间:{{info.end_time||'暂无'}}</view>
  24. </view>
  25. <view class="thr">
  26. <view class="thr_1">
  27. <view class="left">地址:</view>
  28. <view class="right"><text :user-select='true'>{{info.address||'暂无'}}</text></view>
  29. </view>
  30. <view class="thr_1">
  31. <view class="left">总客房数:</view>
  32. <view class="right">
  33. <text>{{info.num||'暂无'}}间</text>
  34. </view>
  35. </view>
  36. <view class="thr_1">
  37. <view class="left">联系电话:</view>
  38. <view class="right"><text :user-select='true'>{{info.phone||'暂无'}}</text></view>
  39. </view>
  40. <view class="thr_2" v-if="couponList.length>0" @tap="toCoupon">
  41. <view class="left">优惠卷</view>
  42. <view class="center">
  43. <view class="center_1" v-for="(item,index) in couponList" :key="index">
  44. <text
  45. v-if="item.discount_type=='min'&&item.discount_config.limit=='0'">立减{{item.discount_config.min}}</text>
  46. <text
  47. v-if="item.discount_type=='min'&&item.discount_config.limit!='0'">满{{item.discount_config.limit}}减{{item.discount_config.min}}</text>
  48. </view>
  49. </view>
  50. <view class="right">领卷<text class="iconfont icon-dayuhao"></text></view>
  51. </view>
  52. </view>
  53. <view class="four">
  54. <uni-collapse>
  55. <uni-collapse-item title="酒店民宿简介">
  56. <view class="content">
  57. <view class="four" v-if="info.prompt">
  58. <view class="four_1">接待提示</view>
  59. <rich-text :nodes="formatRichText(info.prompt)"></rich-text>
  60. </view>
  61. <view class="four" v-if="info.children">
  62. <view class="four_1">儿童及加床</view>
  63. <rich-text :nodes="formatRichText(info.children)"></rich-text>
  64. </view>
  65. <view class="four">
  66. <view class="four_1">简介</view>
  67. <rich-text :nodes="formatRichText(info.brief)"></rich-text>
  68. </view>
  69. </view>
  70. </uni-collapse-item>
  71. </uni-collapse>
  72. </view>
  73. <view class="five">
  74. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  75. <view class="list-scroll-view">
  76. <view class="list" v-for="(item, index) in list" :key="index" @tap="toInfo(item)">
  77. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
  78. mode="aspectFill">
  79. </image>
  80. <view class="list_1">
  81. <view class="name textOne">{{ item.name ||'暂无'}}</view>
  82. <view class="other other_1">¥{{ item.money ||'暂无'}}</view>
  83. <view v-if="item.num==0" class="other other_2"><text>当天剩余房量:</text>售罄</view>
  84. <view v-else class="other other_2"><text>当天剩余房量:</text>
  85. {{ item.num||'暂无' }} 间
  86. </view>
  87. <view class="button">
  88. <button v-if="item.num==0" size="mini" type="primary">售罄</button>
  89. <button v-else @tap.stop="toBuy(item)" size="mini" type="primary">预订</button>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="is_bottom" v-if="is_bottom">
  94. <text>{{config.bottom_title}}</text>
  95. </view>
  96. </view>
  97. </scroll-view>
  98. </view>
  99. </view>
  100. <!-- 领取优惠卷 -->
  101. <uni-popup ref="coupon" background-color="#fff" type="bottom" :is-mask-click="false" @change="change">
  102. <view class="coupon">
  103. <view class="close">
  104. <text>抵用券</text>
  105. <text @click="toCouponClose" class="iconfont icon-shanchu"></text>
  106. </view>
  107. <view class="info_1">
  108. <scroll-view scroll-y="true" class="scroll-view">
  109. <view class="list-scroll-view">
  110. <view class="list" v-for="(item, index) in discountList" :key="index">
  111. <view class="list_1">
  112. <view class="left">
  113. <view class="left_1">
  114. ¥<text>{{item.discount_config.min}}</text>
  115. </view>
  116. <view class="left_2">
  117. <text v-if="item.discount_config.limit=='0'">无门槛</text>
  118. <text
  119. v-else>满{{item.discount_config.limit}}减{{item.discount_config.min}}</text>
  120. </view>
  121. </view>
  122. <view class="center">
  123. <view class="name textOver">{{item.name}}</view>
  124. <view class="content">有效日期:({{item.expire_type_label}}) {{item.expire_time}}
  125. </view>
  126. </view>
  127. <view class="right">
  128. <button v-if="item.is_receive==false" class="button" type="primary"
  129. @tap="toReceive(item)">立即领取</button>
  130. <button v-else class="button_1" type="primary" @tap="toUser(item)">去使用</button>
  131. </view>
  132. </view>
  133. <view class="list_2">
  134. <uni-collapse>
  135. <uni-collapse-item title="使用规则补充说明" :open="false">
  136. <view class="content">{{item.brief}}</view>
  137. </uni-collapse-item>
  138. </uni-collapse>
  139. </view>
  140. </view>
  141. </view>
  142. </scroll-view>
  143. </view>
  144. </view>
  145. </uni-popup>
  146. </view>
  147. </template>
  148. <script>
  149. import moment from 'moment';
  150. export default {
  151. data() {
  152. return {
  153. id: '',
  154. user: {},
  155. info: {
  156. file: []
  157. },
  158. config: {},
  159. list: [],
  160. total: 0,
  161. skip: 0,
  162. limit: 10,
  163. page: 0,
  164. // 优惠卷
  165. couponList: [],
  166. // 优惠券全部
  167. discountList: [],
  168. // 数据是否触底
  169. is_bottom: false,
  170. scrollTop: 0,
  171. // 禁止滚动穿透
  172. show: false
  173. }
  174. },
  175. onLoad: async function(e) {
  176. const that = this;
  177. that.$set(that, `id`, e && e.id || '');
  178. },
  179. onShow: async function(e) {
  180. const that = this;
  181. await that.searchOther();
  182. await that.searchConfig();
  183. await that.searchToken();
  184. await that.clearPage();
  185. await that.search();
  186. },
  187. methods: {
  188. // 禁止滚动穿透
  189. change(e) {
  190. const that = this;
  191. that.show = e.show
  192. },
  193. searchToken() {
  194. const that = this;
  195. try {
  196. const res = uni.getStorageSync('token');
  197. if (res) that.$set(that, `user`, res);
  198. } catch (e) {
  199. uni.showToast({
  200. title: err.errmsg,
  201. icon: 'error',
  202. duration: 2000
  203. });
  204. }
  205. },
  206. searchConfig() {
  207. const that = this;
  208. try {
  209. const res = uni.getStorageSync('config');
  210. if (res) that.$set(that, `config`, res);
  211. } catch (e) {
  212. uni.showToast({
  213. title: err.errmsg,
  214. icon: 'error',
  215. duration: 2000
  216. });
  217. }
  218. },
  219. async search() {
  220. const that = this;
  221. if (that.id) {
  222. const data = {}
  223. if (that.user._id) data.user = that.user._id
  224. const res = await that.$api(`/hotel/hotel/${that.id}`, 'GET', data)
  225. if (res.errcode == '0') {
  226. that.$set(that, `info`, res.data)
  227. } else {
  228. uni.showToast({
  229. title: res.errmsg,
  230. });
  231. }
  232. let info = {
  233. skip: that.skip,
  234. limit: that.limit,
  235. is_use: '0',
  236. hotel: res.data._id
  237. }
  238. const room = await that.$api(`/room`, 'GET', {
  239. ...info
  240. })
  241. if (room.errcode == '0') {
  242. let list = [...that.list, ...room.data];
  243. that.$set(that, `list`, list)
  244. that.$set(that, `total`, room.total)
  245. } else {
  246. uni.showToast({
  247. title: room.errmsg,
  248. });
  249. }
  250. }
  251. },
  252. // 领卷
  253. async toCoupon() {
  254. const that = this;
  255. // 优惠券
  256. const res = await that.$api(`/coupon/specialQuery`, 'GET', {
  257. is_use: '0',
  258. user: that.user._id,
  259. type: '0'
  260. })
  261. if (res.errcode == '0') that.$set(that, `discountList`, res.data);
  262. that.$refs.coupon.open()
  263. },
  264. // 领取优惠券
  265. async toReceive(item) {
  266. const that = this;
  267. if (that.user._id) {
  268. const form = {
  269. user: that.user._id,
  270. type: item.type,
  271. coupon: item._id,
  272. is_use: '0'
  273. }
  274. if (item.expire_type == 'fixed') form.time = item.expire_time
  275. else {
  276. form.time = `${moment().format('YYYY-MM-DD HH:mm:ss')} 至 ${moment()
  277. .add(item.days, 'days')
  278. .format('YYYY-MM-DD HH:mm:ss')}`;
  279. }
  280. const res = await that.$api(`/userCoupon`, 'POST', form);
  281. if (res.errcode == '0') {
  282. uni.showToast({
  283. title: '领取成功',
  284. icon: 'none'
  285. })
  286. that.toCoupon()
  287. } else {
  288. uni.showToast({
  289. title: res.errmsg,
  290. icon: 'none'
  291. })
  292. }
  293. } else {
  294. uni.navigateTo({
  295. url: `/pagesIndex/login/index`
  296. })
  297. }
  298. },
  299. // 去使用
  300. toUser(item) {
  301. uni.navigateTo({
  302. url: `/pagesMy/coupon/index`
  303. })
  304. },
  305. // 关闭弹框
  306. toCouponClose() {
  307. const that = this;
  308. that.$refs.coupon.close();
  309. },
  310. // 查询其他信息
  311. async searchOther() {
  312. const that = this;
  313. let res;
  314. // 优惠券
  315. res = await that.$api(`/coupon/specialQuery`, 'GET', {
  316. is_use: '0',
  317. discount_type: 'min',
  318. user: that.user._id,
  319. type: '0'
  320. })
  321. if (res.errcode == '0') that.$set(that, `couponList`, res.data.slice(0, 3));
  322. },
  323. // 处理富文本
  324. formatRichText(html) {
  325. if (html) {
  326. // 富文本内容格式化
  327. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  328. // 查找所有的 img 元素
  329. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  330. '')
  331. // 删除找到的所有 img 元素中的 style 属性
  332. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  333. }
  334. },
  335. // 详情
  336. toInfo(e) {
  337. uni.navigateTo({
  338. url: `/pagesHome/hotel/detail?id=${e.id||e._id}`
  339. })
  340. },
  341. // 预订
  342. toBuy(item) {
  343. const that = this;
  344. if (that.user && that.user._id) {
  345. console.log(item);
  346. } else {
  347. uni.navigateTo({
  348. url: `/pagesIndex/login/index`
  349. })
  350. }
  351. },
  352. // 收藏
  353. async onClick(item) {
  354. const that = this;
  355. if (that.user && that.user._id) {
  356. let res;
  357. if (item.is_collect == false) {
  358. const form = {
  359. user: that.user._id,
  360. source: item._id,
  361. source_type: "hotel",
  362. type: '1',
  363. create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
  364. }
  365. res = await that.$api(`/like`, 'POST', form);
  366. } else res = await that.$api(`/like/${item.collect}`, 'DELETE', {})
  367. if (res.errcode == '0') that.search()
  368. } else {
  369. uni.navigateTo({
  370. url: `/pagesIndex/login/index`
  371. })
  372. }
  373. },
  374. // 分页
  375. toPage(e) {
  376. const that = this;
  377. let list = that.list;
  378. let limit = that.limit;
  379. if (that.total > list.length) {
  380. uni.showLoading({
  381. title: '加载中',
  382. mask: true
  383. })
  384. let page = that.page + 1;
  385. that.$set(that, `page`, page)
  386. let skip = page * limit;
  387. that.$set(that, `skip`, skip)
  388. that.searchComment();
  389. uni.hideLoading();
  390. } else that.$set(that, `is_bottom`, true)
  391. },
  392. // 触底
  393. toScroll(e) {
  394. const that = this;
  395. let up = that.scrollTop;
  396. that.$set(that, `scrollTop`, e.detail.scrollTop);
  397. let num = Math.sign(up - e.detail.scrollTop);
  398. if (num == 1) that.$set(that, `is_bottom`, false);
  399. },
  400. // 清空列表
  401. clearPage() {
  402. const that = this;
  403. that.$set(that, `list`, [])
  404. that.$set(that, `skip`, 0)
  405. that.$set(that, `limit`, 10)
  406. that.$set(that, `page`, 0)
  407. },
  408. }
  409. }
  410. </script>
  411. <style lang="scss" scoped>
  412. .main {
  413. .one {
  414. .swiper {
  415. height: 70vw;
  416. .list {
  417. .image {
  418. width: 100%;
  419. height: 100%;
  420. }
  421. }
  422. }
  423. }
  424. .bottom {
  425. position: absolute;
  426. top: 65vw;
  427. left: 0;
  428. right: 0;
  429. background-color: var(--mainColor);
  430. border-radius: 20px;
  431. padding: 2vw 0 0 0;
  432. display: flex;
  433. flex-direction: column;
  434. width: 100vw;
  435. height: 100vh;
  436. .two {
  437. padding: 4vw 2vw;
  438. .two_1 {
  439. display: flex;
  440. justify-content: space-between;
  441. align-items: center;
  442. .name {
  443. width: 80vw;
  444. padding: 1vw 0;
  445. font-weight: bold;
  446. font-size: var(--font16Size);
  447. }
  448. }
  449. .two_2 {
  450. color: var(--f85Color);
  451. font-size: var(--font12Size);
  452. }
  453. }
  454. .thr {
  455. padding: 0 2vw;
  456. .thr_1 {
  457. display: flex;
  458. font-size: var(--font14Size);
  459. padding: 0 0 1vw 0;
  460. .left {
  461. padding: 0 1vw 0 0;
  462. font-weight: bold;
  463. }
  464. .right {
  465. color: var(--f85Color);
  466. .text_1 {
  467. font-size: var(--font14Size);
  468. color: var(--f3CColor);
  469. }
  470. }
  471. }
  472. .thr_2 {
  473. display: flex;
  474. justify-content: space-between;
  475. align-items: center;
  476. padding: 3vw 2vw;
  477. font-size: var(--font14Size);
  478. background-color: var(--f9Color);
  479. border-radius: 10px;
  480. margin: 2vw 0;
  481. .center {
  482. display: flex;
  483. align-items: center;
  484. width: 65vw;
  485. .center_1 {
  486. text {
  487. margin: 0 1vw 0 0;
  488. padding: 2px;
  489. font-size: var(--font12Size);
  490. color: var(--mainColor);
  491. border-radius: 5px;
  492. background: linear-gradient(to right, #FFA500, #FF0000);
  493. }
  494. }
  495. }
  496. .right {
  497. display: flex;
  498. align-items: center;
  499. font-size: var(--font14Size);
  500. color: var(--fF0Color);
  501. }
  502. }
  503. }
  504. .four {
  505. padding: 0 2vw;
  506. /deep/.uni-collapse-item__title-box {
  507. padding: 0 !important;
  508. }
  509. .four_1 {
  510. font-weight: bold;
  511. font-size: var(--font16Size);
  512. padding: 0 0 1vw 0;
  513. }
  514. }
  515. .five {
  516. position: relative;
  517. flex-grow: 1;
  518. background-color: var(--f9Color);
  519. margin: 2vw 0 0 0;
  520. .list {
  521. display: flex;
  522. background-color: var(--mainColor);
  523. border: 1px solid var(--f5Color);
  524. padding: 2vw;
  525. margin: 2vw 2vw 0 2vw;
  526. border-radius: 5px;
  527. .image {
  528. width: 25vw;
  529. height: 25vw;
  530. border-radius: 5px;
  531. }
  532. .list_1 {
  533. width: 63vw;
  534. padding: 0 0 0 2vw;
  535. .name {
  536. font-size: var(--font14Size);
  537. font-weight: bold;
  538. padding: 0 0 1vw 0;
  539. }
  540. .other {
  541. font-size: var(--font12Size);
  542. padding: 0 0 2px 0;
  543. text {
  544. color: #000;
  545. }
  546. }
  547. .other_1 {
  548. color: red;
  549. }
  550. .other_2 {
  551. color: var(--f85Color);
  552. }
  553. .button {
  554. text-align: right;
  555. button {
  556. font-size: var(--font12Size);
  557. background-color: var(--f3CColor);
  558. }
  559. }
  560. }
  561. }
  562. }
  563. }
  564. }
  565. .uni-popup {
  566. z-index: 9999 !important;
  567. }
  568. .coupon {
  569. display: flex;
  570. flex-direction: column;
  571. width: 100vw;
  572. height: 60vh;
  573. background-color: var(--f9Color);
  574. .close {
  575. display: flex;
  576. justify-content: space-between;
  577. padding: 2vw;
  578. text:first-child {
  579. font-size: var(--font16Size);
  580. font-weight: bold;
  581. }
  582. }
  583. .info_1 {
  584. position: relative;
  585. display: flex;
  586. flex-direction: column;
  587. height: 54vh;
  588. padding: 2vw;
  589. .list {
  590. background-color: var(--mainColor);
  591. border: 1px solid var(--f5Color);
  592. padding: 2vw;
  593. margin: 2vw 2vw 0 2vw;
  594. border-radius: 5px;
  595. .list_1 {
  596. display: flex;
  597. justify-content: space-between;
  598. align-items: center;
  599. .left {
  600. width: 20vw;
  601. display: flex;
  602. flex-direction: column;
  603. justify-content: center;
  604. align-items: center;
  605. padding: 3vw;
  606. color: var(--fF0Color);
  607. font-size: var(--font14Size);
  608. .left_1 {
  609. text {
  610. font-weight: bold;
  611. font-size: 25px;
  612. }
  613. }
  614. .left_2 {
  615. font-size: var(--font12Size);
  616. }
  617. }
  618. .center {
  619. width: 40vw;
  620. .name {
  621. font-size: var(--font14Size);
  622. font-weight: bold;
  623. margin: 0 0 1vw 0;
  624. }
  625. .content {
  626. color: var(--f85Color);
  627. font-size: var(--font12Size);
  628. }
  629. }
  630. .right {
  631. .button {
  632. font-size: 12px;
  633. border-radius: 20px;
  634. background: linear-gradient(to right, #FFA500, #FF0000);
  635. }
  636. .button_1 {
  637. font-size: 12px;
  638. border-radius: 20px;
  639. border: 1px solid var(--fF0Color);
  640. color: var(--fF0Color);
  641. background: var(--mainColor);
  642. }
  643. }
  644. }
  645. .list_2 {
  646. font-size: var(--font12Size);
  647. /deep/.uni-collapse-item__title-box {
  648. padding: 0 !important;
  649. font-size: 12px !important;
  650. }
  651. /deep/.uni-collapse-item__title-text {
  652. font-size: 12px !important;
  653. }
  654. .content {
  655. padding: 2vw;
  656. }
  657. }
  658. }
  659. }
  660. }
  661. .scroll-view {
  662. position: absolute;
  663. top: 0;
  664. left: 0;
  665. right: 0;
  666. bottom: 0;
  667. .list-scroll-view {
  668. display: flex;
  669. flex-direction: column;
  670. }
  671. }
  672. .is_bottom {
  673. width: 100%;
  674. text-align: center;
  675. text {
  676. padding: 2vw 0;
  677. display: inline-block;
  678. color: var(--f85Color);
  679. font-size: var(--font14Size);
  680. }
  681. }
  682. </style>