Explorar el Código

手机号验证

linwu hace 2 años
padre
commit
a249175f59
Se han modificado 3 ficheros con 23 adiciones y 11 borrados
  1. 21 7
      app/admin/controller/User.php
  2. 1 3
      app/common/validate/User.php
  3. 1 1
      app/mainapp/controller/Train.php

+ 21 - 7
app/admin/controller/User.php

@@ -737,6 +737,20 @@ class User extends BaseController
                 'msg'  => $e->getError(),
             ]));
         }
+        
+        //手机号
+        $check_user_where = [['mobile', '=', $mobile]];
+        if (!empty($id)) {
+            $check_user_where[] = ['id', '!=', $id];
+        }
+        $check_user = UserModel::where($check_user_where)->find();
+        if (!empty($check_user)) {
+            exit(json_encode([
+                'code' => 1,
+                'msg'  => '手机号已存在',
+            ]));
+        }
+
         $address      = input('address/s', "");
         $jobintention = input('jobintention/s', "");
         if (!$address) {
@@ -1006,12 +1020,12 @@ class User extends BaseController
         $cateList   = ComjobsCateModel::column('id', 'title');
 
         foreach ($list as $v) {
-            $item                   = [];
-            $item['nickname']       = $item['realname'] = $v['nickname'];
-            $item['gender']         = $gender[$v['gender']];
-            $item['mobile']         = $v['mobile'];
-            $item['education']      = $education[$v['education']];
-            $item['birthday']       = date('Y-m-d', strtotime($v['birthday']));
+            $item              = [];
+            $item['nickname']  = $item['realname'] = $v['nickname'];
+            $item['gender']    = $gender[$v['gender']];
+            $item['mobile']    = $v['mobile'];
+            $item['education'] = $education[$v['education']];
+            $item['birthday']  = date('Y-m-d', strtotime($v['birthday']));
             if (empty($workexperience[$v['workexperience']])) {
                 halt($v['workexperience']);
             }
@@ -1039,7 +1053,7 @@ class User extends BaseController
             $item['address']       = $v['address'] ?: '';
             $item['eduexperience'] = $v['eduexperience'] ?: '';
 
-            $item['groupsid']     = 2;
+            $item['groupsid']   = 2;
             $item['status']     = 2;
             $item['authstatus'] = 3;
             $item['createtime'] = time();

+ 1 - 3
app/common/validate/User.php

@@ -7,13 +7,11 @@ use think\Validate;
 class User extends Validate
 {
     protected $rule = [
-        'mobile'     =>  'require|mobile|unique:user'
+        'mobile'     =>  'require|mobile'
     ];
 	
 	protected $message  =   [
         'mobile.require' => '手机号不能为空',
 		'mobile.mobile'  => '手机号格式不正确',
-        'mobile.unique'  => '手机号不能重复'
     ];
-
 }

+ 1 - 1
app/mainapp/controller/Train.php

@@ -54,7 +54,7 @@ class Train extends BaseController
 
         $check = TrainJoinModel::where('train_id',$train_id)->where('user_id',$userid)->find();
         if (!empty($check)) {
-            page_result(1, "请勿重复报名");
+            page_result(1, "恭喜您已报名成功!具体开班时间视报名人数而定,会有老师统一通知,如需加急或有其他疑问,可同柯老师联系,联系电话18659000595 (微信同号)。");
         }
 
         TrainJoinModel::create([