作者 lihan
1 个管道 的构建 通过 耗费 0 秒

自动定位功能

@@ -48,12 +48,16 @@ class ActivityController extends HomeBaseController @@ -48,12 +48,16 @@ class ActivityController extends HomeBaseController
48 } else { 48 } else {
49 require_once EXTEND_PATH . '/WeChatCommon.php'; 49 require_once EXTEND_PATH . '/WeChatCommon.php';
50 $wx = new \WeChatCommon(); 50 $wx = new \WeChatCommon();
51 - $pos = Db:: name('user')->field('lat,lng')->where(['id'=>session('user.id')])->find();  
52 - $return = json_decode(anti_analysis($pos['lat'], $pos['lng']), true); 51 + if(empty(session('user.city'))) {
  52 + $pos = Db:: name('user')->field('lat,lng')->where(['id' => session('user.id')])->find();
  53 + $return = json_decode(anti_analysis($pos['lat'], $pos['lng']), true);
  54 + $city = $return['result']['address_component']['city'];
  55 + session('user.city', $city);
  56 + }
53 return $this->fetch(':_list', [ 57 return $this->fetch(':_list', [
54 'result' => $result, 58 'result' => $result,
55 'js_sdk' => $wx->js_sdk(), 59 'js_sdk' => $wx->js_sdk(),
56 - 'city' => $return['result']['address_component']['city'] 60 + 'city' => session('user.city')
57 ]); 61 ]);
58 } 62 }
59 } 63 }