|
@@ -75,7 +75,8 @@ class User extends Api
|
|
{
|
|
{
|
|
$mobile = $this->request->post('mobile');
|
|
$mobile = $this->request->post('mobile');
|
|
$captcha = $this->request->post('captcha');
|
|
$captcha = $this->request->post('captcha');
|
|
- if (!$mobile || !$captcha) {
|
|
|
|
|
|
+ $openid = $this->request->post('openid');
|
|
|
|
+ if (!$mobile || !$captcha || !$openid) {
|
|
$this->error(__('Invalid parameters'));
|
|
$this->error(__('Invalid parameters'));
|
|
}
|
|
}
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
@@ -579,7 +580,7 @@ class User extends Api
|
|
$openid = input('openid', '', 'trim');
|
|
$openid = input('openid', '', 'trim');
|
|
$mobile = input('mobile','','trim');
|
|
$mobile = input('mobile','','trim');
|
|
$nickName = input('nickname','');
|
|
$nickName = input('nickname','');
|
|
- $avatar = input('avatar','');
|
|
|
|
|
|
+ $avatar = input('avatar','/assets/img/avatar.png');
|
|
$sex = input('gender',0);
|
|
$sex = input('gender',0);
|
|
if (!$openid) {
|
|
if (!$openid) {
|
|
throw new Exception('未获取到用户openid');
|
|
throw new Exception('未获取到用户openid');
|
|
@@ -587,10 +588,10 @@ class User extends Api
|
|
$user = UserM::where(['mini_openid'=>$openid])->find();
|
|
$user = UserM::where(['mini_openid'=>$openid])->find();
|
|
if (!$user) {//未查到用户信息
|
|
if (!$user) {//未查到用户信息
|
|
//用户手机号注册
|
|
//用户手机号注册
|
|
- if (empty($mobile)) {
|
|
|
|
|
|
+ /*if (empty($mobile)) {
|
|
throw new Exception('未获取到手机号');
|
|
throw new Exception('未获取到手机号');
|
|
}
|
|
}
|
|
- $user = UserM::where(['mobile'=>$mobile])->find();
|
|
|
|
|
|
+ $user = UserM::where(['mobile'=>$mobile])->find();*/
|
|
if (empty($user)) {//微信登录注册
|
|
if (empty($user)) {//微信登录注册
|
|
$time = time();
|
|
$time = time();
|
|
$ip = request()->ip();
|
|
$ip = request()->ip();
|
|
@@ -598,7 +599,7 @@ class User extends Api
|
|
'nickname' => $nickName,
|
|
'nickname' => $nickName,
|
|
'avatar' => $avatar,
|
|
'avatar' => $avatar,
|
|
'gender' => $sex,
|
|
'gender' => $sex,
|
|
- 'mobile' => $mobile,
|
|
|
|
|
|
+ //'mobile' => $mobile,
|
|
'joinip' => $ip,
|
|
'joinip' => $ip,
|
|
'jointime' => $time,
|
|
'jointime' => $time,
|
|
'createtime'=> $time,
|
|
'createtime'=> $time,
|
|
@@ -610,13 +611,7 @@ class User extends Api
|
|
}
|
|
}
|
|
$user = Userm::getById($userAdd);
|
|
$user = Userm::getById($userAdd);
|
|
}
|
|
}
|
|
- if (empty($user->openid)) {//手机号绑定openid
|
|
|
|
- $user->mini_openid = $openid;
|
|
|
|
- $userRes = $user->save();
|
|
|
|
- if (!$userRes) {
|
|
|
|
- throw new Exception('绑定微信失败');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
$userUpdate = [];
|
|
$userUpdate = [];
|
|
if (!empty($nickName) && empty($user->nick_name)) {
|
|
if (!empty($nickName) && empty($user->nick_name)) {
|
|
@@ -628,6 +623,9 @@ class User extends Api
|
|
if (!empty($sex) && $sex != $user->sex) {
|
|
if (!empty($sex) && $sex != $user->sex) {
|
|
$userUpdate['gender'] = $sex;
|
|
$userUpdate['gender'] = $sex;
|
|
}
|
|
}
|
|
|
|
+ if (empty($user->mini_openid)) {//手机号绑定openid
|
|
|
|
+ $userUpdate['mini_openid'] = $openid;
|
|
|
|
+ }
|
|
if (!empty($userUpdate)) {
|
|
if (!empty($userUpdate)) {
|
|
$userUpRes = Db::name('user')->where(['id'=>$user->id])->update($userUpdate);
|
|
$userUpRes = Db::name('user')->where(['id'=>$user->id])->update($userUpdate);
|
|
if (!$userUpRes) {
|
|
if (!$userUpRes) {
|