正在显示
1 个修改的文件
包含
16 行增加
和
16 行删除
@@ -71,22 +71,22 @@ class User extends Api | @@ -71,22 +71,22 @@ class User extends Api | ||
71 | $code = $this->request->post('code'); | 71 | $code = $this->request->post('code'); |
72 | $user_info = $this->request->post('user_info'); | 72 | $user_info = $this->request->post('user_info'); |
73 | $testopenid = $this->request->post('testopenid'); | 73 | $testopenid = $this->request->post('testopenid'); |
74 | - // $session = Wechat::miniProgram()->auth->session($code); | ||
75 | - // // 自动注册用户 | ||
76 | - // $userInfo = json_decode(htmlspecialchars_decode($user_info), true); | ||
77 | - // if (!$user = $this->model->get(['openid' => $session['openid']])) { | ||
78 | - // $user = $this->model; | ||
79 | - // $userInfo['openid'] = $session['openid']; | ||
80 | - // } | ||
81 | - // $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickName']); | ||
82 | - // $userInfo['avatar'] = $userInfo['avatarUrl']; | ||
83 | - // if (!$user->allowField(true)->save($userInfo)) { | ||
84 | - // $this->error('用户登录失败'); | ||
85 | - // } | ||
86 | - $session = [ | ||
87 | - 'openid' => $testopenid ?: 'test', | ||
88 | - ]; | ||
89 | - $user = $this->model->get(['openid' => $session['openid']]); | 74 | + $session = Wechat::miniProgram()->auth->session($code); |
75 | + // 自动注册用户 | ||
76 | + $userInfo = json_decode(htmlspecialchars_decode($user_info), true); | ||
77 | + if (!$user = $this->model->get(['openid' => $session['openid']])) { | ||
78 | + $user = $this->model; | ||
79 | + $userInfo['openid'] = $session['openid']; | ||
80 | + } | ||
81 | + $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickName']); | ||
82 | + $userInfo['avatar'] = $userInfo['avatarUrl']; | ||
83 | + if (!$user->allowField(true)->save($userInfo)) { | ||
84 | + $this->error('用户登录失败'); | ||
85 | + } | ||
86 | + // $session = [ | ||
87 | + // 'openid' => $testopenid ?: 'test', | ||
88 | + // ]; | ||
89 | + // $user = $this->model->get(['openid' => $session['openid']]); | ||
90 | // 生成token (session3rd) | 90 | // 生成token (session3rd) |
91 | $guid = guidv4();// 生成一个不会重复的随机字符串 | 91 | $guid = guidv4();// 生成一个不会重复的随机字符串 |
92 | $timeStamp = microtime(true);// 当前时间戳 (精确到毫秒) | 92 | $timeStamp = microtime(true);// 当前时间戳 (精确到毫秒) |
-
请 注册 或 登录 后发表评论