diff --git a/components/diy_public/diy_public.js b/components/diy_public/diy_public.js index 2eadc60..d915145 100644 --- a/components/diy_public/diy_public.js +++ b/components/diy_public/diy_public.js @@ -50,9 +50,12 @@ Component({ '2':"/miniapp/images/component/pingd/pingd.png", '6':"/miniapp/images/component/pingd/pingd.png", '8':"/miniapp/images/component/presale.png", + '9':"/miniapp/images/component/luckyactivity_new1.png", + // '9':"/images/luckyactivity_new.png", }, nav1:'/packageA/pages/goodsInfo/goodsInfo?', nav2:'/pages/goods/goodsInfo/goodsInfo?', + }, pageLifetimes: { @@ -98,7 +101,7 @@ Component({ prom_text:'已团', nav1:'/pages/goods/goodsInfo/goodsInfo?', nav2:'/pages/goods/goodsInfo/goodsInfo?' - }) + }) } if (this.data.prom_type==8) { //预售 this.setData({ @@ -107,6 +110,14 @@ Component({ nav2:'/packageC/pages/presell/goodsInfo/goodsInfo?' }) } + if (this.data.prom_type==9) { //幸运购 + this.setData({ + prom_text:'已售', + nav1:'/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?', + nav2:'/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?' + }) + } + var g_id = this.data.object; this.init(g_id); @@ -165,6 +176,10 @@ Component({ gUrl="/api/weshop/marketing/marketingPresellList/page?store_id=" +os.stoid+"&goodsidlist="+goodsidlist + "&user_id="+user_id+'&is_end=0&timetype=3&isuse=1'; } + if (th.data.prom_type==9) { //幸运购 + gUrl="/api/weshop/prom/luckyActivity/getGoodsList?store_id=" + +os.stoid+"&goodsidlist="+goodsidlist + "&user_id="+user_id+'&is_end=0&timetype=1&type=1'; + } @@ -226,6 +241,18 @@ Component({ pageSize:9 } } + if (this.data.prom_type==9) { //幸运购 + gUrl="/api/weshop/prom/luckyActivity/page" + req={ + store_id:os.stoid, + is_end:0, + timetype:1, + // isuse:1, + // page:1, + // user_id:user_id, + // pageSize:9 + } + } getApp().request.promiseGet(gUrl, { isShowLoading: 1, data:req } @@ -244,6 +271,7 @@ Component({ let prom_type=this.data.prom_type goodslist.forEach(function (vy, indy) { if(!vy.id) vy.id=vy.prom_id; + if(vy.title && !vy.goods_name) vy.goods_name=vy.title; }) // 判断火热,预热 @@ -279,7 +307,7 @@ Component({ var promisies = []; - if (th.data.prom_type !=8) { + if (th.data.prom_type !=8 && th.data.prom_type !=9) { for (const key in all_array) { if (Object.hasOwnProperty.call(all_array, key)) { const val = all_array[key]; @@ -306,6 +334,7 @@ Component({ }; // let price=all_array[i].price.toFixed(2) let price=all_array[i].price + '' + if (th.data.prom_type==8) { //预售 price = all_array[i].presell_price + '' if (all_array[i].status ===0) { @@ -315,8 +344,12 @@ Component({ all_array[i].goods_num=all_array[i].presell_sumqty*1 + all_array[i].virtual_qty*1 all_array[i].buy_num=all_array[i].buy_goodnum + all_array[i].virtual_qty*1 } - - + } + if (th.data.prom_type==9) { //幸运购 + price = (all_array[i].group_price / 100) + '' + // all_array[i].buy_num = all_array[i].group_joined + all_array[i].buy_num = all_array[i].goods_num*1 - all_array[i].actLen*1 + // all_array[i].goods_name = all_array[i].title } @@ -329,6 +362,12 @@ Component({ } all_array[i].residue=all_array[i].goods_num*1 - all_array[i].buy_num*1 + all_array[i].residue = (all_array[i].residue >= 0) ? all_array[i].residue : 0 + if (th.data.prom_type==9) { //幸运购 + all_array[i].residue= all_array[i].actLen + } + + // console.error(all_array[i].residue); if (all_array[i].residue && all_array[i].residue > 0 && all_array[i].status !=2) { empty.push(all_array[i]) } @@ -438,7 +477,14 @@ Component({ sec: '00' } } - var txt = "goods_array[" + j + "][" + i + "].djs"; + let txt = "goods_array[" + j + "][" + i + "].djs"; + + if (!o.status && obj.day=='00' && obj.hou=='00' && obj.min=='00' && obj.sec=='01') { + let t1="goods_array[" + j + "][" + i + "].status"; + ee.setData({ + [t1]:1 + }) + } ee.setData({ [txt]: obj }); @@ -464,6 +510,9 @@ Component({ if (this.data.prom_type==8) { //预售 url="/packageC/pages/presell/list/list"; } + if (this.data.prom_type==9) { //幸运购 + url="/packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList"; + } wx.navigateTo({ url diff --git a/components/diy_public/diy_public.wxml b/components/diy_public/diy_public.wxml index bbadfc0..fa1613e 100644 --- a/components/diy_public/diy_public.wxml +++ b/components/diy_public/diy_public.wxml @@ -33,7 +33,7 @@ 已售罄 - + 距结束时间 距开始时间 @@ -245,7 +245,7 @@ 已售罄 - + 距结束时间 距开始时间 diff --git a/components/diy_public/diy_public.wxss b/components/diy_public/diy_public.wxss index abdb465..f0c1894 100644 --- a/components/diy_public/diy_public.wxss +++ b/components/diy_public/diy_public.wxss @@ -555,4 +555,14 @@ swiper { border-radius: 10rpx; margin-right: 10rpx; opacity: .8; + } + .lucky{ + display: inline-block; + font-size: 24rpx; + padding: 0 10rpx; + background-color: #f23023; + opacity: .8; + color: #fff; + margin-right: 10rpx; + border-radius: 10rpx; } \ No newline at end of file diff --git a/components/promate_pop/promate_pop.wxml b/components/promate_pop/promate_pop.wxml index 73cb6ba..89d832d 100644 --- a/components/promate_pop/promate_pop.wxml +++ b/components/promate_pop/promate_pop.wxml @@ -20,7 +20,8 @@ {{item.title}} {{item.title}} - 消费满{{item.condition}}享优惠({{item.limit}}) + 消费满{{item.condition}} + 享优惠({{item.limit}},限购{{item.goodslimit}}件) 搭配价:{{item.show_price}} diff --git a/packageA/pages/goodsInfo/goodsInfo.wxss b/packageA/pages/goodsInfo/goodsInfo.wxss index 938bc20..6c3850d 100644 --- a/packageA/pages/goodsInfo/goodsInfo.wxss +++ b/packageA/pages/goodsInfo/goodsInfo.wxss @@ -2425,7 +2425,7 @@ margin: auto; */ } .shop_name{ margin-right: 10rpx; - max-width: 375rpx; + max-width: 370rpx; } .address{ /* width: 100%; diff --git a/packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxml b/packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxml index 7f5aafa..e747298 100644 --- a/packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxml +++ b/packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxml @@ -11,7 +11,7 @@ - + presellList.presell_sumqty - presellList.buy_goodnum) { @@ -2777,6 +2785,29 @@ Page({ return false; } + var fres=await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell_id, {}); + //接口调用成功的时候 + if(fres && fres.data.code==0 && fres.data.data){ + //如果有指定门店的时候 + if(fres.data.data.pick_up_lists){ + var idx0=fres.data.data.pick_up_lists.findIndex(function (e){ + return e.pickup_id==order.pickup_id; + }) + if(idx0<0){ + getApp().confirmBox(good.goods_name+"预售活动的门店不可售"); + th.setData({ paying: 0 }); + return false; + } + } + + }else{ + var content = good.goods_name + '未找到预售活动,请取消订单'; + th.toast(content); + th.setData({ paying: 0 }); + return false; + } + + } } diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index e80cc7c..d6ef67f 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -712,6 +712,9 @@ Page({ this.data.show_prew_img = 0; return false; } + th.data.fir_def_store =null; + that.setData({ def_pick_store: null,}); + /*-- //优惠券要实时更新 getApp().getConfig2(function (e) { @@ -878,6 +881,7 @@ Page({ sele_g: t.data.data, userInfo: getApp().globalData.userInfo, }); + ee.init(gid); //获取门店 ee.get_sto(); @@ -1912,6 +1916,7 @@ Page({ //---------拿出门店分类和门店------------ get_sto(e) { var th = this, is_normal = e; + var that=th; if (e == 1) { th.setData({ is_normal: 1 }) @@ -1921,6 +1926,8 @@ Page({ var timer_get = setInterval(function () { if (th.data.is_get_local_ok == 0) return false; + if (!th.data.fir_def_store) return false; + var dd = null, i = getApp().request; if (!th.data.sele_g) return false; @@ -1968,44 +1975,107 @@ Page({ }).then(res => { var e = res; + //确保门店的数量要>0时,才进行计算 if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { - //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 - if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { - th.setData({ - def_pick_store: e.data.data.pageData[0], - sto_sele_name: e.data.data.pageData[0].pickup_name, - sto_sele_id: e.data.data.pageData[0].pickup_id, - sto_sele_distr: e.data.data.pageData[0].distr_type - }); - th.data.fir_def_store = e.data.data.pageData[0]; - } - //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { - for (var k = 0; k < e.data.data.pageData.length; k++) { - if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { - e.data.data.pageData.splice(k, 1); //删除 - break; + + //指定门店判断, 不是普通购买的时候,秒杀的时候,秒杀有指定门店 + var pickup_ids=th.data.presellForm.pick_up_lists + //-- 如果有指定门店的时候 -- + if(pickup_ids){ + + var ok_arr=[]; + for (let i in e.data.data.pageData) { + let ite = e.data.data.pageData[i]; + //-- 查找一下门店有没有在 -- + var idx=pickup_ids.findIndex(function (e){ + return e.pickup_id==ite.pickup_id; + }) + if(idx>-1){ + ok_arr.push(ite) + } + } + + //判断会员的默认的门店是不是匹配指定的门店 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ + //-- 查找一下门店有没有在 -- + var idx1=pickup_ids.findIndex(function (e){ + return e.pickup_id==th.data.def_pick_store.pickup_id; + }) + + if(idx1<0){ + //如果是秒杀的指定门店,就要设置秒杀的 + th.data.def_pick_store.is_no_dis_act=1; + }else{ + th.data.def_pick_store.is_no_dis_act=0; } + + that.setData({ + def_pick_store: th.data.def_pick_store + }) + + } + e.data.data.pageData=ok_arr; //数组重新赋值 + e.data.data.total=ok_arr.length; //数组的长度 + } + else{ + //-- 多规格指定门店优化 -- + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ + th.data.def_pick_store.is_no_dis_act=0; + that.setData({ + def_pick_store: th.data.def_pick_store + }) } - e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 } + //确保门店的数量要>0时,才进行计算 + if(e.data.data.pageData.length > 0) { - th.setData({ all_pick_list: e.data.data.pageData }); - //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售-- - if(!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id - && th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ([1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 || is_normal == 1)) { - setTimeout(function () { - th.deal_pickup_dline(e); - }, 800) - } else { - setTimeout(function () { - th.deal_pickup(e); //--普通门店排版-- - }, 800) + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { + th.setData({ + def_pick_store: e.data.data.pageData[0], + sto_sele_name: e.data.data.pageData[0].pickup_name, + sto_sele_id: e.data.data.pageData[0].pickup_id, + sto_sele_distr: e.data.data.pageData[0].distr_type + }); + th.data.fir_def_store = e.data.data.pageData[0]; + } + + //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { + for (var k = 0; k < e.data.data.pageData.length; k++) { + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { + e.data.data.pageData.splice(k, 1); //删除 + break; + } + } + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 + } + + + th.setData({all_pick_list: e.data.data.pageData}); + + //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售-- + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id + && th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ([1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) == -1 || is_normal == 1)) { + setTimeout(function () { + th.deal_pickup_dline(e); + }, 800) + } else { + setTimeout(function () { + th.deal_pickup(e); //--普通门店排版-- + }, 800) + } } + else{ + wx.hideLoading(); + } + } + else{ + wx.hideLoading(); } }) }, 200) diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.wxml b/packageC/pages/presell/goodsInfo/goodsInfo.wxml index 8c239d1..47b3dcb 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.wxml +++ b/packageC/pages/presell/goodsInfo/goodsInfo.wxml @@ -192,7 +192,10 @@ - (配送不匹配2) + (配送不匹配) + + + (该店不可售) (库存不足) @@ -629,7 +632,8 @@ (库存不足) - (配送不匹配1) + (配送不匹配) + (该店不可售) (库存不足) @@ -671,9 +675,13 @@ - + 门店的不匹配 + + 该门店不可售 + + @@ -855,7 +863,10 @@ - {{item.pickup_name}} + {{item.pickup_name}} + (配送不匹配) + (该店不可售) + @@ -881,7 +892,10 @@ - {{item.pickup_name}} + {{item.pickup_name}} + (配送不匹配) + (该店不可售) + @@ -909,7 +923,10 @@ - {{item.pickup_name}} + {{item.pickup_name}} + (配送不匹配) + (该店不可售) + diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.wxss b/packageC/pages/presell/goodsInfo/goodsInfo.wxss index 600205b..c1d6105 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.wxss +++ b/packageC/pages/presell/goodsInfo/goodsInfo.wxss @@ -3016,4 +3016,6 @@ button.custom-service::after{ border: 2rpx solid rgb(238, 238, 238); padding-left: 30rpx; } - +.c-red22{ + color: #d60021 +} diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index 64912a4..f6f64ba 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -2333,6 +2333,7 @@ Page({ if (get_data.gift_id && parseInt(get_data.zp_mode) != 1 && get_data.zp_num * item_map.bs <= get_data.limit_num-other_gift && get_data.zp_num * item_map.bs <= get_data.gift_storecount + && get_data.zp_num>get_data.must_num //增加一个超量 ) { item_map.gift_id = get_data.gift_id; @@ -2371,7 +2372,17 @@ Page({ var can_zp_num = 0; for (let iy in get_data.giftsinfo) { let item = get_data.giftsinfo[iy]; - can_zp_num += parseInt(item.gift_storecount) > parseInt(item.limit_num) ? parseInt(item.limit_num) : parseInt(item.gift_storecount); + + var c_zp=0; + if(parseInt(item.limit_num)>0){ + c_zp= parseInt(item.gift_storecount) > parseInt(item.can_num) ? parseInt(item.can_num) : parseInt(item.gift_storecount); + }else{ + c_zp= parseInt(item.gift_storecount); + } + + if(c_zp<0) c_zp=0; + can_zp_num +=c_zp; + } var t_zp_num = parseInt(get_data.zp_num) * parseInt(get_data.bs); @@ -2385,7 +2396,8 @@ Page({ giftsinfo: get_data.giftsinfo, zp_num: get_data.zp_num * get_data.bs, gf_pr_name: item_map.name, - prom_id: item_map.prom_id + prom_id: item_map.prom_id, + bs: parseInt(get_data.bs), }); duo_zp_num_arr[item_map.prom_id] = t_zp_num; @@ -4711,6 +4723,8 @@ Page({ var order_prom_list_cart = th.data.order_prom_list_cart; + //优惠商品限购的优化 + var yh_lm_map={}; //--组装推送数据-- for (var i = 0; i < order_prom_list_cart.length; i++) { var t_item = order_prom_list_cart[i]; @@ -4877,8 +4891,6 @@ Page({ var check_map = {}; let groupchat_ids=[] - - //-------------让商品添加到商品列表-------------------- for (var k = 0; k < t_item.goods.length; k++) { @@ -4975,6 +4987,7 @@ Page({ //--赠品的时候,阶梯促销会右重复的情况,还有组合购的时候拆分出去的 -- if (check_map[txt] && goods.prom_type != 10) { getApp().confirmBox(goods.goods_name + "计算金额错误,请重新刷新"); + th.setData({ submit: 0 }) return false; } else { check_map[txt] = 1; @@ -4986,18 +4999,65 @@ Page({ var mo_num=getApp().get_limit_qty(g_item,act.length); var steep=getApp().get_limit_qty(g_item,act.length,1); - if ([0,3,5,7,10].indexOf(goods.prom_type)>-1){ + //赠品要排除之外,不进行判断 + if ([0,3,5,7,10].indexOf(goods.prom_type)>-1 && !goods.is_gift){ if(mo_num>goods.goods_num){ getApp().confirmBox(goods.goods_name + "的未达到起订数量"); th.data.is_summit_ing = 0; + th.setData({ submit: 0 }) return false; } if(steep>1 && (goods.goods_num-mo_num)%steep!=0 ){ getApp().confirmBox(goods.goods_name + "的购买的数量不是起订量的倍数"); th.data.is_summit_ing = 0; + th.setData({ submit: 0 }) return false; } + //-- 要判断一下优惠促销的商品的限购 -- + if(goods.prom_type==3){ + var pro_gd_limit_num=0; + var p_limit_rs= await getApp().request.promisePost('/api/weshop/promgoods/getPromGoodsLimitNum',{ + data:{ + store_id:os.stoid,goods_id:goods.goods_id,prom_id:goods.prom_id,prom_type:3 + } + }) + if(p_limit_rs && p_limit_rs.data.code==0){ + pro_gd_limit_num=p_limit_rs.data.data + } + //-- 如果有商品限购的时候 -- + if(pro_gd_limit_num>0){ + //-- 获取会员之前优惠促销商品买了多少件 -- + var pro_by_num=0; + var lrs= { + store_id: os.stoid,user_id: getApp().globalData.user_id, + goods_id: goods.goods_id, prom_type: 3, + prom_id: goods.prom_id, isnew:1 + }; + var gd_limit_rs=await getApp().promiseGet('/api/weshop/ordergoods/getUserBuyGoodsNum',{data:lrs}); + if(gd_limit_rs && gd_limit_rs.data.code==0){ + pro_by_num=gd_limit_rs.data.data.promgoodsbuynum + } + + var m_ky=goods.goods_id+'|'+goods.prom_id; + + var more_num=yh_lm_map[m_ky]?yh_lm_map[m_ky]:0; + + if(pro_gd_limit_num= t_zp_num && a_stock_num >= t_zp_num) { send_gf[pickid].push({ pickup_id: pickid, giftsinfo: get_data.giftsinfo, zp_num: get_data.zp_num * get_data.bs, - gf_pr_name: prom.name, prom_id: prom.prom_id + gf_pr_name: prom.name, prom_id: prom.prom_id,bs:get_data.bs }); } th.setData({ send_gf: send_gf }); @@ -7190,7 +7251,8 @@ Page({ zp_num: this.data.send_gf[pk][index].zp_num, gift_pkid: pk, gf_prom_id: this.data.send_gf[pk][index].prom_id, - send_gf_index: index + send_gf_index: index, + gf_bs:this.data.send_gf[pk][index].bs }) }, @@ -7207,7 +7269,7 @@ Page({ var gift_id = discount.gift_id; for (var i in alllist) { var list_item = alllist[i]; - //-- 门店相同,活动相同的时候 -- + //-- 门店相同,活动相同的时候,就continue掉 -- if (pick_id == list_item.pickup_id && prom_id == list_item.prom_id) continue; for (var j in list_item.goods) { //如果赠品的ID一样,要进行统计数量 @@ -7216,7 +7278,7 @@ Page({ all_num += list_item.goods[j].goods_num; } if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == gift_id && list_item.goods[j].prom_id == prom_id) { - all_limit_num += list_item.goods[j].limit_num; + all_limit_num += list_item.goods[j].goods_num; } } } @@ -7230,7 +7292,8 @@ Page({ }); return false; } - if (discount.limit_num < all_limit_num) { + //-- 限购一定要大于0,否则就是不限的意思 -- + if (discount.limit_num>0 && discount.can_num < all_limit_num) { wx.showToast({ title: "超出赠品限购", icon: 'none', @@ -7249,10 +7312,22 @@ Page({ th.data.isget_by_quan[gf_pickup_id]=null; var zp_num = this.data.zp_num; + var gf_bs = this.data.gf_bs?this.data.gf_bs:1; + var giftsinfo = this.data.giftsinfo; var all_num = 0; for (let i in giftsinfo) { let item = giftsinfo[i]; + if(item.must_num>0 ){ + if(!item.selected){ + ut.m_toast("必送的赠品没有选中"); + return false; + } + if(item.goods_num - {{gf_pr_name}},可任选{{zp_num}}件商品为赠品 + {{gf_pr_name}},可选{{zp_num}}件商品为赠品 @@ -1054,17 +1054,20 @@ - + - - {{items.goods_name}} + + {{items.goods_name}} + {{items.goodsinfo.goods_color}}{{items.goodsinfo.goods_color?"/":''}}{{items.goodsinfo.goods_spec}} 规格1 + 必选{{items.must_num*gf_bs}}件 + diff --git a/packageE/pages/cart/cart2/cart2.wxss b/packageE/pages/cart/cart2/cart2.wxss index 9ce89dd..0bc2a23 100644 --- a/packageE/pages/cart/cart2/cart2.wxss +++ b/packageE/pages/cart/cart2/cart2.wxss @@ -130,7 +130,13 @@ page { margin-bottom: 16rpx; font-size: 28rpx; color: #333; - +} +.goods-name2 { + min-height: 74rpx; + line-height: 40rpx; + margin-bottom: 16rpx; + font-size: 28rpx; + color: #333; } .goods-color { @@ -1228,6 +1234,10 @@ margin-left: 20rpx; margin-top: 6rpx; } +.c-red { + color: #f23030;vertical-align: top;position: relative;top: 3rpx;font-size: 21rpx;margin-left: 2rpx; +} + diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 4269c3e..c902fac 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -3220,6 +3220,8 @@ Page({ var zh_limit_m={} var zh_all_ck={}; + //多门店的时候,控制不能超出限购 + var yh_by_map={}; // let checkOff=false for (var i = 0; i < this.data.requestData.length; i++) { @@ -3232,6 +3234,10 @@ Page({ } var i_arr = this.data.requestData[i].goods; + + //判断一下商品能不能满足优惠促销的条件 + await th.check_can_yh_pro(i_arr); + for (var j = 0; j < i_arr.length; j++) { if (i_arr[j].selected && i_arr[j].is_gift != 1) { @@ -3251,7 +3257,6 @@ Page({ if (this.data.requestData[i].show_can_cx && (i_arr[j].prom_type == 3 || i_arr[j].prom_type == 7)) { var show_can_cx=this.data.requestData[i].show_can_cx; - //-- 查找选中了什么 -- for (var ik in show_can_cx) { var ch_map = show_can_cx[ik].ch_map; @@ -3269,6 +3274,26 @@ Page({ } else { i_arr[j].prom_id = fd1.prom_id; i_arr[j].prom_type = fd1.prom_type; + + var ky=i_arr[j]['prom_type']+'-'+i_arr[j]['prom_id']+'-'+i_arr[j]['goods_id']; + var ky_n=0; + if(yh_by_map[ky]){ + ky_n+=yh_by_map[ky]; + } + + //-- 判断优惠促销活动的商品的限购,can_yh 表示商品满足优惠促销的条件 -- + if(i_arr[j].prom_type==3 && fd1.act.goodslimit>0 && i_arr[j].can_yh ){ + var p_can_by=fd1.act.goodslimit-fd1.act.goodslimited; + if(i_arr[j].goods_num+ky_n>p_can_by){ + getApp().confirmBox(i_arr[j].goods_name + "超出活动限购数量"+fd1.act.goodslimit+"件"); + wx.hideLoading(); + return false; + } + } + //-- 把购物数量记录到map表中 -- + if(!yh_by_map[ky]) yh_by_map[ky]=0; + yh_by_map[ky]+=i_arr[j].goods_num; + } } @@ -3966,6 +3991,7 @@ Page({ }, + //跳到首页 goto: function (e) { var url = '/pages/index/index/index'; @@ -4165,7 +4191,15 @@ Page({ var a_limit_num = 0; for (let iy in discount.giftsinfo) { let item = discount.giftsinfo[iy]; - can_zp_num += parseInt(item.gift_storecount) > parseInt(item.limit_num) ? parseInt(item.limit_num) : parseInt(item.gift_storecount); + + var c_zp=0; + if(parseInt(item.limit_num)>0){ + c_zp= parseInt(item.gift_storecount) > parseInt(item.can_num) ? parseInt(item.can_num) : parseInt(item.gift_storecount); + }else{ + c_zp= parseInt(item.gift_storecount); + } + if(c_zp<0) c_zp=0; + can_zp_num +=c_zp; } var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); @@ -4290,6 +4324,7 @@ Page({ } }, + //优惠促销用户参与次数 async getUserBuyPromNum_pre(prom_id) { var userInfo = getApp().globalData.userInfo; @@ -4487,7 +4522,14 @@ Page({ var a_limit_num = 0; for (let iy in discount.giftsinfo) { let item = discount.giftsinfo[iy]; - can_zp_num += parseInt(item.gift_storecount) > parseInt(item.limit_num) ? parseInt(item.limit_num) : parseInt(item.gift_storecount); + var c_zp=0; + if(parseInt(item.limit_num)>0) { + c_zp= parseInt(item.gift_storecount) > parseInt(item.can_num) ? parseInt(item.can_num) : parseInt(item.gift_storecount); + }else{ + c_zp= parseInt(item.gift_storecount) + } + if(c_zp<0) c_zp=0; + can_zp_num +=c_zp; } var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); @@ -4727,8 +4769,6 @@ Page({ }); }, - - //-- 开始显示活动的弹出 -- switch_cx_group: function (e) { var idx = e.currentTarget.dataset.index; @@ -4964,6 +5004,81 @@ Page({ 'code': 0, 'msg': '成功' }) + }, + + //-- 判断一下有没有满足优惠促销的条件 -- + check_can_yh_pro:async function (i_arr){ + var map={}; + for (let i = 0; i < i_arr.length; i++) { + var item=i_arr[i]; + if(item.is_gift) continue; + if(item.prom_type!=3) continue; + + if (map[item.prom_id]) { + var ob = map[item.prom_id]; + //-- 避免同一件商品重复添加 -- + if (ob.goods && ob.goods.length) { + var fid = ob.goods.findIndex(function (e) { + e.goods_id == item.goods_id + }) + if (fid > -1) continue; + } + ob.price += item.goods_price * item.goods_num; + ob.goods_num += item.goods_num; + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); + } else { + var prom = null; + await getApp().request.promiseGet("/api/weshop/promgoods/get/" + os.stoid + "/" + item.prom_id, {}).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + } + }) + + var ob = {}; + ob.is_bz = prom.is_bz; + ob.prom_id=item.prom_id; + ob.price = item.goods_price * item.goods_num; + ob.goods_num = item.goods_num; + ob.goods = new Array(); + ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); + map[item.prom_id] = ob; + } + } + + var res=null; + for (const mapKey in map) { + var item_map=map[mapKey]; + //开始判断能不能参与优惠 + res=await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { + data: { + price: parseFloat(item_map.price).toFixed(2), prom_id: item_map.prom_id, + goods_num: item_map.goods_num, user_id: getApp().globalData.user_id, + is_bz: item_map.is_bz + } + }) + if (res.data.code == 0 && res.data.data.condition) { + + for (let i = 0; i < i_arr.length; i++) { + var item_g = i_arr[i]; + if (item_g.is_gift) continue; + + //-- 避免同一件商品重复添加 -- + if (item_map.goods && item_map.goods.length) { + var fid = item_map.goods.findIndex(function (e) { + e.goods_id == item_g.goods_id + }) + if (fid > -1) continue; + } + //判断商品是可以参与优惠促销的 + i_arr[i].can_yh=1; + } + + } + + } + + + } diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 0a5aa9d..ccf0ccb 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -7786,88 +7786,47 @@ Page({ if(th.data.user_pre_buynum >= fir_act.limit_num){ is_yh_out_limit=1; } - } - // var more_arr = []; - // //减价 - // if (fir_act.money > 0){ - // - // more_arr.push({ - // text:'减价' + fir_act.money + '元', - // is_fir:1 - // }); - // } - // if (fir_act.sale > 0) { - // more_arr.push({ - // text:'打' + fir_act.sale + '折', - // is_fir:1 - // }); - // } - // if (fir_act.past == 1) { - // more_arr.push({ - // text:'包邮', - // is_fir:1 - // }); - // } - // if (fir_act.intValue > 0){ - // more_arr.push({ - // text:'送' + fir_act.intValue + '积分', - // is_fir:1 - // }); - // } - // if (fir_act.couponId > 0) { - // more_arr.push({ - // text:'送' + fir_act.couponMoney + '元优惠券', - // is_quan:1 - // }); - // } - // - // if (fir_act.gift_id) { - // var is_more_gf = fir_act.gift_id.split(',') - // if (is_more_gf.length > 1) { - // more_arr.push({ - // text:'送赠品', - // is_gift:1, - // prom_id:fir_act.prom_id - // }); - // } else { - // more_arr.push({ - // text:'送' + fir_act.goods_name + ' x' + fir_act.zp_num, - // is_gift:1, - // prom_id:fir_act.prom_id - // }); - // } - // } - // if (fir_act.lb_id){ - // more_arr.push({ - // text:'送' + fir_act.lbtitle, - // lb_id:fir_act.lb_id - // }); - // } - // if (fir_act.zxlb_id){ - // more_arr.push({ - // text:'送' + fir_act.zxlbtitle, - // zxlb_id:fir_act.zxlb_id - // }); - // } - // if (fir_act.monthgiftbag_id){ - // more_arr.push({ - // text:'送' + fir_act.monthgiftbag_title, - // monthgiftbag_id:fir_act.monthgiftbag_id - // }); - // } - var more_arr=ut.format_yh_act(fir_act); - //-- 开始组装数据 -- - th.add_cx_prom_group({ - id: fir_act.prom_id, - condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), - limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'), - more: more_arr, + + //如果是有限购的时候 + if (fir_act.gd_limit_num>0 && !is_yh_out_limit){ + var lrs= { + store_id: os.stoid, + user_id: user_id, + goods_id: gid, prom_type: 3, - promGoodsListsDtos:r_data.promGoodsLists, - is_yh_out_limit:is_yh_out_limit - }); - //} + prom_id: fir_act.prom_id, isnew:1 + }; + var gd_limit_rs=await getApp().promiseGet('/api/weshop/ordergoods/getUserBuyGoodsNum',{data:lrs}); + var pro_by_num=0; + if(gd_limit_rs && gd_limit_rs.data.code==0){ + pro_by_num=gd_limit_rs.data.data.promgoodsbuynum + } + if(pro_by_num >= fir_act.gd_limit_num){ + is_yh_out_limit=1; + } + } + //-- 如果超出限购,就不显示了 -- + if(!is_yh_out_limit) { + var more_arr = ut.format_yh_act(fir_act); + + var limit='每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'); + if(fir_act.gd_limit_num>0){ + limit+=",限购"+fir_act.gd_limit_num+"件"; + } + + //-- 开始组装数据 -- + th.add_cx_prom_group({ + id: fir_act.prom_id, + condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), + limit: limit, + gd_limit_num:fir_act.gd_limit_num>0?fir_act.gd_limit_num:0, + more: more_arr, + prom_type: 3, + promGoodsListsDtos: r_data.promGoodsLists, + is_yh_out_limit: is_yh_out_limit + }); + } } diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml index 15aa246..78cc564 100644 --- a/pages/index/index/index.wxml +++ b/pages/index/index/index.wxml @@ -484,9 +484,12 @@ - + + + + @@ -530,6 +533,10 @@ + + + + diff --git a/pages/template/index.json b/pages/template/index.json index 42bc7a2..10882a3 100644 --- a/pages/template/index.json +++ b/pages/template/index.json @@ -11,6 +11,7 @@ "searchbox":"/components/diy_searchbox/diy_searchbox", "shopname": "/components/diy_shopname/diy_shopname", "pingd_buy": "/components/diy_pingd_buy/diy_pingd_buy", + "luckyGo": "/components/diy_luckyGo/diy_luckyGo", "diy_public": "/components/diy_public/diy_public", "title": "/components/diy_title/diy_title", "notice": "/components/diy_notice/diy_notice", diff --git a/pages/template/index.wxml b/pages/template/index.wxml index 4071247..7be1c03 100644 --- a/pages/template/index.wxml +++ b/pages/template/index.wxml @@ -41,9 +41,12 @@ - + + + + @@ -79,6 +82,15 @@ + + + + + + + + + diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js index ea0302f..cff2a9e 100644 --- a/pages/user/order_detail/order_detail.js +++ b/pages/user/order_detail/order_detail.js @@ -465,7 +465,7 @@ Page({ } //-- 要进行判断指定门店的判断优化,先做普通商品 -- - if([0,3,5,7,10].indexOf(parseInt(good.prom_type))>-1 && gg.pick_group_ids){ + if([0,3,5,7,10].indexOf(parseInt(good.prom_type))>-1 && gg.pick_group_ids && !good.is_gift){ var idx0=gg.pick_up_lists.findIndex(function (e){ return e.pickup_id==order.pickup_id; }) @@ -607,6 +607,13 @@ Page({ } }) + if(!presellList || !presellList.length){ + var content = good.goods_name + '未找到预售活动,请取消订单'; + th.toast(content); + th.setData({ paying: 0 }); + return false; + } + if (presellList) { if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { var content = good.goods_name + '购买数量超出商品库存,请取消订单'; @@ -622,6 +629,28 @@ Page({ return false; } + var fres=await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell_id, {}); + //接口调用成功的时候 + if(fres && fres.data.code==0 && fres.data.data){ + //如果有指定门店的时候 + if(fres.data.data.pick_up_lists){ + var idx0=fres.data.data.pick_up_lists.findIndex(function (e){ + return e.pickup_id==order.pickup_id; + }) + if(idx0<0){ + getApp().confirmBox(good.goods_name+"预售活动的门店不可售"); + th.setData({ paying: 0 }); + return false; + } + } + + }else{ + var content = good.goods_name + '未找到预售活动,请取消订单'; + th.toast(content); + th.setData({ paying: 0 }); + return false; + } + } } @@ -641,7 +670,19 @@ Page({ var content = good.goods_name + '未找到活动,请取消订单重新购买'; th.toast(content); p_ok = 0; + }else if(r_data.promGoodsLists && good.prom_type == 3){ + var fir_act = r_data.promGoodsLists[0]; + //如果是有限购的时候 + if (fir_act.gd_limit_num>0){ + if(promgoodsbuynum+good.goods_num > fir_act.gd_limit_num){ + var content = good.goods_name + '超出优惠促销活动商品限购,请取消订单重新购买'; + th.toast(content) + p_ok = 0; + } + } + } + if (!r_data.ladderLists && good.prom_type == 10) { var content = good.goods_name + '未找到活动,请取消订单重新购买'; th.toast(content); diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index 4a9c977..4df4dac 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -780,7 +780,7 @@ Page({ //-- 要进行判断指定门店的判断优化,先做普通商品 -- - if([0,3,5,7,10].indexOf(parseInt(good.prom_type))>-1 && gg.pick_group_ids){ + if([0,3,5,7,10].indexOf(parseInt(good.prom_type))>-1 && gg.pick_group_ids && !good.is_gift){ var idx0=gg.pick_up_lists.findIndex(function (e){ return e.pickup_id==order.pickup_id; }) @@ -922,10 +922,15 @@ Page({ } }) - - if (presellList) { + if(!presellList || !presellList.length){ + var content = good.goods_name + '未找到预售活动,请取消订单'; + th.toast(content); + th.setData({ paying: 0 }); + return false; + } + if (presellList) { if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { var content = good.goods_name + '购买数量超出商品库存,请取消订单'; th.toast(content); @@ -940,6 +945,28 @@ Page({ return false; } + var fres=await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell_id, {}); + //接口调用成功的时候 + if(fres && fres.data.code==0 && fres.data.data){ + + //如果有指定门店的时候 + if(fres.data.data.pick_up_lists){ + var idx0=fres.data.data.pick_up_lists.findIndex(function (e){ + return e.pickup_id==order.pickup_id; + }) + if(idx0<0){ + getApp().confirmBox(good.goods_name+"预售活动的门店不可售"); + th.setData({ paying: 0 }); + return false; + } + } + + }else{ + var content = good.goods_name + '未找到预售活动,请取消订单'; + th.toast(content); + th.setData({ paying: 0 }); + return false; + } } } @@ -955,16 +982,32 @@ Page({ th.toast(content) p_ok = 0; } + if (!r_data.promGoodsLists && good.prom_type == 3) { var content = good.goods_name + '未找到活动,请取消订单重新购买'; th.toast(content); p_ok = 0; + }else if(r_data.promGoodsLists && good.prom_type == 3){ + var fir_act = r_data.promGoodsLists[0]; + //如果是有限购的时候 + if (fir_act.gd_limit_num>0){ + if(promgoodsbuynum+good.goods_num > fir_act.gd_limit_num){ + var content = good.goods_name + '超出优惠促销活动商品限购,请取消订单重新购买'; + th.toast(content) + p_ok = 0; + } + } + } + if (!r_data.ladderLists && good.prom_type == 10) { var content = good.goods_name + '未找到活动,请取消订单重新购买'; th.toast(content); p_ok = 0; } + + + } else { var content = good.goods_name + '未找到活动,请取消订单重新购买'