diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index acbf170..da1e3fd 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -828,7 +828,7 @@ Page({ //---------------全选,全选的时候要判断是否门店的匹配方式一致-------------- checkAll: function() { - var e = this, + var e = this,th=this, dda = e.data.requestData, sdda = e.data.service_data, tfeel = 0, @@ -846,11 +846,17 @@ Page({ this.data.btn_click=1; + + + var offline_price=0; + var offline_num=0; + + if(dda && dda.length>0){ for (var i = 0; i < dda.length; i++) { var item = dda[i].goods; - if (!e.data.checkAllToggle) { + if (e.data.checkAllToggle) { var txt = "requestData[" + i + "].selected"; e.setData({ [txt]: 0, @@ -889,6 +895,13 @@ Page({ tfeel += item[j].goods_num * item[j].goods_price; t_num += item[j].goods_num; } + + //-- 如果这个商品是线下取价的时候 -- + if(item[j].is_offline && item[j].prom_type!=7){ + offline_price+= (item[j].goods_price-item[j].offline_price)*item[j].goods_num; + offline_num+=item[j].goods_num; + } + } } @@ -900,13 +913,42 @@ Page({ }); return false; } else { - + for (var i = 0; i < dda.length; i++) { + + if (!e.data.checkAllToggle) { + var txt = "requestData[" + i + "].selected"; + e.setData({ + [txt]: 1, + }); + } + //总的价格,把组合商品的价格拿出来 var zh_calc_res=zh_calc.calculate_zh(dda,i,this); tfeel+=zh_calc_res.tfeel; + offline_price+=zh_calc_res.offline_price; + offline_num+=zh_calc_res.offline_num; + + //当有线下取价的时候 + if(offline_price){ + var txt1= "requestData[" + i + "].offline_price"; + var txt2= "requestData[" + i+ "].offline_num"; + th.setData({ + [txt1]: offline_price.toFixed(2), + [txt2]: offline_num, + }); + }else{ + if(dda[i].offline_price>0){ + var txt1= "requestData[" + i + "].offline_price"; + var txt2= "requestData[" + i + "].offline_num"; + th.setData({ + [txt1]: 0, + [txt2]: 0 + }); + } + } } - + e.setData({ checkAllToggle: !e.data.checkAllToggle, total_fee: tfeel.toFixed(2), @@ -922,7 +964,7 @@ Page({ if(sdda && sdda.length>0){ for (var i = 0; i < sdda.length; i++) { var item = sdda[i].goods; - if (!e.data.checkAllToggle) { + if (e.data.checkAllToggle) { var txt = "service_data[" + i + "].selected"; e.setData({ [txt]: 0, diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index accff90..7778475 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -2324,8 +2324,8 @@ Page({ 'store_id': oo.stoid, }; - //-- 线下取价也要写入 -- - if (g_item.offline_price && t_item.is_offline == 1) { + //-- 线下取价也要写入,组合购的商品不能去线下价格 -- + if (g_item.offline_price && t_item.is_offline == 1 && g_item.prom_type!=7) { goods.goods_price = g_item.offline_price; goods.member_goods_price = g_item.offline_price; goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); diff --git a/pages/cart/cart2/zh_calculate.js b/pages/cart/cart2/zh_calculate.js index 5b6f061..d27dc1f 100644 --- a/pages/cart/cart2/zh_calculate.js +++ b/pages/cart/cart2/zh_calculate.js @@ -42,14 +42,14 @@ module.exports = { if (item.num > item.zhqty) { for (let i = 0; i < item.num - item.zhqty; i++) { no_in_arr.push({ - price: item.goods_price, goods_id: item.goods_id, offline_price: item.offline_price + price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price }) } } } else { for (let j = 0; j < item.num; j++) { no_in_arr.push({ - price: item.goods_price, goods_id: item.goods_id, offline_price: item.offline_price + price: item.goods_price, goods_id: item.goods_id, offline_price: item_j.offline_price }) } } @@ -92,7 +92,7 @@ module.exports = { for (let ii in no_in_arr) { let item = no_in_arr[ii]; if (item.offline_price) { - offline_price += item.goods_price - item.offline_price; + offline_price += item.price - item.offline_price; offline_num += 1; } if (goods_map[item.goods_id]) {