|
|
@@ -173,7 +173,7 @@ class AuthController
|
|
|
return app('json')->fail($time . '秒内有效');
|
|
|
$code = rand(100000, 999999);
|
|
|
$data['code'] = $code;
|
|
|
- $res = ShortLetterRepositories::send(true, $phone, $data, 'VERIFICATION_CODE');
|
|
|
+ $res = ShortLetterRepositories::NewSmsSend($phone, $data, 'VERIFICATION_CODE');
|
|
|
if ($res !== true)
|
|
|
return app('json')->fail('短信平台验证码发送失败' . $res);
|
|
|
CacheService::set('code_' . $phone, $code, $time);
|
|
|
@@ -196,12 +196,12 @@ class AuthController
|
|
|
} catch (ValidateException $e) {
|
|
|
return app('json')->fail($e->getError());
|
|
|
}
|
|
|
-// $verifyCode = CacheService::get('code_' . $account);
|
|
|
-// if (!$verifyCode)
|
|
|
-// return app('json')->fail('请先获取验证码');
|
|
|
-// $verifyCode = substr($verifyCode, 0, 6);
|
|
|
-// if ($verifyCode != $captcha)
|
|
|
-// return app('json')->fail('验证码错误');
|
|
|
+ $verifyCode = CacheService::get('code_' . $account);
|
|
|
+ if (!$verifyCode)
|
|
|
+ return app('json')->fail('请先获取验证码');
|
|
|
+ $verifyCode = substr($verifyCode, 0, 6);
|
|
|
+ if ($verifyCode != $captcha)
|
|
|
+ return app('json')->fail('验证码错误');
|
|
|
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 16)
|
|
|
return app('json')->fail('密码必须是在6到16位之间');
|
|
|
if ($password == '123456') return app('json')->fail('密码太过简单,请输入较为复杂的密码');
|
|
|
@@ -372,23 +372,45 @@ class AuthController
|
|
|
$verifyCode = substr($verifyCode, 0, 6);
|
|
|
if ($verifyCode != $captcha)
|
|
|
return app('json')->fail('验证码错误');
|
|
|
-
|
|
|
- $userInfo = User::where('uid', $request->uid())->find();
|
|
|
- $userPhone = $userInfo->phone;
|
|
|
- if (!$userInfo) return app('json')->fail('用户不存在');
|
|
|
- if ($userInfo->phone) return app('json')->fail('您的账号已经绑定过手机号码!');
|
|
|
- if (User::where('phone', $phone)->where('user_type', '<>', 'h5')->count())
|
|
|
- return app('json')->success('此手机已经绑定,无法多次绑定!');
|
|
|
- if (User::where('account', $phone)->where('phone', $phone)->where('user_type', 'h5')->find()) {
|
|
|
- if (!$step) return app('json')->success('H5已有账号是否绑定此账号上', ['is_bind' => 1]);
|
|
|
- $userInfo->phone = $phone;
|
|
|
+ $userInfo = User::where('account', $phone)->find();
|
|
|
+ if ($userInfo) {
|
|
|
+ //直接绑定到老帐号
|
|
|
+// var_dump($request->uid());
|
|
|
+ $wechat = WechatUser::where('uid', $userInfo['uid'])->find();
|
|
|
+ if ($wechat['openid'] || $wechat['unionid'] || $wechat['routine_openid']) {
|
|
|
+ if (!$userInfo) return app('json')->fail('该手机或邮箱已绑定微信账号');
|
|
|
+ } else {
|
|
|
+ $now = WechatUser::where('uid', $request->uid())->find()->toArray();
|
|
|
+ unset($now['site_id']);
|
|
|
+ unset($now['uid']);
|
|
|
+ unset($now['add_time']);
|
|
|
+ unset($now['stair']);
|
|
|
+ unset($now['second']);
|
|
|
+ unset($now['order_stair']);
|
|
|
+ unset($now['order_second']);
|
|
|
+ unset($now['now_money']);
|
|
|
+ unset($now['user_type']);
|
|
|
+ WechatUser::where('uid', $userInfo['uid'])->update($now);
|
|
|
+ WechatUser::where('uid', $request->uid())->delete();
|
|
|
+ User::where('uid', $request->uid())->delete();
|
|
|
+ $request->tokenData()->delete();
|
|
|
+ return app('json')->success('绑定成功,请重新登录');
|
|
|
+ }
|
|
|
} else {
|
|
|
+ //账号的H5信息设置上
|
|
|
+ $userInfo = User::where('uid', $request->uid())->find();
|
|
|
+ $userPhone = $userInfo->account;
|
|
|
+ if (!$userInfo) return app('json')->fail('用户不存在');
|
|
|
+ if ($userInfo->account == $userInfo->email || $userInfo->account == $userInfo->phone) return app('json')->fail('您的账号已经绑定过手机号码或邮箱!');
|
|
|
$userInfo->account = $phone;
|
|
|
- $userInfo->phone = $phone;
|
|
|
+ if (mobile_check($phone))
|
|
|
+ $userInfo->phone = $phone;
|
|
|
+ else
|
|
|
+ $userInfo->email = $phone;
|
|
|
+ if ($userInfo->save() || $userPhone == $phone)
|
|
|
+ return app('json')->success('绑定成功');
|
|
|
+ else
|
|
|
+ return app('json')->fail('绑定失败');
|
|
|
}
|
|
|
- if ($userInfo->save() || $userPhone == $phone)
|
|
|
- return app('json')->success('绑定成功');
|
|
|
- else
|
|
|
- return app('json')->fail('绑定失败');
|
|
|
}
|
|
|
}
|