Commit a86716551c09c3c0576daf19b6fd7ebfe43d61e1
1 parent
ecdefd73
测试的5条的bug优化
Showing
1 changed file
with
72 additions
and
30 deletions
pages/cart/cart/cart.js
... | ... | @@ -66,6 +66,8 @@ Page({ |
66 | 66 | |
67 | 67 | //优惠促销活动的集合 |
68 | 68 | yhcx_act_map: {}, |
69 | + //-- 活动的购买数量的map -- | |
70 | + act_buy_map:{} | |
69 | 71 | }, |
70 | 72 | |
71 | 73 | |
... | ... | @@ -645,7 +647,7 @@ Page({ |
645 | 647 | } |
646 | 648 | |
647 | 649 | //-- 如果有优惠促销,和阶梯促销,要看下有没有组合购,搭配购,看一下优惠促销和阶梯促销谁是指定商品参与的 -- |
648 | - if (item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7 || item.prom_type == 10) { | |
650 | + if (item.prom_type == 0 || item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7 || item.prom_type == 10) { | |
649 | 651 | var c_prom_type = 0; |
650 | 652 | var c_prom_id = 0; |
651 | 653 | |
... | ... | @@ -1190,24 +1192,27 @@ Page({ |
1190 | 1192 | // if (this.data.btn_click) { |
1191 | 1193 | // return false; |
1192 | 1194 | // } |
1193 | - this.data.btn_click = 1; | |
1194 | 1195 | |
1195 | - var a = t.currentTarget.dataset.item; | |
1196 | - var b = t.currentTarget.dataset.pitems; | |
1197 | - a = this.data.requestData[b].goods[a]; | |
1198 | - var e = a; | |
1199 | - var th = this; | |
1196 | + setTimeout(() => { | |
1197 | + if (this.data.up_dating == 1) return false; | |
1198 | + this.data.btn_click = 1; | |
1199 | + var a = t.currentTarget.dataset.item; | |
1200 | + var b = t.currentTarget.dataset.pitems; | |
1201 | + a = this.data.requestData[b].goods[a]; | |
1202 | + var e = a; | |
1203 | + var th = this; | |
1200 | 1204 | |
1201 | - if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { | |
1202 | - //this.clear_req(); | |
1203 | - var s = { | |
1204 | - goods_num: a, | |
1205 | - goods_id: e.goods_id, | |
1206 | - id: e.id, | |
1207 | - store_id: oo.stoid | |
1208 | - }; | |
1209 | - th.postCardList(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); | |
1210 | - } | |
1205 | + if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { | |
1206 | + //this.clear_req(); | |
1207 | + var s = { | |
1208 | + goods_num: a, | |
1209 | + goods_id: e.goods_id, | |
1210 | + id: e.id, | |
1211 | + store_id: oo.stoid | |
1212 | + }; | |
1213 | + th.postCardList(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); | |
1214 | + } | |
1215 | + },200) | |
1211 | 1216 | }, |
1212 | 1217 | |
1213 | 1218 | //-------------加减数量的时候,要把show_can_cx清理掉, |
... | ... | @@ -2632,11 +2637,13 @@ Page({ |
2632 | 2637 | //console.log("累计:"+tfeel); |
2633 | 2638 | |
2634 | 2639 | //-- 如果价格有发生变动,要更新界面中的价格显示 -- |
2635 | - if(item[c].goods_price!=th.data.dp_car[a].goods[c].goods_price){ | |
2636 | - let txt='requestData['+a+'].goods['+c+'].goods_price'; | |
2637 | - th.setData({ | |
2638 | - [txt]:item[c].goods_price | |
2639 | - }) | |
2640 | + if(th.data.dp_car && th.data.dp_car[a] && th.data.dp_car[a].goods) { | |
2641 | + if (item[c].goods_price != th.data.dp_car[a].goods[c].goods_price) { | |
2642 | + let txt = 'requestData[' + a + '].goods[' + c + '].goods_price'; | |
2643 | + th.setData({ | |
2644 | + [txt]: item[c].goods_price | |
2645 | + }) | |
2646 | + } | |
2640 | 2647 | } |
2641 | 2648 | |
2642 | 2649 | } |
... | ... | @@ -3572,7 +3579,8 @@ Page({ |
3572 | 3579 | //-- 如果是商品的结算 -- |
3573 | 3580 | if (check_is_goods_selected) { |
3574 | 3581 | var glist = []; //商品数组 |
3575 | - var map = new Map(); //使用map值键进行运算 | |
3582 | + var map = new Map(); //使用map值键进行运算 | |
3583 | + this.data.act_buy_map={}; //使用map值键进行运算活动商品的购买数量 | |
3576 | 3584 | |
3577 | 3585 | var g_arr = new Array(); //已选的商品列表 |
3578 | 3586 | var user_id = getApp().globalData.user_id; |
... | ... | @@ -3612,7 +3620,7 @@ Page({ |
3612 | 3620 | //-- 判断门店配送是不是匹配 -- |
3613 | 3621 | if(_pick && _pick.distr_type!=0 && i_arr[j].distr_type!=0 && _pick.distr_type!= i_arr[j].distr_type){ |
3614 | 3622 | getApp().confirmBox(i_arr[j].goods_name + "配送方式和门店不一致"); |
3615 | - wx.hideLoading(); | |
3623 | + th.clear_checkouting(); | |
3616 | 3624 | return false; |
3617 | 3625 | } |
3618 | 3626 | |
... | ... | @@ -3653,7 +3661,7 @@ Page({ |
3653 | 3661 | var p_can_by=fd1.act.goodslimit-fd1.act.goodslimited; |
3654 | 3662 | if(i_arr[j].goods_num+ky_n>p_can_by){ |
3655 | 3663 | getApp().confirmBox(i_arr[j].goods_name + "超出活动限购数量"+fd1.act.goodslimit+"件"); |
3656 | - wx.hideLoading(); | |
3664 | + th.clear_checkouting(); | |
3657 | 3665 | return false; |
3658 | 3666 | } |
3659 | 3667 | } |
... | ... | @@ -3736,9 +3744,18 @@ Page({ |
3736 | 3744 | } else { |
3737 | 3745 | map.set(i_arr[j].goods_id + "", i_arr[j].goods_num); |
3738 | 3746 | } |
3747 | + | |
3748 | + var ky_0=i_arr[j].prom_type + "-"+i_arr[j].prom_id; | |
3749 | + if(th.data.act_buy_map[ky_0]){ | |
3750 | + var n11 = th.data.act_buy_map[ky_0]; | |
3751 | + var n22 = parseInt(i_arr[j].goods_num) + parseInt(num11); | |
3752 | + th.data.act_buy_map[ky_0]=n22 | |
3753 | + }else{ | |
3754 | + th.data.act_buy_map[ky_0]=i_arr[j].goods_num | |
3755 | + } | |
3756 | + | |
3739 | 3757 | } |
3740 | 3758 | //glist += i_arr[j].goods_id + ","; |
3741 | - | |
3742 | 3759 | if(!i_arr[j].is_gift){ |
3743 | 3760 | var et= {"prom_type":i_arr[j].prom_type,"prom_id":i_arr[j].prom_id,"goods_id":i_arr[j].goods_id}; |
3744 | 3761 | glist.push(et); |
... | ... | @@ -3993,7 +4010,6 @@ Page({ |
3993 | 4010 | //进行到下一步 |
3994 | 4011 | th.cart_buy_next(glist,map,g_arr,checkArr7) |
3995 | 4012 | |
3996 | - | |
3997 | 4013 | } else if (res.cancel) { |
3998 | 4014 | th.clear_checkouting(); |
3999 | 4015 | console.log('用户点击取消') |
... | ... | @@ -4133,6 +4149,11 @@ Page({ |
4133 | 4149 | var num = map.get(val.goods_id + ""); |
4134 | 4150 | |
4135 | 4151 | var ky=val.goods_id + "-"+val.prom_type + "-"+val.prom_id; |
4152 | + var ky2=val.prom_type + "-"+val.prom_id; | |
4153 | + | |
4154 | + var num = map.get(val.goods_id + ""); | |
4155 | + var num2 = th.data.act_buy_map[ky2]; | |
4156 | + | |
4136 | 4157 | var buyed = map_limit.get(ky); |
4137 | 4158 | var cur_buyed=act_buyed_map[ky] |
4138 | 4159 | |
... | ... | @@ -4184,7 +4205,7 @@ Page({ |
4184 | 4205 | break; |
4185 | 4206 | } |
4186 | 4207 | |
4187 | - if (num + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) { | |
4208 | + if (num2 + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) { | |
4188 | 4209 | isok = 0; |
4189 | 4210 | gname = val.goods_name; |
4190 | 4211 | err="超出活动限购"; |
... | ... | @@ -4205,7 +4226,7 @@ Page({ |
4205 | 4226 | break; |
4206 | 4227 | } |
4207 | 4228 | } else { |
4208 | - if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price > 0) { | |
4229 | + if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price && val.prom_price > 0 && (g_arr[i].prom_type==1 && g_arr[i].prom_type==2) ) { | |
4209 | 4230 | isok = 0; |
4210 | 4231 | gname = val.goods_name; |
4211 | 4232 | err="商品价格已经变化"; |
... | ... | @@ -4466,7 +4487,12 @@ Page({ |
4466 | 4487 | //用来存销赠品的--2024-2-1 |
4467 | 4488 | let cart_zp=this.data.cart_zp; |
4468 | 4489 | //要清空一下门店下的赠品 |
4469 | - if(cart_zp[list.pid]){ | |
4490 | + if(cart_zp[list.pid] && cart_zp[list.pid].goods && cart_zp[list.pid].goods.length){ | |
4491 | + let ids = cart_zp[list.pid].goods.map(obj => obj.id); | |
4492 | + //-- 批量把赠品删掉 -- | |
4493 | + var url = '/api/weshop/cart/delIds/' + oo.stoid + '/' +getApp().globalData.user_id + '/' + ids.join(','); | |
4494 | + getApp().request.delete(url, {}); | |
4495 | + | |
4470 | 4496 | cart_zp[list.pid]={}; |
4471 | 4497 | } |
4472 | 4498 | //主要判断有没有促销活动 |
... | ... | @@ -4820,6 +4846,22 @@ Page({ |
4820 | 4846 | this.data.duo_zp_num_arr = {}; |
4821 | 4847 | //用来存销赠品的--2024-2-1 |
4822 | 4848 | let cart_zp=this.data.cart_zp; |
4849 | + | |
4850 | + if(cart_zp){ | |
4851 | + let ids=[]; | |
4852 | + for (const Ky in cart_zp) { | |
4853 | + if(cart_zp[Ky].goods && cart_zp[Ky].goods.length) { | |
4854 | + let ids0 = cart_zp[Ky].goods.map(obj => obj.id); | |
4855 | + ids = [...ids, ...ids0]; | |
4856 | + } | |
4857 | + } | |
4858 | + //调用接口把赠品删除 | |
4859 | + if(ids.length>0){ | |
4860 | + //-- 批量把赠品删掉 -- | |
4861 | + var url = '/api/weshop/cart/delIds/' + oo.stoid + '/' + getApp().globalData.user_id + '/' + ids.join(','); | |
4862 | + getApp().request.delete(url, {}); | |
4863 | + } | |
4864 | + } | |
4823 | 4865 | //要清空一下赠品数组 |
4824 | 4866 | cart_zp={}; |
4825 | 4867 | ... | ... |