hookehuyr

feat(预约): 添加时段类型支持并优化支付逻辑

添加 period_type 字段以区分日常和春节预约时段
修改支付逻辑以接口返回的 need_pay 为准判断是否需要支付
1 <!-- 1 <!--
2 * @Date: 2024-01-15 13:35:51 2 * @Date: 2024-01-15 13:35:51
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-15 16:47:29 4 + * @LastEditTime: 2026-01-16 17:33:27
5 * @FilePath: /xyxBooking-weapp/src/pages/booking/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/booking/index.vue
6 * @Description: 预约页面 6 * @Description: 预约页面
7 --> 7 -->
...@@ -234,9 +234,10 @@ const chooseDay = async (date) => { // 点击日期回调 ...@@ -234,9 +234,10 @@ const chooseDay = async (date) => { // 点击日期回调
234 // 如果可约,查询时间段信息 234 // 如果可约,查询时间段信息
235 if (info.reserve_full === ReserveStatus.AVAILABLE) { 235 if (info.reserve_full === ReserveStatus.AVAILABLE) {
236 // 选择日期后,查询时间段信息 236 // 选择日期后,查询时间段信息
237 - const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value}); 237 + const { code, data } = await canReserveTimeListAPI({ month_date: checked_day.value });
238 if (code) { 238 if (code) {
239 // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约; 239 // rest_qty >0表示有余量,可约;=0表示没有余量,不可约;<0表示不限,可约;
240 + // period_type 时段类型 REGULAR=日常预约,SPRING_FESTIVAL=春节预约
240 timePeriod.value = data; 241 timePeriod.value = data;
241 checked_time.value = -1; // 重置已选择的时间段 242 checked_time.value = -1; // 重置已选择的时间段
242 } 243 }
...@@ -293,7 +294,7 @@ const nextBtn = () => { ...@@ -293,7 +294,7 @@ const nextBtn = () => {
293 if (!checked_day.value || checked_time.value === -1) { 294 if (!checked_day.value || checked_time.value === -1) {
294 Taro.showToast({ title: '请选择日期和时间段', icon: 'none' }); 295 Taro.showToast({ title: '请选择日期和时间段', icon: 'none' });
295 } else { 296 } else {
296 - go('/submit', { date: checked_day.value, time: `${timePeriod.value[checked_time.value]['begin_time'].slice(0, -3)}-${timePeriod.value[checked_time.value]['end_time'].slice(0, -3)}`, price: checked_day_price.value }); 297 + go('/submit', { date: checked_day.value, time: `${timePeriod.value[checked_time.value]['begin_time'].slice(0, -3)}-${timePeriod.value[checked_time.value]['end_time'].slice(0, -3)}`, price: checked_day_price.value, period_type: timePeriod.value[checked_time.value].period_type });
297 } 298 }
298 } 299 }
299 </script> 300 </script>
......
1 <!-- 1 <!--
2 * @Date: 2024-01-15 16:25:51 2 * @Date: 2024-01-15 16:25:51
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2026-01-16 16:13:44 4 + * @LastEditTime: 2026-01-16 17:29:46
5 * @FilePath: /xyxBooking-weapp/src/pages/submit/index.vue 5 * @FilePath: /xyxBooking-weapp/src/pages/submit/index.vue
6 * @Description: 预约人员信息 6 * @Description: 预约人员信息
7 --> 7 -->
...@@ -71,6 +71,7 @@ const visitorList = ref([]); ...@@ -71,6 +71,7 @@ const visitorList = ref([]);
71 const date = ref(''); 71 const date = ref('');
72 const time = ref(''); 72 const time = ref('');
73 const price = ref(0); 73 const price = ref(0);
74 +const period_type = ref('');
74 75
75 /** 76 /**
76 * 生成15位身份证号中间8位替换为*号 77 * 生成15位身份证号中间8位替换为*号
...@@ -124,6 +125,7 @@ const goToVisitor = () => { ...@@ -124,6 +125,7 @@ const goToVisitor = () => {
124 125
125 // 待支付订单ID 126 // 待支付订单ID
126 const pending_pay_id = ref(null); 127 const pending_pay_id = ref(null);
128 +const pending_need_pay = ref(null);
127 129
128 const submitBtn = async () => { 130 const submitBtn = async () => {
129 if (!checked_visitors.value.length) { 131 if (!checked_visitors.value.length) {
...@@ -132,6 +134,7 @@ const submitBtn = async () => { ...@@ -132,6 +134,7 @@ const submitBtn = async () => {
132 } 134 }
133 135
134 let pay_id = pending_pay_id.value; 136 let pay_id = pending_pay_id.value;
137 + let need_pay = pending_need_pay.value;
135 138
136 if (!pay_id) { // TAG: 提交订单, 如果没有待支付订单ID, 则创建一个新的订单 139 if (!pay_id) { // TAG: 提交订单, 如果没有待支付订单ID, 则创建一个新的订单
137 Taro.showLoading({ title: '提交中...' }); 140 Taro.showLoading({ title: '提交中...' });
...@@ -139,20 +142,23 @@ const submitBtn = async () => { ...@@ -139,20 +142,23 @@ const submitBtn = async () => {
139 reserve_date: date.value, 142 reserve_date: date.value,
140 begin_time: time.value.split('-')[0], 143 begin_time: time.value.split('-')[0],
141 end_time: time.value.split('-')[1], 144 end_time: time.value.split('-')[1],
142 - person_id_list: JSON.stringify(checked_visitors.value) 145 + person_id_list: JSON.stringify(checked_visitors.value),
146 + period_type: period_type.value
143 }); 147 });
144 148
145 Taro.hideLoading(); 149 Taro.hideLoading();
146 150
147 - if (!code || code !== 1) { 151 + if (code != 1) {
148 return; 152 return;
149 } 153 }
150 pay_id = data.pay_id; 154 pay_id = data.pay_id;
151 pending_pay_id.value = pay_id; 155 pending_pay_id.value = pay_id;
156 + need_pay = data?.need_pay;
157 + pending_need_pay.value = need_pay;
152 } 158 }
153 159
154 - // 如果金额大于零, 走微信支付, 如果等于零直接跳转成功页 160 + // 以接口返回的 need_pay 为准:1=需要支付,0=不需要支付
155 - if (total.value > 0) { 161 + if (Number(need_pay) === 1 || need_pay === true) {
156 Taro.showLoading({ title: '支付准备中...' }); 162 Taro.showLoading({ title: '支付准备中...' });
157 const payParams = await wxPayAPI({ pay_id }); // 参数接口 163 const payParams = await wxPayAPI({ pay_id }); // 参数接口
158 Taro.hideLoading(); 164 Taro.hideLoading();
...@@ -166,6 +172,8 @@ const submitBtn = async () => { ...@@ -166,6 +172,8 @@ const submitBtn = async () => {
166 signType: pay_params.signType, 172 signType: pay_params.signType,
167 paySign: pay_params.paySign, 173 paySign: pay_params.paySign,
168 success(res) { 174 success(res) {
175 + pending_pay_id.value = null;
176 + pending_need_pay.value = null;
169 go('/success', { pay_id }); 177 go('/success', { pay_id });
170 }, 178 },
171 fail(res) { 179 fail(res) {
...@@ -176,10 +184,12 @@ const submitBtn = async () => { ...@@ -176,10 +184,12 @@ const submitBtn = async () => {
176 }) 184 })
177 } else { 185 } else {
178 pending_pay_id.value = null; // 支付参数获取失败,重置订单ID 186 pending_pay_id.value = null; // 支付参数获取失败,重置订单ID
187 + pending_need_pay.value = null;
179 Taro.showToast({ title: payParams.msg || '获取支付信息失败', icon: 'none' }); 188 Taro.showToast({ title: payParams.msg || '获取支付信息失败', icon: 'none' });
180 } 189 }
181 } else { 190 } else {
182 - // 金额等于零, 直接跳转成功页 191 + pending_pay_id.value = null;
192 + pending_need_pay.value = null;
183 go('/success', { pay_id }); 193 go('/success', { pay_id });
184 } 194 }
185 } 195 }
...@@ -189,9 +199,10 @@ useDidShow(async () => { ...@@ -189,9 +199,10 @@ useDidShow(async () => {
189 date.value = params.date || ''; 199 date.value = params.date || '';
190 time.value = params.time || ''; 200 time.value = params.time || '';
191 price.value = params.price || 0; 201 price.value = params.price || 0;
202 + period_type.value = params.period_type || '';
192 203
193 if (date.value && time.value) { 204 if (date.value && time.value) {
194 - const { code, data } = await personListAPI({ reserve_date: date.value, begin_time: time.value.split('-')[0], end_time: time.value.split('-')[1] }); 205 + const { code, data } = await personListAPI({ reserve_date: date.value, begin_time: time.value.split('-')[0], end_time: time.value.split('-')[1], period_type: period_type.value });
195 if (code) { 206 if (code) {
196 visitorList.value = data || []; 207 visitorList.value = data || [];
197 } 208 }
......