From cce898e3f7da7a8db591d7361682eb77d353516e Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 9 Aug 2023 11:40:29 +0800 Subject: [PATCH] 商品详情页面的优化 --- pages/goods/goodsInfo/goodsInfo.js | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index b86cca8..1211e2a 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -273,6 +273,7 @@ Page({ cx_prom_group: [], //促销活动,用于显示和判断默认要用什么促销活动 showFold:true, new_share_imgurl:'', //普通商品分享图片 + }, //------初始化加载---------- @@ -846,28 +847,29 @@ Page({ }); var ee = JSON.parse(JSON.stringify(e)); - //--定时器推迟一下-- - setTimeout(function () { - if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; - //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对-- - if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) { - ee.is_no_dis = 1; - } - //-- 如果有指定门店的时候,pickup_ids是经过判断是不是普通商品后才会有的 -- - if(th.data.sele_g && th.data.sele_g.pickup_ids){ + //--定时器推迟一下-- + var appd = getApp().globalData; + var w_time = setInterval(function () { + if (that.data.is_get_local_ok == 0) return false; + if (!that.data.sele_g) return false; + + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; + //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对-- + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) { + ee.is_no_dis = 1; + } + + //-- 如果有指定门店的时候,pickup_ids是经过判断是不是普通商品后才会有的 -- + if(th.data.sele_g && th.data.sele_g.pickup_ids && th.data.prom_type==0){ var idx=th.data.sele_g.pickup_ids.findIndex(function (e){ - return e.pickup_id==ee.pickup_id; + return e.pickup_id==ee.pickup_id; }) if(idx<0){ - ee.is_no_dis=1; + ee.is_no_dis_nor=1; } - } - + } - var appd = getApp().globalData; - var w_time = setInterval(function () { - if (that.data.is_get_local_ok == 0) return false; clearInterval(w_time); var distance = null; var e = JSON.parse(JSON.stringify(ee)); @@ -910,8 +912,8 @@ Page({ that.set_def_storage(e); } } - }, 500) - }, 700) + }, 200) + }); }, @@ -3418,13 +3420,17 @@ Page({ prom = res.data.data; } }) - let times = new Date().getTime() - prom.show_time_off = "" - let atimes = prom.start_time * 1000 - if (atimes > times) { - prom.show_time_off = ut.formatTime(prom.start_time) + if(prom){ + let times = new Date().getTime() + prom.show_time_off = "" + let atimes = prom.start_time * 1000 + + if (atimes > times) { + prom.show_time_off = ut.formatTime(prom.start_time) + } } + } console.log('活动详情------------'); console.log(prom); @@ -3515,6 +3521,8 @@ Page({ var timer_get = setInterval(function () { if (th.data.is_get_local_ok == 0) return false; + if (!th.data.fir_def_store) return false; + var dd = null, i = getApp().request; if (!th.data.sele_g) return false; @@ -3564,12 +3572,13 @@ Page({ var pickup_ids=th.data.sele_g.pickup_ids; //指定门店判断, 不是普通购买的时候,秒杀的时候,秒杀有指定门店 - if(is_normal==0 && th.data.prom_type==1 && th.data.prom_act.pickup_ids){ - pickup_ids=th.data.prom_act.pickup_ids + if(!is_normal && th.data.prom_type==1 && th.data.prom_act.pick_up_lists){ + pickup_ids=th.data.prom_act.pick_up_lists } //-- 如果有指定门店的时候 -- if(pickup_ids){ + var ok_arr=[]; for (let i in e.data.data.pageData) { let ite = e.data.data.pageData[i]; @@ -3586,16 +3595,12 @@ Page({ if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ //-- 查找一下门店有没有在 -- - var idx1=th.data.sele_g.pickup_ids.findIndex(function (e){ + var idx1=pickup_ids.findIndex(function (e){ return e.pickup_id==th.data.def_pick_store.pickup_id; }) if(idx1<0){ th.data.def_pick_store.is_no_dis_nor=1; - //-- 如果不是活动的普通购买的时候 -- - if(!th.data.is_normal){ - th.data.def_pick_store.is_no_dis=1; - } that.setData({ def_pick_store: th.data.def_pick_store }) @@ -4038,6 +4043,7 @@ Page({ var def_pick_store = th.data.def_pick_store; var plist = res.data.data.pageData; + if (th.data.sales_rules == 3) { var lock_num = 0; var Qty = 0; @@ -4060,6 +4066,14 @@ Page({ is_find_def_store = 1; } + //-- 如果库存为0就要重新赋值 -- + def_pick_store.CanOutQty=Qty; + th.setData({ + def_pick_store + }) + + + } else { th.setData({ all_sto: null, @@ -4085,6 +4099,13 @@ Page({ if (n_item.CanOutQty > lock_num) { o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; new_list.push(o_plist[kk]); + + var ck_store=th.data.fir_def_store; + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ + ck_store=th.data.def_pick_store; + } + + //--如果找到默认门店,同时也应该判断配送方式对不对-- if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; @@ -4094,6 +4115,13 @@ Page({ }) is_find_def_store = 1; } + + //-- 如果库存为0就要重新赋值 -- + if(n_item.StorageNo ==def_pick_store.pickup_no) { + def_pick_store.CanOutQty= o_plist[kk].CanOutQty; + th.setData({ def_pick_store }) + } + } break; } -- libgit2 0.21.4