AreaController.php 3.8 KB
<?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);

    }
}