...
|
...
|
@@ -35,12 +35,14 @@ class User extends Api |
|
|
*
|
|
|
* @param string $openid openid
|
|
|
*
|
|
|
* @param string $mobile
|
|
|
*
|
|
|
* @return boolean
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
private function register($openid)
|
|
|
private function register($openid,$mobile = '')
|
|
|
{
|
|
|
// 检测用户openid是否存在
|
|
|
$user = new \app\admin\model\User;
|
...
|
...
|
@@ -57,7 +59,7 @@ class User extends Api |
|
|
'username' => '',
|
|
|
'password' => '',
|
|
|
'email' => '',
|
|
|
'mobile' => '',
|
|
|
'mobile' => $mobile,
|
|
|
'level' => 1,
|
|
|
'score' => 0,
|
|
|
'avatar' => '',
|
...
|
...
|
@@ -140,8 +142,9 @@ class User extends Api |
|
|
|
|
|
$mini = new \WeMini\Crypt($this->config);
|
|
|
$getUserInfo = $mini->decode($iv,$sessionKey,$encryptedData);
|
|
|
$mobile = $getUserInfo['purePhoneNumber'];
|
|
|
if(isset($mobile)){
|
|
|
$mobile = isset($getUserInfo['purePhoneNumber'])?$getUserInfo['purePhoneNumber']:'';
|
|
|
|
|
|
if(!empty($mobile)){
|
|
|
$user = new \app\admin\model\User;
|
|
|
$user->save(['openid'=>$openid],['mobile'=>$mobile,'openid'=>'']);
|
|
|
}
|
...
|
...
|
@@ -155,7 +158,7 @@ class User extends Api |
|
|
$user = new \app\admin\model\User;
|
|
|
$user = $user->where(['openid'=>$openid])->find();
|
|
|
if(empty($user)){
|
|
|
$ret = $this->register($openid);
|
|
|
$ret = $this->register($openid,empty($mobile)?'':$mobile);
|
|
|
}
|
|
|
}
|
|
|
if (!$ret) {
|
...
|
...
|
|