Commit cce898e3f7da7a8db591d7361682eb77d353516e

Authored by yvan.ni
1 parent f3080613

商品详情页面的优化

pages/goods/goodsInfo/goodsInfo.js
@@ -273,6 +273,7 @@ Page({ @@ -273,6 +273,7 @@ Page({
273 cx_prom_group: [], //促销活动,用于显示和判断默认要用什么促销活动 273 cx_prom_group: [], //促销活动,用于显示和判断默认要用什么促销活动
274 showFold:true, 274 showFold:true,
275 new_share_imgurl:'', //普通商品分享图片 275 new_share_imgurl:'', //普通商品分享图片
  276 +
276 }, 277 },
277 278
278 //------初始化加载---------- 279 //------初始化加载----------
@@ -846,28 +847,29 @@ Page({ @@ -846,28 +847,29 @@ Page({
846 }); 847 });
847 848
848 var ee = JSON.parse(JSON.stringify(e)); 849 var ee = JSON.parse(JSON.stringify(e));
849 - //--定时器推迟一下--  
850 - setTimeout(function () {  
851 - if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;  
852 - //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对--  
853 - if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) {  
854 - ee.is_no_dis = 1;  
855 - }  
856 850
857 - //-- 如果有指定门店的时候,pickup_ids是经过判断是不是普通商品后才会有的 --  
858 - if(th.data.sele_g && th.data.sele_g.pickup_ids){ 851 + //--定时器推迟一下--
  852 + var appd = getApp().globalData;
  853 + var w_time = setInterval(function () {
  854 + if (that.data.is_get_local_ok == 0) return false;
  855 + if (!that.data.sele_g) return false;
  856 +
  857 + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
  858 + //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对--
  859 + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) {
  860 + ee.is_no_dis = 1;
  861 + }
  862 +
  863 + //-- 如果有指定门店的时候,pickup_ids是经过判断是不是普通商品后才会有的 --
  864 + if(th.data.sele_g && th.data.sele_g.pickup_ids && th.data.prom_type==0){
859 var idx=th.data.sele_g.pickup_ids.findIndex(function (e){ 865 var idx=th.data.sele_g.pickup_ids.findIndex(function (e){
860 - return e.pickup_id==ee.pickup_id; 866 + return e.pickup_id==ee.pickup_id;
861 }) 867 })
862 if(idx<0){ 868 if(idx<0){
863 - ee.is_no_dis=1; 869 + ee.is_no_dis_nor=1;
864 } 870 }
865 - }  
866 - 871 + }
867 872
868 - var appd = getApp().globalData;  
869 - var w_time = setInterval(function () {  
870 - if (that.data.is_get_local_ok == 0) return false;  
871 clearInterval(w_time); 873 clearInterval(w_time);
872 var distance = null; 874 var distance = null;
873 var e = JSON.parse(JSON.stringify(ee)); 875 var e = JSON.parse(JSON.stringify(ee));
@@ -910,8 +912,8 @@ Page({ @@ -910,8 +912,8 @@ Page({
910 that.set_def_storage(e); 912 that.set_def_storage(e);
911 } 913 }
912 } 914 }
913 - }, 500)  
914 - }, 700) 915 + }, 200)
  916 +
915 }); 917 });
916 }, 918 },
917 919
@@ -3418,13 +3420,17 @@ Page({ @@ -3418,13 +3420,17 @@ Page({
3418 prom = res.data.data; 3420 prom = res.data.data;
3419 } 3421 }
3420 }) 3422 })
3421 - let times = new Date().getTime()  
3422 - prom.show_time_off = ""  
3423 - let atimes = prom.start_time * 1000  
3424 3423
3425 - if (atimes > times) {  
3426 - prom.show_time_off = ut.formatTime(prom.start_time) 3424 + if(prom){
  3425 + let times = new Date().getTime()
  3426 + prom.show_time_off = ""
  3427 + let atimes = prom.start_time * 1000
  3428 +
  3429 + if (atimes > times) {
  3430 + prom.show_time_off = ut.formatTime(prom.start_time)
  3431 + }
3427 } 3432 }
  3433 +
3428 } 3434 }
3429 console.log('活动详情------------'); 3435 console.log('活动详情------------');
3430 console.log(prom); 3436 console.log(prom);
@@ -3515,6 +3521,8 @@ Page({ @@ -3515,6 +3521,8 @@ Page({
3515 3521
3516 var timer_get = setInterval(function () { 3522 var timer_get = setInterval(function () {
3517 if (th.data.is_get_local_ok == 0) return false; 3523 if (th.data.is_get_local_ok == 0) return false;
  3524 + if (!th.data.fir_def_store) return false;
  3525 +
3518 var dd = null, 3526 var dd = null,
3519 i = getApp().request; 3527 i = getApp().request;
3520 if (!th.data.sele_g) return false; 3528 if (!th.data.sele_g) return false;
@@ -3564,12 +3572,13 @@ Page({ @@ -3564,12 +3572,13 @@ Page({
3564 var pickup_ids=th.data.sele_g.pickup_ids; 3572 var pickup_ids=th.data.sele_g.pickup_ids;
3565 3573
3566 //指定门店判断, 不是普通购买的时候,秒杀的时候,秒杀有指定门店 3574 //指定门店判断, 不是普通购买的时候,秒杀的时候,秒杀有指定门店
3567 - if(is_normal==0 && th.data.prom_type==1 && th.data.prom_act.pickup_ids){  
3568 - pickup_ids=th.data.prom_act.pickup_ids 3575 + if(!is_normal && th.data.prom_type==1 && th.data.prom_act.pick_up_lists){
  3576 + pickup_ids=th.data.prom_act.pick_up_lists
3569 } 3577 }
3570 3578
3571 //-- 如果有指定门店的时候 -- 3579 //-- 如果有指定门店的时候 --
3572 if(pickup_ids){ 3580 if(pickup_ids){
  3581 +
3573 var ok_arr=[]; 3582 var ok_arr=[];
3574 for (let i in e.data.data.pageData) { 3583 for (let i in e.data.data.pageData) {
3575 let ite = e.data.data.pageData[i]; 3584 let ite = e.data.data.pageData[i];
@@ -3586,16 +3595,12 @@ Page({ @@ -3586,16 +3595,12 @@ Page({
3586 if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ 3595 if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){
3587 3596
3588 //-- 查找一下门店有没有在 -- 3597 //-- 查找一下门店有没有在 --
3589 - var idx1=th.data.sele_g.pickup_ids.findIndex(function (e){ 3598 + var idx1=pickup_ids.findIndex(function (e){
3590 return e.pickup_id==th.data.def_pick_store.pickup_id; 3599 return e.pickup_id==th.data.def_pick_store.pickup_id;
3591 }) 3600 })
3592 3601
3593 if(idx1<0){ 3602 if(idx1<0){
3594 th.data.def_pick_store.is_no_dis_nor=1; 3603 th.data.def_pick_store.is_no_dis_nor=1;
3595 - //-- 如果不是活动的普通购买的时候 --  
3596 - if(!th.data.is_normal){  
3597 - th.data.def_pick_store.is_no_dis=1;  
3598 - }  
3599 that.setData({ 3604 that.setData({
3600 def_pick_store: th.data.def_pick_store 3605 def_pick_store: th.data.def_pick_store
3601 }) 3606 })
@@ -4038,6 +4043,7 @@ Page({ @@ -4038,6 +4043,7 @@ Page({
4038 4043
4039 var def_pick_store = th.data.def_pick_store; 4044 var def_pick_store = th.data.def_pick_store;
4040 var plist = res.data.data.pageData; 4045 var plist = res.data.data.pageData;
  4046 +
4041 if (th.data.sales_rules == 3) { 4047 if (th.data.sales_rules == 3) {
4042 var lock_num = 0; 4048 var lock_num = 0;
4043 var Qty = 0; 4049 var Qty = 0;
@@ -4060,6 +4066,14 @@ Page({ @@ -4060,6 +4066,14 @@ Page({
4060 is_find_def_store = 1; 4066 is_find_def_store = 1;
4061 } 4067 }
4062 4068
  4069 + //-- 如果库存为0就要重新赋值 --
  4070 + def_pick_store.CanOutQty=Qty;
  4071 + th.setData({
  4072 + def_pick_store
  4073 + })
  4074 +
  4075 +
  4076 +
4063 } else { 4077 } else {
4064 th.setData({ 4078 th.setData({
4065 all_sto: null, 4079 all_sto: null,
@@ -4085,6 +4099,13 @@ Page({ @@ -4085,6 +4099,13 @@ Page({
4085 if (n_item.CanOutQty > lock_num) { 4099 if (n_item.CanOutQty > lock_num) {
4086 o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; 4100 o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num;
4087 new_list.push(o_plist[kk]); 4101 new_list.push(o_plist[kk]);
  4102 +
  4103 + var ck_store=th.data.fir_def_store;
  4104 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){
  4105 + ck_store=th.data.def_pick_store;
  4106 + }
  4107 +
  4108 +
4088 //--如果找到默认门店,同时也应该判断配送方式对不对-- 4109 //--如果找到默认门店,同时也应该判断配送方式对不对--
4089 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)) { 4110 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)) {
4090 th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; 4111 th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num;
@@ -4094,6 +4115,13 @@ Page({ @@ -4094,6 +4115,13 @@ Page({
4094 }) 4115 })
4095 is_find_def_store = 1; 4116 is_find_def_store = 1;
4096 } 4117 }
  4118 +
  4119 + //-- 如果库存为0就要重新赋值 --
  4120 + if(n_item.StorageNo ==def_pick_store.pickup_no) {
  4121 + def_pick_store.CanOutQty= o_plist[kk].CanOutQty;
  4122 + th.setData({ def_pick_store })
  4123 + }
  4124 +
4097 } 4125 }
4098 break; 4126 break;
4099 } 4127 }