feat: 商品详情交互开发

This commit is contained in:
duanshuwen
2025-08-04 21:31:11 +08:00
parent 9546662cc9
commit a6bd06e06c
7 changed files with 182 additions and 40 deletions

View File

@@ -1,5 +1,10 @@
<template>
<uni-popup ref="popup" type="bottom" @maskClick="handleMaskClick">
<uni-popup
ref="popup"
type="bottom"
:safe-area="false"
@maskClick="handleMaskClick"
>
<!-- 弹窗主体 -->
<view class="calendar-popup" @tap.stop>
<!-- 头部区域 -->
@@ -7,7 +12,7 @@
<view class="header-content">
<text class="header-title">日历选择</text>
<text class="header-subtitle"
>选择入住和离店日期以下价格为单晚参考价</text
>选择住宿日期以下价格为单晚参考价</text
>
</view>
<view class="header-close" @tap="handleClose">
@@ -269,8 +274,12 @@ const getDateLabel = (dateStr) => {
return props.customLabels[dateStr];
}
// 为范围选择模式自动生成住/离标签
// 为范围选择模式自动生成住/离标签
if (props.mode === "range") {
if (dateStr === rangeStart.value && dateStr === rangeEnd.value) {
// 当入住和离店是同一天时,显示"住/离"
return "住/离";
}
if (dateStr === rangeStart.value) {
return "入住";
}
@@ -343,26 +352,26 @@ const handleRangeSelection = (dateInfo) => {
rangeEnd.value = dateInfo.date;
isRangeSelecting.value = false;
// 确保开始日期于结束日期
// 允许选择相同日期,但确保开始日期不大于结束日期
if (new Date(rangeStart.value) > new Date(rangeEnd.value)) {
[rangeStart.value, rangeEnd.value] = [rangeEnd.value, rangeStart.value];
}
// 检查日期跨度是否超过28天
// 检查日期跨度是否超过28天相同日期跨度为0天允许通过
const daysBetween = calculateDaysBetween(rangeStart.value, rangeEnd.value);
if (daysBetween > 28) {
// 使用uni.showToast显示错误提示
uni.showToast({
title: '预定时间不能超过28天',
icon: 'none',
duration: 3000
title: "预定时间不能超过28天",
icon: "none",
duration: 3000,
});
// 重置选择状态
rangeStart.value = null;
rangeEnd.value = null;
isRangeSelecting.value = false;
return;
}