Commit fde00771069e9bb0370f4e09d1695cbf0919b5ba

Authored by 后端研发-倪永富
1 parent 7df3bc8e

选择门店的默认的不出来的优化

pages/goods/goodsInfo/goodsInfo.js
... ... @@ -370,72 +370,76 @@ Page({
370 370 th.data.fir_def_store={}; //赋值空对象
371 371 return false;
372 372 }
373   - var g_distr_type=th.data.data.distr_type;
374 373  
375   - //--如果默认门店的配送方式不对,就不能被选择--
376   - if(ee.distr_type!=0 && g_distr_type!=0 && ee.distr_type!=g_distr_type ){
377   - th.data.fir_def_store={}; //赋值空对象
378   - return false;
379   - }
  374 + //--定时器推迟一下--
  375 + setTimeout(function () {
  376 + var g_distr_type=th.data.data.distr_type;
  377 + //--如果默认门店的配送方式不对,就不能被选择--
  378 + if(ee.distr_type!=0 && g_distr_type!=0 && ee.distr_type!=g_distr_type ){
  379 + th.data.fir_def_store={}; //赋值空对象
  380 + return false;
  381 + }
  382 +
  383 + var appd=getApp().globalData;
  384 + var w_time = setInterval(function() {
  385 + if (that.data.is_get_local_ok == 0) return false;
  386 + clearInterval(w_time);
  387 + var distance = null;
  388 + var e=JSON.parse(JSON.stringify(ee));
  389 +
  390 + //如果有开启近距离的话,同时距离优不一样了
  391 + if (that.data.lat != null) {
  392 + //如果经纬度有变化的话
  393 + if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){
  394 + that.data.fir_def_store=e;
  395 + that.setData({
  396 + def_pick_store: e,
  397 + sto_sele_name: e.pickup_name,
  398 + sto_sele_id: e.pickup_id,
  399 + sto_sele_distr: e.distr_type
  400 + })
  401 + }else{
  402 + //要用接口是获取距离,js的计算不准
  403 + getApp().request.promiseGet("/api/weshop/pickup/list",{
  404 + data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
  405 + }).then(res=>{
  406 + if(res.data.code==0){
  407 + e=res.data.data.pageData[0];
  408 + if (e){
  409 + appd.pk_store=e;
  410 + that.data.fir_def_store=e;
  411 + that.setData({
  412 + def_pick_store: e,
  413 + sto_sele_name: e.pickup_name,
  414 + sto_sele_id: e.pickup_id,
  415 + sto_sele_distr: e.distr_type
  416 + })
  417 + }
  418 +
  419 + }
  420 + })
  421 + }
  422 +
  423 + //e.distance = distance;
  424 + appd.lat=that.data.lat;
  425 + appd.lon=that.data.lon;
  426 +
  427 + }else{
  428 + if (e) {
  429 + e.distance = null;
  430 + that.data.fir_def_store=e;
  431 + that.setData({
  432 + def_pick_store: e,
  433 + sto_sele_name: e.pickup_name,
  434 + sto_sele_id: e.pickup_id,
  435 + sto_sele_distr: e.distr_type
  436 + })
  437 + }
  438 + }
  439 +
  440 + }, 500)
  441 + },1000)
380 442  
381   - var appd=getApp().globalData;
382   - var w_time = setInterval(function() {
383   - if (that.data.is_get_local_ok == 0) return false;
384   - clearInterval(w_time);
385   - var distance = null;
386   - var e=JSON.parse(JSON.stringify(ee));
387   -
388   - //如果有开启近距离的话,同时距离优不一样了
389   - if (that.data.lat != null) {
390   - //如果经纬度有变化的话
391   - if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){
392   - that.data.fir_def_store=e;
393   - that.setData({
394   - def_pick_store: e,
395   - sto_sele_name: e.pickup_name,
396   - sto_sele_id: e.pickup_id,
397   - sto_sele_distr: e.distr_type
398   - })
399   - }else{
400   - //要用接口是获取距离,js的计算不准
401   - getApp().request.promiseGet("/api/weshop/pickup/list",{
402   - data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
403   - }).then(res=>{
404   - if(res.data.code==0){
405   - e=res.data.data.pageData[0];
406   - if (e){
407   - appd.pk_store=e;
408   - that.data.fir_def_store=e;
409   - that.setData({
410   - def_pick_store: e,
411   - sto_sele_name: e.pickup_name,
412   - sto_sele_id: e.pickup_id,
413   - sto_sele_distr: e.distr_type
414   - })
415   - }
416   -
417   - }
418   - })
419   - }
420   -
421   - //e.distance = distance;
422   - appd.lat=that.data.lat;
423   - appd.lon=that.data.lon;
424   -
425   - }else{
426   - if (e) {
427   - e.distance = null;
428   - that.data.fir_def_store=e;
429   - that.setData({
430   - def_pick_store: e,
431   - sto_sele_name: e.pickup_name,
432   - sto_sele_id: e.pickup_id,
433   - sto_sele_distr: e.distr_type
434   - })
435   - }
436   - }
437   -
438   - }, 500)
439 443 });
440 444  
441 445 },
... ...