diff --git a/components/diy_pingd_buy/diy_pingd_buy.js b/components/diy_pingd_buy/diy_pingd_buy.js index be709c4..26d126f 100644 --- a/components/diy_pingd_buy/diy_pingd_buy.js +++ b/components/diy_pingd_buy/diy_pingd_buy.js @@ -104,7 +104,11 @@ Component({ var url= "/api/weshop/teamlist/pageteam/2?page=1&pageSize=9"; getApp().request.promiseGet(url, { data: { - store_id: os.stoid,is_end: 0,is_show: 1, + store_id: + os.stoid, + is_end: 0, + is_show: 1, + user_id: getApp().globalData.user_id, } }).then(res => { if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){ @@ -139,7 +143,7 @@ Component({ //--三个三个一组--- for(var i=0;i< all_array.length;i+=3){ arr.push(all_array.slice(i,i+3)); - } + } /*--熏染到前台--*/ th.setData({goods_array:arr}); var newTime = ut.gettimestamp(); diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js index af5ec6c..29d9dcf 100644 --- a/packageB/pages/zuhegou/index/index.js +++ b/packageB/pages/zuhegou/index/index.js @@ -1972,15 +1972,8 @@ Page({ if (this.data.act.is_bzyh && zhqty_bz.length > 0) { if (zhqty_bz.length > 1) { let zhqty_bz_arr = []; - let zhqty_bz_flag = zhqty_bz.every((item1, i) => { - var bz_num = be * item1['zhqty']; //超量倍增 - var num = item1['num'] - item1['zhqty']; //购买数量减去超量 - if (bz_num > num) { - zhqty_bz_arr.push(item1); - zhqty_bz.splice(i, 1) - } - return bz_num <= num; - }) + let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr); + if (zhqty_bz_flag) { for (let i = 0; i < zhqty_bz.length; i++) { var vv = zhqty_bz[i]; @@ -1995,11 +1988,12 @@ Page({ } } } else { + zhqty_len=1; let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { - return o['num'] + return o['num']; })); let new_arr = zhqty_bz_arr.filter(ii => { - return ii['num'] == min_bz_num + return ii['num'] == min_bz_num; }) var vv = new_arr[0]; var bz_num = be * new_arr[0].zhqty; //超量倍增 @@ -2018,16 +2012,20 @@ Page({ } bz_num_ok = be * vv.zhqty; } - - for (let j = 0; j < bz_num_ok; j++) { - let index = no_in_arr.findIndex(i => { - return vv.goods_id === i.goods_id - }) - if (index > -1) { - delete_num++ - no_in_arr.splice(index, 1) + + for(let i = 0; i < zhqty_bz.length; i++){ + let item1=zhqty_bz[i]; + for (let j = 0; j < be * item1['zhqty']; j++) { + let index = no_in_arr.findIndex(i => { + return item1.goods_id === i.goods_id + }) + if (index > -1) { + // delete_num++ + no_in_arr.splice(index, 1) + } } } + aprice += be * aprice; } } else { var vv = zhqty_bz[0]; @@ -2258,6 +2256,20 @@ Page({ } if (func) func(list) - } + }, + zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ + let zhqty_bz_flag =true; + for(let i=0;i num) { + zhqty_bz_flag=false; + zhqty_bz_arr.push(item); + // zhqty_bz.splice(i,1) + } + } + return zhqty_bz_flag; + } }) \ No newline at end of file diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 075c2c2..8cba3d4 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -1693,7 +1693,7 @@ Page({ item = item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight >= 0 && item['money'] && out_of_weight > 0) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price = parseFloat(item['money']); if (goods_weight > item['first_weight']) { var fw = goods_weight - item['first_weight']; diff --git a/pages/cart/cart/zh_calculate.js b/pages/cart/cart/zh_calculate.js index 04fae18..e68c1b0 100644 --- a/pages/cart/cart/zh_calculate.js +++ b/pages/cart/cart/zh_calculate.js @@ -239,15 +239,8 @@ module.exports = { if (act.is_bzyh && zhqty_bz.length > 0) { if (zhqty_bz.length > 1) { let zhqty_bz_arr = []; - let zhqty_bz_flag = zhqty_bz.every((item1, i) => { - var bz_num = be * item1['zhqty']; //超量倍增 - var num = item1['num'] - item1['zhqty']; //购买数量减去超量 - if (bz_num > num) { - zhqty_bz_arr.push(item1); - zhqty_bz.splice(i, 1) - } - return bz_num <= num; - }) + let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr); + if (zhqty_bz_flag) { for (let i = 0; i < zhqty_bz.length; i++) { var vv = zhqty_bz[i]; @@ -262,11 +255,12 @@ module.exports = { } } } else { + zhqty_len=1; let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { - return o['num'] + return o['num']; })); let new_arr = zhqty_bz_arr.filter(ii => { - return ii['num'] == min_bz_num + return ii['num'] == min_bz_num; }) var vv = new_arr[0]; var bz_num = be * new_arr[0].zhqty; //超量倍增 @@ -285,18 +279,22 @@ module.exports = { } bz_num_ok = be * vv.zhqty; } - - for (let j = 0; j < bz_num_ok; j++) { - let index = no_in_arr.findIndex(i => { - return vv.goods_id === i.goods_id - }) - if (index > -1) { - delete_num++ - no_in_arr.splice(index, 1) + + for(let i = 0; i < zhqty_bz.length; i++){ + let item1=zhqty_bz[i]; + for (let j = 0; j < be * item1['zhqty']; j++) { + let index = no_in_arr.findIndex(i => { + return item1.goods_id === i.goods_id + }) + if (index > -1) { + // delete_num++ + no_in_arr.splice(index, 1) + } } } + aprice += be * aprice; } - } else { + } else { var vv = zhqty_bz[0]; var bz_num = be * vv.zhqty; //超量倍增 var num = vv['num'] - vv.zhqty; //购买数量减去超量 @@ -310,14 +308,11 @@ module.exports = { // be=be-bz_num_ok; if (num % vv.zhqty == 0) { be = num / vv.zhqty; - // bz_num_ok = num; } else { be = Math.floor(num / vv.zhqty) - // bz_num_ok = num - (be * vv.zhqty); } bz_num_ok = be * vv.zhqty; } - // be=vv.num; for (let j = 0; j < bz_num_ok; j++) { let index = no_in_arr.findIndex(i => { return vv.goods_id === i.goods_id @@ -496,7 +491,22 @@ module.exports = { } } return dest; - } + }, + + zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ + let zhqty_bz_flag =true; + for(let i=0;i num) { + zhqty_bz_flag=false; + zhqty_bz_arr.push(item); + // zhqty_bz.splice(i,1) + } + } + return zhqty_bz_flag; + } } \ No newline at end of file diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index f414b42..6c161ed 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -3055,7 +3055,7 @@ Page({ item = item.config; if (item == null) return o_shipping_price; //------按重量---------- - if (goods_weight >= 0 && item['money'] && out_of_weight > 0) { + if (goods_weight >= 0 && item['money'] && out_of_weight >= 0) { fw_price = parseFloat(item['money']); if (goods_weight > item['first_weight']) { var fw = goods_weight - item['first_weight']; diff --git a/pages/cart/cart2/zh_calculate.js b/pages/cart/cart2/zh_calculate.js index 0475ca1..149d638 100644 --- a/pages/cart/cart2/zh_calculate.js +++ b/pages/cart/cart2/zh_calculate.js @@ -152,15 +152,8 @@ module.exports = { if (act.is_bzyh && zhqty_bz.length > 0) { if (zhqty_bz.length > 1) { let zhqty_bz_arr = []; - let zhqty_bz_flag = zhqty_bz.every((item1, i) => { - var bz_num = be * item1['zhqty']; //超量倍增 - var num = item1['num'] - item1['zhqty']; //购买数量减去超量 - if (bz_num > num) { - zhqty_bz_arr.push(item1); - zhqty_bz.splice(i, 1) - } - return bz_num <= num; - }) + let zhqty_bz_flag=this.zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr); + if (zhqty_bz_flag) { for (let i = 0; i < zhqty_bz.length; i++) { var vv = zhqty_bz[i]; @@ -175,11 +168,12 @@ module.exports = { } } } else { + zhqty_len=1; let min_bz_num = Math.min.apply(Math, zhqty_bz_arr.map(function (o) { - return o['num'] + return o['num']; })); let new_arr = zhqty_bz_arr.filter(ii => { - return ii['num'] == min_bz_num + return ii['num'] == min_bz_num; }) var vv = new_arr[0]; var bz_num = be * new_arr[0].zhqty; //超量倍增 @@ -198,18 +192,22 @@ module.exports = { } bz_num_ok = be * vv.zhqty; } - - for (let j = 0; j < bz_num_ok; j++) { - let index = no_in_arr.findIndex(i => { - return vv.goods_id === i.goods_id - }) - if (index > -1) { - delete_num++ - no_in_arr.splice(index, 1) + + for(let i = 0; i < zhqty_bz.length; i++){ + let item1=zhqty_bz[i]; + for (let j = 0; j < be * item1['zhqty']; j++) { + let index = no_in_arr.findIndex(i => { + return item1.goods_id === i.goods_id + }) + if (index > -1) { + // delete_num++ + no_in_arr.splice(index, 1) + } } } + aprice += be * aprice; } - } else { + } else { var vv = zhqty_bz[0]; var bz_num = be * vv.zhqty; //超量倍增 var num = vv['num'] - vv.zhqty; //购买数量减去超量 @@ -223,19 +221,16 @@ module.exports = { // be=be-bz_num_ok; if (num % vv.zhqty == 0) { be = num / vv.zhqty; - // bz_num_ok = num; } else { be = Math.floor(num / vv.zhqty) - // bz_num_ok = num - (be * vv.zhqty); } bz_num_ok = be * vv.zhqty; } - // be=vv.num; for (let j = 0; j < bz_num_ok; j++) { let index = no_in_arr.findIndex(i => { return vv.goods_id === i.goods_id }) - if(index > -1){ + if (index > -1) { delete_num++ no_in_arr.splice(index, 1) } @@ -515,6 +510,20 @@ module.exports = { } + }, + zhqty_bz_fun(zhqty_bz,be,zhqty_bz_arr){ + let zhqty_bz_flag =true; + for(let i=0;i num) { + zhqty_bz_flag=false; + zhqty_bz_arr.push(item); + // zhqty_bz.splice(i,1) + } + } + return zhqty_bz_flag; } diff --git a/pages/team/team_show/team_show.js b/pages/team/team_show/team_show.js index 110ef29..0f00042 100644 --- a/pages/team/team_show/team_show.js +++ b/pages/team/team_show/team_show.js @@ -94,18 +94,29 @@ Page({ }, onLoad: function(options) { - wx.setNavigationBarTitle({ title: "拼团订单",}) //var postdata=getApp().globalData.to_group; var postdata=options; - var tg_id = postdata.tg_id, first_leader=options.first_leader; + var tg_id = postdata.tg_id, first_leader=options.first_leader,goods_id=options.goods_id; //如果tg_id是空的话 - if(tg_id==undefined || tg_id==null || tg_id==""){ + if(tg_id==null ||goods_id==null){ var tg_id_str=decodeURIComponent(postdata.scene); tg_id_str=tg_id_str.split("_"); - tg_id=tg_id_str[0]; - if(tg_id_str.length>1){ - first_leader=tg_id_str[1]; + console.log(tg_id_str.length); + //tg_id_str[0] teamgroup.id tg_id_str[1] user_id tg_id_str[2] goods_id + switch(tg_id_str.length){ + case 1: + tg_id=tg_id_str[0]; + break; + case 2: + tg_id=tg_id_str[0]; + first_leader=tg_id_str[1]; + break; + case 3: + tg_id=tg_id_str[0]; + first_leader=tg_id_str[1]; + goods_id=tg_id_str[2]; + break; } } //--判断一下是不是导购-- @@ -118,14 +129,13 @@ Page({ } }) } - - this.setData({tg_id: tg_id }); + this.setData({tg_id: tg_id,goods_id}); getApp().globalData.to_group=null; - var th=this; - getApp().getConfig2(function(e) { - th.setData({ bconfig: e,}); - th.wait_for_store_config(); //获取默认的门店 + var th=this; + getApp().getConfig2(function(e) { + th.setData({ bconfig: e,}); + th.wait_for_store_config(); //获取默认的门店 }) }, @@ -358,17 +368,47 @@ Page({ max_num = 0, min_price = 0, th=this, - that=th; + that=th, + flag=null; + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2",{ + data:{ + store_id: os.stoid, + is_end: 0, + is_show: 1, + user_id: getApp().globalData.user_id, + pageSize:1000 + } + }).then(res=>{ + let pd_list=res.data.data.pageData; + if(res.data.code==0 && pd_list.length>0){ + flag =pd_list.some(pd=>{ + // if(th.data.goods_id){ + return pd.goods_id==th.data.goods_id; + // } + }) + } + }) + if(!flag){ + wx.showToast({title: "当前会员身份不符,无法参与", icon: 'none', duration: 3000}); + setTimeout(function () { + ut.wx_back(); + }, 1000) + return false; + } //获取活动从表信息team_id,listno团编号(券号) await getApp().request.promiseGet("/api/weshop/teamgroup/get/"+os.stoid+"/"+tg_id, { }).then(res => { + + if(res.data.code !=0 ){ + getApp().showWarning(res.data.msg); + th.go_back(); + return false; + } - - if(res.data.code==0 && res.data && res.data.data ) { + if(res.data && res.data.data ) { teamgroup = res.data.data; - //获取当前时间,并且判断剩余时间 var nt = ut.gettimestamp(); var buy_start_date = ut.formatTime(teamgroup.buy_start_date, "yyyy-MM-dd hh:mm:ss"); @@ -388,7 +428,6 @@ Page({ } } - }) //判断是不是要继续的开关 @@ -433,36 +472,10 @@ Page({ //获取活动表的信息根据活动team_id await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + teamgroup.team_id, { data: {} - }).then(async res => { - var flag=null; + }).then(res => { if (res.data.code == 0) { teamlist = res.data.data; goods_id = res.data.data.goods_id; - - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{ - data:{ - store_id: os.stoid, - is_end: 0, - is_show: 1, - user_id: getApp().globalData.user_id, - pageSize:1000 - } - }).then(res=>{ - let pd_list=res.data.data.pageData; - if(res.data.code==0 && pd_list.length>0){ - flag =pd_list.some(pd=>{ - return pd.goods_id==teamlist['goods_id'] - }) - } - }) - if(!flag){ - wx.showToast({title: "当前会员身份不符,无法参与", icon: 'none', duration: 3000}); - // setTimeout(function () { - ut.wx_back(); - // }, 2000) - return false; - } - //----------查看阶梯团------------ if (teamlist.ct_rylist != "" && teamlist.ct_rylist != null && teamlist.ct_rylist != undefined) { var ct_rylist = JSON.parse(teamlist.ct_rylist); diff --git a/pages/team/team_success/team_success.js b/pages/team/team_success/team_success.js index 0bb3b38..f833456 100644 --- a/pages/team/team_success/team_success.js +++ b/pages/team/team_success/team_success.js @@ -398,19 +398,26 @@ Page({ var app = getApp(); var unit = that.data.screenWidth / 750 * 1.35; var scene=th.data.teamgroup.id; + var goods_id=th.data.teamlist.goods_id; var user_id=getApp().globalData.user_id?getApp().globalData.user_id:0; if(user_id>0){ scene+="_"+user_id; } + if(goods_id !==""){ + scene+="_"+goods_id; + } //二微码 var path3 = os.url+ "/api/wx/open/app/user/getWeAppEwm/"+ os.stoid+"?sceneValue="+scene+"&pageValue=pages/team/team_show/team_show"; + console.log(path3,6000); + //读取文件成功则OK-- wx.getImageInfo({ src: path3, success:function (res) { + console.log(res,5000); //回调写法 th.get_head_temp(th.get_goods_temp,function () { var vpath = res.path; @@ -812,7 +819,8 @@ Page({ onShareAppMessage: function (e) { var th=this; var scene=this.data.teamgroup.id; - var url="/pages/team/team_show/team_show?tg_id="+scene; + var goods_id=this.data.teamlist.goods_id; + var url="/pages/team/team_show/team_show?tg_id="+scene+"&goods_id"+goods_id; //--分享图片-- var img=th.data.iurl+th.data.teamlist.share_imgurl; //--把会员分享出去-- @@ -828,7 +836,6 @@ Page({ if(th.data.teamlist.share_title){ share_title=th.data.teamlist.share_title; } - console.log(url,3000); return { path:url, title: share_title,