Browse Source

去掉用户手机号86开头

lizhen_gitee 7 tháng trước cách đây
mục cha
commit
d3a548d5f9

+ 5 - 14
application/api/controller/Sms.php

@@ -16,16 +16,7 @@ class Sms extends Api
     protected $noNeedLogin = '*';
     protected $noNeedRight = '*';
 
-    public function codelist(){
-        $keyword = input('keyword','');
 
-        $map = [];
-        if(!empty($keyword)){
-            $map['en|cn'] = ['LIKE','%'.$keyword.'%'];
-        }
-        $list = Db::name('country_code')->where($map)->order('en asc')->select();
-        $this->success(1,$list);
-    }
 
     /**
      * 发送验证码
@@ -37,15 +28,15 @@ class Sms extends Api
     public function send()
     {
         $mobile = input("mobile");
-        $countrycode = input("countrycode",86,'intval');
+
         $event = input("event",'default');
         $event = $event ? $event : 'register';
 
-        $fullmobile = $countrycode.$mobile;
+
         if (!$mobile) {
             $this->error(__('手机号不正确'));
         }
-        $last = Smslib::get($fullmobile, $event);
+        $last = Smslib::get($mobile, $event);
         if ($last && time() - $last['createtime'] < 60) {
             $this->error(__('发送频繁'));
         }
@@ -54,7 +45,7 @@ class Sms extends Api
             $this->error(__('ip发送频繁'));
         }
         if ($event) {
-            $userinfo = User::getByMobile($fullmobile);
+            $userinfo = User::getByMobile($mobile);
             if ($event == 'register' && $userinfo) {
                 //已被注册
                 $this->error(__('已被注册'));
@@ -69,7 +60,7 @@ class Sms extends Api
         if (!Hook::get('sms_send')) {
             $this->error(__('请在后台插件管理安装短信验证插件'));
         }
-        $ret = Smslib::send($mobile, null, $event,$countrycode);
+        $ret = Smslib::send($mobile, null, $event);
         if ($ret) {
             $this->success(__('发送成功'));
         } else {

+ 40 - 49
application/api/controller/User.php

@@ -31,15 +31,6 @@ class User extends Api
         parent::_initialize();
 
     }
-
-    /**
-     * 会员中心
-     */
-    public function index()
-    {
-        $this->success('', ['welcome' => $this->auth->nickname]);
-    }
-
     /**
      * 会员登录
      *
@@ -49,15 +40,15 @@ class User extends Api
      */
     public function login()
     {
-        $countrycode = input('countrycode',86,'intval');
+
         $account = input('account');
         $password = input('password');
 
-        if (!$countrycode || !$account || !$password) {
+        if (!$account || !$password) {
             $this->error(__('Invalid parameters'));
         }
 
-        $account = $countrycode.$account;
+
         $ret = $this->auth->login($account, $password);
         if ($ret) {
             $data = $this->userInfo('return');
@@ -77,18 +68,18 @@ class User extends Api
      */
     public function mobilelogin()
     {
-        $countrycode = input('countrycode',86,'intval');
+
         $mobile = input('mobile');
         $captcha = input('captcha');
 
-        if (!$countrycode || !$mobile || !$captcha) {
+        if (!$mobile || !$captcha) {
             $this->error(__('Invalid parameters'));
         }
-        /*if (!Validate::regex($mobile, "^1\d{10}$")) {
+        if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
-        }*/
-        $simplemobile = $mobile;
-        $mobile = $countrycode.$mobile;
+        }
+
+
         if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
             $this->error(__('Captcha is incorrect'));
         }
@@ -106,7 +97,7 @@ class User extends Api
 
         } else {
             $extend = [
-                'simplemobile' => $simplemobile,
+
             ];
             $ret = $this->auth->register('', '', '', $mobile, $extend);
 
@@ -226,9 +217,9 @@ class User extends Api
             } else {
                 // 取号成功, 执行登录等流程
                 // 用户登录逻辑 === 开始
-                $countrycode = 86;
-                $simplemobile = $mobile;
-                $mobile = $countrycode.$mobile;
+
+
+
                 $user = \app\common\model\User::getByMobile($mobile);
                 if ($user) {
                     if ($user->status == -1) {
@@ -244,7 +235,7 @@ class User extends Api
 
                 } else {
                     $extend = [
-                        'simplemobile' => $simplemobile,
+
                     ];
                     $ret = $this->auth->register('', '', '', $mobile, $extend);
                     $is_register = 1;
@@ -540,17 +531,17 @@ class User extends Api
     {
         $user = $this->auth->getUser();
         $oldcaptcha = $this->request->request('oldcaptcha');
-        $countrycode = $this->request->request('countrycode',86,'intval');
+
         $mobile = $this->request->request('mobile');
         $captcha = $this->request->request('captcha');
-        if (!$oldcaptcha || !$countrycode || !$mobile || !$captcha) {
+        if (!$oldcaptcha || !$mobile || !$captcha) {
             $this->error(__('Invalid parameters'));
         }
-        /*if (!Validate::regex($mobile, "^1\d{10}$")) {
+        if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
-        }*/
-        $simplemobile = $mobile;
-        $mobile = $countrycode.$mobile;
+        }
+
+
         if($user->mobile == $mobile){
             $this->error('新手机号不能与旧手机号相同');
         }
@@ -570,7 +561,7 @@ class User extends Api
         Sms::flush($mobile, 'changemobile');
 
         $user->mobile = $mobile;
-        $user->simplemobile = $simplemobile;
+
         $user->save();
 
         $this->success();
@@ -585,19 +576,19 @@ class User extends Api
      */
     public function applebindmobile()
     {
-        $countrycode = $this->request->request('countrycode',86,'intval');
+
         $mobile    = $this->request->param('mobile');
         $captcha   = $this->request->param('captcha');
         $iosUserId = $this->request->param('ios_user_id','');
 
-        if (!$countrycode || !$mobile || !$captcha || !$iosUserId) {
+        if (!$mobile || !$captcha || !$iosUserId) {
             $this->error(__('Invalid parameters'));
         }
-        /*if (!Validate::regex($mobile, "^1\d{10}$")) {
+        if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
-        }*/
-        $simplemobile = $mobile;
-        $mobile = $countrycode.$mobile;
+        }
+
+
         $result = Sms::check($mobile, $captcha, 'changemobile');
         if (!$result) {
             $this->error(__('Captcha is incorrect'));
@@ -635,7 +626,7 @@ class User extends Api
         } else {
             $extend = [
                 'ios_user_id' => $iosUserId,
-                'simplemobile' => $simplemobile,
+
             ];
             $ret = $this->auth->register('', '','', $mobile, $extend);
         }
@@ -656,19 +647,19 @@ class User extends Api
      */
     public function bindmobile()
     {
-        $countrycode = $this->request->param('countrycode',86,'intval');
+
         $mobile = $this->request->param('mobile');
         $captcha = $this->request->param('captcha');
         $code = $this->request->param('code');
 
-        if (!$countrycode || !$mobile || !$captcha || !$code) {
+        if (!$mobile || !$captcha || !$code) {
             $this->error(__('Invalid parameters'));
         }
-        /*if (!Validate::regex($mobile, "^1\d{10}$")) {
+        if (!Validate::regex($mobile, "^1\d{10}$")) {
             $this->error(__('Mobile is incorrect'));
-        }*/
-        $simplemobile = $mobile;
-        $mobile = $countrycode.$mobile;
+        }
+
+
         $result = Sms::check($mobile, $captcha, 'changemobile');
         if (!$result) {
             $this->error(__('Captcha is incorrect'));
@@ -710,7 +701,7 @@ class User extends Api
         } else {
             $extend = [
                 'wechat_openid' => $wechatCode['openid'],
-                'simplemobile' => $simplemobile,
+
             ];
             $ret = $this->auth->register('', '','', $mobile, $extend);
         }
@@ -765,20 +756,20 @@ class User extends Api
     {
         //$type = input("type");
         $type = 'mobile';
-        $countrycode = input("countrycode",86,'intval');
+
         $mobile = input("mobile");
 //        $email = input("email");
         $newpassword = input("newpassword");
         $captcha = input("captcha");
-        if (!$countrycode || !$mobile || !$newpassword || !$captcha) {
+        if (!$mobile || !$newpassword || !$captcha) {
             $this->error(__('Invalid parameters'));
         }
 
-        $mobile = $countrycode.$mobile;
+
         if ($type == 'mobile') {
-            /*if (!Validate::regex($mobile, "^1\d{10}$")) {
+            if (!Validate::regex($mobile, "^1\d{10}$")) {
                 $this->error(__('Mobile is incorrect'));
-            }*/
+            }
             $user = \app\common\model\User::getByMobile($mobile);
             if (!$user) {
                 $this->error(__('User not found'));

+ 4 - 8
application/common/library/Sms.php

@@ -48,20 +48,20 @@ class Sms
      * @param   string $event  事件
      * @return  boolean
      */
-    public static function send($mobile, $code = null, $event = 'default',$countrycode = 86)
+    public static function send($mobile, $code = null, $event = 'default')
     {
         $event = 'default';
         $code = is_null($code) ? mt_rand(1000, 9999) : $code;
         $time = time();
         $ip = request()->ip();
-        $sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $countrycode.$mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time, 'countrycode' => $countrycode]);
+        $sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time ]);
 //        $result = Hook::listen('sms_send', $sms, null, true);
 
         //阿里短信
         $params['mobile'] = $mobile;
         $params['code'] = $code;
 
-        $result = self::smsSend($params,$countrycode);
+        $result = self::smsSend($params);
 
         if (!$result) {
             $sms->delete();
@@ -75,15 +75,11 @@ class Sms
      * @param array $params 必须包含mobile,event,code
      * @return  boolean
      */
-    public static function smsSend($params,$countrycode)
+    public static function smsSend($params)
     {
         $config = config('alisms');
 
         $template = $config['template_cn'];  //默认国内模板
-        if($countrycode != 86){
-            $params['mobile'] = $countrycode.$params['mobile'];
-            $template = $config['template_guoji'];
-        }
 
         $alisms = new Alisms();
         $result = $alisms->mobile($params['mobile'])