diff --git a/app.js b/app.js index 638efc4..3ba33ea 100644 --- a/app.js +++ b/app.js @@ -50,7 +50,7 @@ App({ config: null, //门店参数 config2: null, //门店配置 code: null, - user_id:null,//3277,// 6519901,//6453964,// 4687,// 6519870,//5682094, + user_id:null,// 6519870,//5682094, buy_now:null, picklist:null, //门店列表 wuliuprice: null, //物流价格表 @@ -661,8 +661,10 @@ App({ this.globalData.config=null; //清除config的缓存 this.globalData.gr_index=0; //商品分组的序列 this.globalData.pk_store=null; - this.globalData.wxapp_buy_obj=null - + this.globalData.wxapp_buy_obj=null; + this.globalData.dis_buy_obj=null; //等级卡的购买记录 + this.globalData.storeFooter=null; //底部的导航 + this.globalData.full_screen=null; //全屏 }, clear_word:function (word) { diff --git a/components/diy_goodsGroup/diy_goodsGroup.js b/components/diy_goodsGroup/diy_goodsGroup.js index ebfd0dd..4bee7f0 100644 --- a/components/diy_goodsGroup/diy_goodsGroup.js +++ b/components/diy_goodsGroup/diy_goodsGroup.js @@ -432,7 +432,9 @@ Component({ set_good:async function(goods){ var now=ut.gettimestamp(); var th=this; - if(!goods || goods.length==0) return false; + if(!goods || goods.length==0) return false; + var user_id=getApp().globalData.userInfo.user_id; + if(!user_id) user_id=0; for(var i in goods){ var val=goods[i]; var item = {}; @@ -441,7 +443,7 @@ Component({ var url="/api/weshop/activitylist/getGoodActInfo"; var req_data={ - store_id:os.stoid,goodsidlist:val.goods_id,is_detail:1 + store_id:os.stoid,goodsidlist:val.goods_id,is_detail:1,user_id:user_id }; //获取商品的实际活动 diff --git a/components/diy_goodsGroup/diy_goodsGroup.wxml b/components/diy_goodsGroup/diy_goodsGroup.wxml index 913c444..34e1241 100644 --- a/components/diy_goodsGroup/diy_goodsGroup.wxml +++ b/components/diy_goodsGroup/diy_goodsGroup.wxml @@ -669,7 +669,7 @@ - + diff --git a/components/diy_pingd_buy/diy_pingd_buy.js b/components/diy_pingd_buy/diy_pingd_buy.js index 72ad1e6..be709c4 100644 --- a/components/diy_pingd_buy/diy_pingd_buy.js +++ b/components/diy_pingd_buy/diy_pingd_buy.js @@ -47,7 +47,12 @@ Component({ th.countDown2(th); }, 1000); } - } + }, + + hide:function () { + // 页面被被销毁的时候,清除定时器 + clearInterval(this.data.timer); + } }, diff --git a/components/diy_seckill/diy_seckill.js b/components/diy_seckill/diy_seckill.js index e1bdff7..fdd208d 100644 --- a/components/diy_seckill/diy_seckill.js +++ b/components/diy_seckill/diy_seckill.js @@ -35,6 +35,7 @@ Component({ ylp_img: "https://mshopimg.yolipai.net/", imghost: os.imghost, timer: null, + user_id:0 }, pageLifetimes: { @@ -43,7 +44,12 @@ Component({ //会员身份变化 var th = this; var g_id = this.data.object; - this.init(g_id); + //只有再会员登陆之后,才重新调用接口 + + if(this.data.user_id!=getApp().globalData.user_id){ + this.data.user_id=getApp().globalData.user_id + this.init(g_id); + } setTimeout(function () { if (th.data.goods_array && th.data.goods_array.length > 0) { th.data.timer = setInterval(function () { @@ -51,12 +57,18 @@ Component({ }, 1000); } },600) + }, + + hide:function () { + // 页面被被销毁的时候,清除定时器 + clearInterval(this.data.timer); } }, ready: function () { var g_id = this.data.object; this.init(g_id); + this.data.user_id=getApp().globalData.user_id; }, detached() { // 页面被被销毁的时候,清除定时器 diff --git a/components/goods_list/goods_list.js b/components/goods_list/goods_list.js index 8b1ccfc..5c9ce87 100644 --- a/components/goods_list/goods_list.js +++ b/components/goods_list/goods_list.js @@ -207,5 +207,11 @@ Component({ func(ob); }) }, + + go_url:function (e) { + var url=e.currentTarget.dataset.url; + getApp().goto(url); + } + }, }) \ No newline at end of file diff --git a/components/goods_list/goods_list.wxml b/components/goods_list/goods_list.wxml index 3be78b8..7675f86 100644 --- a/components/goods_list/goods_list.wxml +++ b/components/goods_list/goods_list.wxml @@ -5,17 +5,17 @@ - + - + {{item.goods_name}} - + {{item.prom_integral}}积分 diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index 2cf2e5b..e229a34 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -9,33 +9,43 @@ Component({ list:app.def_list, cartGoodsNum:0, }, - lifetimes: { attached: function() { var th=this; - getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{ var dis=rs.data.data; if( dis && dis.switch==0){ th.setData({is_no_distri:1}) } - }) - - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{ - if(res.data.code==0){ - var arr = res.data.data.pageData; - if (arr.length > 0) { - var item=arr[0]; - if(item.is_sy==0){ - var now = Date.parse(new Date());now = now / 1000; - if(item.end_time 0) { + var item=arr[0]; + if(item.is_sy==0){ + var now = Date.parse(new Date());now = now / 1000; + if(item.end_time{ + if(res.data.code==0){ + var arr = res.data.data.pageData; + getApp().globalData.dis_buy_obj=arr; + if (arr.length > 0) { + var item=arr[0]; + if(item.is_sy==0){ + var now = Date.parse(new Date());now = now / 1000; + if(item.end_time { - getApp().globalData.is_read=true; - var e = res; - if(e.data.code != -1 && e.data.data && e.data.data.data){ - var itemList = e.data.data.data; - itemList = JSON.parse(itemList) - //如果是有定义自定义导航的小程序链接 - if(itemList[0].weappurl && itemList[0].weappurl!=""){ - getApp().globalData.custum_data=e.data.data; - var custum_data=e.data.data; - th.set_list(custum_data); - } - - } - - }) + + //全局缓存 + if(getApp().globalData.storeFooter) { + var itemList = getApp().globalData.storeFooter; + itemList = JSON.parse(itemList) + //-- 如果是有定义自定义导航的小程序链接 -- + if (itemList[0].weappurl && itemList[0].weappurl != "") { + getApp().globalData.custum_data = e.data.data; + var custum_data = e.data.data; + th.set_list(custum_data); + } + + }else{ + var stoid = os.stoid; + getApp().request.promiseGet("/api/weshop/storeFooter/get/" + stoid, {}).then(res => { + getApp().globalData.is_read = true; + var e = res; + if (e.data.code != -1 && e.data.data && e.data.data.data) { + var itemList = e.data.data.data; + getApp().globalData.storeFooter=itemList; + itemList = JSON.parse(itemList) + //-- 如果是有定义自定义导航的小程序链接 -- + if (itemList[0].weappurl && itemList[0].weappurl != "") { + getApp().globalData.custum_data = e.data.data; + var custum_data = e.data.data; + th.set_list(custum_data); + } + } + + }) + } } }, }, diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index d92a8ec..379e3f8 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -333,7 +333,7 @@ Page({ getApp().request.promiseGet("/api/weshop/pickup/list",{ data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon, is_pos: 1}, }).then(res=>{ - if(res.data.code==0){ + if(ut.ajax_ok(res)){ e=res.data.data.pageData[0]; if (e){ e.is_no_dis=ee.is_no_dis; diff --git a/packageA/pages/my_service/appment_main.js b/packageA/pages/my_service/appment_main.js index f2795f4..977611f 100644 --- a/packageA/pages/my_service/appment_main.js +++ b/packageA/pages/my_service/appment_main.js @@ -697,7 +697,7 @@ Page({ } }).then(res => { //-- 如果是门店的话 -- - if (res.data.code == 0 && res.data.data && res.data.data.pageData) { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) { var store_data=null; for(var i in res.data.data.pageData){ var it=res.data.data.pageData[i]; diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index 19609b7..3878500 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -1246,13 +1246,15 @@ Page({ getApp().request.promiseGet("/api/weshop/pickup/list", { data: dd, }).then(res => { - var top_store=res.data.data.pageData[0]; - th.setData({ - stoname: top_store.pickup_name, - sto_sele_name: top_store.pickup_name, - sto_sele_id: top_store.pickup_id, - sto_sele_distr: top_store.distr_type, - }) + if(ut.ajax_ok(res)){ + var top_store=res.data.data.pageData[0]; + th.setData({ + stoname: top_store.pickup_name, + sto_sele_name: top_store.pickup_name, + sto_sele_id: top_store.pickup_id, + sto_sele_distr: top_store.distr_type, + }) + } }) }else{ diff --git a/packageA/pages/prom_list/prom_list.js b/packageA/pages/prom_list/prom_list.js index f4349c0..546becc 100644 --- a/packageA/pages/prom_list/prom_list.js +++ b/packageA/pages/prom_list/prom_list.js @@ -120,7 +120,7 @@ Page({ getApp().request.promiseGet("/api/weshop/pickup/list",{ data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon,is_pos: 1}, }).then(res=>{ - if(res.data.code==0 && res.data.data && res.data.data.pageData){ + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ e=res.data.data.pageData[0]; if (e){ appd.pk_store=e; @@ -1030,7 +1030,7 @@ Page({ }) }).then(res=>{ if(res.data.code==0){ - if(res.data.data.pageData){ + if(res.data.data.pageData && res.data.data.pageData.length){ var plist=res.data.data.pageData; var def_pick_store=th.data.def_pick_store; //以原来的数组为外循环,保证距离的顺序 diff --git a/packageB/pages/user/add_comment/add_comment.js b/packageB/pages/user/add_comment/add_comment.js index 859847a..13d5b01 100644 --- a/packageB/pages/user/add_comment/add_comment.js +++ b/packageB/pages/user/add_comment/add_comment.js @@ -1,4 +1,4 @@ -var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../../utils/util.js"), +var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../../utils/util.js"),ut=s, i = require("../../../../utils/selectFiles.js"); var regeneratorRuntime = require('../../../../utils/runtime.js'); @@ -27,9 +27,11 @@ Page({ var th = this; await getApp().request.promiseGet("/api/weshop/ordergoods/pageGoods", { data:{store_id:os.stoid,goods_id:a.goods_id, order_id:a.order_id}}).then(res => { - a.img = th.data.iurl + res.data.data.pageData[0].original_img; - a.goods_name=res.data.data.pageData[0].goods_name; - a.goods_num=res.data.data.pageData[0].goods_num; + if(ut.ajax_ok(res)) { + a.img = th.data.iurl + res.data.data.pageData[0].original_img; + a.goods_name = res.data.data.pageData[0].goods_name; + a.goods_num = res.data.data.pageData[0].goods_num; + } }) this.setData({ options: a }); t.getUserInfo(function (e) { diff --git a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js index f568ee8..79d7362 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -1042,7 +1042,7 @@ Page({ th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price > freight_free) { + if (freight_free > 0 && o_price >= freight_free) { return 0; } if (user_addr == null) { diff --git a/packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js b/packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js index d6c761b..84762b1 100644 --- a/packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js +++ b/packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js @@ -531,6 +531,7 @@ Page({ check_more_order:async function(item){ var pickup=null,th=this; var user_id=getApp().globalData.userInfo.user_id; + if(!user_id) user_id=0; wx.showLoading(); //--------获取门店----------- await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + item.pickup_id, { @@ -617,7 +618,7 @@ Page({ var url="/api/weshop/activitylist/getGoodActInfo"; var req_data={ - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1 + store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id }; await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ if(res.data.code==0){ diff --git a/packageC/pages/presell/cart/cart2_pre.js b/packageC/pages/presell/cart/cart2_pre.js index ec01b55..39a3410 100644 --- a/packageC/pages/presell/cart/cart2_pre.js +++ b/packageC/pages/presell/cart/cart2_pre.js @@ -706,7 +706,7 @@ Page({ var price =0,th=this; price +=parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price > freight_free){ return 0;} + if (freight_free > 0 && o_price >= freight_free){ return 0;} if (user_addr==null) { return 0; } //计算物流的config item; var item=null; diff --git a/pages/activity/pind_list/pind_list.js b/pages/activity/pind_list/pind_list.js index c12e46f..254970d 100644 --- a/pages/activity/pind_list/pind_list.js +++ b/pages/activity/pind_list/pind_list.js @@ -129,12 +129,13 @@ Page({ await getApp().request.promiseGet(i, {isShowLoading:1,data:{store_id:os.stoid,is_end:0,is_show:1}} ).then(res=>{ - plist=res.data.data.pageData; + if(ut.ajax_ok(res)) plist=res.data.data.pageData; }); - if(plist.length<=0){ + if(!plist || plist.length<=0){ getApp().showWarning("没有更多数据"); th.data.ismore=0; + return false; } //--循环读取接口--- for(var i=0;i{ - plist=res.data.data.pageData; - console.log("是什么即将开始",plist); + if(ut.ajax_ok(res)) plist=res.data.data.pageData; + }); if(plist.length<=0){ diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index c8695bf..b847d39 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -5,8 +5,9 @@ var t = getApp(), app = getApp(), rq = t.request, ut = require("../../../utils/util.js"), - zh_calc = require("zh_calculate.js"); - var regeneratorRuntime = require('../../../utils/runtime.js'); + zh_calc = require("zh_calculate.js"), + ladder_calc = require("ladder_calculate.js"); + var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ data: { @@ -38,6 +39,8 @@ Page({ zuhe_map:{}, zuhe_map_good:{}, in_zhact_gdmap:{}, //不同门店参与同一活动的限购 + + ladder_map:{}, //阶梯促销需要的map }, onLoad: function() { var a = this,ee=a; @@ -83,7 +86,6 @@ Page({ th.setData({ bconfig: e,sales_rules:e.sales_rules }); - getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{ //未购买 if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){ @@ -210,6 +212,8 @@ Page({ get_cart: function() { var th = this; th.data.in_zhact_gdmap={}; + th.data.ladder_map={}; + var rd = Math.random().toString(36).substr(2, 15); var user_id=getApp().globalData.userInfo.user_id; getApp().request.get("/api/weshop/cart/list", { @@ -223,8 +227,7 @@ Page({ success:async function(su) { console.log(su,10000); //按门店分类的数组 - var arr = new Array(), - carr = su.data.data.pageData; + var arr = new Array(), carr = su.data.data.pageData; var all_num = 0; if(carr && carr.length>0) { @@ -353,21 +356,22 @@ Page({ }) } } - - //--判断优惠活动有没有过期-- + //--判断优惠活动有没有过期,-- else if (item.prom_type == 3) { var isok = 1,is_g_prom=0; + //因为有全场优惠活动,商品参加的活动还未开始 var url="/api/weshop/activitylist/getGoodActInfo"; var req_data={ - store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id + store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id }; await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) { if(res.data.code==0 && res.data.data && res.data.data.length){ for(let i in res.data.data){ - let item=res.data.data[i]; - if(item.prom_type==3) { - is_g_prom=1; break; + let item=res.data.data[i]; + if(item.prom_type==3) { + is_g_prom=1; break; + } } } @@ -430,6 +434,7 @@ Page({ } if (!isok) continue; + } else if (item.prom_type == 7) { if(!th.data.zuhe_map[item.prom_id]){ @@ -517,6 +522,68 @@ Page({ // continue; // } } + else if (item.prom_type == 10) { + if(!th.data.ladder_map[item.prom_id]){ + //如果有组合购 + var isok = 1; + var is_flag=1; + var act=null; + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id; + await getApp().request.promiseGet(url, {}).then(res => { + console.log(res,1000); + if(res.data.code==0 && res.data.data){ + if(res.data.data.isuse!=1){ + isok=0; + } + //如果活动已经结束 + if(res.data.data.is_end==1){ + isok=0; + } + //已经结束 + if(ut.gettimestamp()>res.data.data.end_time){ + isok=0; + } + //还未开始 + if(ut.gettimestamp() { + if (rs1.data.code==0 && rs1.data.data) { + var gdlist = rs1.data.data; + th.data.ladder_map[item.prom_id].ladder_list=gdlist; + } + }) + } + //直接把活动赋值给元素 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){ + item.act=th.data.ladder_map[item.prom_id]; + } + + } + else if(item.prom_type == 0) { //如果有优惠活动,要更新活动 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => { @@ -529,9 +596,86 @@ Page({ }); item.prom_type=3; item.prom_id=r_data.promGoodsLists[0].prom_id; + }else if(r_data.ladderLists){ + + item.prom_type=10; + item.prom_id=r_data.ladderLists[0].form_id; + } } }) + + //如果是阶梯购的时候 + if(item.prom_type==10){ + + + if(!th.data.ladder_map[item.prom_id]){ + //如果有阶梯购,要判断身份 + var isok = 1; + var is_flag=1; + var act=null; + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id; + await getApp().request.promiseGet(url, {}).then(res => { + console.log(res,1000); + if(res.data.code==0 && res.data.data){ + if(res.data.data.isuse!=1){ + isok=0; + } + //如果活动已经结束 + if(res.data.data.is_end==1){ + isok=0; + } + //已经结束 + if(ut.gettimestamp()>res.data.data.end_time){ + isok=0; + } + //还未开始 + if(ut.gettimestamp() { + if (rs1.data.code==0 && rs1.data.data) { + var gdlist = rs1.data.data; + th.data.ladder_map[item.prom_id].ladder_list=gdlist; + } + }) + } + + } + //直接把活动赋值给元素 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){ + item.act=th.data.ladder_map[item.prom_id]; + + //如果有活动,就更新商品的活动那个 + var url = '/api/weshop/cart/update'; + getApp().request.put(url, { + data:{id:item.id,store_id:oo.stoid,prom_type:10,prom_id:item.prom_id} + }); + + } + } + } all_num += item.goods_num; @@ -622,9 +766,6 @@ Page({ } } - // console.log('AAAAAAAAAAAA', all_num); - // getApp().globalData.cartGoodsNum = all_num; - th.setData({ requestData: arr, all_num: all_num, @@ -995,11 +1136,13 @@ Page({ if(item[j].is_gift) continue; var obj=JSON.parse(JSON.stringify(item[j])); - //计算之前先移除 + //计算之前先移除组合购的计算 if(obj.prom_type==7) zh_calc.remove_zhprom(dda,i,obj); - - + //计算之前先移除阶梯购的计算 + if(obj.prom_type==10) + ladder_calc.remove_ladder_prom(dda,i,obj); + if (fir == 0) { fir = item[j].distr_type; } else { @@ -1012,8 +1155,12 @@ Page({ var txt = "requestData[" + i + "].goods[" + j + "].selected"; if(e.data.checkAllToggle) obj.goods_num=0; - if(obj.prom_type==7) - zh_calc.add_zhprom(dda,i,obj); + + //加入组合购计算 + if(obj.prom_type==7) zh_calc.add_zhprom(dda,i,obj); + //加入阶梯促销计算 + if(obj.prom_type==10) ladder_calc.add_ladder_prom(dda,i,obj); + e.setData({ [txt]: !e.data.checkAllToggle, @@ -1021,7 +1168,7 @@ Page({ if (!e.data.checkAllToggle) { //组合购的金额要另外算 - if(item[j].prom_type!=7) + if(item[j].prom_type!=7 && item[j].prom_type!=10) tfeel += item[j].goods_num * item[j].goods_price; t_num += item[j].goods_num; } @@ -1059,6 +1206,12 @@ Page({ offline_price+=zh_calc_res.offline_price; offline_num+=zh_calc_res.offline_num; + //总的价格,把阶梯促销的商品的价格拿出来 + var ladder_calc_res=ladder_calc.calculate_ladder(dda,i,this); + tfeel+=ladder_calc_res.tfeel; + offline_price+=ladder_calc_res.offline_price; + offline_num+=ladder_calc_res.offline_num; + //当有线下取价的时候 if(offline_price){ var txt1= "requestData[" + i + "].offline_price"; @@ -1363,8 +1516,7 @@ Page({ if(car && car.length>0){ th.data.in_zhact_gdmap={}; for (var a = 0; a < car.length; a++) { - var item = car[a].goods, - is_s_sele = 1; + var item = car[a].goods,is_s_sele = 1; var offline_price=0; var offline_num=0; for (var c = 0; c < item.length; c++) { @@ -1373,7 +1525,10 @@ Page({ //不管怎么样都要移出去 var obj=JSON.parse(JSON.stringify(item[c])); + zh_calc.remove_zhprom(car,a,obj); + ladder_calc.remove_ladder_prom(car,a,obj); + if (item[c].selected == 0) { ischeck = 0; is_s_sele = 0; @@ -1381,11 +1536,20 @@ Page({ obj.goods_num=0; zh_calc.add_zhprom(car,a,obj); } + if(item[c].prom_type==10) { + obj.goods_num=0; + ladder_calc.add_ladder_prom(car,a,obj); + } + + } else { if(item[c].prom_type==7){ - //先把商品放入组合计算的专用的区域 - zh_calc.add_zhprom(car,a,obj); - }else{ + //先把商品放入组合计算的专用的区域 + zh_calc.add_zhprom(car,a,obj); + }else if(item[c].prom_type==10){ + ladder_calc.add_ladder_prom(car,a,obj); + } + else{ tfeel += item[c].goods_num * item[c].goods_price; } t_num += item[c].goods_num; @@ -1400,10 +1564,17 @@ Page({ //总的价格,把组合商品的价格拿出来 var zh_calc_res=zh_calc.calculate_zh(car,a,th); + //总的价格,把阶梯促销商品的价格拿出来 + var ladder_calc_res=ladder_calc.calculate_ladder(car,a,th); + tfeel+=zh_calc_res.tfeel; offline_price+=zh_calc_res.offline_price; offline_num+=zh_calc_res.offline_num; + tfeel+=ladder_calc_res.tfeel; + offline_price+=ladder_calc_res.offline_price; + offline_num+=ladder_calc_res.offline_num; + var txt = "requestData[" + a + "].selected"; th.setData({ [txt]: Number(is_s_sele) @@ -1456,9 +1627,6 @@ Page({ }); } } - - // getApp().globalData.cartGoodsNum = all_num; - // console.log('CCCCCCC', all_num, getApp().globalData.cartGoodsNum); this.setData({ checkAllToggle: ischeck, @@ -1494,6 +1662,8 @@ Page({ // console.log('update'); // console.log('9995959595959',t); + var e = this,th=e; + var user_id = getApp().globalData.user_id; rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, { isShowLoading: 0, async success(d) { @@ -1523,8 +1693,10 @@ Page({ } goodsbuynum = buy_num_data.goodsbuynum; + }) + var buyed_mum2 = t.goods_num + goodsbuynum; if (buyed_mum2 > limit && limit > 0) { wx.showModal({ @@ -1778,7 +1950,7 @@ Page({ await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid} }).then(res=>{ - if(res.data.code==0){ + if(ut.ajax_ok(res)){ plist=res.data.data.pageData[0]; } }) @@ -2075,7 +2247,7 @@ Page({ //如果会员是等级会员,商品有等级价,且不是活动商品 if (card_field && val[card_field] > 0 && - ((val.prom_type == 0 && g_arr[i].prom_type==0) || val.prom_type == 3 || val.prom_type == 4 || val.prom_type == 5 || val.prom_type == 7 || normal_arr[val.goods_id])) { + ((val.prom_type == 0 && g_arr[i].prom_type==0) || val.prom_type == 3 || val.prom_type == 4 || val.prom_type == 5 || val.prom_type == 7 || val.prom_type == 10 || normal_arr[val.goods_id])) { if (g_arr[i].goods_price != val[card_field]) { isok = 0; gname = val.goods_name; @@ -2514,17 +2686,30 @@ Page({ //跳转到商品 go_gd:function (e) { + var user_id=getApp().globalData.user_id; + if(!user_id) user_id=0; var gd= e.currentTarget.dataset.gd; var good_url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd; var url="/api/weshop/activitylist/getGoodActInfo"; var req_data={ - store_id:os.stoid,goodsidlist:gd,is_detail:1 + store_id:os.stoid,goodsidlist:gd,is_detail:1,user_id:user_id }; //获取秒杀的多规格 getApp().request.promiseGet(url, {data:req_data}).then(res=>{ if(res.data.code==0 && res.data.data){ if(res.data.data.length==1){ - good_url+="&prom_type="+res.data.data[0].prom_type+"&prom_id="+res.data.data[0].act_id; + var item=res.data.data[0]; + switch (item.prom_type){ + case 9: + good_url= '/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + gd + '&group_id=' + item.prom_id; + break; + case 8: + good_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+gd+"&prom_id="+item.prom_id + break; + default: + good_url="/pages/goods/goodsInfo/goodsInfo?goods_id="+gd+"&prom_id="+item.prom_id+"&prom_type=1"; + break + } } getApp().goto(good_url); diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index bbd4c83..8329100 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -164,6 +164,15 @@ + + + + + {{item.title}} + 去凑单 + + + diff --git a/pages/cart/cart/ladder_calculate.js b/pages/cart/cart/ladder_calculate.js new file mode 100644 index 0000000..c08e8f0 --- /dev/null +++ b/pages/cart/cart/ladder_calculate.js @@ -0,0 +1,212 @@ +module.exports = { + //辅助数组添加元素功能 + find_in_add: function(list, ele) { + var idx=list.findIndex(function (e) { + return e.goods_id==ele.goods_id; + }) + if(idx>-1) return false; + list.push(ele); + }, + //辅助数组添加元素功能 + find_in_remove: function(list, ele) { + var idx=list.findIndex(function (e) { + return e.goods_id==ele.goods_id; + }) + if(idx==-1) return false; + list.splice(idx, 1); + }, + + //主要是把组合购的商品分离出来 + add_ladder_prom: function(car, a, ele) { + var point = car[a]; + if (point.ladder_map) { + if (point.ladder_map[ele.prom_id]) { + this.find_in_add(point.ladder_map[ele.prom_id].goods, ele); + } else { + point.ladder_map[ele.prom_id] = { + goods: [], + act: ele.act + }; + point.ladder_map[ele.prom_id].goods.push(ele); + } + } else { + point.ladder_map = {}; + point.ladder_map[ele.prom_id] = { + goods: [], + act: ele.act + }; + point.ladder_map[ele.prom_id].goods.push(ele); + } + }, + //未选中的商品,要从中剔除 + remove_ladder_prom: function(car, a, ele) { + var point = car[a]; + if (point.ladder_map) { + if (point.ladder_map[ele.prom_id]) { + this.find_in_remove(point.ladder_map[ele.prom_id].goods, ele); + } + } + }, + + //把组合购的商品价格计算出来,同时每个会员都有购买组合商品的上限!ladder_b_num是已经购买了多少件 + calculate_ladder: function(car, a, th) { + var car_item = car[a]; + var tfeel = 0,offline_price = 0,offline_num = 0; + var txt = "requestData[" + a + "].l_need_list"; + var need_to=[]; + + //活动的列表都存储在这里面,可以快速查询 + if (!car_item.ladder_map) { + var res = { + tfeel: tfeel, + offline_price: offline_price, + offline_num: offline_num + }; + th.setData({ + [txt]: null + }); + return res; + } + + //因为可能有多个组合购的活动 + for (var mi in car_item.ladder_map) { + var bitem = car_item.ladder_map[mi]; + var act = bitem.act; //获取到组合购的详情 + var all_num = 0; //商品数量之和 + var all_price = 0; + var aprice=0; + var no_in_arr = []; //剩余的未加入组合购 + + var title =""; //提示语; + var goods = car_item.goods; + + //-- 每件商品要剔除的量 -- + for (let v3 in car_item.goods) { + car_item.goods[v3].l_need_downlow_num=0; + } + + //寻找一下 + function get_num2(ite) { + var vh=car_item.goods.findIndex(function (e) { + return e.goods_id == ite.goods_id + }) + if(vh>-1) return car_item.goods[vh]; + return 0; + } + + for (var i in goods) { + if(goods[i].prom_type!=10) continue; + if(!goods[i].selected) continue; + if(goods[i].prom_id!=act.id) continue; + var item = goods[i]; + item.goods_price=item.goods_price; + item.offline_price=item.offline_price; + item.cart_num =item.goods_num; + all_num += item.cart_num; + for (var j = 0; j < item.cart_num; j++) { + no_in_arr.push({ + price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,shop_price:item.shop_price + }) + } + } + + function sortData(a, b) { + return a.price - b.price + } + no_in_arr.sort(sortData); + + //开始阶梯计算价格 + var lev=0; + for(let j in act.ladder_list){ + if(no_in_arr.length==0) break; + let item_j=act.ladder_list[j]; + var end=no_in_arr.pop(); + var new_price=parseInt(item_j.discount_field)==1?end.shop_price:end.price; + aprice+=new_price* parseFloat(item_j.discount)/10; + lev++; + } + + //获取阶梯促销的下一个促销 + if(lev>0 && lev { - if (res.data.code == 0 && res.data.data) { - //如果活动已经结束 - if (res.data.data.is_end == 1) { - isok = 0; - } - if (ut.gettimestamp() > res.data.data.end_time) { - isok = 0; + if(item1.prom_type == 7) { + if(!th.data.zuhe_map_good[item1.prom_id]) { + var isok = 1; + var is_flag = 1; + //如果有组合购 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id; + await getApp().request.promiseGet(url, {}).then(res => { + if (res.data.code == 0 && res.data.data) { + //如果活动已经结束 + if (res.data.data.is_end == 1) { + isok = 0; + } + if (ut.gettimestamp() > res.data.data.end_time) { + isok = 0; + } + item1.act = res.data.data; + th.data.zhhe_act_map[item1.prom_id] = res.data.data; + } else { + //未找到商品的活动 + is_flag = 0; } - item1.act = res.data.data; - } else { - //未找到商品的活动 - is_flag = 0; + }) + if (!isok) { + getApp().my_warnning("组合购的活动已经过期", 0, th); + return false; } - }) - if (!isok) { - getApp().my_warnning("组合购的活动已经过期", 0, th); - return false; + var url1 = "/api/weshop/prom/zhbuyGoods/page"; + var req_data = { + page: 1, + pageSize: 2000, + store_id: os.stoid, + zh_id: item1.prom_id, + } + await getApp().request.promiseGet(url1, { + data: req_data + }).then(res => { + if (ut.ajax_ok(res)) { + var gdlist = res.data.data.pageData; + gdlist.forEach(i => { + if (item1.goods_id == i.goods_id && !is_flag) { + item1.prom_type = 0; + item1.prom_type1 = 0; + item1.prom_id = 0; + item1.prom_id1 = 0 + } + }) + th.data.zuhe_map_good[item1.prom_id] = gdlist; + } + }) } - var url1 = "/api/weshop/prom/zhbuyGoods/page"; - var req_data = { - page: 1, - pageSize: 2000, - store_id: os.stoid, - zh_id: item1.prom_id, + else + { + item1.act = th.data.zhhe_act_map[item1.prom_id]; } - await getApp().request.promiseGet(url1, { - data: req_data - }).then(res => { - if (ut.ajax_ok(res)) { - var gdlist = res.data.data.pageData; - gdlist.forEach(i=>{ - if(item1.goods_id==i.goods_id&&!is_flag){ - item1.prom_type=0; - item1.prom_type1=0; - item1.prom_id=0; - item1.prom_id1=0 + } + if(item1.prom_type==10){ + if(!th.data.ladder_map[item1.prom_id]){ + //如果有组合购 + var isok = 1; + var is_flag=1; + var act=null; + var url="/api/weshop/prom/ladderForm/get/"+os.stoid+"/"+item1.prom_id; + await getApp().request.promiseGet(url, {}).then(res => { + console.log(res,1000); + if(res.data.code==0 && res.data.data){ + if(res.data.data.isuse!=1){ + isok=0; } - }) - th.data.zuhe_map_good[item1.prom_id]=gdlist; + //如果活动已经结束 + if(res.data.data.is_end==1){ + isok=0; + } + //已经结束 + if(ut.gettimestamp()>res.data.data.end_time){ + isok=0; + } + //还未开始 + if(ut.gettimestamp() { + if (rs1.data.code==0 && rs1.data.data) { + var gdlist = rs1.data.data; + th.data.ladder_map[item1.prom_id].ladder_list=gdlist; + } + }) + } } + } //在分组的时候,就不要再调用接口,await @@ -560,6 +637,7 @@ Page({ } arr[j].exp_type = e_t; if (e_t == 0) th.setData({is_all_zt: 0}); + else if(e_t==1) th.setData({is_all_zt: 1}); //} //-- 把等级卡会优惠多少钱装进去 -- @@ -688,31 +766,31 @@ Page({ //存储不同活动的商品列表 u_item.zh_prom_goods = {}; for (let var1 in obj) { - var h_item=obj[var1]; - var gdlist= th.data.zuhe_map_good[h_item.prom_id]; - //获取活动需要的商品列表 - // u_item.zh_prom_goods[h_item.prom_id]=gdlist; - // var h_item = obj[var1]; - // var gdlist = null; - // var url1 = "/api/weshop/prom/zhbuyGoods/page"; - // var req_data = { - // page: 1, - // pageSize: 2000, - // store_id: os.stoid, - // zh_id: h_item.prom_id, - // } - // await getApp().request.promiseGet(url1, { - // data: req_data - // }).then(res => { - // if (ut.ajax_ok(res)) { - // gdlist = res.data.data.pageData; - // } - // }) + var h_item = obj[var1]; + var gdlist = th.data.zuhe_map_good[h_item.prom_id]; //获取活动需要的商品列表 u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act}; } zh_calc.fir_set_arr(u_item, th); } + + //每一个门店内的阶梯促销要进行拆分, + //还得把阶梯促销商品的多余商品的线下价格算一算 + for (let var1 in arr) { + //把阶梯促销进行分组 + var obj = ladder_calc.find_split(u_item); + if (!obj) continue; + //存储不同阶梯促销活动的商品列表 + u_item.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; + } + ladder_calc.fir_set_arr(u_item, th); + } + //深拷贝 th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); th.setData({ @@ -806,8 +884,8 @@ Page({ } - gd.prom_type=gg.prom_type; - gd.prom_id=gg.prom_id; + gd.prom_type=gg.prom_type?gg.prom_type:0; + gd.prom_id=gg.prom_id?gg.prom_id:0; switch (gd.prom_type) { case 0: @@ -1270,6 +1348,7 @@ Page({ var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格 var all_cutprice = 0; //所有的优惠减 var all_zh_cutprice = 0; //所有的组合优惠减 + var all_ladder_cutprice = 0; //所有的阶梯促销优惠减 var all_order_prom = 0; //所有的订单优惠 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0); @@ -1302,6 +1381,8 @@ Page({ await th.calc_per(c_arr); //调用函数计算每件组合购商品的单价, await zh_calc.calc_zh_split_price(c_arr,th); + //调用函数计算每件阶梯促销商品的单价, + await ladder_calc.calc_split_price(c_arr,th); //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品 await th.get_cart_quan(c_arr); //---循环购物车--- @@ -1333,7 +1414,10 @@ Page({ var coupon_price = 0; var quan_no = null; var is_has_zh=c_arr[i].is_has_zh; - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 + var is_has_ladder=c_arr[i].is_has_ladder; + + var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 + var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) quan_no = th.data.using_quan[pickid].coupon_no; @@ -1361,12 +1445,24 @@ Page({ //--------循环计算总价----------- for (var j = 0; j < item.length; j++) { - if(item[j].prom_type!=7){ - o_price_no_zh += item[j].goods_price * item[j].goods_num; + + var is_no_zh=0; + if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1; + + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 + if(item[j].prom_type==7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id] + && th.data.zhhe_act_map[item[j].prom_id].is_orderyh ) + { + is_no_zh=1; } //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 - else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh ) + if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id] + && th.data.ladder_map[item[j].prom_id].is_useorderyh ) { + is_no_zh=1; + } + + if(is_no_zh){ o_price_no_zh += item[j].goods_price * item[j].goods_num; } o_price += item[j].goods_price * item[j].goods_num; @@ -1385,13 +1481,25 @@ Page({ //找到那些可以订单优惠叠加的 for(let ij in zh_prom_goods){ let kitem=zh_prom_goods[ij]; - var is_has_zh=kitem.is_has_zh; if(kitem.act.is_orderyh) o_price_no_zh-=kitem.cut_price; } } } + //如果有组合购优惠的钱,就要减价 + if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){ + o_price -= c_arr[i].ladder_cut_price; + if(o_price_no_zh>0){ + //找到那些可以订单优惠叠加的 + for(let ij in ladder_prom_goods){ + let kitem=ladder_prom_goods[ij]; + if(th.data.ladder_map[ij].is_useorderyh ) + o_price_no_zh-=kitem.cut_price; + } + } + } + //-- 计算线下取价的功能 -- if (cart_item.is_offline == 1) { o_price = o_price - cart_item.offline_price; @@ -1581,6 +1689,13 @@ Page({ o_condition=o_price_no_zh-quan_price; } + //看一下是不是不用组合购的订单优惠的叠加 + if(is_has_ladder){ + o_condition=o_price_no_zh-quan_price; + } + + + var order_m = 0; //---判断是不是有订单优惠--- await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { @@ -1664,6 +1779,7 @@ Page({ all_coupon_price_m += parseFloat(cart_item.coupon_price); all_cutprice += parseFloat(cart_item.cut_price); all_zh_cutprice += parseFloat(cart_item.zh_cut_price); + all_ladder_cutprice += parseFloat(cart_item.ladder_cut_price); all_order_prom += parseFloat(cart_item.order_prom_amount); } @@ -1677,6 +1793,7 @@ Page({ all_cutprice = all_cutprice.toFixed(2); all_order_prom = all_order_prom.toFixed(2); all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2); + all_ladder_cutprice = parseFloat(all_ladder_cutprice).toFixed(2); var atxt = "formData.total_amount"; var atxt1 = "formData.order_amount"; @@ -1687,12 +1804,13 @@ Page({ var atxt6 = "formData.cut_price"; var atxt7 = "formData.order_prom_amount"; var atxt8 = "formData.zh_cut_price"; + var atxt9 = "formData.ladder_cut_price"; th.setData({ [atxt]: all_total_m, [atxt1]: all_order_m, [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice, - [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice + [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice }) th.data.order_prom_list_cart = c_arr; th.set_can_num(); @@ -2380,13 +2498,22 @@ Page({ //--判断优惠活动的提交-- if (t_item.cut_price > 0) { order_prom_list.discount_amount += t_item.cut_price; - order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); } //--判断组合优惠活动的提交-- if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { order_prom_list.discount_amount += t_item.zh_cut_price; order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); } + + //--判断阶梯优惠活动的提交-- + if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) { + order_prom_list.discount_amount += t_item.ladder_cut_price; + } + + if(t_item.prom_pt_json){ + order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); + } + if (t_item.s_intValue > 0) { order_prom_list.give_integral = t_item.s_intValue; } @@ -2423,6 +2550,15 @@ Page({ //房间号的ids var room_ids = ""; + + //-- 把券的钱,写入从表 --- + if (t_item.quan_youhui_list && t_item.coupon_price) { + for (var kk in t_item.quan_youhui_list) { + var you_item = t_item.quan_youhui_list[kk]; + //-- 对券的价格进行平摊 -- + await th.split_set_goods_quanprice(you_item,t_item); + } + } //-------------让商品添加到商品列表-------------------- for (var k = 0; k < t_item.goods.length; k++) { var g_item = t_item.goods[k]; @@ -2445,22 +2581,15 @@ Page({ goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); goods.pricing_type = g_item.pricing_type; } - - //--把券的钱,写入从表--- - if (t_item.quan_youhui_list && t_item.coupon_price) { - for (var kk in t_item.quan_youhui_list) { - var you_item = t_item.quan_youhui_list[kk]; - if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) { - goods.quan_num = you_item.WareCashSum; - goods.quan_no = you_item.CashRepNo; - } - } + if(g_item.quan_num){ + goods.quan_num=g_item.quan_num; + goods.quan_no=g_item.quan_no; } - //--判断活动的类型-- switch (g_item.prom_type) { case 1: case 2: + case 10: goods.prom_type = g_item.prom_type; goods.prom_id = g_item.prom_id; break; @@ -2525,6 +2654,12 @@ Page({ goods.room_id = g_item.room_id; room_ids += g_item.room_id + ","; } + + //如果有阶梯促销 + if(g_item.ladder_list_id){ + goods.ladder_list_id=g_item.ladder_list_id; + } + item.order_goods.push(goods); } @@ -3409,6 +3544,7 @@ Page({ get_cart_quan: async function (order_prom_list_cart) { var th = this; var is_xz_yh = 1; + var user_id=getApp().globalData.user_id; //等待值的出现 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () { //var arr=th.data.order_prom_list_cart; @@ -3442,7 +3578,19 @@ Page({ }).then(res => { if (res.data.code == 0) prom1 = res.data.data; }) - if(!prom1.isQuan){ + if(prom1 && !prom1.isQuan){ + continue; + } + } + + //--如果是团购,要判断有没有限制使用优惠券 + if(gd.prom_type == 10){ + var prom1=null; + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, { + }).then(res => { + if (res.data.code == 0) prom1 = res.data.data; + }) + if(prom1 && prom1.isuse && prom1. is_usecoupon){ continue; } } @@ -3482,6 +3630,16 @@ Page({ } } + var prom_pt_json= ep.prom_pt_json; + if(prom_pt_json){ + for(let oj in prom_pt_json){ + let item_j=prom_pt_json[oj]; + if(item_j.ladder_prom_id){ + cut_price += parseFloat(item_j.dis); + } + } + } + arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price; arr[ind].check_quan_ware_list = check_quan_ware_list; arr[ind].check_quan_price_list = check_quan_price_list; @@ -3899,6 +4057,73 @@ Page({ go_url:function (e) { var url = e.currentTarget.dataset.url; getApp().goto(url); + }, + + //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表 + split_set_goods_quanprice:async function (you_item,t_item) { + var coupon_price=you_item.WareCashSum; + var goods=t_item.goods; + var arr=[]; + //判断是不是有goods_id重复 + for(var i=0;i { + if (res.data.code == 0) { + pt_res = res.data.data; + } + }) + if (pt_res) { + var q_s_num = 0; + for (var i in pt_res) { + var idx = pt_res[i].idx; + //有account的实收价,就要用account实收价 + var price=(t_item.goods[idx].account?t_item.goods[idx].account:t_item.goods[idx].goods_price); + price=(price - pt_res[i].fisrt_account)* t_item.goods[idx].goods_num; + t_item.goods[idx].quan_num =price; + + t_item.goods[idx].quan_num =Math.floor(t_item.goods[idx].quan_num * 100) / 100; + t_item.goods[idx].quan_no=t_item.quan_no; + q_s_num += t_item.goods[idx].quan_num; + } + + if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)){ + for (var ik in arr) { + if (arr[ik].goods_num == 1) { + var id = arr[ik].idx; + var pri=Math.floor(coupon_price*100)/100-Math.floor(q_s_num*100)/100 + t_item.goods[id].quan_num+=pri; + break; + } + } + } + } } diff --git a/pages/cart/cart2/cart2.wxml b/pages/cart/cart2/cart2.wxml index 0983b21..95bea2b 100644 --- a/pages/cart/cart2/cart2.wxml +++ b/pages/cart/cart2/cart2.wxml @@ -95,7 +95,8 @@ - {{filters.toFix(items.goods_price,2)}} + {{filters.toFix(items.goods_price,2)}}({{items.discount}}折) + {{filters.toFix(items.goods_price,2)}} x{{items.goods_num}} @@ -431,6 +432,11 @@ 组合购优惠 - ¥ {{filters.toFix(formData.zh_cut_price,2)}}元 + + + 阶梯促销优惠 + - ¥ {{filters.toFix(formData.ladder_cut_price,2)}}元 + diff --git a/pages/cart/cart2/ladder_calculate.js b/pages/cart/cart2/ladder_calculate.js new file mode 100644 index 0000000..4c23827 --- /dev/null +++ b/pages/cart/cart2/ladder_calculate.js @@ -0,0 +1,242 @@ +var regeneratorRuntime = require('../../../utils/runtime.js'); +module.exports = { + //主要的作用,就是把阶梯促销多余的商品进行拆分, + //如果没有达成阶梯促销的要求,所有的商品都打回原价购买 + fir_set_arr: function (c_item, th) { + //寻找一下 + function get_num2(ite) { + var vh = c_item.goods.findIndex(function (e) { + return e.goods_id == ite.goods_id + }) + if (vh > -1) return vh; + return 0; + } + + //组合活动,以及组合活动从表的商品 + 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) { + let title = ""; //提示语; + //其中的一个活动 + let act_item = ladder_map[i]; + let ladder_list = act_item.ladder_list; + + let all_num = 0; //商品数量之和 + let all_price0 = 0; //商品数量之和 + let aprice = 0; //达到活动条件的购买价格 + + let no_in_arr = []; //剩余的未加入组合购 + let del_g=[]; + for (var li in goods) { + if (goods[li].prom_type != 10) continue; + if (goods[li].prom_id != act_item.id) continue; + var item = goods[li]; + item.goods_price = item.goods_price; + item.offline_price = item.offline_price; + item.cart_num = item.goods_num; + all_num += item.cart_num; + for (var j = 0; j < item.cart_num; j++) { + no_in_arr.push({ + price: item.goods_price, + offline_price: item.offline_price, + goods_id: item.goods_id, + shop_price: item.shop_price, + item:item + }) + } + del_g.push(item); + } + + function sortData(a, b) { + return a.price - b.price + } + no_in_arr.sort(sortData); + + //开始阶梯计算价格 + var lev = 0; + for (let j in ladder_list) { + if (no_in_arr.length == 0) break; + let item_j =ladder_list[j]; + var end = no_in_arr.pop(); + var new_price = parseInt(item_j.discount_field) == 1 ? end.shop_price : end.price; + var account=new_price * parseFloat(item_j.discount) / 10; + aprice +=account; + + //-- 单个文件新增 -- + let new_g = JSON.parse(JSON.stringify(end.item)); + new_g.goods_num = 1; + //如果有平摊到单品的时候,account要显示 + if(!th.data.ispt_goods) new_g.account = account.toFixed(2); + new_g.discount = item_j.discount; + new_g.goods_price =new_price; + new_g.ladder_list_id =item_j.id; + goods.push(new_g); + lev++; + } + + let goods_map = {}; + //算一下剩余的商品 + if (no_in_arr.length) { + for (let ii in no_in_arr) { + let item = no_in_arr[ii]; + if (item.offline_price) { + offline_price += item.price - item.offline_price; + offline_num += 1; + } + if (goods_map[item.goods_id]) { + var num = goods_map[item.goods_id]; + goods_map[item.goods_id] = ++num; + } else { + goods_map[item.goods_id] = 1; + } + } + } + + if (Object.keys(goods_map).length) { + //这里就开始拆分提交订单时的列表 + for (let j in goods_map) { + //map中存的就是商品的数量 + let num = goods_map[j]; + //找到相应的商品 + let idx = goods.findIndex(function (ele) { + return ele.goods_id == j; + }) + //goods[idx].goods_num -= num; + let new_g = JSON.parse(JSON.stringify(goods[idx])); + new_g.goods_num = num; + new_g.prom_type = 0; + new_g.prom_id = 0; + goods.push(new_g); + //goods.splice(idx, 1); + } + } + + //-- 最后剔除不要参与的数据 -- + for(var h in del_g){ + var it=del_g[h]; + let idx = goods.findIndex(function (ele) { + return ele.goods_id == it.goods_id + }) + goods.splice(idx, 1); + } + + //-- 只统计是参与活动的商品 -- + for (var ij in goods) { + var iter = goods[ij]; + if (iter.prom_type != 10 || iter.prom_id != act_item.id) { + continue; + } + all_price0 += iter.goods_num * iter.goods_price; + } + + if(!c_item.ladder_prom_goods) c_item.ladder_prom_goods={}; + if(!c_item.ladder_prom_goods[act_item.id]) c_item.ladder_prom_goods[act_item.id]={}; + + //-- 活动的条件已经满足 -- + c_item.ladder_prom_goods[act_item.id].is_has_ladder = 1; + c_item.is_has_ladder = 1; + c_item.ladder_prom_goods[act_item.id].actual_price = aprice; + c_item.ladder_prom_goods[act_item.id].cut_price = all_price0 - aprice; + + tfeel += aprice; + cut_price += all_price0 - aprice; + + } + + c_item.ladder_all_price = tfeel; + c_item.ladder_cut_price = cut_price; + + if (c_item.is_offline == 1) { + c_item.offline_price += offline_price; + c_item.offline_num += offline_num; + } else { + c_item.is_offline == 1; + c_item.offline_price = offline_price; + c_item.offline_num = offline_num; + } + }, + //筛选组合购,纯粹的数组按活动id分组 + find_split: function (arr) { + //过滤只有团购的商品 + let oarr = arr.goods.filter(function (ele) { + return ele.prom_type == 10 + }) + if (!oarr || oarr.length == 0) return null; + //看一下有多少个不同的团购 + let map = {}, + dest = []; + for (let i = 0; i < oarr.length; i++) { + let ai = oarr[i]; + let index = map[ai.prom_id] + if (!index) { + dest.push({ + prom_id: ai.prom_id, + act: ai.act, + data: [ai] + }); + map[ai.prom_id] = dest.length; //存储下标 + } else { + let dj = dest[index - 1]; + dj.data.push(ai); + } + } + return dest; + }, + + //-- 组装阶梯购的价格 -- + calc_split_price: async function (c_arr, th) { + //-- 循环处理 -- + for (var k in c_arr) { + var cart_item = c_arr[k]; //就是每一单的意思 + var ord_goods = c_arr[k].goods; //就是每一单的从表的意思 + + var ladder_map = cart_item.ladder_prom_goods; //一单中所有的组合购的集合 + var item_map = {}; + for (let i in ladder_map) { + let item = ladder_map[i]; + let prom_id = i; + //如果这个活动还没有达到要求,继续下一个计算 + if (!item.is_has_ladder) continue; + //过滤出相应组合购活动的商品 + let glist = ord_goods.filter(function (ele) { + return ele.prom_type == 10 && ele.prom_id == i; + }) + + var all_good_price = 0; + var post_gd = []; + for (let j in glist) { + let item = glist[j]; + all_good_price += item.goods_price * item.goods_num; + var gitem = { + goods_id: item.goods_id, + goods_num: item.goods_num, + goods_price: item.goods_price + } + post_gd.push(gitem); + } + //要进行优惠的计算 + if (all_good_price - item.actual_price) { + if (cart_item.prom_pt_json) { + cart_item.prom_pt_json.push({ + "ladder_prom_id": prom_id, + "dis": (all_good_price - item.actual_price).toFixed(2), + "ispt": 0 + }) + } else { + cart_item.prom_pt_json = [{ + "ladder_prom_id": prom_id, + "dis": (all_good_price - item.actual_price).toFixed(2), + "ispt": 0 + }]; + } + } + } + + + } + } + + +} diff --git a/pages/cart/cart2/zh_calculate.js b/pages/cart/cart2/zh_calculate.js index f42189f..c23727e 100644 --- a/pages/cart/cart2/zh_calculate.js +++ b/pages/cart/cart2/zh_calculate.js @@ -15,6 +15,7 @@ module.exports = { let act_item = zh_prom_goods[i]; let act_goos = act_item.gdlist; let act = act_item.act; + if(!act) continue; let all_num = 0; //商品数量之和 let all_price0 = 0; //商品数量之和 @@ -103,7 +104,7 @@ module.exports = { } //当满足组合的要求:总数要满足,起购数要满足 - if (all_num >= act.zhbuyqty && !need_to_buy) { + if (act && all_num >= act.zhbuyqty && !need_to_buy) { //商品的列表 for (var u in act_goos) { diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index 6bbe117..0f2a7f6 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -839,7 +839,7 @@ Page({ await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid} }).then(res=>{ - if(res.data.code==0){ + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){ plist=res.data.data.pageData[0]; } }) diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 680b6cf..377b76f 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -296,7 +296,7 @@ Page({ th.setData({ user_addr: ie }); if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { th.setData({ add_back: 1 }); - if (this.data.bn_goods) th.calculatePrice2(); + if (th.data.bn_goods) th.calculatePrice2(); } }) //--更新默认地址--,看一下是不是跳到地址页面 @@ -779,7 +779,7 @@ Page({ var price =0,th=this; price +=parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price > freight_free){ return 0;} + if (freight_free > 0 && o_price >= freight_free){ return 0;} if (user_addr==null) { return 0; } //计算物流的config item; var item=null; diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 7d21c37..f55f477 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -470,7 +470,7 @@ Page({ var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price > freight_free) { return 0; } + if (freight_free > 0 && o_price >= freight_free) { return 0; } if (user_addr == null) { return 0; } //计算物流的config item; var item = null; diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index e9c84d1..06a7141 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -39,6 +39,8 @@ Page({ orderSn: options.orderSn, getUserID: d.user_id, }) + + if(options.lbId) th.data.lbId=options.lbId; //-- 获取分享人的ID -- var first_leader = options.first_leader || getApp().globalData.first_leader; if (first_leader) { diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 04d03e7..1be1ca1 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -850,7 +850,7 @@ 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) { + 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) { //默认门店要拿下门店库存 if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { //获取门店 @@ -1353,10 +1353,15 @@ Page({ }) } - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5) { + else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type==10) { newd.prom_type = 0; newd.prom_id = 0; + if(th.data.prom_type == 10){ + newd.prom_type = th.data.prom_type; + newd.prom_id = th.data.prom_id; + } + //---如果是线下门店销售的时候--- if (th.data.sales_rules == 2) { var pick = th.get_pick_from_list(th.data.sto_sele_id) @@ -1449,6 +1454,7 @@ Page({ user_id: oo.user_id, goods_id: a, pick_id: e.data.sto_sele_id, + state:0 }, success: function (re) { @@ -1517,9 +1523,41 @@ Page({ }); } - //else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d); else { + if(newd.prom_type==10){ + //----先看会员在购物车中是否加入了该商品,立即购买的----- + 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("/pages/cart/cart2/cart2?state=1"); + } + }); + + + } + }) + return false; + } + + if (th.data.prom_goods) { var prom_d = th.data.prom_goods; for (var i in prom_d) { @@ -1825,6 +1863,7 @@ Page({ }); }, + openSpecModel: function (t) { var th = this; var open_store = t.currentTarget.dataset.ind; @@ -1869,9 +1908,35 @@ Page({ //var is_open=th.data.config th.get_off_price(); }) + //--先判断会员状态-- + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + wx.navigateTo({ + url: '/pages/togoin/togoin', + }) + return false; + } + var is_go_next = 1; + if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) { + is_go_next = 0; + } + if (is_go_next) { + var ind = t.currentTarget.dataset.ind; + //回调。判断是不是优惠促销 + th.check_is_prom_goods(function () { + th.setData({ + openSpecModal: !0, + openSpecModal_ind: ind, + }); + //var is_open=th.data.config + th.get_off_price(); + }) + } else { + th.setData({is_pop_more: 1}); + + } } }, - open_next(){ var th=this; //回调。判断是不是优惠促销 @@ -2261,10 +2326,12 @@ Page({ switch (goodsinfo.prom_type) { case 1: - await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, { - }).then(res => { - if (res.data.code == 0) prom = res.data.data; - }) + + if(goodsinfo.prom_id) { + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { + if (res.data.code == 0) prom = res.data.data; + }) + } break; case 6: @@ -3040,7 +3107,7 @@ Page({ var user_id=getApp().globalData.user_id; if(!user_id) user_id=0; - if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9) { + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) { this.setData({ prom_type: 0,isshow: 1, }); @@ -3642,7 +3709,16 @@ Page({ //如果是秒杀的时候 if(th.data.prom_type==0 && gd.prom_type == 1 ){ gd.prom_type= 0; - } + } + //如果全场优惠,商品做了秒杀 + if(th.data.prom_type==3 && gd.prom_type == 1 ){ + gd.prom_type= 0; + } + //如果全场阶梯优惠,商品做了秒杀 + if(th.data.prom_type==10 && gd.prom_type == 1 ){ + gd.prom_type= 0; + } + if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { //----获取活动购买数---- @@ -5660,12 +5736,40 @@ Page({ //---检查有没有优惠活动--- check_is_youhui: function (gid, is_nor) { var th = this; + var user_id=getApp().globalData.user_id; + if(!user_id) user_id=0; //如果是普通购买的时候,要进行调用 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; + + if(r_data.ladderLists){ + var act_id=r_data.ladderLists[0].form_id; + //-- 判断会员能不能参与阶梯促销 -- + 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=""; + 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 + }) + } + }) + } + th.setData({ prom_goods: r_data.promGoodsLists, }) @@ -5679,7 +5783,7 @@ Page({ getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", { success: function (res) { console.log(res); - if (res.data.code == 0) { + if (res.data.code == 0 && res.data.data) { var r_data = res.data.data; var max = 0, min = 0; if (r_data.collocationList) { @@ -5693,6 +5797,32 @@ Page({ 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(r_data.ladderLists){ + var act_id=r_data.ladderLists[0].form_id; + //-- 判断会员能不能参与阶梯促销 -- + 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=""; + 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 + }) + } + }) + } + th.setData({ order_prom: r_data.promOrder, collocationGoods: r_data.collocationPromList, @@ -5701,11 +5831,8 @@ Page({ th.is_show_more_buy(); } } - }) } - - }, closePoster() { @@ -6026,13 +6153,31 @@ Page({ check_has_flash:function () { var th=this; var url="/api/weshop/activitylist/getGoodActInfo"; + var user_id=getApp().globalData.user_id; + if(!user_id) user_id=0; + var req_data={ - store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1 + store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1,user_id:user_id }; //获取秒杀的多规格 - getApp().request.promiseGet(url, {data:req_data}).then(res=>{ + getApp().request.promiseGet(url, {data:req_data}).then(async function (res) { if(res.data.code==0 && res.data.data && res.data.data.length){ - th.setData({more_flash:res.data.data}); + var arr_data=res.data.data; + var new_arr=[]; + for(let i in arr_data){ + let item=arr_data[i]; + //找不到活动要剔除 + if(!item.act_name) continue; + if(item.prom_type!=1) continue; + new_arr.push(item); + } + + if(new_arr.length==1){ + th.data.prom_id=new_arr[0].act_id; + th.data.prom_type=new_arr[0].prom_type; + } + + th.setData({more_flash:new_arr}); } }) }, @@ -6058,7 +6203,6 @@ Page({ success(res) {} }) }, - get_normal(gid){ this.setData({ prom_type: 0, @@ -6069,6 +6213,7 @@ Page({ this.check_is_youhui(gid,1); this.data.is_normal=1; }, + // 促销 -> 送礼包 -> 查看详情 viewLbDetails(e) { @@ -6076,8 +6221,12 @@ Page({ let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 // console.log('myurl', url); getApp().goto(url); - } + }, + go_more_ladder:function (e) { + var prom_id=e.currentTarget.dataset.id; + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id); + } diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 82fbb69..6824c01 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -619,6 +619,24 @@ + + + + 阶梯促 + + + + {{jieti_prom}} + + + + + + + + + @@ -659,26 +677,30 @@ - - - - 秒杀 - - - - - - {{item.act_name}} - - (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}}) + + + 秒杀 + + + + + + {{item.act_name}} + + (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}}) + + + + - - + + @@ -686,8 +708,6 @@ - - diff --git a/pages/goods/goodsInfo/goodsInfo.wxss b/pages/goods/goodsInfo/goodsInfo.wxss index cc8baea..107174b 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxss +++ b/pages/goods/goodsInfo/goodsInfo.wxss @@ -3838,6 +3838,7 @@ button.custom-service::after { color: #aaa; } + .tick { position: relative; } @@ -3880,3 +3881,6 @@ button.custom-service::after { border-radius: 0 0 10rpx 0; margin-right: 4rpx; } + +.jie_show{ display: inline-block; width: 40rpx; height: 40rpx; background-color:#ff0505;border-radius:50%;color: #fff;text-align: center; margin: 0 20rpx } + diff --git a/pages/goods/goodsList/goodsList.js b/pages/goods/goodsList/goodsList.js index 0268b85..287403a 100644 --- a/pages/goods/goodsList/goodsList.js +++ b/pages/goods/goodsList/goodsList.js @@ -22,7 +22,8 @@ Page({ is_hot:0, prom_goods_list:null, rq_data:null, - isToggle: false, //切换商品视图控制符 + isToggle: false, //切换商品视图控制符 + show_all:1, //判断显示 }, onLoad: function(t) { @@ -69,8 +70,18 @@ Page({ if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; } if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; } - - + if (0 != t.ladder_id && t.ladder_id != undefined) { + url += "&ladder_id=" + t.ladder_id; + this.setData({ + ladder_id:t.ladder_id, + baseUrl:url, + }) + } + + var user_id=getApp().globalData.user_id; + if(!user_id) user_id=0; + url += "&user_id="+user_id; + // 优惠促销列表 if(t.prom_goods_id) { url += '&prom_goods_id=' + t.prom_goods_id; @@ -96,6 +107,54 @@ Page({ } }) } + + //--- 阶梯优惠活动的凑单 --- + if(t.ladder_id){ + var user_id=getApp().globalData.user_id; + if(!user_id) user_id=0; + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+oo.stoid+"/"+user_id+"/"+t.ladder_id,{ + }).then(res=>{ + if(res.data.code==0 && res.data.data){ + var arr= res.data.data; + + if(arr.is_end==1){ + th.setData({show_all:0,err_txt:'活动已结束'}); + return false; + } + if(arr.start_time>ut.gettimestamp()){ + th.setData({show_all:0,err_txt:'活动还未开始'}); + return false; + } + if(arr.end_time{ @@ -206,7 +268,7 @@ Page({ item.prom_type=res.data.data[0].prom_type; item.prom_id=res.data.data[0].act_id; } - }) + })--*/ var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 var prom_id=item.prom_id; @@ -379,4 +441,10 @@ Page({ }, + go_url:function (e) { + var url=e.currentTarget.dataset.url; + getApp().goto(url); + } + + }); \ No newline at end of file diff --git a/pages/goods/goodsList/goodsList.wxml b/pages/goods/goodsList/goodsList.wxml index b90eee8..d398acf 100644 --- a/pages/goods/goodsList/goodsList.wxml +++ b/pages/goods/goodsList/goodsList.wxml @@ -1,5 +1,5 @@ - + @@ -12,12 +12,14 @@ 送{{item.content.lb_name}} + + 阶梯促销:{{jieti_prom}} + - - 搜索店铺商品 + 搜索店铺商品 @@ -290,10 +292,10 @@ 暂无相关商品 - 回到首页 + 回到首页 -