From 567644cfb2574d12341b1a0d6bbfa3af860a1057 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Mon, 15 Apr 2024 10:03:39 +0800 Subject: [PATCH] 团购活动 指定用户参与 --- components/diy_goodsGroup/diy_goodsGroup.js | 3 +++ components/diy_serviceCard/diy_serviceCard.js | 3 +++ packageA/pages/distribution/shop/shop.wxml | 2 +- packageG/pages/group_buy/goodsInfo/goodsInfo.js | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------ pages/goods/categoryList/categoryList.js | 10 ++++++---- pages/goods/goodsInfo/goodsInfo.js | 20 +++++++++++++++----- pages/template/index.json | 3 ++- pages/template/index.wxml | 6 ++++++ 8 files changed, 87 insertions(+), 59 deletions(-) diff --git a/components/diy_goodsGroup/diy_goodsGroup.js b/components/diy_goodsGroup/diy_goodsGroup.js index e2e09f2..022730d 100644 --- a/components/diy_goodsGroup/diy_goodsGroup.js +++ b/components/diy_goodsGroup/diy_goodsGroup.js @@ -541,6 +541,9 @@ Component({ th.data.requestData.push(item); }) } else { + item.prom_type = 0; + item.prom_id = 0; + item.prom_price = null; th.data.requestData.push(item); } } diff --git a/components/diy_serviceCard/diy_serviceCard.js b/components/diy_serviceCard/diy_serviceCard.js index 4049c6f..c243e24 100644 --- a/components/diy_serviceCard/diy_serviceCard.js +++ b/components/diy_serviceCard/diy_serviceCard.js @@ -508,6 +508,9 @@ Component({ case 1: url+="&prom_type=1&prom_id="+arr[0].act_id; break; + case 2: + url="/packageG/pages/group_buy/goodsInfo/goodsInfo?goods_id="+gid+"&prom_id="+arr2[0].act_id; + break; case 6: url = `/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?goods_id=${gid}&prom_type=${arr2[0].prom_type}&prom_id=${arr[0].act_id}`; break; diff --git a/packageA/pages/distribution/shop/shop.wxml b/packageA/pages/distribution/shop/shop.wxml index 1fa8aac..9ddfef6 100644 --- a/packageA/pages/distribution/shop/shop.wxml +++ b/packageA/pages/distribution/shop/shop.wxml @@ -235,7 +235,7 @@ {{item.goods_name}} - + {{item.prom_integral}} diff --git a/packageG/pages/group_buy/goodsInfo/goodsInfo.js b/packageG/pages/group_buy/goodsInfo/goodsInfo.js index b1cb093..97e2e11 100644 --- a/packageG/pages/group_buy/goodsInfo/goodsInfo.js +++ b/packageG/pages/group_buy/goodsInfo/goodsInfo.js @@ -871,60 +871,63 @@ Page({ var boughtNum = 0; var is_ok = 1; - // 获取redis当前可以购买的数量 - // 如果数量为0,设置和显示已抢光 - // 否则,进一步判断是否超出限购或超出库存 - await this.getactLen().then(async function (res) { - redisNums = res; - let curNum = th.data.goodsInputNum; - // res: redis可购买数量 - console.log('当前可以购买的数量:', res); - if (res <= 0) { - // 可购买数量<=0, 设置和显示已抢光 - th.setData({ - prom_r_null: 1, - }); - getApp().my_warnning('超出活动库存', 0, self); - is_ok = 0; - return false; - } else { - - if(curNum>redisNums){ + if(this.data.prom_type == 2) { + + // 获取redis当前可以购买的数量 + // 如果数量为0,设置和显示已抢光 + // 否则,进一步判断是否超出限购或超出库存 + await this.getactLen().then(async function (res) { + redisNums = res; + let curNum = th.data.goodsInputNum; + // res: redis可购买数量 + console.log('当前可以购买的数量:', res); + if (res <= 0) { + // 可购买数量<=0, 设置和显示已抢光 + th.setData({ + prom_r_null: 1, + }); getApp().my_warnning('超出活动库存', 0, self); is_ok = 0; return false; - } - // 可购买数量>0 - // 计算自己还可以购买的数量 - // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b - // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 - // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 - let actInfo = th.data.sele_g; - if(actInfo.buy_limit>0){ - await th.get_buy_num2().then(function (data) { - let limited = actInfo.buy_limit; // 限购数量a - let promcardbuynum = data.data.data.promcardbuynum; - let canBuyNum = limited - promcardbuynum; // 自己还可购买的数量c - - limitNum = limited; - boughtNum = promcardbuynum; + } else { - if (canBuyNum <= 0) { - canBuyNum = 0; - } + if (curNum > redisNums) { + getApp().my_warnning('超出活动库存', 0, self); + is_ok = 0; + return false; + } + // 可购买数量>0 + // 计算自己还可以购买的数量 + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 + let actInfo = th.data.sele_g; + if (actInfo.buy_limit > 0) { + await th.get_buy_num2().then(function (data) { + let limited = actInfo.buy_limit; // 限购数量a + let promcardbuynum = data.data.data.promcardbuynum; + let canBuyNum = limited - promcardbuynum; // 自己还可购买的数量c + + limitNum = limited; + boughtNum = promcardbuynum; + + if (canBuyNum <= 0) { + canBuyNum = 0; + } - if (curNum > canBuyNum) { - getApp().my_warnning('超出限购数量', 0, self); - th.setData({ - goodsInputNum: canBuyNum || 1, - }); - is_ok = 0; - return false; - } - }) + if (curNum > canBuyNum) { + getApp().my_warnning('超出限购数量', 0, self); + th.setData({ + goodsInputNum: canBuyNum || 1, + }); + is_ok = 0; + return false; + } + }) + } } - } - }) + }) + } if (!is_ok) return false; diff --git a/pages/goods/categoryList/categoryList.js b/pages/goods/categoryList/categoryList.js index 844176f..204cc45 100644 --- a/pages/goods/categoryList/categoryList.js +++ b/pages/goods/categoryList/categoryList.js @@ -1068,10 +1068,11 @@ Page({ requestGoodsList: function (t) { var that = this; + var user=getApp().globalData.user_id || 0; that.data.requestUrl = t; console.error(666666); - e.get("/api/weshop/goods/page?1=1", { - data: { page: that.data.stylePage, cat_id: that.data.cat_id, parent_id: 0, orderField: 'sort', orderType: 'asc', is_mainshow: 1, isonsale: 1, store_id: oo.stoid, is_recommend: 1 }, + e.get("/api/weshop/goods/page?1=1&isnewwhere=1", { + data: { page: that.data.stylePage, cat_id: that.data.cat_id, parent_id: 0, orderField: 'sort', orderType: 'asc', is_mainshow: 1, isonsale: 1, store_id: oo.stoid, is_recommend: 1,user_id:user_id }, success: function (data) { console.log(data.data.data.pageData) that.setData({ @@ -1173,8 +1174,9 @@ Page({ console.log("cid:=" + cid) console.log("cid:=" + this.data.cat_id); var s = this - e.get("/api/weshop/goods/page?1=1", { - data: { page: page, cat_id: cid, parent_id: 0, orderField: 'sort', orderType: 'asc', is_mainshow: 1, isonsale: 1, store_id: oo.stoid, is_recommend: 1 }, + var user_id=getApp().globalData.user_id || 0; + e.get("/api/weshop/goods/page?1=1&isnewwhere=1", { + data: { page: page, cat_id: cid, parent_id: 0, orderField: 'sort', orderType: 'asc', is_mainshow: 1, isonsale: 1, store_id: oo.stoid, is_recommend: 1,user_id:user_id }, success: function (e) { console.log('上拉加载。。。。。。。。。'); console.log(e.data.data.pageData) diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index da6d5b1..018b237 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -4771,7 +4771,7 @@ Page({ prom_r_null: 1 }); //拿取价格并且判断时间-- - getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gid + "/" + prom_id, { + getApp().request.get("/api/weshop/goods/groupBuy/getNewActInfo/" + os.stoid + "/" + gid + "/" + prom_id+"/"+user_id, { success: function (t) { if (t.data.code != 0) { ee.get_normal(gid); @@ -9027,10 +9027,20 @@ Page({ }, get_normal(gid) { - this.setData({ - prom_type: 0, - isshow: 1, - }); + + var set_ob={}; + if (this.data.data.pick_up_lists && this.data.data.pick_up_lists.length) { + set_ob={ + ['data.pickup_ids']:this.data.data.pick_up_lists, + ['sele_g.pickup_ids']:this.data.data.pick_up_lists, + ['front_g.pickup_ids']:this.data.data.pick_up_lists, + } + } + set_ob.prom_type= 0; + set_ob.isshow=1; + this.setData(set_ob); + + this.get_sku(os.stoid, this.data.data, gid); this.get_sto(); if (!this.data.data.whsle_id) diff --git a/pages/template/index.json b/pages/template/index.json index 531a4b1..33c2a73 100644 --- a/pages/template/index.json +++ b/pages/template/index.json @@ -27,7 +27,8 @@ "floatingWindow": "/components/diy_floatingWindow/diy_floatingWindow", "floatingBox": "/components/diy_floatingBox/diy_floatingBox", "div_tab_bar": "/custom-tab-bar/index", - "presell": "/components/diy_pregoods/diy_pregoods" + "presell": "/components/diy_pregoods/diy_pregoods", + "serviceCard": "/components/diy_serviceCard/diy_serviceCard" }, "enablePullDownRefresh": false, "onReachBottomDistance":300, diff --git a/pages/template/index.wxml b/pages/template/index.wxml index 1dc39a4..a054ced 100644 --- a/pages/template/index.wxml +++ b/pages/template/index.wxml @@ -177,6 +177,12 @@ + + + + + + -- libgit2 0.21.4