|
@@ -12,28 +12,6 @@ class Main extends Core
|
|
|
parent::__construct();
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- public function home()
|
|
|
- {
|
|
|
- $where['city'] = Dever::input('city');
|
|
|
-
|
|
|
- $this->data['focus'] = Dever::db('shop/focus')->select(array('location' => 1));
|
|
|
-
|
|
|
- if ($where['city']) {
|
|
|
-
|
|
|
- $where['status'] = 1;
|
|
|
- $this->data['shop'] = Dever::db('shop/info')->getOne($where);
|
|
|
- if ($this->data['shop']) {
|
|
|
-
|
|
|
- $this->data['city'] = 1;
|
|
|
- } else {
|
|
|
-
|
|
|
- $this->data['city'] = 2;
|
|
|
- }
|
|
|
- }
|
|
|
- return $this->data;
|
|
|
- }
|
|
|
|
|
|
|
|
|
public function user()
|
|
@@ -42,57 +20,53 @@ class Main extends Core
|
|
|
$this->data['config'] = Dever::db('main/config')->find();
|
|
|
return $this->data;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- public function apply()
|
|
|
+
|
|
|
+
|
|
|
+ public function home()
|
|
|
{
|
|
|
- $data['name'] = Dever::input('name');
|
|
|
- $data['mobile'] = Dever::input('mobile');
|
|
|
- $data['city'] = Dever::input('city');
|
|
|
- $data['uid'] = $this->uid;
|
|
|
+ $city = Dever::input('city');
|
|
|
+ $lng = Dever::input('lng');
|
|
|
+ $lat = Dever::input('lat');
|
|
|
|
|
|
- if (!$data['name']) {
|
|
|
- Dever::alert('请输入姓名');
|
|
|
- }
|
|
|
- if (!$data['mobile']) {
|
|
|
- Dever::alert('请输入手机号');
|
|
|
- }
|
|
|
- if (!$data['city']) {
|
|
|
- Dever::alert('请选择城市');
|
|
|
+
|
|
|
+ $this->data['shop'] = array();
|
|
|
+ if ($city && $lng && $lat) {
|
|
|
+ $this->data['shop'] = Dever::load('shop/lib/info')->get($city, $lng, $lat);
|
|
|
}
|
|
|
|
|
|
- $info = Dever::db('shop/info')->find($data);
|
|
|
-
|
|
|
- if (!$info) {
|
|
|
- $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];
|
|
|
- }
|
|
|
+
|
|
|
+ $this->data['focus'] = Dever::db('shop/focus')->select(array('location' => 2));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $this->data['hot'] = Dever::load('shop/lib/info')->getTopGoods($this->data['shop'], 1);
|
|
|
+
|
|
|
+
|
|
|
+ $this->data['top'] = Dever::load('shop/lib/info')->getTopGoods($this->data['shop'], 2);
|
|
|
+
|
|
|
+ return $this->data;
|
|
|
+ }
|
|
|
|
|
|
- $data['status'] = 3;
|
|
|
- Dever::db('shop/info')->insert($data);
|
|
|
+
|
|
|
+ public function getShop()
|
|
|
+ {
|
|
|
+ $city = Dever::input('city');
|
|
|
+ $lng = Dever::input('lng');
|
|
|
+ $lat = Dever::input('lat');
|
|
|
+ $name = Dever::input('name');
|
|
|
+
|
|
|
+
|
|
|
+ $this->data['shop'] = array();
|
|
|
+ if ($city && $lng && $lat) {
|
|
|
+ $this->data['shop'] = Dever::load('shop/lib/info')->get($city, $lng, $lat, $name, 'fetchAll');
|
|
|
}
|
|
|
|
|
|
- $this->data['msg'] = '提交成功,我们会在3个工作日内与您联系,感谢您的信任。';
|
|
|
return $this->data;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
public function getShop()
|
|
|
{
|
|
|
$config = Dever::db('main/config')->find(1);
|
|
@@ -138,25 +112,19 @@ class Main extends Core
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
|
|
|
- public function getGoods($shop_id)
|
|
|
+ public function getGoods()
|
|
|
{
|
|
|
- $cate = Dever::load('category/api')->getTop(1);
|
|
|
+ $shop_id = Dever::input('shop_id');
|
|
|
+
|
|
|
+ $column = Dever::db('goods/column')->select();
|
|
|
|
|
|
$data = array();
|
|
|
- $data['cate'] = array();
|
|
|
- $data['cate'] = array
|
|
|
- (
|
|
|
- array('id' => -1, 'name' => '人气食材'),
|
|
|
- array('id' => -2, 'name' => '每日优惠'),
|
|
|
- );
|
|
|
-
|
|
|
- $data['cate'][0]['data'] = Dever::db('shop/goods')->getData(array('top' => 1));
|
|
|
- $data['cate'][1]['data'] = Dever::db('shop/goods')->getData(array('youhui' => 1));
|
|
|
if ($cate) {
|
|
|
foreach ($cate as $k => $v) {
|
|
|
- $v['data'] = Dever::db('shop/goods')->getData(array('top_category_id' => $v['id']));
|
|
|
+ $v['data'] = Dever::load('shop/lib/info')->getTopGoods($this->data['shop'], 3, $v['id']);
|
|
|
$data['cate'][] = $v;
|
|
|
}
|
|
|
}
|