index.vue 3.43 KB
<!--
 * @Date: 2022-09-19 14:11:06
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2023-12-21 11:45:01
 * @FilePath: /meihuaApp/src/pages/detail/index.vue
 * @Description: 房间详情页面
-->
<template>
  <view class="detail-page">
    <nut-swiper :init-page="page" :pagination-visible="true" pagination-color="#426543" auto-play="5000">
      <nut-swiper-item v-for="(item, index) in state.imgData" :key="index">
        <image @tap="showFn" style="width: 100%; height: 150px;" mode="aspectFill" :src="item.src" />
      </nut-swiper-item>
    </nut-swiper>
    <view class="detail-info-wrapper">
      <view class="detail-info-title">非凡魅力豪华总统套房</view>
      <view class="detail-info-content">两室 宜住3人</view>
    </view>
    <!-- 日历选择器 -->
    <view v-if="showBook" class="book-cal">
      <calendar-select @on-dates-change="onDatesChange"></calendar-select>
    </view>
    <view v-else class="no-calendar-border"></view>
    <!-- END -->
    <view class="detail-introduce-title">房间介绍</view>
    <view class="detail-introduce-html">
      <view id="taro_html" v-html="taro_html" class="taro_html"></view>
    </view>
    <view v-if="showBook" class="book-bar">
      <nut-row>
        <nut-col :span="18">
          <view class="book-price">
            <text class="price">¥980</text>
            <text class="old-price">¥1280</text>
          </view>
        </nut-col>
        <nut-col :span="6">
          <view class="book-btn" @tap="goToConfirm">预定</view>
        </nut-col>
      </nut-row>
    </view>
    <nut-image-preview :show="state.showPreview" :images="state.imgData" :is-Loop="false" @close="hideFn" />
  </view>
</template>

<script setup>
import Taro from '@tarojs/taro'
import { ref, computed, reactive, onMounted } from "vue";
import calendarSelect from '@/components/calendarSelect.vue'
import { getCurrentPageParam } from "@/utils/weapp";

onMounted(() => {
  console.warn('id', getCurrentPageParam().id);
});

const taro_html = ref('<div>123</div>');

// TODO: 到时候根据后端实际字段修改
// const book_status = ref('已约满');
const book_status = ref('');

const showBook = computed(() => {
  return book_status.value !== '已约满'
});

const start_date = ref('');
const end_date = ref('');
const between_date = ref('');
const start_date_week = ref('');
const end_date_week = ref('');

const onDatesChange = ({ startDate, endDate, betweenDate, startDateWeek, endDateWeek }) => {
  start_date.value = startDate;
  end_date.value = endDate;
  start_date_week.value = startDateWeek;
  end_date_week.value = endDateWeek;
  between_date.value = betweenDate;
}

const page = ref(1);

const goToConfirm = () => {
  Taro.navigateTo({
    url: `/pages/confirm/index?id=123&start_date=${start_date.value}&end_date=${end_date.value}&between_date=${between_date.value}&start_date_week=${start_date_week.value}&end_date_week=${end_date_week.value}`,
  })
}

const state = reactive({
  showPreview: false,
  imgData: [
    {
      src: 'https://cdn.ipadbiz.cn/meihua/img1@2x.png'
    },
    {
      src: 'https://cdn.ipadbiz.cn/meihua/banner1@2x.png'
    },
    {
      src: 'https://cdn.ipadbiz.cn/meihua/img1@2x.png'
    },
    {
      src: 'https://cdn.ipadbiz.cn/meihua/img1@2x.png'
    }
  ]
});

const showFn = () => {
  state.showPreview = true;
};

const hideFn = () => {
  state.showPreview = false;
};
</script>

<script>
import "./index.less";

export default {
  name: "detailPage",
};
</script>