...
|
...
|
@@ -71,22 +71,22 @@ class User extends Api |
|
|
$code = $this->request->post('code');
|
|
|
$user_info = $this->request->post('user_info');
|
|
|
$testopenid = $this->request->post('testopenid');
|
|
|
// $session = Wechat::miniProgram()->auth->session($code);
|
|
|
// // 自动注册用户
|
|
|
// $userInfo = json_decode(htmlspecialchars_decode($user_info), true);
|
|
|
// if (!$user = $this->model->get(['openid' => $session['openid']])) {
|
|
|
// $user = $this->model;
|
|
|
// $userInfo['openid'] = $session['openid'];
|
|
|
// }
|
|
|
// $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickName']);
|
|
|
// $userInfo['avatar'] = $userInfo['avatarUrl'];
|
|
|
// if (!$user->allowField(true)->save($userInfo)) {
|
|
|
// $this->error('用户登录失败');
|
|
|
// }
|
|
|
$session = [
|
|
|
'openid' => $testopenid ?: 'test',
|
|
|
];
|
|
|
$user = $this->model->get(['openid' => $session['openid']]);
|
|
|
$session = Wechat::miniProgram()->auth->session($code);
|
|
|
// 自动注册用户
|
|
|
$userInfo = json_decode(htmlspecialchars_decode($user_info), true);
|
|
|
if (!$user = $this->model->get(['openid' => $session['openid']])) {
|
|
|
$user = $this->model;
|
|
|
$userInfo['openid'] = $session['openid'];
|
|
|
}
|
|
|
$userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickName']);
|
|
|
$userInfo['avatar'] = $userInfo['avatarUrl'];
|
|
|
if (!$user->allowField(true)->save($userInfo)) {
|
|
|
$this->error('用户登录失败');
|
|
|
}
|
|
|
// $session = [
|
|
|
// 'openid' => $testopenid ?: 'test',
|
|
|
// ];
|
|
|
// $user = $this->model->get(['openid' => $session['openid']]);
|
|
|
// 生成token (session3rd)
|
|
|
$guid = guidv4();// 生成一个不会重复的随机字符串
|
|
|
$timeStamp = microtime(true);// 当前时间戳 (精确到毫秒)
|
...
|
...
|
|