|
@@ -35,12 +35,14 @@ class User extends Api |
|
@@ -35,12 +35,14 @@ class User extends Api |
35
|
*
|
35
|
*
|
36
|
* @param string $openid openid
|
36
|
* @param string $openid openid
|
37
|
*
|
37
|
*
|
|
|
38
|
+ * @param string $mobile
|
|
|
39
|
+ *
|
38
|
* @return boolean
|
40
|
* @return boolean
|
39
|
* @throws \think\db\exception\DataNotFoundException
|
41
|
* @throws \think\db\exception\DataNotFoundException
|
40
|
* @throws \think\db\exception\ModelNotFoundException
|
42
|
* @throws \think\db\exception\ModelNotFoundException
|
41
|
* @throws \think\exception\DbException
|
43
|
* @throws \think\exception\DbException
|
42
|
*/
|
44
|
*/
|
43
|
- private function register($openid)
|
45
|
+ private function register($openid,$mobile = '')
|
44
|
{
|
46
|
{
|
45
|
// 检测用户openid是否存在
|
47
|
// 检测用户openid是否存在
|
46
|
$user = new \app\admin\model\User;
|
48
|
$user = new \app\admin\model\User;
|
|
@@ -57,7 +59,7 @@ class User extends Api |
|
@@ -57,7 +59,7 @@ class User extends Api |
57
|
'username' => '',
|
59
|
'username' => '',
|
58
|
'password' => '',
|
60
|
'password' => '',
|
59
|
'email' => '',
|
61
|
'email' => '',
|
60
|
- 'mobile' => '',
|
62
|
+ 'mobile' => $mobile,
|
61
|
'level' => 1,
|
63
|
'level' => 1,
|
62
|
'score' => 0,
|
64
|
'score' => 0,
|
63
|
'avatar' => '',
|
65
|
'avatar' => '',
|
|
@@ -140,8 +142,9 @@ class User extends Api |
|
@@ -140,8 +142,9 @@ class User extends Api |
140
|
|
142
|
|
141
|
$mini = new \WeMini\Crypt($this->config);
|
143
|
$mini = new \WeMini\Crypt($this->config);
|
142
|
$getUserInfo = $mini->decode($iv,$sessionKey,$encryptedData);
|
144
|
$getUserInfo = $mini->decode($iv,$sessionKey,$encryptedData);
|
143
|
- $mobile = $getUserInfo['purePhoneNumber'];
|
|
|
144
|
- if(isset($mobile)){
|
145
|
+ $mobile = isset($getUserInfo['purePhoneNumber'])?$getUserInfo['purePhoneNumber']:'';
|
|
|
146
|
+
|
|
|
147
|
+ if(!empty($mobile)){
|
145
|
$user = new \app\admin\model\User;
|
148
|
$user = new \app\admin\model\User;
|
146
|
$user->save(['openid'=>$openid],['mobile'=>$mobile,'openid'=>'']);
|
149
|
$user->save(['openid'=>$openid],['mobile'=>$mobile,'openid'=>'']);
|
147
|
}
|
150
|
}
|
|
@@ -155,7 +158,7 @@ class User extends Api |
|
@@ -155,7 +158,7 @@ class User extends Api |
155
|
$user = new \app\admin\model\User;
|
158
|
$user = new \app\admin\model\User;
|
156
|
$user = $user->where(['openid'=>$openid])->find();
|
159
|
$user = $user->where(['openid'=>$openid])->find();
|
157
|
if(empty($user)){
|
160
|
if(empty($user)){
|
158
|
- $ret = $this->register($openid);
|
161
|
+ $ret = $this->register($openid,empty($mobile)?'':$mobile);
|
159
|
}
|
162
|
}
|
160
|
}
|
163
|
}
|
161
|
if (!$ret) {
|
164
|
if (!$ret) {
|