diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 8c3c9b5..3071d1f 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -654,6 +654,13 @@ Page({ quan_price = res.data.data[0].WareCashSum; } }) + }else{ + th.setData({quan_price:0}); + if(th.data.using_quan[bn_pick].isby==1){ + var txt="using_quan["+bn_pick+"]"; + th.setData({[txt]:{}}); + } + } if(quan_price>0){ @@ -697,11 +704,13 @@ Page({ th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) } - o_condition1=parseFloat(o_condition1)-parseFloat(th.data.presell.presell_deposit); - th.setData({ exp_price: 0, order_m: o_condition1 }) + o_condition1=parseFloat(o_condition1)-parseFloat(th.data.presell.presell_deposit); + if(o_condition1<0) o_condition1=0; + th.setData({ exp_price: 0, order_m: o_condition1 }) }) }else{ o_condition=parseFloat(o_condition)-parseFloat(th.data.presell.presell_deposit); + if(o_condition<0) o_condition=0; th.setData({ exp_price: 0, order_m: o_condition }) } } @@ -742,168 +751,6 @@ Page({ }); }, - calc_per: async function (c_arr) { - var th = this; - //-- 循环处理 -- - for (var i in c_arr) { - var cart_item = c_arr[i]; //就是每一单的意思 - var pickid = cart_item.pickup_id; - var ord_goods = c_arr[i].goods; //就是每一单的从表的意思 - var o_price = 0, q_conditin = 0; - //--------循环计算总价----------- - for (var j = 0; j < ord_goods.length; j++) { - o_price += ord_goods[j].goods_price * ord_goods[j].goods_num; - } - - //---如果该门店的相关活动,就要算一下减价-- - if (th.data.prom_goods_map[pickid]) { - var ob = th.data.prom_goods_map[pickid]; - for (var ii in ob) { - var item_map = ob[ii]; - if (item_map.bs == undefined || item_map.bs == null) { - //等待,获取一下优惠活动的信息 - await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { - data: { - price: item_map.price, prom_id: item_map.prom_id, - goods_num: item_map.goods_num, user_id: getApp().globalData.user_id, - is_bz: item_map.is_bz - } - }).then(res => { - if (res.data.code == 0 && res.data.data.condition) { - var get_data = res.data.data; - item_map.is_bz = get_data.is_bz; //是不是倍增 - item_map.bs = get_data.bs; //是不是倍数 - item_map.is_past = get_data.is_past; //是不是包邮 - item_map.prom_price = get_data.price >= 0 ? get_data.price : item_map.price; - item_map.s_intValue = get_data.intValue; - item_map.s_coupon_id = get_data.coupon_id; - item_map.s_coupon_num = get_data.coupon_num; - if (get_data.gift_id && get_data.goodsinfo) { - item_map.gift_id = get_data.gift_id; - item_map.gift_goods_id = get_data.goods_id; - item_map.gift_goods_name = get_data.goods_name; - item_map.gift_goods_color = get_data.goodsinfo.goods_color ? get_data.goodsinfo.goods_color : ''; - item_map.gift_goods_spec = get_data.goodsinfo.goods_spec ? get_data.goodsinfo.goods_spec : ''; - item_map.gift_original_img = get_data.goodsinfo.original_img; - item_map.gift_limit_num = get_data.limit_num; - item_map.gift_storecount = get_data.gift_storecount; - item_map.gift_weight = get_data.goodsinfo.weight; - item_map.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type; - item_map.uniform_exp_sum = get_data.goodsinfo.uniform_exp_sum; - - } - item_map.s_libao = get_data.libao; - item_map.s_lb_num = get_data.lb_num; - } - }) - } - - //有活动,且优惠活动并没有限制使用优惠券,且有减价 - //--看有没有减价-- - //if(item_map.prom_price>=0 && item_map.price-item_map.prom_price){ - if (item_map.price - item_map.prom_price && item_map.prom_price !== null) { - if (cart_item.prom_pt_json) { - cart_item.prom_pt_json.push({ - "prom_id": item_map.prom_id, - "dis": (item_map.price - item_map.prom_price).toFixed(2), - "ispt": 0 - }) - } else { - cart_item.prom_pt_json = [{ - "prom_id": item_map.prom_id, - "dis": (item_map.price - item_map.prom_price).toFixed(2), - "ispt": 0 - }]; - } - - //-- 如果系统要平摊到单品 -- - - var pt_data = { - 'prom_id': item_map.prom_id, - 'dis': parseFloat((item_map.price - item_map.prom_price).toFixed(2)), - 'goods': item_map.goods - } - - var pt_res = null; - await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", { - is_json: 1, - data: pt_data - }).then(res => { - if (res.data.code == 0) { - pt_res = res.data.data; - } - }) - if (pt_res) { - for (var io in item_map.goods) { - //平摊赋值 - item_map.goods[io].account_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account; - item_map.goods[io].account_yu_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account_yu; - if (!th.data.ispt_goods) { - item_map.goods[io].account = item_map.goods[io].account_fir; - item_map.goods[io].account_yu = item_map.goods[io].account_yu_fir; - } - } - } - - - o_price -= (item_map.price - item_map.prom_price); - //如果有限制使用优惠券,就要减掉参与的活动商品的钱 - if (!item_map.is_xz_yh) q_conditin = o_price; - } - - //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- - for (var j = 0; j < ord_goods.length; j++) { - if (ord_goods[j].is_gift) continue; - if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) { - ord_goods[j].is_xz_yh = item_map.is_xz_yh; - ord_goods[j].is_past = item_map.is_past; - 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 (!cart_item.cut_price) cart_item.cut_price = 0; - //-- -- - 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}]; - } - 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}) - } - } - } - } - } - }, - set_can_num: function () { var th = this; //-- 这个地方,循环计算几张优惠券可用-- @@ -1257,20 +1104,13 @@ Page({ var txt = ""; var txt1 = ""; var quan_item = null; - if (th.data.is_b_now) { + quan_item = this.data.get_by_quan_list[ind]; txt = "get_by_quan_list[" + ind + "].show_red"; var obj = {}; obj[txt] = 1; this.setData(obj); - } else { - txt = "by_quan_list_cart[" + ind + "].show_red"; - quan_item = th.data.by_quan_list_cart[ind]; - var obj = {}; - obj[txt] = 1; - this.setData(obj); - th.data.get_by_quan_list_cart[pickid] = JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组 - } + if (using_quan[th.data.selected_quan_pick]) { using_quan[th.data.selected_quan_pick].is_nouse_red = 0; @@ -1888,15 +1728,17 @@ Page({ } }) - if(quan_price>0) { - if (quan_price