Jelajahi Sumber

手机号登录/注册

15954078560 2 tahun lalu
induk
melakukan
7232465022
1 mengubah file dengan 24 tambahan dan 2 penghapusan
  1. 24 2
      application/api/controller/User.php

+ 24 - 2
application/api/controller/User.php

@@ -2006,13 +2006,35 @@ class User extends Api
 
     //手机号登录/注册
     public function mobileloginregister() {
-        $mobile = $this->request->post('mobile');
+        $user_token = input('user_token', '', 'trim');
+        if (!$user_token) {
+            $this->error('参数缺失');
+        }
+
+        $url = 'http://10.12.5.61:8088/bussiness/1.0/hdc/svc/sso/loginUserInfo/cmtokenid/' . $user_token;
+        //获取鉴权token
+        $sign_bytes = '/1.0/hdc/svc/sso/loginUserInfo/cmtokenid/' . $user_token;
+        $hdc_token = base64_encode(hash_hmac('sha256', $sign_bytes, config('pingtai_appkey'), true));
+        $header = [
+            'Host:10.12.5.61:8088',
+            'Content-Type:application/json',
+            'Authorization: HDCAUTH appid="' . config('pingtai_appid') . '",token="' . $hdc_token . '"'
+        ];
+        $user_info = httpRequest($url, 'GET', '', $header);
+        $user_info = simplexml_load_string($user_info, 'SimpleXMLElement', LIBXML_NOCDATA);
+        $user_info = (array)$user_info;
+        if (!$user_info) {
+            $this->error('您的网络开小差了~');
+        }
+
+        $mobile = $user_info['phoneNum'];
+        /*$mobile = $this->request->post('mobile');
         if (!$mobile) {
             $this->error(__('Invalid parameters'));
         }
         if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
-        }
+        }*/
 
         $user = \app\common\model\User::getByMobile($mobile);
         if ($user) {