|
@@ -1138,17 +1138,20 @@ class User extends Api
|
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
throw new Exception(__('Mobile is incorrect'));
|
|
|
}
|
|
|
+ $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
+ if (!$result && $captcha != 1212 ) {
|
|
|
+ throw new Exception(__('Captcha is incorrect'));
|
|
|
+ }
|
|
|
$where['mobile'] = $mobile;
|
|
|
$where['id'] = ['neq',$this->auth->id];
|
|
|
$where['status'] = ['neq','new'];
|
|
|
- $userData = model('User')->where($where)->find();
|
|
|
+ $userData = model('User')->where($where)->find();//老用户
|
|
|
if (!empty($userData)) {
|
|
|
- $this->error('该手机号已被其他用户绑定');
|
|
|
- }
|
|
|
-
|
|
|
- $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
- if (!$result && $captcha != 1212 ) {
|
|
|
- throw new Exception(__('Captcha is incorrect'));
|
|
|
+ if (empty($userData['openid'])) {
|
|
|
+ model('User')->update(['openid'=>$userData['openid']],$where);
|
|
|
+ } else {
|
|
|
+ $this->error('该手机号已被其他用户绑定');
|
|
|
+ }
|
|
|
}
|
|
|
$verification = $user->verification;
|
|
|
$verification->mobile = 1;
|