diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index ebadaab..26e77cf 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -280,22 +280,17 @@ Page({ surplus: 0, canBuy: false, - + btnHidden: false, }, //------初始化加载---------- onLoad: function (t) { - - + + if(t && t.group_id) { - // wx.setStorage({ - // key: 'group_id', - // data: t.group_id, - // }); this.data.group_id = t.group_id; }; - - + var ee = this, @@ -757,6 +752,63 @@ Page({ return false; } + // 判断活动是否暂停 + //获取单个活动成团信息 + await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', { + data: { + store_id: o.stoid, + is_end: 0, + timetype: 1, + id: this.data.group_id, + } + }).then(res => { + if (res.data.code == 0) { + console.log('成团信息=======》', res.data.data); + if(res.data.data.pageData && res.data.data.pageData.length == 0) { + let obj = { + day: '00', + hou: '00', + min: '00', + sec: '00' + }; + + th.setData({ + djs: obj, + isTimeUp: true, + }); + } else { + th.setData({ + luckGoInfo: res.data.data.pageData[0], + team_id: res.data.data.pageData[0].team_id, + luckGoMembers: [], + }); + + th.countDown(th.data.luckGoInfo.end_time, 0); + }; + + } else { + this.data.isTimeUp = true; + th.setData({ + isTimeUp: true, + }); + + }; + + + }); + // 活动暂停显示空白 + if (this.data.isTimeUp) { + wx.showModal({ + title: '提示', + content: '活动已经暂停', + showCancel: false, + success: function(){ + wx.navigateBack(); + } + }) + return false; + } + //优惠券要实时更新 getApp().getConfig2(function (e) { var json_d = JSON.parse(e.switch_list); @@ -825,26 +877,7 @@ Page({ title: t.data.data.goods_name, }); - //-- 判断是不是组合购活动,必须要登录后才能判断 -- - // if (getApp().globalData.userInfo && t.data.data.prom_type == 7) { - // //获取活动信息 - // var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + - // t.data.data.prom_id + "/" + getApp().globalData.user_id; - // getApp().request.get(url, { - // success: function (e) { - // if (e.data.code == 0 && e.data.data) { - // if (ut.gettimestamp() < e.data.data.start_time) { - // return false; - // } - // if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { - // //-- 获取商品列表 -- - // th.setData({ zh_act: e.data.data }); - // } - - // } - // } - // }); - // } + //-- 把商品的赋值 -- ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); @@ -977,45 +1010,8 @@ Page({ } }); this.data.enterAddressPage && (this.data.enterAddressPage = !1); - - // 检查幸运购活动商品库存 - getApp().request.get("/api/weshop/activitylist/getActLen/" + o.stoid + "/9/" + this.data.group_id, { - success: function(res) { - //console.log('当前幸运购活动的剩余库存', res.data.data); - if(res.data.code == 0) { - th.setData({ - // 剩余库存量 - surplus: res.data.data, - }); - }; - // else { - // th.setData({ - // surplus: 0, - // }); - // } - } - }); - - - // 检查是否已经参团购买 - getApp().request.get("/api/weshop/prom/luckyOrder/getUserOrderInfo/" + o.stoid + "/" + oo.user_id + "/" + this.data.group_id, { - success: function(res) { - console.log('当前幸运购活动是否已经参团', res.data.code); - if(res.data.code == 0) { - th.setData({ - showDetails: true, - buyInfo: res.data.data, - }); - } else { - th.setData({ - showDetails: false, - }); - }; - } - }); - - - + + //获取单个活动已成团数量 getApp().request.get(`/api/weshop/prom/luckyTeam/getCtNum/${o.stoid}/${this.data.group_id}`, { success: function (res) { @@ -1026,8 +1022,8 @@ Page({ } } }); - - + + //获取单个活动中奖记录 getApp().request.promiseGet('/api/weshop/prom/luckyOrder/page', { data: { @@ -1059,50 +1055,7 @@ Page({ }); - //获取单个活动成团信息 - await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', { - data: { - store_id: o.stoid, - is_end: 0, - timetype: 1, - id: this.data.group_id, - } - }).then(res => { - if (res.data.code == 0) { - console.log('成团信息=======》', res.data.data); - if(res.data.data.pageData && res.data.data.pageData.length == 0) { - let obj = { - day: '00', - hou: '00', - min: '00', - sec: '00' - }; - - th.setData({ - djs: obj, - isTimeUp: true, - }); - } else { - th.setData({ - luckGoInfo: res.data.data.pageData[0], - team_id: res.data.data.pageData[0].team_id, - luckGoMembers: [], - }); - // wx.setStorage({ - // key: 'team_id', - // data: th.data.team_id, - // }); - th.countDown(th.data.luckGoInfo.end_time, 0); - }; - - } else { - th.setData({ - isTimeUp: true, - }); - }; - - - }); + // 获取购买次数,判断是否已经超出限购 @@ -1142,23 +1095,54 @@ Page({ } }); + var p1 = new Promise((resolve, reject) => { + // 检查幸运购活动商品库存 + getApp().request.get("/api/weshop/activitylist/getActLen/" + o.stoid + "/9/" + this.data.group_id, { + success: function(res) { + //console.log('当前幸运购活动的剩余库存', res.data.data); + if(res.data.code == 0) { + th.setData({ + // 剩余库存量 + surplus: res.data.data, + }); + }; + resolve(); + } + }); + + }); + + var p2 = new Promise((resolve, reject) => { + // 检查是否已经参团购买 + getApp().request.get("/api/weshop/prom/luckyOrder/getUserOrderInfo/" + o.stoid + "/" + oo.user_id + "/" + this.data.group_id, { + success: function(res) { + console.log('当前幸运购活动是否已经参团', res.data.code); + if(res.data.code == 0) { + th.setData({ + showDetails: true, + buyInfo: res.data.data, + }); + } else { + th.setData({ + showDetails: false, + }); + }; + resolve(); + } + }); + + }); + + Promise.all([p1, p2]).then(res => { + th.setData({ + btnHidden: true, + }); + }); - - - - - - - }, - // 暂时无用 - // enterAddress: function () { - // this.data.enterAddressPage = !0, wx.navigateTo({ - // url: "/pages/user/address_list/address_list?operate=selectAddress" - // }); - // }, + // 页面卸载 @@ -1185,11 +1169,7 @@ Page({ 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); }, - // tabClick2: function (t) { - // this.setData({ - // activeCategoryId2: t.currentTarget.id - // }); - // }, + // 点击评价选项卡下的各评价按钮 @@ -1288,19 +1268,7 @@ Page({ th.setData({ open_ind_store: ind }); - //如果是秒杀的话,要看redis够不够 - // if (this.data.prom_type == 1) { - // this.getactLen(function (num) { - // if (num < th.data.goodsInputNum) { - // getApp().my_warnning("秒杀库存不足!", 0, th); - // return false; - // } else { - // th.add_cart_func(t); - // } - // }); - // } else { - // th.add_cart_func(t); - // } + th.add_cart_func(t); }, @@ -3755,35 +3723,7 @@ Page({ } // console.log('cd'); } else { - // if (th.data.prom_st == 0) { - // //var endTime2 = new Date(th.data.prom_end_time).getTime(); - // var endTime2 = th.data.prom_act.end_time; - // th.setData({ - // prom_time_text: '距结束还剩:', - // prom_st: 1 - // }) - // setTimeout(function () { - // th.countDown(endTime2) - // }, 1000); - // return false; - - // } else { - // //活动已结束,全部设置为'00' - // obj = { - // day: '00', - // hou: '00', - // min: '00', - // sec: '00' - // } - // th.setData({ - // prom_time_text: '活动已经结束:', - // prom_st: 3 - // }) - // th.setData({ - // djs: obj - // }); - // return false; - // } + obj = { diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml index 68bbe47..5031964 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml @@ -920,12 +920,12 @@ - 活动已经结束 + 活动已经结束 - 查看详情 - 已经抢光了 - 已超限购次数 - 立即参团 + 查看详情 + 已经抢光了 + 已超限购次数 + 立即参团