|
@@ -10,14 +10,60 @@ Page({ |
|
@@ -10,14 +10,60 @@ Page({ |
|
10
|
available: '1', //输入金额够优惠券最低消费1 不够0
|
10
|
available: '1', //输入金额够优惠券最低消费1 不够0
|
|
11
|
couponArr: [], //所有券列表
|
11
|
couponArr: [], //所有券列表
|
|
12
|
dataStr: Date.now() * 1 / 1000,
|
12
|
dataStr: Date.now() * 1 / 1000,
|
|
|
|
13
|
+ discountPrice: '', //优惠价格
|
|
|
|
14
|
+ actualPrice: '', //实付价格
|
|
13
|
},
|
15
|
},
|
|
14
|
couponModal: '',
|
16
|
couponModal: '',
|
|
|
|
17
|
+ monidata: [{
|
|
|
|
18
|
+ desc: "0", //优惠条件
|
|
|
|
19
|
+ price: "6", //优惠金额
|
|
|
|
20
|
+ showCpupon: '1', //是否可选
|
|
|
|
21
|
+ checked: true, //是否勾选
|
|
|
|
22
|
+ activity_id: "566",
|
|
|
|
23
|
+ aid: "948",
|
|
|
|
24
|
+ aname: "新测试一下",
|
|
|
|
25
|
+ cdate: "1739429461", //领取日期
|
|
|
|
26
|
+ arule: {
|
|
|
|
27
|
+ commission: "1",
|
|
|
|
28
|
+ is_accumulation: "1",
|
|
|
|
29
|
+ is_appointment: "1",
|
|
|
|
30
|
+ is_commission: "1",
|
|
|
|
31
|
+ is_compartment: "1",
|
|
|
|
32
|
+ is_eatin: "1",
|
|
|
|
33
|
+ is_same_day: "1", //领取当日是否可用
|
|
|
|
34
|
+ is_share_have: "1",
|
|
|
|
35
|
+ is_share_lose: "1",
|
|
|
|
36
|
+ is_takeout: "1",
|
|
|
|
37
|
+ },
|
|
|
|
38
|
+ etime: "1739635199",
|
|
|
|
39
|
+ exp_date: '{"week_show":"无","week_data":[{"id":null,"title":"周日","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"周一","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"周二","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"周三","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"周四","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"周五","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"周六","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false},{"id":null,"title":"法定假日","select":false,"roleName":null,"phone":null,"account":null,"selectMor":false,"selectNoon":false,"selectNig":false}]}',
|
|
|
|
40
|
+ explain: "",
|
|
|
|
41
|
+ grant_last: "93",
|
|
|
|
42
|
+ grant_num: "100",
|
|
|
|
43
|
+ id: "948",
|
|
|
|
44
|
+ is_examine: "1",
|
|
|
|
45
|
+ is_open: "1",
|
|
|
|
46
|
+ is_type: "3",
|
|
|
|
47
|
+ lite_qrcode: "https://xt04.colorcun.com/activity/LiteQRcode/activity_948.jpeg",
|
|
|
|
48
|
+ map_address: "陕西省西安市沣惠南路36号",
|
|
|
|
49
|
+ openid: "oB-xJ5NGdgXHM0Pdsq2kAf7z-n9k",
|
|
|
|
50
|
+ phone: "15715807436",
|
|
|
|
51
|
+ seller_image: "http://libpc.colorcun.com/20241118173230_b2dbe5ec7ca79a64bf7eea6f0cab3dca",
|
|
|
|
52
|
+ seller_tel: "010-6257270,15236523652336",
|
|
|
|
53
|
+ sellerid: "4352",
|
|
|
|
54
|
+ sellername: "长安大排档总店",
|
|
|
|
55
|
+ status: "1",
|
|
|
|
56
|
+ stime: "1739289600",
|
|
|
|
57
|
+ uid: "7035",
|
|
|
|
58
|
+ uid_list: null,
|
|
|
|
59
|
+ urllink: "https://wxaurl.cn/m7EcFm28Kfr",
|
|
|
|
60
|
+ }],
|
|
15
|
/**
|
61
|
/**
|
|
16
|
* 生命周期函数--监听页面加载
|
62
|
* 生命周期函数--监听页面加载
|
|
17
|
*/
|
63
|
*/
|
|
18
|
onLoad(options) {
|
64
|
onLoad(options) {
|
|
19
|
this.couponModal = this.selectComponent("#couponModal");
|
65
|
this.couponModal = this.selectComponent("#couponModal");
|
|
20
|
- this.couponModal.showModal()
|
66
|
+ // this.couponModal.showModal()
|
|
21
|
this.setData({
|
67
|
this.setData({
|
|
22
|
...options
|
68
|
...options
|
|
23
|
})
|
69
|
})
|
|
@@ -49,11 +95,6 @@ Page({ |
|
@@ -49,11 +95,6 @@ Page({ |
|
49
|
this.getCoupon()
|
95
|
this.getCoupon()
|
|
50
|
})
|
96
|
})
|
|
51
|
},
|
97
|
},
|
|
52
|
- // 点确认选择
|
|
|
|
53
|
- checkCertificate() {
|
|
|
|
54
|
- console.log('1111111111');
|
|
|
|
55
|
- this.closeCouponModal()
|
|
|
|
56
|
- },
|
|
|
|
57
|
// 获取所有优惠券列表
|
98
|
// 获取所有优惠券列表
|
|
58
|
getCoupon() {
|
99
|
getCoupon() {
|
|
59
|
App.Activity.ActivityListByOpenid().then(res => {
|
100
|
App.Activity.ActivityListByOpenid().then(res => {
|
|
@@ -65,6 +106,9 @@ Page({ |
|
@@ -65,6 +106,9 @@ Page({ |
|
65
|
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
|
106
|
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
|
|
66
|
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
|
107
|
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
|
|
67
|
detail.arule = detail.arule ? util.determine(detail.arule) : '';
|
108
|
detail.arule = detail.arule ? util.determine(detail.arule) : '';
|
|
|
|
109
|
+ if (detail.arule) {
|
|
|
|
110
|
+ detail.accumulationShow = detail.arule.is_accumulation
|
|
|
|
111
|
+ }
|
|
68
|
if (detail.exp_date && detail.exp_date.week_data) {
|
112
|
if (detail.exp_date && detail.exp_date.week_data) {
|
|
69
|
let noon = this.hasConsecutiveSelect(detail.exp_date.week_data, '1').rArr.join('、')
|
113
|
let noon = this.hasConsecutiveSelect(detail.exp_date.week_data, '1').rArr.join('、')
|
|
70
|
let nig = this.hasConsecutiveSelect(detail.exp_date.week_data, '2').rArr.join('、')
|
114
|
let nig = this.hasConsecutiveSelect(detail.exp_date.week_data, '2').rArr.join('、')
|
|
@@ -74,10 +118,13 @@ Page({ |
|
@@ -74,10 +118,13 @@ Page({ |
|
74
|
detail.nigText = nig;
|
118
|
detail.nigText = nig;
|
|
75
|
}
|
119
|
}
|
|
76
|
detail.checked = false;
|
120
|
detail.checked = false;
|
|
|
|
121
|
+ detail.showCpupon = '0';
|
|
|
|
122
|
+ detail.cdateText = util.unixtoTime(detail.cdate, 'YYYY-MM-DD')
|
|
77
|
detail.endDateStr = util.unixtoTime(detail.stime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.etime, 'YYYY-MM-DD')
|
123
|
detail.endDateStr = util.unixtoTime(detail.stime, 'YYYY-MM-DD') + '至' + util.unixtoTime(detail.etime, 'YYYY-MM-DD')
|
|
78
|
})
|
124
|
})
|
|
79
|
- console.log(list);
|
|
|
|
80
|
-
|
125
|
+ list.sort((a, b) => {
|
|
|
|
126
|
+ return (a.etime * 1) - (b.etime * 1)
|
|
|
|
127
|
+ })
|
|
81
|
let couponArr = list
|
128
|
let couponArr = list
|
|
82
|
this.setData({
|
129
|
this.setData({
|
|
83
|
couponArr
|
130
|
couponArr
|
|
@@ -85,14 +132,229 @@ Page({ |
|
@@ -85,14 +132,229 @@ Page({ |
|
85
|
}
|
132
|
}
|
|
86
|
})
|
133
|
})
|
|
87
|
},
|
134
|
},
|
|
|
|
135
|
+ // 勾选券
|
|
88
|
checkboxChange(e) {
|
136
|
checkboxChange(e) {
|
|
89
|
console.log('checkbox发生change事件,携带value值为:', e.detail.value)
|
137
|
console.log('checkbox发生change事件,携带value值为:', e.detail.value)
|
|
|
|
138
|
+ const list = this.data.couponArr
|
|
|
|
139
|
+ const values = e.detail.value
|
|
|
|
140
|
+ for (let i = 0, lenI = list.length; i < lenI; ++i) {
|
|
|
|
141
|
+ list[i].checked = false
|
|
|
|
142
|
+ for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
|
|
|
|
143
|
+ if (list[i].activity_id === values[j]) {
|
|
|
|
144
|
+ list[i].checked = true
|
|
|
|
145
|
+ break
|
|
|
|
146
|
+ }
|
|
|
|
147
|
+ }
|
|
|
|
148
|
+ }
|
|
|
|
149
|
+ this.setData({
|
|
|
|
150
|
+ couponArr: list
|
|
|
|
151
|
+ })
|
|
90
|
},
|
152
|
},
|
|
91
|
// 输入金额
|
153
|
// 输入金额
|
|
92
|
bindKeyInput(e) {
|
154
|
bindKeyInput(e) {
|
|
|
|
155
|
+ console.log('输入金额,bindchange携带value值为:', e.detail.value);
|
|
|
|
156
|
+ let list = this.data.couponArr;
|
|
|
|
157
|
+ // 所有的券重置
|
|
|
|
158
|
+ list.forEach(i => {
|
|
|
|
159
|
+ i.checked = false;
|
|
|
|
160
|
+ i.showCpupon = '0'
|
|
|
|
161
|
+ })
|
|
93
|
this.setData({
|
162
|
this.setData({
|
|
94
|
- inputValue: e.detail.value
|
163
|
+ inputValue: e.detail.value,
|
|
|
|
164
|
+ couponArr: list
|
|
95
|
})
|
165
|
})
|
|
|
|
166
|
+
|
|
|
|
167
|
+ this.colationData()
|
|
|
|
168
|
+ },
|
|
|
|
169
|
+ // 点确认选择
|
|
|
|
170
|
+ checkCertificate() {
|
|
|
|
171
|
+ this.closeCouponModal()
|
|
|
|
172
|
+ let list = this.data.couponArr;
|
|
|
|
173
|
+ list = list.filter(i => {
|
|
|
|
174
|
+ return i.checked
|
|
|
|
175
|
+ })
|
|
|
|
176
|
+ let price = 0;
|
|
|
|
177
|
+ list.forEach(i => {
|
|
|
|
178
|
+ price += i.price * 1
|
|
|
|
179
|
+ })
|
|
|
|
180
|
+ console.log('优惠金额----', price);
|
|
|
|
181
|
+ let val = this.data.inputValue * 1;
|
|
|
|
182
|
+ let actualPrice = val - price.toFixed(2)
|
|
|
|
183
|
+ this.setData({
|
|
|
|
184
|
+ discountPrice: price,
|
|
|
|
185
|
+ actualPrice: actualPrice > 0 ? actualPrice : 0.1,
|
|
|
|
186
|
+ })
|
|
|
|
187
|
+ console.log('点确认选择后', list);
|
|
|
|
188
|
+ },
|
|
|
|
189
|
+ // 处理显示券可用、不可用的列表
|
|
|
|
190
|
+ async colationData() {
|
|
|
|
191
|
+ let list = this.data.couponArr;
|
|
|
|
192
|
+ // list = list
|
|
|
|
193
|
+ list = await this.filterCoupons(list);
|
|
|
|
194
|
+ list = await this.findBestCoupons(list);
|
|
|
|
195
|
+ console.log('eeeeeeeeeeee', list);
|
|
|
|
196
|
+ list.sort((a, b) => b.showCpupon - a.showCpupon);
|
|
|
|
197
|
+ // list.filter(i=>{return i.aexpiration!='0' && i.aexpiration>0})
|
|
|
|
198
|
+ this.setData({
|
|
|
|
199
|
+ couponArr: list
|
|
|
|
200
|
+ })
|
|
|
|
201
|
+ },
|
|
|
|
202
|
+ filterCoupons(list) {
|
|
|
|
203
|
+ console.log(1111111, list);
|
|
|
|
204
|
+ // const currentTime = Math.floor(Date.now() / 1000); // 获取当前时间的 Unix 时间戳(秒)
|
|
|
|
205
|
+ // const today = new Date(); // 获取今天的日期
|
|
|
|
206
|
+ // today.setHours(0, 0, 0, 0); // 将时间设为今天的开始时间
|
|
|
|
207
|
+ // const todayTimestamp = Math.floor(today.getTime() / 1000); // 获取今天的开始时间戳
|
|
|
|
208
|
+
|
|
|
|
209
|
+ // return list.filter(coupon => {
|
|
|
|
210
|
+ // const couponCDate = parseInt(coupon.cdate); // 领取日期
|
|
|
|
211
|
+ // const validDays = parseInt(coupon.aexpiration); // 有效天数
|
|
|
|
212
|
+ // const isSameDay = parseInt(coupon.arule.is_same_day); // 领取当日是否可用
|
|
|
|
213
|
+
|
|
|
|
214
|
+ // // 计算有效期结束时间
|
|
|
|
215
|
+ // const couponExpirationDate = couponCDate + validDays * 24 * 60 * 60; // 有效期结束时间戳
|
|
|
|
216
|
+ // // 筛选条件
|
|
|
|
217
|
+ // const isWithinValidity = todayTimestamp >= couponCDate && todayTimestamp <= couponExpirationDate;
|
|
|
|
218
|
+ // return (
|
|
|
|
219
|
+ // (todayTimestamp > couponCDate && isWithinValidity) || // 今天不是领取当日,但在有效天数内
|
|
|
|
220
|
+ // (todayTimestamp === couponCDate && isSameDay === 1 && validDays >= 1) // 今天是领取当日且可用
|
|
|
|
221
|
+ // );
|
|
|
|
222
|
+ // });
|
|
|
|
223
|
+
|
|
|
|
224
|
+
|
|
|
|
225
|
+ // const currentTime = Math.floor(Date.now() / 1000); // 获取当前时间的 Unix 时间戳(秒)
|
|
|
|
226
|
+ // const today = new Date(); // 获取今天的日期
|
|
|
|
227
|
+ // today.setHours(0, 0, 0, 0); // 将时间设为今天的开始时间
|
|
|
|
228
|
+ // const todayTimestamp = Math.floor(today.getTime() / 1000); // 获取今天的开始时间戳
|
|
|
|
229
|
+
|
|
|
|
230
|
+ // list.forEach(coupon => {
|
|
|
|
231
|
+ // const couponCDate = parseInt(coupon.cdate); // 领取日期
|
|
|
|
232
|
+ // const validDays = parseInt(coupon.aexpiration); // 有效天数
|
|
|
|
233
|
+ // const isSameDay = parseInt(coupon.arule.is_same_day); // 领取当日是否可用
|
|
|
|
234
|
+ // // const couponExpirationDate = couponCDate + validDays * 24 * 60 * 60; // 有效期结束时间戳
|
|
|
|
235
|
+
|
|
|
|
236
|
+ // let date = new Date(couponCDate * 1000);
|
|
|
|
237
|
+ // date.setDate(date.getDate() + validDays);
|
|
|
|
238
|
+ // date.setHours(23, 59, 59, 0);
|
|
|
|
239
|
+ // let couponExpirationDate = Math.floor(date.getTime() / 1000);
|
|
|
|
240
|
+ // // 今天的开始时间戳 <= 领取日期
|
|
|
|
241
|
+ // const isWithinValidity = (todayTimestamp <= couponCDate) && (todayTimestamp <= couponExpirationDate);
|
|
|
|
242
|
+ // console.log('领取日期---',couponCDate);
|
|
|
|
243
|
+ // console.log('有效天数---',validDays);
|
|
|
|
244
|
+ // console.log('领取当日是否可用---',isSameDay);
|
|
|
|
245
|
+ // console.log('有效期结束时间戳---',couponExpirationDate);
|
|
|
|
246
|
+ // console.log('isWithinValidity---',isWithinValidity);
|
|
|
|
247
|
+ // console.log('获取今天的开始时间戳---',todayTimestamp);
|
|
|
|
248
|
+ // console.log('wwwwwwwwwww---',(todayTimestamp >= couponCDate));
|
|
|
|
249
|
+ // console.log('ggggggggggg---',(todayTimestamp <= couponExpirationDate));
|
|
|
|
250
|
+ // // 今天不是领取当日,但在有效天数内 || 今天是领取当日且可用
|
|
|
|
251
|
+ // if ((todayTimestamp > couponCDate && isWithinValidity) || (todayTimestamp === couponCDate && isSameDay === 1 && validDays >= 1)) {
|
|
|
|
252
|
+ // coupon.aa = '1';
|
|
|
|
253
|
+ // console.log('可用',coupon.aname);
|
|
|
|
254
|
+ // } else {
|
|
|
|
255
|
+ // coupon.aa = '0';
|
|
|
|
256
|
+ // console.log('不可用',coupon.aname);
|
|
|
|
257
|
+ // }
|
|
|
|
258
|
+ // });
|
|
|
|
259
|
+
|
|
|
|
260
|
+
|
|
|
|
261
|
+ const currentTime = Math.floor(Date.now() / 1000); // 获取当前时间的 Unix 时间戳(秒)
|
|
|
|
262
|
+
|
|
|
|
263
|
+ // 获取今天的开始时间和结束时间
|
|
|
|
264
|
+ const today = new Date();
|
|
|
|
265
|
+ today.setHours(0, 0, 0, 0); // 设置为今天的开始时间
|
|
|
|
266
|
+ const todayStartTimestamp = Math.floor(today.getTime() / 1000); // 今天的开始时间戳
|
|
|
|
267
|
+
|
|
|
|
268
|
+ today.setHours(23, 59, 59); // 设置为今天的结束时间
|
|
|
|
269
|
+ const todayEndTimestamp = Math.floor(today.getTime() / 1000); // 今天的结束时间戳
|
|
|
|
270
|
+
|
|
|
|
271
|
+ list.forEach(coupon => {
|
|
|
|
272
|
+ const couponCDate = parseInt(coupon.cdate); // 领取日期
|
|
|
|
273
|
+ const validDays = parseInt(coupon.aexpiration); // 有效天数
|
|
|
|
274
|
+ const isSameDay = parseInt(coupon.arule.is_same_day); // 领取当日是否可用
|
|
|
|
275
|
+
|
|
|
|
276
|
+ // 计算有效期结束时间
|
|
|
|
277
|
+ const couponExpirationDate = couponCDate + validDays * 24 * 60 * 60; // 有效期结束时间戳
|
|
|
|
278
|
+
|
|
|
|
279
|
+ // 判断条件
|
|
|
|
280
|
+ const isWithinValidity = todayStartTimestamp > couponCDate && todayEndTimestamp < couponExpirationDate;
|
|
|
|
281
|
+
|
|
|
|
282
|
+ if (
|
|
|
|
283
|
+ (todayStartTimestamp > couponCDate && isWithinValidity) || // 今天不是领取当日,但在有效天数内
|
|
|
|
284
|
+ (todayStartTimestamp === couponCDate && isSameDay === 1 && validDays >= 1) // 今天是领取当日且可用
|
|
|
|
285
|
+ ) {
|
|
|
|
286
|
+ coupon.aa = '1'; // 符合条件,设置为可选
|
|
|
|
287
|
+ } else {
|
|
|
|
288
|
+ coupon.aa = '0'; // 不符合条件,设置为不可选
|
|
|
|
289
|
+ }
|
|
|
|
290
|
+ });
|
|
|
|
291
|
+
|
|
|
|
292
|
+
|
|
|
|
293
|
+
|
|
|
|
294
|
+
|
|
|
|
295
|
+
|
|
|
|
296
|
+
|
|
|
|
297
|
+
|
|
|
|
298
|
+
|
|
|
|
299
|
+ console.log('1111', list);
|
|
|
|
300
|
+ return list
|
|
|
|
301
|
+ },
|
|
|
|
302
|
+ // (消费要求为无门槛 或者 小于输入金额的) && 勾选最优的
|
|
|
|
303
|
+ findBestCoupons(arr) {
|
|
|
|
304
|
+ console.log(333333333);
|
|
|
|
305
|
+ let inputValue = this.data.inputValue;
|
|
|
|
306
|
+ const amount = parseFloat(inputValue); // 将输入金额转换为数字
|
|
|
|
307
|
+ const validCoupons = arr.filter(coupon => (coupon.aa == '1' && parseFloat(coupon.desc) <= amount)); // 筛选符合条件的优惠券
|
|
|
|
308
|
+ console.log('validCouponsvalidCoupons', validCoupons);
|
|
|
|
309
|
+ let bestDiscount = 0;
|
|
|
|
310
|
+ let bestCoupons = [];
|
|
|
|
311
|
+
|
|
|
|
312
|
+ // 按到期时间排序,确保优先选择最早到期的券
|
|
|
|
313
|
+ validCoupons.sort((a, b) => parseInt(a.etime) - parseInt(b.etime));
|
|
|
|
314
|
+
|
|
|
|
315
|
+ // 使用递归函数来查找所有组合
|
|
|
|
316
|
+ function findBestCombination(currentCoupons, currentDiscount, remainingCoupons) {
|
|
|
|
317
|
+ const totalDiscount = currentDiscount;
|
|
|
|
318
|
+ const finalPrice = amount - totalDiscount;
|
|
|
|
319
|
+ // 检查当前组合是否是最佳组合且实付价格不小于0
|
|
|
|
320
|
+ if (finalPrice >= 0 && totalDiscount > bestDiscount) {
|
|
|
|
321
|
+ bestDiscount = totalDiscount;
|
|
|
|
322
|
+ bestCoupons = currentCoupons.slice(); // 复制当前组合
|
|
|
|
323
|
+ }
|
|
|
|
324
|
+
|
|
|
|
325
|
+ // 遍历剩余的优惠券
|
|
|
|
326
|
+ for (let i = 0; i < remainingCoupons.length; i++) {
|
|
|
|
327
|
+ const nextCoupon = remainingCoupons[i];
|
|
|
|
328
|
+ currentCoupons.push(nextCoupon); // 选择当前优惠券
|
|
|
|
329
|
+ findBestCombination(currentCoupons, currentDiscount + parseFloat(nextCoupon.price), remainingCoupons.slice(i + 1)); // 递归查找
|
|
|
|
330
|
+ currentCoupons.pop(); // 回溯
|
|
|
|
331
|
+ }
|
|
|
|
332
|
+ }
|
|
|
|
333
|
+
|
|
|
|
334
|
+ findBestCombination([], 0, validCoupons);
|
|
|
|
335
|
+
|
|
|
|
336
|
+
|
|
|
|
337
|
+ let totalDiscountPrice = 0;
|
|
|
|
338
|
+ // 更新选中的优惠券
|
|
|
|
339
|
+ bestCoupons.forEach(coupon => {
|
|
|
|
340
|
+ console.log('选中的券', {
|
|
|
|
341
|
+ ...coupon
|
|
|
|
342
|
+ });
|
|
|
|
343
|
+ coupon.showCpupon = '1';
|
|
|
|
344
|
+ coupon.checked = true;
|
|
|
|
345
|
+ totalDiscountPrice += parseFloat(coupon.price); // 使用 parseFloat 确保类型正确
|
|
|
|
346
|
+ });
|
|
|
|
347
|
+
|
|
|
|
348
|
+ console.log('总优惠金额:', totalDiscountPrice);
|
|
|
|
349
|
+ let actualPrice = (amount - totalDiscountPrice).toFixed(2);
|
|
|
|
350
|
+ console.log('实际支付金额:', actualPrice);
|
|
|
|
351
|
+
|
|
|
|
352
|
+ this.setData({
|
|
|
|
353
|
+ discountPrice: totalDiscountPrice,
|
|
|
|
354
|
+ actualPrice: actualPrice > 0 ? actualPrice : '0.1', // 确保实际支付金额不小于0.01
|
|
|
|
355
|
+ });
|
|
|
|
356
|
+
|
|
|
|
357
|
+ return arr; // 返回更新后的数组
|
|
96
|
},
|
358
|
},
|
|
97
|
// 处理优惠券不可用日期数据
|
359
|
// 处理优惠券不可用日期数据
|
|
98
|
hasConsecutiveSelect(arr, type) {
|
360
|
hasConsecutiveSelect(arr, type) {
|