52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| namespace app\front;
 | |
| use app\model\User;
 | |
| use app\service\CmbService;
 | |
| use app\service\util\CmbLifeUtils;
 | |
| use app\util\CmbHttpUtils;
 | |
| use app\util\StringUtil;
 | |
| use think\Request;
 | |
| 
 | |
| class Oauth
 | |
| {
 | |
|     /**
 | |
|      * 发起授权登录
 | |
|      * @param Request $request
 | |
|      * @return \think\Response
 | |
|      * @throws \app\exception\BusinessException
 | |
|      */
 | |
|     public function approval(Request $request)
 | |
|     {
 | |
|         $params =$request->post();
 | |
|         $approvalUrl = CmbService::genApprovalProtocol($params);
 | |
|         return response_json($approvalUrl);
 | |
|     }
 | |
|     /**
 | |
|      * 获取openId
 | |
|      * @param Request $request
 | |
|      * @return \think\Response
 | |
|      * @throws \app\exception\BusinessException
 | |
|      */
 | |
|     public function accessToken(Request $request)
 | |
|     {
 | |
|         $code = $request->post('code');
 | |
|         $res = CmbService::accessToken($code);
 | |
|         return response_json($res);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 手机号绑定
 | |
|      * @param Request $request
 | |
|      * @return \think\Response
 | |
|      * @throws \think\db\exception\DataNotFoundException
 | |
|      * @throws \think\db\exception\ModelNotFoundException
 | |
|      */
 | |
|     public function bindMobile(Request $request)
 | |
|     {
 | |
|         $params = $request->post();
 | |
|         $params['open_id'] = $request->open_id;
 | |
|         CmbService::bindMobile($params);
 | |
|         return response_json([], 200, '手机号绑定成功!');
 | |
|     }
 | |
| }
 |