|
@@ -76,19 +76,28 @@ class User extends Api
|
|
|
$mobile = $this->request->post('mobile');
|
|
|
$captcha = $this->request->post('captcha');
|
|
|
$openid = $this->request->post('openid');
|
|
|
+
|
|
|
if (!$mobile || !$captcha || !$openid) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error(__('Mobile is incorrect'));
|
|
|
}
|
|
|
- if (!Sms::check($mobile, $captcha, 'mobilelogin') && $captcha != '8888') {
|
|
|
+ if (!Sms::check($mobile, $captcha, 'mobilelogin') && $captcha != '1212') {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
if (!empty($openid)) {
|
|
|
$user = \app\common\model\User::getByMiniOpenid($openid);
|
|
|
- if (!empty($user) && $user['mobile'] != $mobile) {
|
|
|
- $this->error('请用初始手机号登录');
|
|
|
+ if (!empty($user)) {
|
|
|
+ if (!empty($user['mobile']) && $user['mobile'] != $mobile) {
|
|
|
+ $this->error('请用初始手机号登录');
|
|
|
+ } else {
|
|
|
+ $user->mobile = $mobile;
|
|
|
+ $userRes = $user->save();
|
|
|
+ if (!$userRes) {
|
|
|
+ $this->error('绑定失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$user = \app\common\model\User::getByMobile($mobile);
|