From b8804951f81b88d003e45c339521dae05b202f42 Mon Sep 17 00:00:00 2001 From: banche Date: Wed, 23 Mar 2022 09:32:38 +0800 Subject: [PATCH] fix修正细节 --- packageA/pages/details_serviceCard/details_serviceCard.js | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 134 insertions(+), 136 deletions(-) diff --git a/packageA/pages/details_serviceCard/details_serviceCard.js b/packageA/pages/details_serviceCard/details_serviceCard.js index c511731..7673ed3 100644 --- a/packageA/pages/details_serviceCard/details_serviceCard.js +++ b/packageA/pages/details_serviceCard/details_serviceCard.js @@ -262,163 +262,161 @@ Page({ } else { var len = details.list.length; - + // 底导航购物车红点显示的数量 + var c_num = 0; + // 多商品 for (let i = 0; i < len; i++) { - - - - var newd = { - // service_id: th.data.data.id, - // service_sn:th.data.data.service_sn, - // service_name:th.data.data.goods_name, - // goods_num: th.data.goodsInputNum, - // pick_id: th.data.sto_sele_id, - // user_id:oo.user_id, - // store_id:os.stoid, - // money:th.data.data.shop_price, - - service_id: details.list[i].card_id, - service_sn: details.list[i].service_sn, - service_name: details.list[i].service_name, - goods_num: details.list[i].qty, - pick_id: details.list[i].pickup_id, - user_id: user_id, - store_id: app.globalData.setting.stoid, - money: details.list[i].price, - }; - if (getApp().globalData.guide_id) { - newd['guide_id'] = getApp().globalData.guide_id; - newd['guide_type'] = 0; - }; - // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价 - if(details.list[0].prom_type == 1) { - newd['prom_type'] = details.list[i].prom_type; - newd['prom_id'] = details.list[i].prom_id; - }; - - var prom_id = details.list[i].prom_id > 0 ? details.list[i].prom_id : 0; - var card_id = details.list[i].card_id; - var prom_type = details.list[i].prom_type > 0 ? details.list[i].prom_type : 0; - var is_pd_normal = details.list[i].is_pd_normal; - // 库存 - var redisNums = 0; - // 限购数 - var limitNum = 0; - // 已购买数量 - var boughtNum = 0; - - // 秒杀活动中购买 - if (prom_type == 1 && !is_pd_normal) { - - // 获取已购数量 - await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+card_id+"&prom_type="+prom_type+"&prom_id="+prom_id, { - }).then(res => { - boughtNum = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum; - }); - - // 获取库存 - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { - if (res.data.code == 0) { - redisNums = !res.data.data ? 0 : res.data.data; - }; - }); + var newd = { + // service_id: th.data.data.id, + // service_sn:th.data.data.service_sn, + // service_name:th.data.data.goods_name, + // goods_num: th.data.goodsInputNum, + // pick_id: th.data.sto_sele_id, + // user_id:oo.user_id, + // store_id:os.stoid, + // money:th.data.data.shop_price, + + service_id: details.list[i].card_id, + service_sn: details.list[i].service_sn, + service_name: details.list[i].service_name, + goods_num: details.list[i].qty, + pick_id: details.list[i].pickup_id, + user_id: user_id, + store_id: app.globalData.setting.stoid, + money: details.list[i].price, + }; + if (getApp().globalData.guide_id) { + newd['guide_id'] = getApp().globalData.guide_id; + newd['guide_type'] = 0; + }; + // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价 + if(details.list[i].prom_type == 1) { + newd['prom_type'] = details.list[i].prom_type; + newd['prom_id'] = details.list[i].prom_id; + }; - // 获取限购数 - - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, {}).then(res => { - if (res.data.code == 0) { - limitNum = res.data.data.buy_limit; - } - }); + var prom_id = details.list[i].prom_id > 0 ? details.list[i].prom_id : 0; + var card_id = details.list[i].card_id; + var prom_type = details.list[i].prom_type > 0 ? details.list[i].prom_type : 0; + var is_pd_normal = details.list[i].is_pd_normal; + // 库存 + var redisNums = 0; + // 限购数 + var limitNum = 0; + // 已购买数量 + var boughtNum = 0; + + // 秒杀活动中购买 + if (prom_type == 1 && !is_pd_normal) { + + // 获取已购数量 + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+card_id+"&prom_type="+prom_type+"&prom_id="+prom_id, { + }).then(res => { + boughtNum = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum; + }); + + // 获取库存 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { + if (res.data.code == 0) { + redisNums = !res.data.data ? 0 : res.data.data; + }; + }); - var snum = limitNum - boughtNum; - if (snum <= 0) { - wx.showModal({ - title: '超出限购数量', + // 获取限购数 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, {}).then(res => { + if (res.data.code == 0) { + limitNum = res.data.data.buy_limit; + } }); - return false; - } - } + var snum = limitNum - boughtNum; + if (snum <= 0) { + wx.showModal({ + title: '超出限购数量', + }); + return false; + } + } - //----先看会员在购物车中是否加入了该商品----- - app.request.get("/api/weshop/cartService/page", { - data: { - store_id: app.globalData.setting.stoid, - user_id: user_id, - service_id: details.list[0].card_id, - pick_id: details.list[0].pickup_id, - }, - success: function(re) { - //-------如果购物车中有相关的数据--------- - if (re.data.data.total > 0) { - var item = re.data.data.pageData[0]; - var totalNum = details.list[i].qty + item.goods_num; - - if (prom_type == 1 && !is_pd_normal) { - // 秒杀购物车购买 修正数量 - var snum = limitNum - boughtNum; - if (totalNum >= redisNums){ - if (redisNums > snum) { - totalNum = snum; - } else { - totalNum = redisNums; - } - } else { - if (totalNum > snum) - totalNum = snum; + //----先看会员在购物车中是否加入了该商品----- + app.request.get("/api/weshop/cartService/page", { + data: { + store_id: app.globalData.setting.stoid, + user_id: user_id, + service_id: details.list[i].card_id, + pick_id: details.list[i].pickup_id, + }, + success: function(re) { + //-------如果购物车中有相关的数据--------- + if (re.data.data.total > 0) { + var item = re.data.data.pageData[0]; + var totalNum = details.list[i].qty + item.goods_num; + + if (prom_type == 1 && !is_pd_normal) { + // 秒杀购物车购买 修正数量 剩余购买数量 + var snum = limitNum - boughtNum; + + if (totalNum >= redisNums){ + if (redisNums > snum) { + totalNum = snum; + } else { + totalNum = redisNums; + } + } else { + if (totalNum > snum) + totalNum = snum; + } } - } - var updata = { - id: item.id, - goods_num: totalNum, - money: details.list[i].price, - store_id: app.globalData.setting.stoid, - }; + var updata = { + id: item.id, + goods_num: totalNum, + money: details.list[i].price, + store_id: app.globalData.setting.stoid, + }; - if (getApp().globalData.guide_id) { - updata['guide_id'] = getApp().globalData.guide_id; - updata['guide_type'] = 1; - } + if (getApp().globalData.guide_id) { + updata['guide_id'] = getApp().globalData.guide_id; + updata['guide_type'] = 1; + } - getApp().request.put("/api/weshop/cartService/update", { - data: updata, - success: function(t) { - // getApp().my_warnning('加入购物车成功', 1, th, 450); - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; - th.setData({ - cartGoodsNum: c_num + getApp().request.put("/api/weshop/cartService/update", { + data: updata, + success: function(t) { + // getApp().my_warnning('加入购物车成功', 1, th, 450); + c_num += th.data.cartGoodsNum + th.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num + }); + + // th.closeSpecModal(); + } }); - app.goto('/pages/cart/cart/cart'); - // th.closeSpecModal(); - } - }); - } else { + } else { - getApp().request.post("/api/weshop/cartService/save", { - data: newd, - success: function(t) { - // getApp().my_warnning('加入购物车成功', 1, th, 450); - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; - th.setData({ - cartGoodsNum: c_num + getApp().request.post("/api/weshop/cartService/save", { + data: newd, + success: function(t) { + // getApp().my_warnning('加入购物车成功', 1, th, 450); + c_num += th.data.cartGoodsNum + th.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num + }); + + // th.closeSpecModal(); + } }); - app.goto('/pages/cart/cart/cart'); - // th.closeSpecModal(); } - }); - } - } - }); + } + }); } - + app.goto('/pages/cart/cart/cart'); } }, -- libgit2 0.21.4