|
@@ -11,6 +11,7 @@ namespace app\portal\controller; |
|
@@ -11,6 +11,7 @@ namespace app\portal\controller; |
11
|
|
11
|
|
12
|
use cmf\controller\HomeBaseController;
|
12
|
use cmf\controller\HomeBaseController;
|
13
|
use think\Db;
|
13
|
use think\Db;
|
|
|
14
|
+use wxapp\aes\WXBizDataCrypt;
|
14
|
|
15
|
|
15
|
/**
|
16
|
/**
|
16
|
* @title 登录相关接口
|
17
|
* @title 登录相关接口
|
|
@@ -54,4 +55,37 @@ class LoginController extends HomeBaseController{ |
|
@@ -54,4 +55,37 @@ class LoginController extends HomeBaseController{ |
54
|
$this->apiResponse(301,'获取登录凭证失败',$loginData);
|
55
|
$this->apiResponse(301,'获取登录凭证失败',$loginData);
|
55
|
}
|
56
|
}
|
56
|
}
|
57
|
}
|
|
|
58
|
+
|
|
|
59
|
+ /**
|
|
|
60
|
+ * @title 获取手机号
|
|
|
61
|
+ * @description 获取手机号
|
|
|
62
|
+ * @author 董瑞恩
|
|
|
63
|
+ * @url /portal/login/getPhone
|
|
|
64
|
+ * @method GET
|
|
|
65
|
+ *
|
|
|
66
|
+ * @param name:code type:String require:1 default:无 other: desc:code
|
|
|
67
|
+ * @param name:encrypted_data type:String require:1 default:无 other: desc:encrypted_data
|
|
|
68
|
+ * @param name:iv type:String require:1 default:无 other: desc:iv
|
|
|
69
|
+ *
|
|
|
70
|
+ * @return result:退款接口返回值
|
|
|
71
|
+ */
|
|
|
72
|
+ public function getPhone(){
|
|
|
73
|
+ $param = $this->request->param();
|
|
|
74
|
+ $loginUrl="https://api.weixin.qq.com/sns/jscode2session?appid=".$this->appId."&secret=".$this->appSecret."&js_code=".$param['code']."&grant_type=authorization_code";
|
|
|
75
|
+ $response=json_decode(file_get_contents($loginUrl),true);
|
|
|
76
|
+ if (!empty($response['errcode'])) {
|
|
|
77
|
+ $this->error('操作失败!');
|
|
|
78
|
+ }
|
|
|
79
|
+ $openid = $response['openid'];
|
|
|
80
|
+ $sessionKey = $response['session_key'];
|
|
|
81
|
+
|
|
|
82
|
+ $pc = new WXBizDataCrypt($this->appId, $sessionKey);
|
|
|
83
|
+ $errCode = $pc->decryptData($param['encrypted_data'], $param['iv'], $wxUserData);
|
|
|
84
|
+ if ($errCode != 0) {
|
|
|
85
|
+ $this->apiResponse(301,'操作失败');
|
|
|
86
|
+ }
|
|
|
87
|
+
|
|
|
88
|
+ $this->apiResponse(200,'success',$wxUserData);
|
|
|
89
|
+
|
|
|
90
|
+ }
|
57
|
} |
91
|
} |