You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.6 KiB
91 lines
2.6 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller\personnel;
|
|
|
|
use app\service\api\personnel\WechatBindService;
|
|
use core\base\BaseApiController;
|
|
|
|
/**
|
|
* 人员微信绑定控制器
|
|
* Class WechatBind
|
|
* @package app\api\controller\personnel
|
|
*/
|
|
class WechatBind extends BaseApiController
|
|
{
|
|
|
|
/**
|
|
* 获取微信openid(小程序code换openid)
|
|
* @return \think\Response
|
|
*/
|
|
public function getWechatOpenid()
|
|
{
|
|
$data = $this->request->params([
|
|
['code', ''],
|
|
['type', 'miniprogram'] // miniprogram: 小程序, official: 公众号
|
|
]);
|
|
|
|
return success('获取成功', (new WechatBindService())->getWechatOpenid($data['code'], $data['type']));
|
|
}
|
|
|
|
/**
|
|
* 绑定微信openid
|
|
* @return \think\Response
|
|
*/
|
|
public function bindWechatOpenid()
|
|
{
|
|
$data = $this->request->params([
|
|
['miniprogram_openid', ''],
|
|
['official_openid', ''],
|
|
['type', 'miniprogram'] // miniprogram: 小程序绑定, official: 公众号绑定, both: 同时绑定
|
|
]);
|
|
|
|
return success('绑定成功', (new WechatBindService())->bindWechatOpenid($data));
|
|
}
|
|
|
|
/**
|
|
* 微信授权跳转
|
|
* @return \think\Response
|
|
*/
|
|
public function wechatAuthorize()
|
|
{
|
|
$data = $this->request->params([
|
|
['redirect_uri', ''],
|
|
['state', '']
|
|
]);
|
|
|
|
return (new WechatBindService())->wechatAuthorize($data['redirect_uri'], $data['state']);
|
|
}
|
|
|
|
/**
|
|
* 微信授权回调
|
|
* @return \think\Response
|
|
*/
|
|
public function wechatCallback()
|
|
{
|
|
$data = $this->request->params([
|
|
['code', ''],
|
|
['state', '']
|
|
]);
|
|
|
|
return (new WechatBindService())->wechatCallback($data['code'], $data['state']);
|
|
}
|
|
|
|
/**
|
|
* 获取绑定状态
|
|
* @return \think\Response
|
|
*/
|
|
public function getBindStatus()
|
|
{
|
|
return success('获取成功', (new WechatBindService())->getBindStatus());
|
|
}
|
|
|
|
}
|