diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 2d3e58e..22ad37a 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -370,72 +370,76 @@ Page({ th.data.fir_def_store={}; //赋值空对象 return false; } - var g_distr_type=th.data.data.distr_type; - //--如果默认门店的配送方式不对,就不能被选择-- - if(ee.distr_type!=0 && g_distr_type!=0 && ee.distr_type!=g_distr_type ){ - th.data.fir_def_store={}; //赋值空对象 - return false; - } + //--定时器推迟一下-- + setTimeout(function () { + var g_distr_type=th.data.data.distr_type; + //--如果默认门店的配送方式不对,就不能被选择-- + if(ee.distr_type!=0 && g_distr_type!=0 && ee.distr_type!=g_distr_type ){ + th.data.fir_def_store={}; //赋值空对象 + return false; + } + + 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)); + + //如果有开启近距离的话,同时距离优不一样了 + if (that.data.lat != null) { + //如果经纬度有变化的话 + if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){ + that.data.fir_def_store=e; + that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type + }) + }else{ + //要用接口是获取距离,js的计算不准 + getApp().request.promiseGet("/api/weshop/pickup/list",{ + data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon}, + }).then(res=>{ + if(res.data.code==0){ + e=res.data.data.pageData[0]; + if (e){ + appd.pk_store=e; + that.data.fir_def_store=e; + that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type + }) + } + + } + }) + } + + //e.distance = distance; + appd.lat=that.data.lat; + appd.lon=that.data.lon; + + }else{ + if (e) { + e.distance = null; + that.data.fir_def_store=e; + that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type + }) + } + } + + }, 500) + },1000) - 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)); - - //如果有开启近距离的话,同时距离优不一样了 - if (that.data.lat != null) { - //如果经纬度有变化的话 - if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){ - that.data.fir_def_store=e; - that.setData({ - def_pick_store: e, - sto_sele_name: e.pickup_name, - sto_sele_id: e.pickup_id, - sto_sele_distr: e.distr_type - }) - }else{ - //要用接口是获取距离,js的计算不准 - getApp().request.promiseGet("/api/weshop/pickup/list",{ - data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon}, - }).then(res=>{ - if(res.data.code==0){ - e=res.data.data.pageData[0]; - if (e){ - appd.pk_store=e; - that.data.fir_def_store=e; - that.setData({ - def_pick_store: e, - sto_sele_name: e.pickup_name, - sto_sele_id: e.pickup_id, - sto_sele_distr: e.distr_type - }) - } - - } - }) - } - - //e.distance = distance; - appd.lat=that.data.lat; - appd.lon=that.data.lon; - - }else{ - if (e) { - e.distance = null; - that.data.fir_def_store=e; - that.setData({ - def_pick_store: e, - sto_sele_name: e.pickup_name, - sto_sele_id: e.pickup_id, - sto_sele_distr: e.distr_type - }) - } - } - - }, 500) }); },