From 33964552ae9ed38b2a820f59bbe7319394fcaa51 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Sat, 9 Oct 2021 14:35:44 +0800 Subject: [PATCH] 预售的限购问题优化问题完成 --- packageC/pages/presell/cart/cart.js | 17 +++++++++++++++-- packageC/pages/presell/cart/cart.wxml | 5 ++--- packageC/pages/presell/goodsInfo/goodsInfo.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 96c9768..41fb3eb 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -423,10 +423,11 @@ Page({ //------获取预售主表---------- await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell.prom_id, {}).then(res => { if (res.data.code == 0 && res.data.data) { + act=res.data.data; + th.setData({ act: res.data.data, }); - } }) @@ -487,6 +488,17 @@ Page({ } } + + var g_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+order_goods.goods_id+"&pre_id="+pre_arr.id; + if(act.is_end || th.data.act.end_time { goods = res.data.data; @@ -584,7 +596,8 @@ Page({ order_goods:order_goods, all_price:pre_arr.presell_price*order_goods.goods_num, pickup_id:pickup.pickup_id, - send_time:send_time + send_time:send_time, + g_url:g_url }); th.get_diff(); //统一进行计算金额 diff --git a/packageC/pages/presell/cart/cart.wxml b/packageC/pages/presell/cart/cart.wxml index a77b892..32475a2 100644 --- a/packageC/pages/presell/cart/cart.wxml +++ b/packageC/pages/presell/cart/cart.wxml @@ -177,12 +177,11 @@ {{pickup.pickup_name}} - + - + {{goods.goods_name}} diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index 7633cee..d43cea2 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -2372,47 +2372,56 @@ Page({ //-------------获取购买数量的总函数---------------- - get_buy_num: function (gd, func) { - var map = this.data.g_buy_num, - th = this, - user_id = getApp().globalData.user_id; - if (user_id == null) { - map.set(gd.goods_id, 0); - th.setData({ - g_buy_num: map, - prom_buy_num: 0, - }); - "function" == typeof func && func(); - return false; - } + get_buy_num: function (gd, func) { + var map = this.data.g_buy_num, + th = this, + user_id = getApp().globalData.user_id; + if (user_id == null) { + map.set(gd.goods_id, 0); + th.setData({ + g_buy_num: map, + prom_buy_num: 0, + }); + "function" == typeof func && func(); + return false; + } - if (map.has(gd.goods_id)) { - "function" == typeof func && func(); - } else { - //----获取商品购买数---- - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { - data: { - store_id: os.stoid, - user_id: user_id, - goods_id: gd.goods_id, - prom_type: gd.prom_type, - prom_id: gd.prom_id - }, - success: function (t) { - if (t.data.code == 0) { - var g_buy_num = t.data.data.goodsbuynum; - map.set(gd.goods_id, g_buy_num); - th.setData({ - g_buy_num: map, - prom_buy_num: t.data.data.goodsbuynum, - }); - "function" == typeof func && func(); + if (map.has(gd.goods_id)) { + "function" == typeof func && func(); + } else { + //----获取商品购买数---- + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { + data: { + store_id: os.stoid, + user_id: user_id, + goods_id: gd.goods_id, + }, + success: function (t) { + if (t.data.code == 0) { + var g_buy_num = t.data.data.goodsbuynum; + map.set(gd.goods_id, g_buy_num); + th.setData({ + g_buy_num: map, + }); + getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum",{ + data: {store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: gd.prom_id}, + success: function (e) { + if (e.data.code == 0) { + th.setData({prom_buy_num: e.data.data.sumgoodsnum}) + "function" == typeof func && func(); + } else { + th.setData({prom_buy_num: 0,}) + "function" == typeof func && func(); + } + + } + }); - } + } + } + }); } - }); - } - }, + }, //--拼单推荐的显示--- tj_Click: function (e) { @@ -3887,7 +3896,6 @@ Page({ } }) - } else { //------获取预售从表---------- await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => { -- libgit2 0.21.4