diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index c7278a5..119d753 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -842,6 +842,7 @@ Page({ }) } } + //-- 判断一下,获取搭配购的消息 -- if ((item1.prom_type == 0 || item1.prom_type == 5) && (!carr[i].collocationList || !carr[i].collocationList.length)) { @@ -1102,19 +1103,21 @@ Page({ //每一个门店内的阶梯促销要进行拆分, //还得把阶梯促销商品的多余商品的线下价格算一算 - for (let var1 in arr) { + for (let var2 in arr) { + var u_item1 = arr[var2]; + //把阶梯促销进行分组 - var obj = ladder_calc.find_split(u_item); + var obj = ladder_calc.find_split(u_item1); if (!obj) continue; //存储不同阶梯促销活动的商品列表 - u_item.ladder_map = {}; + u_item1.ladder_map = {}; for (let var1 in obj) { var h_item = obj[var1]; var act = th.data.ladder_map[h_item.prom_id]; //获取活动需要的商品列表 - u_item.ladder_map[h_item.prom_id] = act; + u_item1.ladder_map[h_item.prom_id] = act; } - ladder_calc.fir_set_arr(u_item, th); + ladder_calc.fir_set_arr(u_item1, th); } diff --git a/packageE/pages/cart/cart2/ladder_calculate.js b/packageE/pages/cart/cart2/ladder_calculate.js index 0da2246..00a8001 100644 --- a/packageE/pages/cart/cart2/ladder_calculate.js +++ b/packageE/pages/cart/cart2/ladder_calculate.js @@ -15,6 +15,9 @@ module.exports = { //组合活动,以及组合活动从表的商品 let ladder_map = c_item.ladder_map; let goods = c_item.goods; //一个门店中所有的商品 + + + let tfeel = 0, cut_price = 0, offline_price = 0, offline_num = 0; //多个活动要拿来循环一下 for (let i in ladder_map) { @@ -43,7 +46,9 @@ module.exports = { offline_price: item.offline_price, goods_id: item.goods_id, shop_price: item.shop_price, - item:item + item:item, + prom_id:act_item.id, + prom_type:10, }) } del_g.push(item); @@ -102,7 +107,7 @@ module.exports = { let num = goods_map[j]; //找到相应的商品 let idx = goods.findIndex(function (ele) { - return ele.goods_id == j; + return ele.goods_id == j && ele.prom_id==act_item.id && ele.prom_type==10 }) //goods[idx].goods_num -= num; let new_g = JSON.parse(JSON.stringify(goods[idx])); @@ -118,7 +123,7 @@ module.exports = { for(var h in del_g){ var it=del_g[h]; let idx = goods.findIndex(function (ele) { - return ele.goods_id == it.goods_id + return ele.goods_id == it.goods_id && ele.prom_id==act_item.id && ele.prom_type==10 }) goods.splice(idx, 1); } diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index a082408..10066cc 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -561,7 +561,7 @@ Page({ let prom_id = 0 if (prom) { prom.map(item => { - if (item.prom_type == 3 || item.prom_type == 7) { + if (item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7 || item.prom_type == 10) { prom_true = item.prom_type prom_id = item.act_id } diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index dc3db48..bc7743d 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1582,66 +1582,6 @@ Page({ if (th.data.sales_rules >= 2) { var pick = th.get_pick_from_list(th.data.sto_sele_id) //---通过接口获取门店的线下库存信息-- - // getApp().request.get("/api/weshop/goods/getWareStorages", { - // data: { - // storageNos: pick.pickup_no, - // wareIds: encodeURIComponent(th.data.sele_g.erpwareid), - // storeId: os.stoid - // }, - // success: function (res) { - // if (res.data.code == 0) { - // if (res.data.data.pageData.length > 0) { - // var CanOutQty = res.data.data.pageData[0].CanOutQty; - // if (CanOutQty < e.data.goodsInputNum) { - // wx.showToast({ - // title: '库存不足!', - // icon: 'none', - // }); - // return false; - // // return s.my_warnning("库存不足!", 0, th); - // } - // //在调一次接口,读取商品的预出库的数量,lock - // getApp().request.get("/api/weshop/order/ware/lock/page", { - // data: { - // store_id: os.stoid, - // wareId: th.data.sele_g.goods_id, - // storageId: pick.pickup_id, - // pageSize: 1000 - // }, - // success: function (res_data) { - // if (res_data.data.code == 0 && res_data.data.data.total > 0) { - // - // var lock = 0; - // for (var i in res_data.data.data.pageData) { - // lock += res_data.data.data.pageData[i].outQty; - // } - // - // if (CanOutQty <= lock) { - // wx.showToast({ - // title: '库存不足!', - // icon: 'none', - // }); - // return false; - // //return s.my_warnning("库存不足!", 0, th); - // } - // th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); - // } else { - // th.add_cart_next(e, t, a, o, newd, CanOutQty); - // } - // } - // }) - // } else { - // wx.showToast({ - // title: '库存不足!', - // icon: 'none', - // }); - // return false; - // // return s.my_warnning("库存不足!", 0, th); - // } - // - // } - // } - // }) th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { if (CanOutQty) { if (CanOutQty < e.data.goodsInputNum) { @@ -1962,8 +1902,7 @@ Page({ //---加入购物车的最后一步--- add_cart_next(e, t, a, o, newd, CanOutQty) { - var th = this, - i = getApp().request; + var th = this, i = getApp().request; //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ if ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type != 2 && o.prom_type != 1) || th.data.is_normal) { var conf = th.data.bconfig; @@ -1992,11 +1931,10 @@ Page({ //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); if ("add" == t.currentTarget.dataset.action) { - if (newd.prom_type==0 && th.data.prom_goods && !th.data.sele_g.whsle_id) { - newd.prom_type = 3; - newd.prom_id = th.data.prom_goods[0].prom_id; - } - + // if (newd.prom_type==0 && th.data.prom_goods && !th.data.sele_g.whsle_id) { + // newd.prom_type = 3; + // newd.prom_id = th.data.prom_goods[0].prom_id; + // } if( [3,5,10].indexOf(newd.prom_type)>-1){ newd.prom_type=0; newd.prom_id=0; @@ -2017,12 +1955,10 @@ Page({ var item=null; //-------如果购物车中有相关的数据--------- if (re.data.data.total > 0) { - - for (var i=0; i{ - if (res.confirm) { - console.log('用户点击确定') - //----先看会员在购物车中是否加入了该商品,立即购买的----- - getApp().request.get("/api/weshop/cart/page", { - data: { - store_id: e.data.stoid, - user_id: oo.user_id, - state: 1 - }, - success: function (res) { - //-------如果购物车中有相关的数据--------- - if (res.data.code == 0 && res.data.data.total > 0) { - for (let j in res.data.data.pageData) { - let item_j = res.data.data.pageData[j]; - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; - getApp().request.delete(url, {}); - } - } - newd.state = 1; - newd.prom_type=0; - newd.prom_id=0 - getApp().request.post("/api/weshop/cart/save", { - data: newd, - success: function (t) { - th.closeSpecModal(); - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); - } - }); - } - }) - } else if (res.cancel) { + //-- 这一步主要是要让立即购买 走 购物车的逻辑 参与活动,如果有zh_act就强制组合购购买 -- + if(th.data.zh_act && th.data.zh_act.buy_limit !=0 && th.data.zh_act.buy_limit <= th.data.userbuynum && th.data.zh_act.zhbuyqty <= th.data.goodsInputNum){ + wx.hideLoading() + + wx.showModal({ + title: '提示', + // content: `商品${str},组合购活动,购买次数已超,将以普通商品购买?`, + content: `${th.data.data.goods_name}超出组合购限购次数,将以普通商品购买`, + success:res=>{ + if (res.confirm) { + console.log('用户点击确定') + //----先看会员在购物车中是否加入了该商品,立即购买的----- + getApp().request.get("/api/weshop/cart/page", { + data: { + store_id: e.data.stoid, + user_id: oo.user_id, + state: 1 + }, + success: function (res) { + //-------如果购物车中有相关的数据--------- + if (res.data.code == 0 && res.data.data.total > 0) { + for (let j in res.data.data.pageData) { + let item_j = res.data.data.pageData[j]; + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; + getApp().request.delete(url, {}); + } + } + newd.state = 1; + newd.prom_type=0; + newd.prom_id=0 + getApp().request.post("/api/weshop/cart/save", { + data: newd, + success: function (t) { + th.closeSpecModal(); + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); + } + }); + } + }) + } else if (res.cancel) { - console.log('用户点击取消') - } - } - }) - return false - }else{ - //----先看会员在购物车中是否加入了该商品,立即购买的----- - getApp().request.get("/api/weshop/cart/page", { - data: { - store_id: e.data.stoid, - user_id: oo.user_id, - state: 1 - }, - success: function (res) { - //-------如果购物车中有相关的数据--------- - if (res.data.code == 0 && res.data.data.total > 0) { - for (let j in res.data.data.pageData) { - let item_j = res.data.data.pageData[j]; - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; - getApp().request.delete(url, {}); - } + console.log('用户点击取消') + } + } + }) + return false + }else{ + //----先看会员在购物车中是否加入了该商品,立即购买的----- + getApp().request.get("/api/weshop/cart/page", { + data: { + store_id: e.data.stoid, + user_id: oo.user_id, + state: 1 + }, + success: function (res) { + //-------如果购物车中有相关的数据--------- + if (res.data.code == 0 && res.data.data.total > 0) { + for (let j in res.data.data.pageData) { + let item_j = res.data.data.pageData[j]; + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; + getApp().request.delete(url, {}); } - newd.state = 1; - getApp().request.post("/api/weshop/cart/save", { - data: newd, - success: function (t) { - th.closeSpecModal(); - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); - } - }); } - }) - return false; - } + newd.state = 1; + getApp().request.post("/api/weshop/cart/save", { + data: newd, + success: function (t) { + th.closeSpecModal(); + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); + } + }); + } + }) + return false; } if (th.data.prom_goods) { @@ -2198,7 +2132,12 @@ Page({ break; } } + } + //如果有阶梯促销的时候 + if(th.data.jieti_prom){ + newd.prom_type = 7; + newd.prom_id = th.data.ladder_act_id; } newd['pick_name'] = th.data.sto_sele_name; @@ -2273,11 +2212,12 @@ Page({ }) } else { //搭配购特殊处理 - if(th.data.data.prom_type==5){ + if( [3,5,7,10].indexOf(th.data.data.prom_type)>-1){ e.prom_type=th.data.data.prom_type e.prom_id=th.data.data.prom_id e.collocation_goods=[] } + s.set_b_now(e); /*-- wx.redirectTo({ @@ -7606,6 +7546,7 @@ Page({ th.setData({ zh_act: e.data.data }); + th.getUserBuyPromNum(e.data.data.id) } } diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 439dbc5..cb1c6c5 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -594,15 +594,23 @@ + - - 秒杀 + + + 秒杀 + 团购 + 积分购 - + - + + + + + {{item.act_name}} @@ -617,6 +625,8 @@ + +