AreaController.php
3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/1/7
* Time: 14:03
*/
namespace api\index\controller;
use api\index\model\PositionCityModel;
use api\index\model\PositionCountryModel;
use api\index\model\PositionProvinceModel;
use cmf\controller\RestBaseController;
use EasyWeChat\Foundation\Application;
use EasyWeChat\MiniProgram\MiniProgram;
use EasyWeChatComposer\EasyWeChat;
use Hooklife\ThinkphpWechat\Wechat;
/**
* @title 省市区
* @description省市区
*/
class AreaController extends RestBaseController
{
/**
* @title 省市区
* @description 省市区
* @author Xiaogang Wang
* @url /index/area/index
* @method GET
*
* @return province:省@
* @province province_id:省份编号 province_name:省份名称
* @return city:市@
* @city province_id:省份编号 city_id:城市编号 city_name:城市名称
* @return country:区/县@
* @country country_id:区/县编号 city_id:城市编号 country_name:城市名称
*/
public function index(){
$PositionProvinceModel = new PositionProvinceModel();
$province = $PositionProvinceModel->selectData();
$PositionCityModel = new PositionCityModel();
$city = $PositionCityModel->selectData(array('province_id'=>$province[0]['province_id']));
$PositionCountryModel = new PositionCountryModel();
$country = $PositionCountryModel->selectData(array('city_id'=>$city[0]['city_id']));
$data['province'] = $province;
$data['city'] = $city;
$data['country'] = $country;
$this->success('获取成功!',$data);
}
/**
* @title 切换省份获取市和区/县
* @description 切换省份获取市和区/县
* @author Xiaogang Wang
* @url /index/area/get_city
* @method GET
*
* @param name:province_id type:str require:1 other: desc:省份编码
*
* @return city:市@
* @city province_id:省份编号 city_id:城市编号 city_name:城市名称
* @return country:区/县@
* @country country_id:区/县编号 city_id:城市编号 country_name:城市名称
*/
public function get_city(){
$province_id = $this->request->param('province_id');
$PositionCityModel = new PositionCityModel();
$city = $PositionCityModel->selectData(array('province_id'=>$province_id));
$PositionCountryModel = new PositionCountryModel();
$country = $PositionCountryModel->selectData(array('city_id'=>$city[0]['city_id']));
$data['city'] = $city;
$data['country'] = $country;
$this->success('获取成功!',$data);
}
/**
* @title 切换市获取区/县
* @description 切换市获取区/县
* @author Xiaogang Wang
* @url /index/area/get_country
* @method GET
*
* @param name:city_id type:str require:1 other: desc:城市编码
*
* @return country:区/县@
* @country country_id:区/县编号 city_id:城市编号 country_name:城市名称
*/
public function get_country(){
$city_id = $this->request->param('city_id');
$PositionCountryModel = new PositionCountryModel();
$country = $PositionCountryModel->selectData(array('city_id'=>$city_id));
$this->success('获取区/县成功!',$country);
}
public function test(){
$appId=config('app_id');
$secret=config('secret');
$config = [
'app_id' => $appId,
'secret' => $secret,
];
dump($config);
$wechat=new Application($config);
$notice=$wechat->mini_program->notice;
$message = [
'touser' => '',
'template_id' => '',
'page' => '',
'form_id' => '',
'data' => [],
'emphasis_keyword' => '',
];
$notice->send($message);
}
}