|
|
@@ -50,15 +50,20 @@ class Passport extends Controller
|
|
|
* 微信小程序快捷登录 (需提交wx.login接口返回的code、微信用户公开信息)
|
|
|
* 实现流程:判断openid是否存在 -> 存在: 更新用户登录信息 -> 返回userId和token
|
|
|
* -> 不存在: 返回false, 跳转到注册页面
|
|
|
+ * @return array|\think\response\Json
|
|
|
+ * @throws \app\common\exception\BaseException
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
public function mpWxLogin()
|
|
|
{
|
|
|
- // 执行登录
|
|
|
+ // 微信小程序一键登录
|
|
|
$LoginService = new LoginService;
|
|
|
if (!$LoginService->mpWxLogin($this->postForm())) {
|
|
|
return $this->renderError($LoginService->getError());
|
|
|
}
|
|
|
- // 用户信息
|
|
|
+ // 获取登录成功后的用户信息
|
|
|
$userInfo = $LoginService->getUserInfo();
|
|
|
return $this->renderSuccess([
|
|
|
'userId' => (int)$userInfo['user_id'],
|