Browse Source

手机号一键登录

whitefang 1 year ago
parent
commit
b95aba2404
2 changed files with 5 additions and 3 deletions
  1. 2 2
      app/api/controller/LoginController.php
  2. 3 1
      app/api/logic/LoginLogic.php

+ 2 - 2
app/api/controller/LoginController.php

@@ -123,14 +123,14 @@ class LoginController extends BaseApiController
     /**
      * @return \think\response\Json
      */
-    public function getMnpPhone()
+    public function getMnpSessionKey()
     {
         $params = (new WechatLoginValidate())->post()->goCheck('wechatAuth');
         $res = LoginLogic::mnpPhoneCode($params);
         if (false === $res) {
             return $this->fail(LoginLogic::getError());
         }
-        return $this->success('', (array)$res);
+        return $this->success('', $res);
     }
 
 

+ 3 - 1
app/api/logic/LoginLogic.php

@@ -241,12 +241,14 @@ class LoginLogic extends BaseLogic
     /**
      * @param array $params
      * @return array|false
+     *
      */
     public static function mnpPhoneCode(array $params)
     {
         Db::startTrans();
         try {
-            $response = (new WeChatMnpService())->getUserPhoneNumber($params['code']);
+            //通过code获取微信 openid
+            $response = (new WeChatMnpService())->getMnpResByCode($params['code']);
             Db::commit();
             return $response;
         } catch (\Exception  $e) {