From 00becdb95d0464eda466581aa904a66c72672f85 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 21 Jun 2023 15:57:50 +0800 Subject: [PATCH] cart2的优化 --- packageE/pages/cart/cart2/cart2.js | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------- 1 file changed, 100 insertions(+), 93 deletions(-) diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index f80da51..264136b 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -1256,25 +1256,6 @@ Page({ //计算佣金的商品 var commission_gds = []; for (var c = 0; c < item.length; c++) { - - - //-- 要判断总开关有没有同城配送 -- - if(th.data.is_same_city) { - //----- 判断每一个商品的配送方式,和门店的配送方式 ------- - for (var ik = 0; ik < arr.length; ik++) { - if (!arr[ik].sto.is_same_city) continue; - var fd = arr[ik].goods.filter(function (e) { - return e.is_same_city != 1 || e.whsle_id > 0 - }) - if (!fd || fd.length == 0) { - arr[ik].show_same_city = 1; - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 2) { - arr[ik].exp_type=2; - th.setData({ is_all_zt: 0 }); - } - - } - if (!item[c].is_gift) { var hr = { goods_id: item[c].goods_id, @@ -1403,6 +1384,8 @@ Page({ }, 500) }, + + //-----单个商品购买的入口判断---- get_buy_goods: function (e) { var th = this; @@ -1997,7 +1980,7 @@ Page({ }, calc_per: async function (c_arr) { - + var send_gf = {}; var duo_zp_num_arr = {}; var th = this; @@ -2035,7 +2018,7 @@ Page({ }).then(res => { if (res.data.code == 0 && res.data.data.condition) { var get_data = res.data.data; - item_map.cy_cx=1; + item_map.cy_cx = 1; item_map.is_bz = get_data.is_bz; //是不是倍增 item_map.bs = get_data.bs; //是不是倍数 item_map.is_past = get_data.is_past; //是不是包邮 @@ -2049,8 +2032,8 @@ Page({ item_map.monthlbtitle = get_data.monthlbtitle; //------end------- if (get_data.gift_id && parseInt(get_data.zp_mode) != 1 - && get_data.zp_num * item_map.bs <= get_data.limit_num - && get_data.zp_num * item_map.bs <= get_data.gift_storecount + && get_data.zp_num * item_map.bs <= get_data.limit_num + && get_data.zp_num * item_map.bs <= get_data.gift_storecount ) { item_map.gift_id = get_data.gift_id; @@ -2104,8 +2087,7 @@ Page({ duo_zp_num_arr[item_map.prom_id] = t_zp_num; } } - } - else item_map.cy_cx=0; + } else item_map.cy_cx = 0; }) } @@ -2174,85 +2156,108 @@ Page({ ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; - //-- 如果有参与促销才来进行计算 -- - if(item_map.cy_cx) { - //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- - for (var j = 0; j < ord_goods.length; j++) { - if (ord_goods[j].is_gift) continue; - if (ord_goods[j].whsle_id) continue; - if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) { - ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh; - ord_goods[j].is_past = item_map.is_past; - ord_goods[j].is_order_yh = item_map.is_order_yh; - ord_goods[j].is_post_temp = item_map.is_post_temp; - - ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir; - ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; - ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; - ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; + //-- 如果有参与促销才来进行计算 -- + if (item_map.cy_cx) { + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- + for (var j = 0; j < ord_goods.length; j++) { + if (ord_goods[j].is_gift) continue; + if (ord_goods[j].whsle_id) continue; + if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) { + ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh; + ord_goods[j].is_past = item_map.is_past; + ord_goods[j].is_order_yh = item_map.is_order_yh; + ord_goods[j].is_post_temp = item_map.is_post_temp; + + ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir; + ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir; + ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account; + ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; + } + } } - } - } - if (item_map.price != undefined && item_map.price != null - && item_map.prom_price != undefined && item_map.prom_price != null) - cart_item.cut_price += (item_map.price - item_map.prom_price); - //---如果有送积分--- - if (item_map.s_intValue) { - if (!cart_item.s_intValue) cart_item.s_intValue = 0; - cart_item.s_intValue += item_map.s_intValue; - } - //-- 如果有送优惠券的情况 -- - if (item_map.s_coupon_id) { - if (!cart_item.s_coupon_id) { - cart_item.s_coupon_id = item_map.s_coupon_id + ""; - cart_item.g_coupon_num = [{ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }]; - } - else { - cart_item.s_coupon_id += "," + item_map.s_coupon_id; - cart_item.g_coupon_num.push({ 'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num }) - } - } + if (item_map.price != undefined && item_map.price != null + && item_map.prom_price != undefined && item_map.prom_price != null) + cart_item.cut_price += (item_map.price - item_map.prom_price); + //---如果有送积分--- + if (item_map.s_intValue) { + if (!cart_item.s_intValue) cart_item.s_intValue = 0; + cart_item.s_intValue += item_map.s_intValue; + } + //-- 如果有送优惠券的情况 -- + if (item_map.s_coupon_id) { + if (!cart_item.s_coupon_id) { + cart_item.s_coupon_id = item_map.s_coupon_id + ""; + cart_item.g_coupon_num = [{'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}]; + } else { + cart_item.s_coupon_id += "," + item_map.s_coupon_id; + cart_item.g_coupon_num.push({'c_id': item_map.s_coupon_id, "num": item_map.s_coupon_num}) + } + } - //-- 如果有送礼包的情况 -- - if (item_map.s_libao) { - if (!cart_item.s_libao) { - cart_item.s_libao = item_map.s_libao + ""; - cart_item.g_lb_num = [{ 'l_id': item_map.s_libao, "num": item_map.s_lb_num, 'lbtitle': item_map.lbtitle }]; - } - else { - cart_item.s_libao += "," + item_map.s_libao; - cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num, 'lbtitle': item_map.lbtitle }) - } - } + //-- 如果有送礼包的情况 -- + if (item_map.s_libao) { + if (!cart_item.s_libao) { + cart_item.s_libao = item_map.s_libao + ""; + cart_item.g_lb_num = [{ + 'l_id': item_map.s_libao, + "num": item_map.s_lb_num, + 'lbtitle': item_map.lbtitle + }]; + } else { + cart_item.s_libao += "," + item_map.s_libao; + cart_item.g_lb_num.push({ + 'l_id': item_map.s_libao, + "num": item_map.s_lb_num, + 'lbtitle': item_map.lbtitle + }) + } + } - if (item_map.zx_libao) { - if (!cart_item.zx_libao) { - cart_item.zx_libao = item_map.zx_libao + ""; - cart_item.g_zxlb_num = [{ 'l_id': item_map.zx_libao, "num": item_map.zx_lb_num, 'zxlbtitle': item_map.zxlbtitle }]; - } - else { - cart_item.zx_libao += "," + item_map.zx_libao; - cart_item.g_zxlb_num.push({ 'l_id': item_map.zx_libao, "num": item_map.zx_lb_num, 'zxlbtitle': item_map.zxlbtitle }) - } - } - //每月礼包 - if (item_map.monthlibao) { - if (!cart_item.monthlibao) { - cart_item.monthlibao = item_map.monthlibao + ""; - cart_item.g_monthlb_num = [{ 'month_id': item_map.monthlibao, "monthnum": item_map.monthlb_num, 'monthlbtitle': item_map.monthlbtitle }]; - } else { - cart_item.monthlibao += "," + item_map.monthlibao; - cart_item.g_monthlb_num.push({ 'month_id': item_map.monthlibao, "monthnum": item_map.monthlb_num, 'monthlbtitle': item_map.monthlbtitle }) + if (item_map.zx_libao) { + if (!cart_item.zx_libao) { + cart_item.zx_libao = item_map.zx_libao + ""; + cart_item.g_zxlb_num = [{ + 'l_id': item_map.zx_libao, + "num": item_map.zx_lb_num, + 'zxlbtitle': item_map.zxlbtitle + }]; + } else { + cart_item.zx_libao += "," + item_map.zx_libao; + cart_item.g_zxlb_num.push({ + 'l_id': item_map.zx_libao, + "num": item_map.zx_lb_num, + 'zxlbtitle': item_map.zxlbtitle + }) + } + } + //每月礼包 + if (item_map.monthlibao) { + if (!cart_item.monthlibao) { + cart_item.monthlibao = item_map.monthlibao + ""; + cart_item.g_monthlb_num = [{ + 'month_id': item_map.monthlibao, + "monthnum": item_map.monthlb_num, + 'monthlbtitle': item_map.monthlbtitle + }]; + } else { + cart_item.monthlibao += "," + item_map.monthlibao; + cart_item.g_monthlb_num.push({ + 'month_id': item_map.monthlibao, + "monthnum": item_map.monthlb_num, + 'monthlbtitle': item_map.monthlbtitle + }) + } + } + //------------end-------- } } - //------------end-------- } } } - + var arr = Object.keys(send_gf); var arr2 = Object.keys(th.data.send_gf); if (arr2.length > 0) return false; @@ -2266,6 +2271,8 @@ Page({ }, + + calclate_lbNum(r_data) { if(!r_data) return false; -- libgit2 0.21.4