Compare commits
No commits in common. "9ca2d72256586d868c5c3a964d8f26271c53ed6d" and "8325ec80add1f6818ac71b61b01ccbc94d6f7d03" have entirely different histories.
9ca2d72256
...
8325ec80ad
@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<uni-popup
|
<uni-popup ref="popup" type="bottom" @maskClick="handleMaskClick">
|
||||||
ref="popup"
|
|
||||||
type="bottom"
|
|
||||||
:safe-area="false"
|
|
||||||
@maskClick="handleMaskClick"
|
|
||||||
>
|
|
||||||
<!-- 弹窗主体 -->
|
<!-- 弹窗主体 -->
|
||||||
<view class="calendar-popup" @tap.stop>
|
<view class="calendar-popup" @tap.stop>
|
||||||
<!-- 头部区域 -->
|
<!-- 头部区域 -->
|
||||||
@ -12,7 +7,7 @@
|
|||||||
<view class="header-content">
|
<view class="header-content">
|
||||||
<text class="header-title">日历选择</text>
|
<text class="header-title">日历选择</text>
|
||||||
<text class="header-subtitle"
|
<text class="header-subtitle"
|
||||||
>选择住宿日期,以下价格为单晚参考价</text
|
>选择入住和离店日期,以下价格为单晚参考价</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<view class="header-close" @tap="handleClose">
|
<view class="header-close" @tap="handleClose">
|
||||||
@ -274,12 +269,8 @@ const getDateLabel = (dateStr) => {
|
|||||||
return props.customLabels[dateStr];
|
return props.customLabels[dateStr];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为范围选择模式自动生成住/离标签
|
// 为范围选择模式自动生成入住/离店标签
|
||||||
if (props.mode === "range") {
|
if (props.mode === "range") {
|
||||||
if (dateStr === rangeStart.value && dateStr === rangeEnd.value) {
|
|
||||||
// 当入住和离店是同一天时,显示"住/离"
|
|
||||||
return "住/离";
|
|
||||||
}
|
|
||||||
if (dateStr === rangeStart.value) {
|
if (dateStr === rangeStart.value) {
|
||||||
return "入住";
|
return "入住";
|
||||||
}
|
}
|
||||||
@ -352,19 +343,19 @@ const handleRangeSelection = (dateInfo) => {
|
|||||||
rangeEnd.value = dateInfo.date;
|
rangeEnd.value = dateInfo.date;
|
||||||
isRangeSelecting.value = false;
|
isRangeSelecting.value = false;
|
||||||
|
|
||||||
// 允许选择相同日期,但确保开始日期不大于结束日期
|
// 确保开始日期小于结束日期
|
||||||
if (new Date(rangeStart.value) > new Date(rangeEnd.value)) {
|
if (new Date(rangeStart.value) > new Date(rangeEnd.value)) {
|
||||||
[rangeStart.value, rangeEnd.value] = [rangeEnd.value, rangeStart.value];
|
[rangeStart.value, rangeEnd.value] = [rangeEnd.value, rangeStart.value];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查日期跨度是否超过28天(相同日期跨度为0天,允许通过)
|
// 检查日期跨度是否超过28天
|
||||||
const daysBetween = calculateDaysBetween(rangeStart.value, rangeEnd.value);
|
const daysBetween = calculateDaysBetween(rangeStart.value, rangeEnd.value);
|
||||||
if (daysBetween > 28) {
|
if (daysBetween > 28) {
|
||||||
// 使用uni.showToast显示错误提示
|
// 使用uni.showToast显示错误提示
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "预定时间不能超过28天",
|
title: '预定时间不能超过28天',
|
||||||
icon: "none",
|
icon: 'none',
|
||||||
duration: 3000,
|
duration: 3000
|
||||||
});
|
});
|
||||||
|
|
||||||
// 重置选择状态
|
// 重置选择状态
|
||||||
|
|||||||
@ -39,25 +39,13 @@
|
|||||||
}}</view>
|
}}</view>
|
||||||
<view class="goods-price">
|
<view class="goods-price">
|
||||||
<text class="currency">¥</text>
|
<text class="currency">¥</text>
|
||||||
<text class="price">
|
<text class="price">{{ goodsData.price || 399 }}</text>
|
||||||
{{ goodsData.specificationPrice || 399 }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="goods-service-list">
|
||||||
class="goods-service-list"
|
|
||||||
v-if="
|
|
||||||
goodsData.commodityServiceList &&
|
|
||||||
goodsData.commodityServiceList.length
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<view class="service-title">包含服务</view>
|
<view class="service-title">包含服务</view>
|
||||||
<view
|
<view class="goods-service-item">
|
||||||
class="goods-service-item"
|
<text class="service-label">随时可退</text>
|
||||||
v-for="item in goodsData.commodityServiceList"
|
<text class="service-value">1份</text>
|
||||||
:key="item.serviceTitle"
|
|
||||||
>
|
|
||||||
<text class="service-label">{{ item.serviceTitle }}</text>
|
|
||||||
<text class="service-value">{{ item.serviceAmount }}</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -66,11 +54,7 @@
|
|||||||
|
|
||||||
<!-- 数量选择区域 -->
|
<!-- 数量选择区域 -->
|
||||||
<view class="quantity-section">
|
<view class="quantity-section">
|
||||||
<ModuleTitle
|
<ModuleTitle title="游客信息" />
|
||||||
:title="
|
|
||||||
goodsData.commodityTypeCode === '0' ? '订房信息' : '游客信息'
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Stepper v-model="quantity" />
|
<Stepper v-model="quantity" />
|
||||||
</view>
|
</view>
|
||||||
@ -83,11 +67,7 @@
|
|||||||
>
|
>
|
||||||
<FormCard
|
<FormCard
|
||||||
v-for="(item, index) in userFormList"
|
v-for="(item, index) in userFormList"
|
||||||
:title="
|
:title="`游客${index + 1}`"
|
||||||
goodsData.commodityTypeCode === '0'
|
|
||||||
? `房间${index + 1}`
|
|
||||||
: `游客${index + 1}`
|
|
||||||
"
|
|
||||||
:form="item"
|
:form="item"
|
||||||
:showDeleteIcon="userFormList.length > 1"
|
:showDeleteIcon="userFormList.length > 1"
|
||||||
:key="index"
|
:key="index"
|
||||||
@ -98,7 +78,7 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 总价区域 -->
|
<!-- 总价区域 -->
|
||||||
<SumCard :referencePrice="goodsData.specificationPrice" :discount="totalPrice" />
|
<SumCard />
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
@ -127,9 +107,7 @@ import SumCard from "@/components/SumCard/index.vue";
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
goodsData: {
|
goodsData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({
|
default: () => ({}),
|
||||||
commodityTypeCode: "0", // 商品类型 0-酒店 1-门票 2-餐饮
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -8,15 +8,6 @@
|
|||||||
<view class="tag-wrapper" v-if="goodsData.timeTag">
|
<view class="tag-wrapper" v-if="goodsData.timeTag">
|
||||||
<view class="time-tag">{{ goodsData.timeTag || "随时可退" }}</view>
|
<view class="time-tag">{{ goodsData.timeTag || "随时可退" }}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 日历ICON,酒店订单显示 -->
|
|
||||||
<uni-icons
|
|
||||||
class="calender-icon"
|
|
||||||
v-if="isShowCalendar"
|
|
||||||
type="calendar"
|
|
||||||
size="24"
|
|
||||||
color="#00A6FF"
|
|
||||||
@click="showCalendar"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 地址区域 -->
|
<!-- 地址区域 -->
|
||||||
@ -40,12 +31,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineProps, defineEmits } from "vue";
|
import { computed, defineProps } from "vue";
|
||||||
import LocationInfo from "@/components/LocationInfo/index.vue";
|
import LocationInfo from "@/components/LocationInfo/index.vue";
|
||||||
|
|
||||||
// 事件定义
|
|
||||||
const emits = defineEmits(["showCalendar"]);
|
|
||||||
|
|
||||||
// Props定义
|
// Props定义
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
goodsData: {
|
goodsData: {
|
||||||
@ -56,23 +44,12 @@ const props = defineProps({
|
|||||||
|
|
||||||
// 设施列表 - 使用computed优化性能
|
// 设施列表 - 使用computed优化性能
|
||||||
const facilitiesList = computed(() => {
|
const facilitiesList = computed(() => {
|
||||||
if (
|
if (props.goodsData.commodityTag && props.goodsData.commodityTag.length) {
|
||||||
props.goodsData.commodityFacilityList &&
|
return props.goodsData.commodityTag;
|
||||||
props.goodsData.commodityFacilityList.length
|
|
||||||
) {
|
|
||||||
return props.goodsData.commodityFacilityList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
// 日历弹窗
|
|
||||||
const showCalendar = () => emits("showCalendar");
|
|
||||||
|
|
||||||
// 是否显示日历按钮
|
|
||||||
const isShowCalendar = computed(() => {
|
|
||||||
return props.goodsData.commodityTypeCode === "0";
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
.good-info {
|
.good-info {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
|
||||||
// 标题区域
|
// 标题区域
|
||||||
.title-section {
|
.title-section {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
@ -12,10 +11,8 @@
|
|||||||
color: #333;
|
color: #333;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
flex: 0 280px;
|
display: block;
|
||||||
overflow: hidden;
|
margin-bottom: 8px;
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag-wrapper {
|
.tag-wrapper {
|
||||||
@ -30,14 +27,11 @@
|
|||||||
border: 1px solid #f55726;
|
border: 1px solid #f55726;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.calender-icon {
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 地址区域
|
// 地址区域
|
||||||
.address-section {
|
.address-section {
|
||||||
|
margin-bottom: 12px;
|
||||||
padding: 12px 0;
|
padding: 12px 0;
|
||||||
border-top: 1px solid #f0f0f0;
|
border-top: 1px solid #f0f0f0;
|
||||||
border-bottom: 1px solid #f0f0f0;
|
border-bottom: 1px solid #f0f0f0;
|
||||||
@ -58,8 +52,6 @@
|
|||||||
|
|
||||||
// 设施信息区域
|
// 设施信息区域
|
||||||
.facilities-section {
|
.facilities-section {
|
||||||
margin-top: 12px;
|
|
||||||
|
|
||||||
.facilities-grid {
|
.facilities-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<view class="goods-content">
|
<view class="goods-content">
|
||||||
<!-- 商品信息组件 -->
|
<!-- 商品信息组件 -->
|
||||||
<GoodInfo :goodsData="goodsData" @showCalendar="showCalendar" />
|
<GoodInfo :goodsData="goodsData" />
|
||||||
|
|
||||||
<ModuleTitle title="购买须知" />
|
<ModuleTitle title="购买须知" />
|
||||||
|
|
||||||
@ -36,32 +36,21 @@
|
|||||||
@confirm="handleConfirmOrder"
|
@confirm="handleConfirmOrder"
|
||||||
@close="handleCloseConfirm"
|
@close="handleCloseConfirm"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 日历组件 -->
|
|
||||||
<Calender
|
|
||||||
:visible="calendarVisible"
|
|
||||||
mode="range"
|
|
||||||
@close="handleCalendarClose"
|
|
||||||
@range-select="handleDateSelect"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
import { goodsDetail, orderPay } from "@/request/api/GoodsApi";
|
import { goodsDetail } from "@/request/api/GoodsApi";
|
||||||
import TopNavBar from "@/components/TopNavBar/index.vue";
|
import TopNavBar from "@/components/TopNavBar/index.vue";
|
||||||
import ImageSwiper from "@/components/ImageSwiper/index.vue";
|
import ImageSwiper from "@/components/ImageSwiper/index.vue";
|
||||||
import GoodInfo from "./components/GoodInfo/index.vue";
|
import GoodInfo from "./components/GoodInfo/index.vue";
|
||||||
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
import ModuleTitle from "@/components/ModuleTitle/index.vue";
|
||||||
import GoodConfirm from "./components/GoodConfirm/index.vue";
|
import GoodConfirm from "./components/GoodConfirm/index.vue";
|
||||||
import Calender from "@/components/Calender/index.vue";
|
|
||||||
|
|
||||||
const calendarVisible = ref(false);
|
|
||||||
const goodsData = ref({});
|
const goodsData = ref({});
|
||||||
const goodConfirmRef = ref(null);
|
const goodConfirmRef = ref(null);
|
||||||
const selectedDate = ref("");
|
|
||||||
|
|
||||||
// 获取商品详情数据
|
// 获取商品详情数据
|
||||||
const goodsInfo = async (params) => {
|
const goodsInfo = async (params) => {
|
||||||
@ -72,71 +61,20 @@ const goodsInfo = async (params) => {
|
|||||||
|
|
||||||
// 显示确认弹窗
|
// 显示确认弹窗
|
||||||
const showConfirmPopup = () => {
|
const showConfirmPopup = () => {
|
||||||
// 当商品类型为"0"时,需要校验入住和离店日期
|
|
||||||
if (goodsData.value.commodityTypeCode === "0") {
|
|
||||||
// 检查是否已选择日期
|
|
||||||
if (
|
|
||||||
!selectedDate.value ||
|
|
||||||
!selectedDate.value.startDate ||
|
|
||||||
!selectedDate.value.endDate
|
|
||||||
) {
|
|
||||||
calendarVisible.value = true;
|
|
||||||
|
|
||||||
uni.showToast({
|
|
||||||
title: "请先选择入住和离店日期",
|
|
||||||
icon: "none",
|
|
||||||
duration: 2000,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验通过或非住宿类商品,显示确认弹窗
|
|
||||||
goodConfirmRef.value?.showPopup();
|
goodConfirmRef.value?.showPopup();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理确认订单
|
// 处理确认订单
|
||||||
const handleConfirmOrder = async (orderData) => {
|
const handleConfirmOrder = (orderData) => {
|
||||||
console.log("确认订单:", orderData);
|
console.log("确认订单:", orderData);
|
||||||
// const commodityId = orderData.commodityId;
|
|
||||||
// const purchaseAmount = orderData.purchaseAmount;
|
|
||||||
// const checkInData = orderData.checkInData;
|
|
||||||
// const checkOutData = orderData.checkOutData;
|
|
||||||
// const consumerInfoEntityList = orderData.consumerInfoEntityList;
|
|
||||||
// const payWay = "0";
|
|
||||||
// const paySource = "1";
|
|
||||||
|
|
||||||
// const params = {
|
|
||||||
// commodityId,
|
|
||||||
// purchaseAmount,
|
|
||||||
// payWay,
|
|
||||||
// paySource,
|
|
||||||
// consumerInfoEntityList,
|
|
||||||
// checkInData,
|
|
||||||
// checkOutData,
|
|
||||||
// };
|
|
||||||
// const res = await orderPay(params);
|
|
||||||
|
|
||||||
// 仅作为示例,非真实参数信息。
|
|
||||||
// uni.requestPayment({
|
|
||||||
// provider: "wxpay",
|
|
||||||
// timeStamp: String(Date.now()),
|
|
||||||
// nonceStr: "A1B2C3D4E5",
|
|
||||||
// package: "prepay_id=wx20180101abcdefg",
|
|
||||||
// signType: "MD5",
|
|
||||||
// paySign: "",
|
|
||||||
// success: (res) => {
|
|
||||||
// console.log("success:" + JSON.stringify(res));
|
|
||||||
// },
|
|
||||||
// fail: (err) => {
|
|
||||||
// console.log("fail:" + JSON.stringify(err));
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "订单确认成功",
|
title: "订单确认成功",
|
||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
|
// 这里可以跳转到订单页面或支付页面
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: '/pages/order/detail?orderId=' + orderData.orderId
|
||||||
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理关闭弹窗
|
// 处理关闭弹窗
|
||||||
@ -147,25 +85,6 @@ const handleCloseConfirm = () => {
|
|||||||
onLoad(({ commodityId = "1950766939442774018" }) => {
|
onLoad(({ commodityId = "1950766939442774018" }) => {
|
||||||
goodsInfo({ commodityId });
|
goodsInfo({ commodityId });
|
||||||
});
|
});
|
||||||
|
|
||||||
// 显示日历弹窗
|
|
||||||
const showCalendar = () => (calendarVisible.value = true);
|
|
||||||
|
|
||||||
const handleCalendarClose = () => (calendarVisible.value = false);
|
|
||||||
|
|
||||||
const handleDateSelect = (data) => {
|
|
||||||
console.log("选择的日期:", data);
|
|
||||||
|
|
||||||
// 保存选择的日期范围
|
|
||||||
selectedDate.value = {
|
|
||||||
startDate: data.startDate,
|
|
||||||
endDate: data.endDate,
|
|
||||||
totalDays: data.totalDays,
|
|
||||||
};
|
|
||||||
|
|
||||||
// 日历组件会自动关闭,无需手动设置
|
|
||||||
calendarVisible.value = false;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@ -4,9 +4,4 @@ const goodsDetail = (args) => {
|
|||||||
return request.post("/hotelBiz/commodity/commodityDetail", args);
|
return request.post("/hotelBiz/commodity/commodityDetail", args);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 订单支付
|
export { goodsDetail };
|
||||||
const orderPay = (args) => {
|
|
||||||
return request.post("/hotelBiz/trade/order", args);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { goodsDetail, orderPay };
|
|
||||||
|
|||||||
@ -19,6 +19,11 @@ const preOrder = (args) => {
|
|||||||
return request.post("/hotelBiz/trade/preOrder", args);
|
return request.post("/hotelBiz/trade/preOrder", args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 订单支付
|
||||||
|
const orderPay = (args) => {
|
||||||
|
return request.post("/hotelBiz/trade/order", args);
|
||||||
|
};
|
||||||
|
|
||||||
// 订单取消
|
// 订单取消
|
||||||
const orderCancel = (args) => {
|
const orderCancel = (args) => {
|
||||||
return request.post("/hotelBiz/trade/cancelRefund", args);
|
return request.post("/hotelBiz/trade/cancelRefund", args);
|
||||||
@ -39,6 +44,7 @@ export {
|
|||||||
userWorkOrderList,
|
userWorkOrderList,
|
||||||
userOrderDetail,
|
userOrderDetail,
|
||||||
preOrder,
|
preOrder,
|
||||||
|
orderPay,
|
||||||
orderCancel,
|
orderCancel,
|
||||||
orderRefund,
|
orderRefund,
|
||||||
orderPayNow,
|
orderPayNow,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user