From 3f4f6cf43bbe605742e89a1f88b8eea3f2465b7b Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 15 Jun 2022 10:07:45 +0800 Subject: [PATCH] 同城配送的bug优化2条 --- pages/cart/cart2/cart2.js | 61 +++++++++++++++++++++++++++++++++++++++++++------------------ pages/cart/cart2/cart2.wxml | 4 ++-- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 3e821e5..1fe027b 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -1510,7 +1510,7 @@ Page({ }, //-------------------计算订单价格------------------- - calculatePrice:async function (t, s) { + calculatePrice:async function (qfunc) { var th = this; th.setData({submit:1}); @@ -1953,7 +1953,7 @@ Page({ var req_data={ - store_id:os.stoid, order_amount:o_condition, + store_id:os.stoid, order_amount:t_o_condition, lon:lon,lat:lat, pickup_id:c_arr[i].pickup_id, goods_weight:gd_w } var is_next=1; @@ -1964,11 +1964,15 @@ Page({ cart_item.shipping_price = res.data.data; }else{ is_next=0; - wx.showToast({ - title: res.data.msg, - icon: 'none', - duration: 2000 - }) + + if(qfunc) qfunc(); + else{ + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 2000 + }) + } } }) if(!is_next) return false @@ -2136,7 +2140,7 @@ Page({ //---------计算立即购买---------- - calculatePrice2: async function () { + calculatePrice2: async function (qfunc) { var th = this, good = this.data.bn_goods; if (!good) return false; @@ -2455,18 +2459,20 @@ Page({ is_json: 1,data: req_data }).then(res => { if (res.data.code == 0) { - - var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: res.data.data, }) }else{ is_next=0; - wx.showToast({ - title: res.data.msg, - icon: 'none', - duration: 2000 - }) + if(qfunc){ + qfunc(); + }else{ + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 2000 + }) + } } }) @@ -3907,7 +3913,9 @@ Page({ }, //----把券插入之后的操作,同时还要重新计算价格---- - insert_into_using_quan: function (item, using_quan, pickid, isby) { + insert_into_using_quan:async function (item, using_quan, pickid, isby) { + + var th = this; if (isby == 1) { using_quan[pickid] = { @@ -3924,9 +3932,26 @@ Page({ } this.setData({ using_quan: using_quan }); if (th.data.is_b_now == 1) { - th.calculatePrice2(); + th.calculatePrice2(function () { + using_quan[pickid]=null; + th.setData({ using_quan: using_quan,submit:0 }); + wx.showToast({ + title: "不能使用优惠券,同城起送价不足", + icon: 'none', + duration: 2000 + }) + + }); } else { - th.calculatePrice(); + th.calculatePrice(function () { + using_quan[pickid]=null; + th.setData({ using_quan: using_quan ,submit:0 }); + wx.showToast({ + title: "不能使用优惠券,同城起送价不足", + icon: 'none', + duration: 2000 + }) + }); } th.setData({ open_quan: 0 }); }, diff --git a/pages/cart/cart2/cart2.wxml b/pages/cart/cart2/cart2.wxml index 4356d5d..4cb6d0c 100644 --- a/pages/cart/cart2/cart2.wxml +++ b/pages/cart/cart2/cart2.wxml @@ -166,7 +166,7 @@ - + @@ -182,7 +182,7 @@ - + {{wu_arr[item.wind].name}} -- libgit2 0.21.4