微信修改了获取用户基本信息 接口返回的参数,不在返回nickname、headimgurl;因此多商户的微信授权方法也需要做兼容. 1.7.2版本已兼容, 之前的版本可以自行按照下面的操作兼容.
- 修改 \app\common\repositories\wechat\WechatUserRepository::syncUser 方法
修改图中划线的代码为
$userInfo['nickname'] = filter_emoji($userInfo['nickname'] ?? ('微信用户' . substr(uniqid(true, true), -6)));
- 修改\app\common\repositories\user\UserRepository::syncWechatUser方法
public function syncWechatUser(WechatUser $wechatUser, $userType = 'wechat')
{
$user = $this->dao->wechatUserIdBytUser($wechatUser->wechat_user_id);
$request = request();
if ($user) {
$user->save([
'nickname' => $wechatUser['nickname'] ?? '',
'avatar' => $wechatUser['headimgurl'] ?? '',
'sex' => $wechatUser['sex'] ?? 0,
'last_time' => date('Y-m-d H:i:s'),
'last_ip' => $request->ip(),
]);
} else {
$user = $this->create($userType, [
'account' => 'wx' . $wechatUser->wechat_user_id . time(),
'wechat_user_id' => $wechatUser->wechat_user_id,
'pwd' => $this->encodePassword($this->dao->defaultPwd()),
'nickname' => $wechatUser['nickname'] ?? '',
'avatar' => $wechatUser['headimgurl'] ?? '',
'sex' => $wechatUser['sex'] ?? 0,
'spread_uid' => 0,
'is_promoter' => 0,
'last_time' => date('Y-m-d H:i:s'),
'last_ip' => $request->ip()
]);
}
return $user;
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}