diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index c0638c6..e2db986 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -2017,6 +2017,113 @@ Page({ // e.prom_id = 0; } + //-- 这一步主要是要让立即购买 走 购物车的逻辑 参与活动,如果有zh_act就强制组合购购买,要计算一下组合购的总数量 -- + if(th.data.zh_act && (!th.data.zh_act.zh_num || th.data.zh_act.zh_buy_num>th.data.zh_act.zh_num ) + && th.data.zh_act.zhbuyqty <= th.data.goodsInputNum){ + wx.hideLoading(); + + if((th.data.zh_act.buy_limit !=0 && th.data.zh_act.buy_limit <= th.data.userbuynum)){ + 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: os.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, {}); + } + } + e.state = 1; + e.prom_type=0; + e.prom_id=0 + getApp().request.post("/api/weshop/cart/save", { + data: e, + success: function (t) { + th.closeSpecModal(); + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); + } + }); + } + }) + } else if (res.cancel) { + + console.log('用户点击取消') + } + } + }) + }else{ + + + //----先看会员在购物车中是否加入了该商品,立即购买的----- + getApp().request.get("/api/weshop/cart/page", { + data: { + store_id: os.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/' + os.stoid + '/' + item_j.id; + getApp().request.delete(url, {}); + } + } + + e.state = 1; + e.prom_type=7; + e.prom_id=th.data.zh_act.id; + getApp().request.post("/api/weshop/cart/save", { + data: e, + success: function (t) { + th.closeSpecModal(); + getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); + } + }); + + } + }) + } + + + return false + }else{ + //----先看会员在购物车中是否加入了该商品,立即购买的----- + getApp().request.get("/api/weshop/cart/page", { + data: { + store_id: os.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, {}); + } + } + + } + }) + + } + if(e.prom_type==10){ //----先看会员在购物车中是否加入了该商品,立即购买的----- @@ -4514,15 +4621,9 @@ Page({ newd['is_normal'] = th.data.is_normal; if (newd['is_normal']) { - newd['is_pd_normal'] = 1; - //判断一下有没有全局优惠活动 - th.check_nor_promgood(newd.goods_id, function (e) { - if (e && e.act_id) { - newd['prom_type'] = e.prom_type; - newd['prom_id'] = e.act_id; - } + newd['is_pd_normal'] = 1; + //判断一下有没有全局优惠活动 th.buyNow(newd); - }); } else { // 点击立即参团 @@ -6106,52 +6207,135 @@ Page({ }, //---检查有没有优惠活动--- - check_is_youhui: function (gid, is_nor) { + check_is_youhui:async function (gid, is_nor) { var th = this; - //如果是普通购买的时候,要进行调用 - if (is_nor) { - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, { - success: function (res) { - if (res.data.code == 0) { - var r_data = res.data.data; - th.setData({ - prom_goods: r_data.promGoodsLists, + var user_id = getApp().globalData.user_id; + if (!user_id) user_id = 0; + + //普通购买的时候,重新算一下组合购有没有 + if(is_nor){ + var arr3=null; + var url = '/api/weshop/activitylist/listGoodActInfo2New'; + var req_d = { + "store_id": os.stoid, + "goods_id": this.data.gid, + "user_id": user_id, + } + await getApp().request.promiseGet(url, { + data: req_d, + }).then(e=>{ + if (e.data.code == 0 && e.data.data && e.data.data.length > 0) { + var arr = e.data.data; + if(arr.length){ + arr3 = arr.filter(function (e) { + return e.s_time < ut.gettimestamp() && e.prom_type==7; }) - th.is_show_more_buy(); } - }, + } }) - } else { - //调用接口判断订单优惠, - getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", { - success: function (res) { - console.log(res); - if (res.data.code == 0) { - var r_data = res.data.data; - var max = 0, min = 0; - if (r_data.collocationList) { - for (var i in r_data.collocationList) { - if (max == 0) max = r_data.collocationList[i].price; - if (min == 0) min = r_data.collocationList[i].price; - - if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price; - if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price; - } - r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); - r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); + if(arr3 && arr3.length>0){ + //获取活动信息 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" +arr3[0].act_id + "/" + getApp().globalData.user_id; + await getApp().request.promiseGet(url, { + + }).then(e=>{ + if (e.data.code == 0 && e.data.data) { + if (ut.gettimestamp() < e.data.data.start_time) { + return false; } - th.setData({ - order_prom: r_data.promOrder, - collocationGoods: r_data.collocationPromList, - prom_goods: r_data.promGoodsLists, - }) - th.is_show_more_buy(); + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { + //-- 获取商品列表 -- + th.data.zh_act=e.data.data; + th.getUserBuyPromNum(e.data.data.id) + } + } + }) + } + } + + + //调用接口判断订单优惠, + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromListNew1/" + os.stoid + "/" + gid + "/0" + "/" + user_id, { + }).then(async res=>{ + if (res.data.code == 0 && res.data.data) { + var r_data = res.data.data; + var max = 0, min = 0; + //暂时积分够 不和 优惠,阶梯重叠 + if(th.data.zh_act){ + r_data.collocationList=null; + r_data.ladderLists=null; + r_data.promGoodsLists=null; + } + + if (r_data.collocationList) { + for (var i in r_data.collocationList) { + if (max == 0) max = r_data.collocationList[i].price; + if (min == 0) min = r_data.collocationList[i].price; + + if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price; + if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price; } + r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); + r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); + + //如果有搭配促销先不和 阶梯促销和优惠测序重合,做到后台可以重合 + r_data.ladderLists=null; + r_data.promGoodsLists=null; } - }) - } + + if (r_data.ladderLists) { + var act_id = r_data.ladderLists[0].form_id; + //-- 判断会员能不能参与阶梯促销 -- + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { + if (res.data.code == 0 && res.data.data) { + var prom_content = ""; + + //暂定优惠促销还不能重叠 + if(res.data.data.good_object==0 && (r_data.promGoodsLists || th.data.zh_act)){ + return false; + } + + if(res.data.data.good_object==1){ + r_data.promGoodsLists=null; + } + + for (let jj in r_data.ladderLists) { + if (r_data.ladderLists[jj].discount == 10) { + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; + } else { + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; + } + } + prom_content = ut.sub_last(prom_content); + th.data.prom_type = 10; + th.data.prom_id = act_id; + th.setData({ + jieti_prom: prom_content, + ladder_act_id: act_id + }) + } + }) + } + + + //普通购买不在界面显示 + if(is_nor){ + th.data.collocationGoods=r_data.collocationPromList; + th.data.prom_goods=r_data.promGoodsLists; + }else{ + th.setData({ + order_prom: r_data.promOrder, + collocationGoods: r_data.collocationPromList, + prom_goods: r_data.promGoodsLists, + }) + } + th.is_show_more_buy(); + } + }) + + }, @@ -6412,7 +6596,7 @@ Page({ if(th.data.zh_act){ obj = { act_id: th.data.zh_act.id, - prom_type:3 + prom_type:7 } back(obj); return false; @@ -6844,5 +7028,22 @@ Page({ }, + async getUserBuyPromNum(prom_id){ + var userInfo = getApp().globalData.userInfo; + var url = `/api/weshop/ordergoods/getUserBuyPromNum?store_id=${os.stoid}&user_id=${userInfo.user_id}&prom_type=7&prom_id=${prom_id}`; + let res = await getApp().request.promiseGet(url, { + data:{} + }); + let userbuynum=0 + if(res.data.code==0 && res.data.data){ + userbuynum=res.data.data.userbuynum + } + this.setData({ + userbuynum + }) + // return userbuynum + }, + + }); diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 8c96832..599e5e4 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -7651,7 +7651,7 @@ Page({ if(th.data.zh_act){ obj = { act_id: th.data.zh_act.id, - prom_type:3 + prom_type:7 } back(obj); return false;