From d96122807a6ab986627271b9ef3286d08013dec5 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 3 Jan 2024 10:55:02 +0800 Subject: [PATCH] 优化完成 --- components/promate_pop/promate_pop.wxss | 1 + packageE/pages/cart/cart2/cart2.js | 2 +- pages/cart/cart/cart.js | 29 ++++++++++++++++++++--------- utils/more_cx.js | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/components/promate_pop/promate_pop.wxss b/components/promate_pop/promate_pop.wxss index cdfc171..0b1f70b 100644 --- a/components/promate_pop/promate_pop.wxss +++ b/components/promate_pop/promate_pop.wxss @@ -261,6 +261,7 @@ .xc-hook.on { transform: rotate(-135deg); background-color: #d60021; + font-size: 24rpx } @import '../../app.wxss'; diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index ffc6a5a..cf76bf1 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -1294,7 +1294,7 @@ Page({ await m_cx.cart_cx_group(th, arr[k].goods, c_item, 0, 0, (show_can_cx) => { arr[k].show_can_cx = show_can_cx; - }) + },2) } else { var show_can_cx = this.data.cartlist[k].show_can_cx; //-- 多促销活动的优化 -- diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 9074bc8..fdb1f8a 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -855,6 +855,7 @@ Page({ item.selected = 0; item.erpwareid = good.erpwareid; //要同步下线商品的id item.shop_price = good.shop_price; //要同步下线商品的id + item.init_goods_price=good.goods_price; //-- 读出每一种商品的所有的活动,方便后面的活动切换使用 -- if (item.prom_type == 0) @@ -1559,6 +1560,10 @@ Page({ var fir = 0; for (var j = 0; j < item.length; j++) { if (item[j].is_gift) continue; + + //把价格还原 + item[j].goods_price=item[j].init_goods_price; + var obj = JSON.parse(JSON.stringify(item[j])); var gd_info=obj; @@ -2078,6 +2083,7 @@ Page({ this.data.btn_click = 1; var garr = e.data.service_data; + //之前没有选中,代表现在要选中 if (!a.selected) { //如果是标记的时候 @@ -2385,7 +2391,7 @@ Page({ //不需要修改价格 await m_cx.cart_cx_group(th, ite1, car[a], 0, n_ok, (show_can_cx) => { rd_arr.push(show_can_cx) - },1) + }) } if(car.length>1 && c_ind>-1){ @@ -2393,7 +2399,7 @@ Page({ //检验和设置商品的最终是以 取用什么活动,因为多促销 await m_cx.cart_cx_group(th, ite2, car[c_ind], 0, n_ok, (show_can_cx) => { rd_arr[c_ind]=show_can_cx; - },1) + }) } for (var a = 0; a < car.length; a++) { @@ -4012,7 +4018,7 @@ Page({ //如果会员是等级会员,商品有等级价,且不是活动商品 if (card_field && val[card_field] > 0 && - ((val.prom_type == 0 && g_arr[i].prom_type == 0) || g_arr[i].prom_type == 3 || g_arr[i].prom_type == 5 || g_arr[i].prom_type == 7 || g_arr[i].prom_type == 10)) { + ((val.prom_type == 0 && g_arr[i].prom_type == 0) || g_arr[i].prom_type == 5 || g_arr[i].prom_type == 7 || g_arr[i].prom_type == 10)) { if (g_arr[i].goods_price != val[card_field]) { isok = 0; gname = val.goods_name; @@ -5104,8 +5110,11 @@ Page({ var th = this; var car = JSON.parse(JSON.stringify(this.data.requestData)); - var item = car[c_idx].goods, - is_s_sele = 1; + var item = car[c_idx].goods, is_s_sele = 1; + + for (var i = 0; i < item.length; i++) { + item[i].goods_price = item[i].init_goods_price; + } var is_has_other = 0; for (var ii = 0; ii < car.length; ii++) { @@ -5126,15 +5135,16 @@ Page({ } //-- 让选择进入对应 -- for (var i = 0; i < item.length; i++) { - if (sele_arr.hasOwnProperty(i)) { - item[i].selected = sele_arr[i]; - } + if (sele_arr.hasOwnProperty(i)) { + item[i].selected = sele_arr[i]; + } } + //-- 先批量判断一下活动的类型,同时要同步跟新 -- m_cx.cart_cx_group(this, item, car[c_idx], 0, 0, (show_can_cx) => { car[c_idx].show_can_cx = show_can_cx; th.cx_check_ok2(func, car); - },1); + }); }, @@ -5257,6 +5267,7 @@ Page({ } } } + func({ 'code': 0, 'msg': '成功' diff --git a/utils/more_cx.js b/utils/more_cx.js index ef1d534..ebe91ce 100644 --- a/utils/more_cx.js +++ b/utils/more_cx.js @@ -364,8 +364,29 @@ module.exports = { return g_item.goods_id==ck_prom_type.goods[b].goods_id && [0,3,5,7,10].indexOf(g_item.prom_type)>-1; }) if(fg>-1){ + + goods[fg].goods_price = goods[fg].init_goods_price; goods[fg].prom_type=ck_prom_type.prom_type; goods[fg].prom_id=ck_prom_type.prom_id; + + if(ck_prom_type.prom_type==3){ + let ffd=th.data.in_yhact[ck_prom_type.prom_id]; + let f_price = goods[fg].goods_price; + if (ffd.discount_field != undefined) { + switch (ffd.discount_field) { + case 0: + f_price = goods[fg].goods_price; + break; + case 1: + f_price = goods[fg].shop_price; + break; + case 2: + f_price = goods[fg].goods_market_price; + break; + } + } + goods[fg].goods_price = f_price; + } } } @@ -402,7 +423,10 @@ module.exports = { //-- 促销活动对象表,最初的map表,包含活动类型,活动id,goods商品 --- var cx_act_map=[]; for(var i=0; i-1){ goods[fg].prom_type=ck_prom_type.prom_type; goods[fg].prom_id=ck_prom_type.prom_id; + + if(ck_prom_type.prom_type==3 && (is_no_change!=2 || ck_prom_type.is_no_ok!=1) ){ + let ffd=th.data.in_yhact[ck_prom_type.prom_id]; + let f_price = goods[fg].goods_price; + if (ffd.discount_field != undefined) { + switch (ffd.discount_field) { + case 0: + f_price = goods[fg].goods_price; + break; + case 1: + f_price = goods[fg].shop_price; + break; + case 2: + f_price = goods[fg].goods_market_price; + break; + } + } + goods[fg].goods_price = f_price; + } } } } -- libgit2 0.21.4