|
@@ -39,6 +39,7 @@ class Main extends Core
|
|
|
public function user()
|
|
|
{
|
|
|
$this->data['user'] = $this->user;
|
|
|
+ $this->data['config'] = Dever::db('main/config')->find();
|
|
|
return $this->data;
|
|
|
}
|
|
|
|
|
@@ -47,26 +48,55 @@ class Main extends Core
|
|
|
{
|
|
|
$data['name'] = Dever::input('name');
|
|
|
$data['mobile'] = Dever::input('mobile');
|
|
|
- $data['city'] = Dever::input('area');
|
|
|
-
|
|
|
+ $data['city'] = Dever::input('city');
|
|
|
$data['uid'] = $this->uid;
|
|
|
|
|
|
- $where['city'] = $data['city'];
|
|
|
- $where['mobile'] = $data['mobile'];
|
|
|
- $info = Dever::db('shop/apply')->find($where);
|
|
|
+ if (!$data['name']) {
|
|
|
+ Dever::alert('请输入姓名');
|
|
|
+ }
|
|
|
+ if (!$data['mobile']) {
|
|
|
+ Dever::alert('请输入手机号');
|
|
|
+ }
|
|
|
+ if (!$data['city']) {
|
|
|
+ Dever::alert('请选择城市');
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = Dever::db('shop/info')->find($data);
|
|
|
|
|
|
if (!$info) {
|
|
|
- Dever::db('shop/apply')->insert($data);
|
|
|
+ $data['truename'] = $data['name'];
|
|
|
+
|
|
|
+ $city = Dever::db('area/city')->find($data['city']);
|
|
|
+ $data['province'] = $city['province_id'];
|
|
|
+ $data['area'] = $data['province'] . ',' . $data['city'];
|
|
|
+
|
|
|
+
|
|
|
+ $url = 'https://restapi.amap.com/v3/geocode/geo';
|
|
|
+ $param['key'] = 'f18cb42560b8aa54e3b53a6265bfd764';
|
|
|
+ $param['city'] = $data['city'];
|
|
|
+ $param['address'] = $city['name'];
|
|
|
+ $result = json_decode(Dever::curl($url, $param), true);
|
|
|
+
|
|
|
+ if (isset($result['geocodes'][0]['location']) && $result['geocodes'][0]['location']) {
|
|
|
+ $data['map'] = $city['name'] . ',' . $result['geocodes'][0]['location'] . ',11';
|
|
|
+ $temp = explode(',', $result['geocodes'][0]['location']);
|
|
|
+ $data['lng'] = $temp[0];
|
|
|
+ $data['lat'] = $temp[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['status'] = 3;
|
|
|
+ Dever::db('shop/info')->insert($data);
|
|
|
}
|
|
|
|
|
|
- return '提交成功,我们会在3个工作日内与您联系,感谢您的信任。';
|
|
|
+ $this->data['msg'] = '提交成功,我们会在3个工作日内与您联系,感谢您的信任。';
|
|
|
+ return $this->data;
|
|
|
}
|
|
|
|
|
|
|
|
|
public function getShop()
|
|
|
{
|
|
|
$config = Dever::db('main/config')->find(1);
|
|
|
- $km = $config['km'];
|
|
|
+ $km = $config['km'] ? $config['km'] : 5;
|
|
|
|
|
|
$lng = Dever::input('lng');
|
|
|
$lat = Dever::input('lat');
|
|
@@ -76,7 +106,7 @@ class Main extends Core
|
|
|
}
|
|
|
$page['template'] = 'list';
|
|
|
$page['num'] = 10;
|
|
|
- $sql = 'select *, (st_distance(point(lng, lat),point('.$lng.', '.$lat.'))*111195) as distance from {table} where status = 1 and state = 1 order by distance asc';
|
|
|
+ $sql = 'select *, round((st_distance(point(lng, lat), point('.$lng.', '.$lat.'))*111195)/1000, 2) as distance from {table} where status = 1 and state = 1 order by distance asc';
|
|
|
$data = Dever::db('shop/info')->fetchAll($sql, array(), $page);
|
|
|
|
|
|
$result = array();
|
|
@@ -133,17 +163,4 @@ class Main extends Core
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- public function getGoodsInfo()
|
|
|
- {
|
|
|
- $id = Dever::input('goods_id');
|
|
|
- if (!$id) {
|
|
|
- Dever::alert('错误的商品');
|
|
|
- }
|
|
|
-
|
|
|
- $data = Dever::load('goods/lib/info')->getInfo($id);
|
|
|
-
|
|
|
- return $data;
|
|
|
- }
|
|
|
}
|