dever 3 years ago
parent
commit
ce5519792d
4 changed files with 39 additions and 4 deletions
  1. 1 1
      app/mshop/lib/Core.php
  2. 14 3
      app/shop/database/info.php
  3. 17 0
      app/shop/lib/Info.php
  4. 7 0
      app/shop/lib/Manage.php

+ 1 - 1
app/mshop/lib/Core.php

@@ -37,7 +37,7 @@ class Core
             Dever::alert('门店不存在');
         }
 
-        $this->shop['coord_address'] = '';
+        //$this->shop['coord_address'] = '';
     }
 
     public function checkLogin()

+ 14 - 3
app/shop/database/info.php

@@ -241,6 +241,17 @@ return array
             //'list'        => true,
         ),
 
+        'coord_address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '门店坐标地址',
+            'default'   => '',
+            'desc'      => '门店坐标地址',
+            'match'     => 'option',
+            //'update'    => 'text',
+            //'list'        => true,
+        ),
+
         'address'       => array
         (
             'type'      => 'varchar-1000',
@@ -456,7 +467,7 @@ return array
             'default'   => '2',
             'desc'      => '优惠券是否同城可用',
             'match'     => 'is_numeric',
-            'update'    => 'radio',
+            //'update'    => 'radio',
             //'update'    => Dever::input('col') ? 'radio' : false,
             'option'    => $yes,
         ),
@@ -468,9 +479,9 @@ return array
             'default'   => '',
             'desc'      => '参与活动',
             'match'     => 'option',
-            'update'    => 'checkbox',
+            //'update'    => 'checkbox',
             'data'      => 'parent',
-            'option'    => $act,
+            //'option'    => $act,
         ),
 
         'pdesc'      => array

+ 17 - 0
app/shop/lib/Info.php

@@ -257,4 +257,21 @@ class Info
 
         return array($lng, $lat, $map);
     }
+
+    # 根据经纬度获取地址
+    public function address($lng, $lat)
+    {
+        $url = 'http://restapi.amap.com/v3/geocode/regeo';
+        $param['key'] = 'f18cb42560b8aa54e3b53a6265bfd764';
+        $param['location'] = $lng . ',' . $lat;
+        $param['radius'] = 2800;
+        $result = json_decode(Dever::curl($url, $param), true);
+
+        $address = '';
+        if (isset($result['regeocode']['formatted_address'])) {
+            $address = $result['regeocode']['formatted_address'];
+        }
+
+        return $address;
+    }
 }

+ 7 - 0
app/shop/lib/Manage.php

@@ -92,6 +92,13 @@ class Manage
             if (isset($temp[1])) {
                 $update['lng'] = $temp[1];
                 $update['lat'] = $temp[2];
+
+                $address = Dever::param('address', $data);
+                $update['coord_address'] = Dever::load('shop/lib/info')->address($temp[1], $temp[2]);
+
+                if (!$address && $update['coord_address']) {
+                    $update['address'] = $update['coord_address'];
+                }
             }
         }