diff --git a/app.js b/app.js index 28c0596..a56a7e9 100644 --- a/app.js +++ b/app.js @@ -51,7 +51,7 @@ App({ config: null, //门店参数 config2: null, //门店配置 code: null, - user_id:null,//6520390,//6520352 + user_id:16072538,//6520390,//6520352 // user_id:6520314,// qa-6519858,// // user_id:14148118,// qa-6519858,// buy_now: null, @@ -1359,13 +1359,13 @@ App({ var limittype=gd.erp_limittype; //不低于0、倍数1 var limitqty=gd.erp_limitqty; //起购量 - //-- 如果有活动的时候 -- + //-- 如果有活动的时候,就直接返回1 -- if(act){ - islimit=act.islimit; - limittype=act.limittype; - limitqty=act.limitqty; + return 1; + //islimit=act.islimit; + //limittype=act.limittype; + //limitqty=act.limitqty; } - //-- 不是限购的时候,返回1-- if(!islimit) return 1; //-- 默认的时候 -- @@ -1374,10 +1374,26 @@ App({ if(!limittype) return 1; //倍数,加减的时候 return limitqty; + }, + //获取商品是不是有促销活动 + async get_has_cx_act(gid){ + var url = '/api/weshop/activitylist/listGoodActInfo2New'; + var req_d = { + "store_id":this.globalData.setting.stoid, + "goods_id": gid, + "user_id":this.globalData.user_id, + } + var res= await this.promiseGet(url,{data:req_d}); + var cx_arr=[]; + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + var arr = res.data.data; + cx_arr=arr.filter(function (e) { + return e.s_time < ut.gettimestamp() && [3,5,7,10].indexOf(e.prom_type)>-1; + }) + } + return cx_arr; } - - }); diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index c8e8c07..bf256a7 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -2154,10 +2154,9 @@ Page({ //----------增加购买数量----------- addCartNum: function (t) { - var add_num=1; if(this.data.is_normal == 1){ - add_num=getApp().get_limit_qty(this.data.sele_g,0,1); + add_num=getApp().get_limit_qty(this.data.sele_g,this.data.is_act,1); } this.checkCartNum(this.data.goodsInputNum + add_num); }, @@ -2165,7 +2164,7 @@ Page({ subCartNum: function (t) { var add_num=1; if(this.data.is_normal == 1){ - add_num=getApp().get_limit_qty(this.data.sele_g,0,1); + add_num=getApp().get_limit_qty(this.data.sele_g,this.data.is_act,1); } this.checkCartNum(this.data.goodsInputNum - add_num); }, @@ -2191,7 +2190,9 @@ Page({ //------检查数量是不是超出限购------ checkCartNum: function (t) { var th = this; - var mo_num=getApp().get_limit_qty(th.data.sele_g); + var mo_num=getApp().get_limit_qty(th.data.sele_g,th.data.is_act); + var steep=getApp().get_limit_qty(th.data.sele_g,th.data.is_act,1); + this.get_buy_num(this.data.sele_g, async function () { //--判断商品是否超出限购-- @@ -2260,8 +2261,20 @@ Page({ e = th.data.def_pick_store.CanOutQty; } } + } + //--- 促销活动也不控制起订量, 这里很重要的一个控制,起订量的 ---- + if(th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ + if(tmo_num && (t-mo_num)%steep!=0){ + wx.showToast({ + title: '购买数必须是起订量的倍数', + icon: 'none', + }); + t=mo_num+ parseInt((t-mo_num)/steep)*steep+steep; + } } + if (!e) e = 0; //库存不足,不增加 if (e < t) { @@ -2269,13 +2282,16 @@ Page({ if (e < 0) e = 0; if(th.data.is_normal == 1){ - if(emo_num && (e-mo_num)%steep!=0){ + e=mo_num+ parseInt((e-mo_num)/steep)*steep; + } } th.setData({ goodsInputNum: e }); return false; } - t > e || 0 == e ? t = e : t < 1 && (t = 1); + t > e || 0 == e ? t = e : t < 1 && (t = 1); //只有普通商品才有起购数 if(th.data.is_normal == 1){ if(t{ if (res.data.code == 0 && res.data.data) { - var r_data = res.data.data; + r_data = res.data.data; var max = 0, min = 0; //暂时积分够 不和 优惠,阶梯重叠 if(th.data.zh_act){ @@ -6387,42 +6400,6 @@ Page({ 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; @@ -6438,8 +6415,50 @@ Page({ } }) + 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 + }) + } + }) + } + + //-- 如果有促销活动也算是有参与活动,参与活动的也统一不进行计算起订的数量 -- + this.data.is_act=0; + if(this.data.zh_act || this.data.prom_goods || this.data.jieti_prom || this.data.collocationGoods ){ + this.data.is_act=1; + } + //-- 更新默认购买的数量 --- + var mo_num=getApp().get_limit_qty(th.data.sele_g,this.data.is_act); + this.setData({goodsInputNum:mo_num}) + this.setData({mo_num:mo_num}) }, diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 4c61b86..071b992 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -1582,7 +1582,7 @@ Page({ }, //-------------加数量--------------------- - addNum: function (t) { + addNum:async function (t) { if (!this.data.is_load) return false; if (this.data.up_dating == 1) return false; this.data.up_dating = 1; @@ -1594,7 +1594,6 @@ Page({ console.log('add+'); if (this.data.sales_rules < 2 || a.whsle_id || [1, 2, 4, 6, 8, 9].indexOf(a.prom_type) > -1) { - if (a.goods_num > a.store_count) { console.log('购买的数量不能-----'); // wx.showModal({ @@ -1613,13 +1612,15 @@ Page({ } var add_num=1; - var mo_num=getApp().get_limit_qty(a); - var steep=getApp().get_limit_qty(a,0,1); - if(steep>1){ - add_num=steep; + //调用接口判断是不是促销活动的商品 + if([0,3,5,7,10].indexOf(a.prom_type) > -1){ + var cx_arr=await getApp().jc(a.goods_id,user_id); + var steep=getApp().get_limit_qty(a,cx_arr.length,1); + if(steep>1){ + add_num=steep; + } } - var e = { goods_num: a.goods_num + add_num, id: a.id, @@ -1627,11 +1628,11 @@ Page({ store_id: oo.stoid }; // console.log('goods_num', e.goods_num); - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); + this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems,cx_arr); }, //-------------减数量--------------------- - subNum: function (t) { + subNum: async function (t) { if (!this.data.is_load) return false; if (this.data.up_dating == 1) return false; this.data.up_dating = 1; @@ -1648,10 +1649,12 @@ Page({ var add_num=1; - var mo_num=getApp().get_limit_qty(a); - var steep=getApp().get_limit_qty(a,0,1); - if(steep>1){ - add_num=steep; + if([0,3,5,7,10].indexOf(a.prom_type) > -1){ + var cx_arr=await getApp().get_has_cx_act(a.goods_id); + var steep = getApp().get_limit_qty(a, cx_arr.length, 1); + if (steep > 1) { + add_num = steep; + } } var e = { @@ -1685,10 +1688,7 @@ Page({ var e = a; var th = this; - - var mo_num=getApp().get_limit_qty(e); - - if (a = isNaN(t.detail.value) || t.detail.value < mo_num ? mo_num : parseInt(t.detail.value)) { + if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { var s = { goods_num: a, goods_id: e.service_id, @@ -2600,15 +2600,15 @@ Page({ th = e, user_id = getApp().globalData.user_id; - function normal_check(store_count, goodsinfo, wareIds) { + function normal_check(store_count, goodsinfo, wareIds,cx_arr) { // getApp().my_warnning('购买数量超出商品库存', 0, th); var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; //-- 要判断是不是起订量不购 -- if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ - var mo_num=getApp().get_limit_qty(goodsinfo); - var steep=getApp().get_limit_qty(goodsinfo,0,1); + var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); + var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); if(mo_num>1 && t.goods_num 0 ? cbuy : limit; if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ - var mo_num=getApp().get_limit_qty(goodsinfo); - var steep=getApp().get_limit_qty(goodsinfo,0,1); + + //-- 判断商品是不是 -- + var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); + + var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); + var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); + if(mo_num>1 && t.goods_num1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0 ){ wx.showToast({ @@ -2740,7 +2745,7 @@ Page({ switch (goodsinfo.prom_type) { case 1: - //读取秒杀 + //-- 读取秒杀 -- rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, { isShowLoading: 0, success: function (res_d) { @@ -2939,10 +2944,10 @@ Page({ normal_check(store_count, goodsinfo, wareIds); } }) - break; default: - normal_check(store_count, goodsinfo, wareIds); + var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); + normal_check(store_count, goodsinfo, wareIds,cx_arr); break } } diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 20a2656..40700e1 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1107,14 +1107,6 @@ Page({ //获取统一条形码,普通商品和优惠促销的商品 if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) { - - //-- 更新默认购买的数量 --- - var mo_num=getApp().get_limit_qty(t.data.data); - - - ee.setData({goodsInputNum:mo_num}) - ee.setData({mo_num:mo_num}) - ee.get_sto(); ee.get_sku(o.stoid, t.data.data, gid); ee.check_has_flash(); @@ -2408,8 +2400,7 @@ Page({ var add_num=1; var p_type=parseInt(this.data.prom_type) if([1,2,4,6,8,9].indexOf(p_type)==-1 || this.data.openSpecModal_inte_normal == 1 || this.data.is_normal == 1){ - - add_num = getApp().get_limit_qty(this.data,this.data.sele_g, 0, 1); + add_num = getApp().get_limit_qty(this.data.sele_g, this.data.is_act, 1); } this.checkCartNum(this.data.goodsInputNum + add_num); @@ -2420,9 +2411,8 @@ Page({ var add_num=1; var p_type=parseInt(this.data.prom_type) if([1,2,4,6,8,9].indexOf(p_type)==-1 || this.data.openSpecModal_inte_normal == 1 || this.data.is_normal == 1){ - if(!th.data.prom_goods && !th.data.jieti_prom && !th.data.zh_act && !th.data.collocationGoods) { - add_num = getApp().get_limit_qty(this.data.sele_g, 0, 1); - } + add_num = getApp().get_limit_qty(this.data.sele_g, this.data.is_act, 1); + } this.checkCartNum(this.data.goodsInputNum - add_num); }, @@ -2448,9 +2438,8 @@ Page({ //------检查数量是不是超出限购------ checkCartNum: function (t) { var th = this; - - var mo_num=getApp().get_limit_qty(th.data.sele_g); - var steep=getApp().get_limit_qty(th.data.sele_g,0,1); + var mo_num=getApp().get_limit_qty(th.data.sele_g,th.data.is_act); + var steep=getApp().get_limit_qty(th.data.sele_g,th.data.is_act,1); this.get_buy_num(this.data.sele_g, async function () { @@ -2539,18 +2528,14 @@ Page({ } //--- 促销活动也不控制起订量, 这里很重要的一个控制,起订量的 ---- - if([0,3,5,7,10].indexOf(p_type)>-1){ - if(th.data.prom_goods || th.data.jieti_prom || th.data.zh_act || th.data.collocationGoods){ - mo_num=1;steep=1; - }else{ - if(tmo_num && (t-mo_num)%steep!=0){ - wx.showToast({ - title: '购买数必须是起订量的倍数', - icon: 'none', - }); - t=mo_num+ parseInt((e-mo_num)/steep)*steep; - } + if([0,3,5,7,10].indexOf(p_type)>-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ + if(tmo_num && (t-mo_num)%steep!=0){ + wx.showToast({ + title: '购买数必须是起订量的倍数', + icon: 'none', + }); + t=mo_num+ parseInt((t-mo_num)/steep)*steep+steep; } } @@ -5017,8 +5002,6 @@ Page({ var th = this; var ind = parseInt(e.currentTarget.dataset.it); - var mo_num=getApp().get_limit_qty(this.data.sele_g); - //如果是拼单活动的普通购买 if (ind == 1) { @@ -5032,9 +5015,6 @@ Page({ th.setData({ is_normal: ind, openSpecModal_pt: 1, - goodsInputNum: mo_num, - mo_num:mo_num - }); } else { th.get_sto(1); @@ -5042,8 +5022,6 @@ Page({ th.setData({ is_normal: ind, openSpecModal_pt: 1, - goodsInputNum: mo_num, - mo_num:mo_num }); }); } @@ -7488,13 +7466,13 @@ Page({ }) } } - + var r_data=null; //调用接口判断订单优惠, 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; + r_data = res.data.data; var max = 0, min = 0; //暂时积分够 不和 优惠,阶梯重叠 if(th.data.zh_act){ @@ -7519,42 +7497,6 @@ Page({ 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; @@ -7570,8 +7512,51 @@ Page({ } }) + //-- 如果有阶梯购的时候 -- + if (r_data && 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 + }) + } + }) + } + + //-- 如果有促销活动也算是有参与活动,参与活动的也统一不进行计算起订的数量 -- + this.data.is_act=0; + if(this.data.zh_act || this.data.prom_goods || this.data.jieti_prom || this.data.collocationGoods ){ + this.data.is_act=1; + } + + //-- 更新默认购买的数量 --- + var mo_num=getApp().get_limit_qty(th.data.sele_g,this.data.is_act); + this.setData({goodsInputNum:mo_num}) + this.setData({mo_num:mo_num}) }, @@ -7634,9 +7619,8 @@ Page({ openSpecModal_inte: 1, goodsInputNum: 1 }); - - }, + //-- 积分购普通购买 -- go_pay_integral_normal: function () { @@ -8155,12 +8139,9 @@ Page({ openSpecModel_Nor: function () { this.data.g_buy_num = new Map(); var th = this; - var mo_num=getApp().get_limit_qty(this.data.sele_g); this.setData({ open_ind_store: 5, - goodsInputNum: mo_num, - mo_num:mo_num }); //拼团直接给4 if (th.data.sku_g_pt) { diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 431f70c..d41e3c8 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -1322,7 +1322,7 @@ (库存不足) (配送不匹配) - + (库存不足)