123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- <template>
- <view class="main">
- <view class="one" v-if="info.file.length>0">
- <swiper class="swiper" circular :indicator-dots="true" indicator-color="#F5F5F5"
- indicator-active-color="#ffffff" :autoplay="true" :interval="3000" :duration="1000">
- <swiper-item class="list" v-for="(item,index) in info.file" :key="index">
- <image class="image" :src="item.url" mode="">
- </image>
- </swiper-item>
- </swiper>
- </view>
- <view class="bottom">
- <view class="two">
- <view class="two_1">{{info.name||'暂无'}}</view>
- <view class="two_2">入住时间:{{info.start_time||'暂无'}}</view>
- <view class="two_2">退房时间:{{info.end_time||'暂无'}}</view>
- </view>
- <view class="thr">
- <view class="thr_1">
- <view class="left">地址:</view>
- <view class="right"><text :user-select='true'>{{info.address||'暂无'}}</text></view>
- </view>
- <view class="thr_1">
- <view class="left">总客房数:</view>
- <view class="right">
- <text>{{info.num||'暂无'}}间</text>
- </view>
- </view>
- <view class="thr_1">
- <view class="left">联系电话:</view>
- <view class="right"><text :user-select='true'>{{info.phone||'暂无'}}</text></view>
- </view>
- </view>
- <view class="four">
- <uni-collapse>
- <uni-collapse-item title="酒店民宿简介">
- <view class="content">
- <view class="four" v-if="info.prompt">
- <view class="four_1">接待提示</view>
- <rich-text :nodes="formatRichText(info.prompt)"></rich-text>
- </view>
- <view class="four" v-if="info.children">
- <view class="four_1">儿童及加床</view>
- <rich-text :nodes="formatRichText(info.children)"></rich-text>
- </view>
- <view class="four">
- <view class="four_1">简介</view>
- <rich-text :nodes="formatRichText(info.brief)"></rich-text>
- </view>
- </view>
- </uni-collapse-item>
- </uni-collapse>
- </view>
- <view class="five">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
- <view class="list-scroll-view">
- <view class="list" v-for="(item, index) in list" :key="index" @tap="toInfo(item)">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
- mode="aspectFill">
- </image>
- <view class="list_1">
- <view class="name textOne">{{ item.name ||'暂无'}}</view>
- <view class="other other_1">¥{{ item.money ||'暂无'}}</view>
- <view v-if="item.num==0" class="other other_2"><text>当天剩余房量:</text>售罄</view>
- <view v-else class="other other_2"><text>当天剩余房量:</text>
- {{ item.num||'暂无' }} 间
- </view>
- <view class="button">
- <button v-if="item.num==0" size="mini" type="primary">售罄</button>
- <button v-else @tap.stop="toBuy(item)" size="mini" type="primary">预订</button>
- </view>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- id: '',
- user: {},
- info: {
- file: []
- },
- config: {},
- list: [],
- total: 0,
- skip: 0,
- limit: 10,
- page: 0,
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- that.searchConfig();
- that.search();
- },
- onShow: async function(e) {
- const that = this;
- that.searchToken();
- },
- methods: {
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) {
- that.$set(that, `user`, res);
- }
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- searchConfig() {
- const that = this;
- try {
- const res = uni.getStorageSync('config');
- if (res) that.$set(that, `config`, res);
- } catch (e) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- },
- async search() {
- const that = this;
- if (that.id) {
- const res = await that.$api(`/hotel/${that.id}`, 'GET', {})
- if (res.errcode == '0') {
- that.$set(that, `info`, res.data)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- let info = {
- skip: that.skip,
- limit: that.limit,
- is_use: '0',
- hotel: res.data._id
- }
- const room = await that.$api(`/room`, 'GET', {
- ...info
- })
- if (room.errcode == '0') {
- let list = [...that.list, ...room.data];
- that.$set(that, `list`, list)
- that.$set(that, `total`, room.total)
- } else {
- uni.showToast({
- title: room.errmsg,
- });
- }
- }
- },
- // 处理富文本
- formatRichText(html) {
- // 富文本内容格式化
- return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
- // 查找所有的 img 元素
- return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
- '')
- // 删除找到的所有 img 元素中的 style 属性
- }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
- },
- // 详情
- toInfo(e) {
- uni.navigateTo({
- url: `/pagesHome/hotel/detail?id=${e.id||e._id}`
- })
- },
- // 预订
- toBuy(item) {
- const that = this;
- if (that.user && that.user._id) {
- console.log(item);
- } else {
- uni.navigateTo({
- url: `/pagesIndex/login/index`
- })
- }
- },
- // 分页
- toPage(e) {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.searchComment();
- uni.hideLoading();
- } else that.$set(that, `is_bottom`, true)
- },
- // 触底
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 10)
- that.$set(that, `page`, 0)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- .one {
- .swiper {
- height: 70vw;
- .list {
- .image {
- width: 100%;
- height: 100%;
- }
- }
- }
- }
- .bottom {
- position: absolute;
- top: 65vw;
- left: 0;
- right: 0;
- background-color: var(--mainColor);
- border-radius: 20px;
- padding: 2vw 0 0 0;
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .two {
- padding: 4vw 2vw;
- .two_1 {
- padding: 1vw 0;
- font-weight: bold;
- font-size: var(--font16Size);
- }
- .two_2 {
- color: var(--f85Color);
- font-size: var(--font12Size);
- }
- }
- .thr {
- padding: 2vw;
- .thr_1 {
- display: flex;
- font-size: var(--font14Size);
- padding: 0 0 1vw 0;
- .left {
- padding: 0 1vw 0 0;
- font-weight: bold;
- }
- .right {
- color: var(--f85Color);
- .text_1 {
- font-size: var(--font14Size);
- color: var(--f3CColor);
- }
- }
- }
- }
- .four {
- padding: 2vw;
- /deep/.uni-collapse-item__title-box {
- padding: 0 !important;
- }
- .four_1 {
- font-weight: bold;
- font-size: var(--font16Size);
- padding: 0 0 1vw 0;
- }
- }
- .five {
- position: relative;
- flex-grow: 1;
- background-color: var(--f9Color);
- margin: 2vw 0 0 0;
- .list {
- display: flex;
- background-color: var(--mainColor);
- border: 1px solid var(--f5Color);
- padding: 2vw;
- margin: 2vw 2vw 0 2vw;
- border-radius: 5px;
- .image {
- width: 25vw;
- height: 25vw;
- border-radius: 5px;
- }
- .list_1 {
- width: 63vw;
- padding: 0 0 0 2vw;
- .name {
- font-size: var(--font14Size);
- font-weight: bold;
- padding: 0 0 1vw 0;
- }
- .other {
- font-size: var(--font12Size);
- padding: 0 0 2px 0;
- text {
- color: #000;
- }
- }
- .other_1 {
- color: red;
- }
- .other_2 {
- color: var(--f85Color);
- }
- .button {
- text-align: right;
- button {
- font-size: var(--font12Size);
- background-color: var(--f3CColor);
- }
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- .is_bottom {
- width: 100%;
- text-align: center;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: var(--f85Color);
- font-size: var(--font14Size);
- }
- }
- </style>
|