From d8c18196f1e5fe692272cd0f0d333227ed0dd950 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Sat, 23 Dec 2023 23:28:16 +0800 Subject: [PATCH] 商品详情的优化 --- pages/goods/goodsInfo/goodsInfo.js | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------- utils/util.js | 8 +++++++- 2 files changed, 116 insertions(+), 46 deletions(-) diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index d19f07e..7395f60 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -2742,6 +2742,8 @@ Page({ return false; } + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); + this.setData({ store: 0, choice_sort_store: 0, @@ -4269,15 +4271,18 @@ Page({ } if(this.data.fir_set_sto==1){ - this.data.fir_set_sto=0; - if(th.data.def_pick_store && th.data.def_pick_store.pickup_id){ - let cp_data=JSON.parse(JSON.stringify(th.data.def_pick_store)); - th.setData({ - front_pick:cp_data, - front_only_pk:th.data.only_pk, - front_def_pickpu_list:th.data.def_pickpu_list, - }) - } + this.data.fir_set_sto=0; + var cp_data=null + if(th.data.def_pick_store && th.data.def_pick_store.pickup_id){ + cp_data=JSON.parse(JSON.stringify(th.data.def_pick_store)); + } + th.setData({ + front_pick:cp_data, + front_only_pk:th.data.only_pk, + front_def_pickpu_list:th.data.def_pickpu_list, + front_pickpu_listt:th.data.pickpu_list, + front_all_sto:th.data.all_sto, + }) } }, @@ -7324,8 +7329,8 @@ Page({ var ind = ee.currentTarget.dataset.ind; var isfront = ee.currentTarget.dataset.isfront; - if(isfront) - th.data.isfront=1; + th.data.isfront=0; + if(isfront) th.data.isfront=1; var bconfig = th.data.bconfig; this.setData({ @@ -7346,40 +7351,91 @@ Page({ return false; } - if (!th.data.only_pk && !th.data.def_pickpu_list && !th.data.change) { - // getApp().confirmBox("门店库存不足", null, 25000, !1); - wx.showToast({ - title: '门店库存不足', - icon: 'none', - }); - return false; - } - th.data.change = 0; + if(th.data.isfront==1){ - if (th.data.only_pk && !th.data.only_pk.length) { - // getApp().confirmBox("门店库存不足", null, 25000, !1); - wx.showToast({ - title: '门店库存不足', - icon: 'none', - }); - return false; - } - if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { - // getApp().confirmBox("门店库存不足", null, 25000, !1); - wx.showToast({ - title: '门店库存不足', - icon: 'none', - }); - return false; - } + if (!th.data.front_only_pk && !th.data.front_def_pickpu_list && !th.data.change) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + th.data.change = 0; + + if (th.data.front_only_pk && !th.data.front_only_pk.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + if (th.data.front_def_pickpu_list && !th.data.front_def_pickpu_list.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + + //-- 把默认的数据拿过来,数据传递要用深拷贝 -- + th.setData({ + def_pick_store: ut.deep_cp(th.data.front_pick), + only_pk:ut.deep_cp(th.data.front_only_pk), + def_pickpu_list:ut.deep_cp(th.data.front_def_pickpu_list), + pickpu_list:ut.deep_cp(th.data.front_pickpu_listt), + all_sto:ut.deep_cp(th.data.front_all_sto) + }) + + + this.setData({ + open_ind_store: ind, + store: 1, + openSpecModal: !1, + openSpecModal_pt: !1, + openSpecModal_flash_normal: !1, + }) - //如果开启了,则不在选择门店 - if (th.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store) { return false; + + + }else{ + if (!th.data.only_pk && !th.data.def_pickpu_list && !th.data.change) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + th.data.change = 0; + + if (th.data.only_pk && !th.data.only_pk.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + } + + + if (bconfig && bconfig.is_sort_storage) { wx.getLocation({ type: 'gcj02', @@ -7524,12 +7580,18 @@ Page({ check_the_pick(item, func) { var th = this; var goodsinfo = th.data.sele_g; + + if(th.data.isfront){ + goodsinfo=this.data.front_g; + } + + var erpwareid = goodsinfo.erpwareid; var plist = null; var lock = 0; //---如果是活动的时候,同时不是普通购买--- - if (getApp().is_virtual(th.data.sele_g) || th.data.sele_g.whsle_id || ([1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) > -1 && !th.data.is_normal)) { + if (getApp().is_virtual(goodsinfo) || goodsinfo.whsle_id || ([1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) > -1 && !th.data.is_normal)) { func(); return false; } @@ -7655,19 +7717,13 @@ Page({ } - - - - if (!th.data.sele_g) return false; //判断门店的配送方式是不是匹配 var g_distr_type = th.data.sele_g.distr_type; - if(th.data.isfront==1){ g_distr_type = th.data.data.distr_type; } - if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { wx.showToast({ title: "门店配送方式不匹配,请选择其他门店", @@ -7689,6 +7745,14 @@ Page({ fir_pick_index: 0 }); + + if(th.data.isfront){ + th.setData({ + front_pick: ut.deep_cp(item) + }) + } + + switch (openindstore) { case 1: th.setData({ diff --git a/utils/util.js b/utils/util.js index 77237f9..b20e9d0 100644 --- a/utils/util.js +++ b/utils/util.js @@ -1012,5 +1012,11 @@ module.exports = { wx_back:wx_back, _debounce, calculatewuliu:calculatewuliu, //计算物流的函数进行抽象 - format_content + format_content, + deep_cp:function(e){ + if(!e) return null; + //判断e是不是对象类型 + var new_e = JSON.parse(JSON.stringify(e)); + return new_e; + } }; -- libgit2 0.21.4