diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 1b51ae9..b7504ec 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -619,7 +619,7 @@ Page({ else if(item.prom_type ==2){ var prom = null; var now = ut.gettimestamp(); - await getApp().request.promiseGet('/api/weshop/goods/groupBuy/getActInfo/' + item.goods_id + '/' + user_id + '/' + item.prom_id, {}).then(res => { + await getApp().request.promiseGet('/api/weshop/goods/groupBuy/getActInfo/'+ oo.stoid + '/' + item.goods_id + '/' + item.prom_id, {}).then(res => { if (res.data.code == 0) { prom = res.data.data; prom.price = prom.user_price; @@ -666,26 +666,35 @@ Page({ if (!r_data.promGoodsLists) { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item); //商品已经无活动 - isok = 0; + // th.disInvalid(item); + // isok = 0; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) } else { //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了 if (item.prom_id != r_data.promGoodsLists[0].prom_id) { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item); //商品已经下架 - isok = 0; + // th.disInvalid(item); + // isok = 0; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) } } } else { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item); - //商品已经下架 - isok = 0; + // th.disInvalid(item); + // //商品已经下架 + // isok = 0; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) } }) @@ -696,43 +705,51 @@ Page({ if (!r_data.promGoodsLists) { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item); - //商品已经无活动 - isok = 0; + // th.disInvalid(item); + // //商品已经无活动 + // isok = 0; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) } else { //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了 if (item.prom_id != r_data.promGoodsLists[0].prom_id) { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item); - //商品已经下架 - isok = 0; + // th.disInvalid(item); + // //商品已经下架 + // isok = 0; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) } } } else { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item,1); - //商品已经下架 - isok = 0; + // th.disInvalid(item,1); + // //商品已经下架 + // isok = 0; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) } }) - } - - if (!isok) continue; + // if (!isok) continue; } else if (item.prom_type == 7) { + console.log('组合购------------'); if(!th.data.zuhe_map[item.prom_id]){ - + console.log('组1') //如果有组合购 var isok = 1; var is_flag = 1; var act = null; var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; await getApp().request.promiseGet(url, {}).then(res => { - console.log(res, 1000); + console.log(res); if (res.data.code == 0 && res.data.data) { if (res.data.data.is_show != 1) { isok = 0; @@ -759,38 +776,44 @@ Page({ if (!isok) { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item); - th.data.zuhe_map[item.prom_id] = -1; - continue; - } - th.data.zuhe_map[item.prom_id] = act; - var url1 = "/api/weshop/prom/zhbuyGoods/page"; - var req_data = { - page: 1, - pageSize: 2000, - store_id: os.stoid, - zh_id: item.prom_id, + //组合购失效不处理 + // th.disInvalid(item); + // th.data.zuhe_map[item.prom_id] = -1; + // continue; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) + }else{ + th.data.zuhe_map[item.prom_id] = act; + var url1 = "/api/weshop/prom/zhbuyGoods/page"; + var req_data = { + page: 1, + pageSize: 2000, + store_id: os.stoid, + zh_id: item.prom_id, + } + await getApp().request.promiseGet(url1, { + data: req_data + }).then(res => { + console.log(res, 2000); + if (ut.ajax_ok(res)) { + var gdlist = res.data.data.pageData; + gdlist.forEach(i => { + if (item.goods_id == i.goods_id && !is_flag) { + item.prom_type = 0; + item.prom_type1 = 0; + item.prom_id = 0; + item.prom_id1 = 0 + } + }) + th.data.zuhe_map_good[item.prom_id] = gdlist; + } + }) } - await getApp().request.promiseGet(url1, { - data: req_data - }).then(res => { - console.log(res, 2000); - if (ut.ajax_ok(res)) { - var gdlist = res.data.data.pageData; - gdlist.forEach(i => { - if (item.goods_id == i.goods_id && !is_flag) { - item.prom_type = 0; - item.prom_type1 = 0; - item.prom_id = 0; - item.prom_id1 = 0 - } - }) - th.data.zuhe_map_good[item.prom_id] = gdlist; - } - }) } - + console.log('组2') if (th.data.zuhe_map[item.prom_id] && th.data.zuhe_map[item.prom_id] != -1) { + console.log('组3') var gdlist = th.data.zuhe_map_good[item.prom_id]; var t_item = gdlist.find(function (ele) { return ele.goods_id == item.goods_id @@ -798,13 +821,18 @@ Page({ if (!t_item) { // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); - th.disInvalid(item,1); - th.data.zuhe_map[item.prom_id] = -1; - continue; - } - item.buyqty = t_item.buyqty; - item.zh_b_num = promgoodsbuynum; - item.act = th.data.zuhe_map[item.prom_id]; + //组合购不处理 + // th.disInvalid(item,1); + // th.data.zuhe_map[item.prom_id] = -1; + // continue; + item.prom_type = 0 + //购物车更新 + th.cartUpFn(item) + }else{ + item.buyqty = t_item.buyqty; + item.zh_b_num = promgoodsbuynum; + item.act = th.data.zuhe_map[item.prom_id]; + } } //else{ // var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; // getApp().request.delete(url, {}); @@ -1082,7 +1110,19 @@ Page({ } }); }, - + //商品购物车修改 + cartUpFn(item){ + let updata1 = { + id: item.id, + prom_type: 0, + prom_id:item.prom_id, + store_id: os.stoid, + user_id: getApp().globalData.userInfo.user_id + }; + getApp().request.put("/api/weshop/cart/update", { + data: updata1, + }) + }, //-----真的获取购物车-------- get_ser_cart: function () { var th = this; diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index c833f31..ce1f9c8 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1863,6 +1863,7 @@ Page({ goods_price: newd.goods_price, member_goods_price: newd.goods_price, store_id: th.data.stoid, + prom_id:newd.prom_id //把活动id带上去(用于购物车失效变成有效商品) }; //---是不是从收藏夹出来的--- @@ -1875,6 +1876,7 @@ Page({ updata['guide_type'] = 0; } } + i.put("/api/weshop/cart/update", { data: updata, @@ -2290,7 +2292,7 @@ Page({ sort_store: 0, open_ind_store: open_store, }) - //--先判断会员状态-- + //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { wx.navigateTo({