|
@@ -62,10 +62,6 @@ class WeixinAuthService extends AxiosService {
|
|
this.ctx.logger.error(JSON.stringify(req.data));
|
|
this.ctx.logger.error(JSON.stringify(req.data));
|
|
throw new BusinessError(ErrorCode.SERVICE_FAULT, '未获取到openid');
|
|
throw new BusinessError(ErrorCode.SERVICE_FAULT, '未获取到openid');
|
|
}
|
|
}
|
|
- // 获取微信的用户信息
|
|
|
|
- const res = await this.httpGet('/api.weixin.qq.com/cgi-bin/user/info?lang=zh_CN', { appid, openid });
|
|
|
|
- const object = _.pick(res, [ 'nickname', 'headimgurl', 'openid' ]); // 昵称,头像,openid
|
|
|
|
- console.log('已获取用户信息');
|
|
|
|
// 验证获取openid结束,接下来应该返回前端
|
|
// 验证获取openid结束,接下来应该返回前端
|
|
const key = `${this.prefix}${state}`;
|
|
const key = `${this.prefix}${state}`;
|
|
let fqueries = await this.app.redis.get(key);
|
|
let fqueries = await this.app.redis.get(key);
|
|
@@ -75,7 +71,11 @@ class WeixinAuthService extends AxiosService {
|
|
// TODO 验证redirect_uri,如果有groupid,type=group=>用户入驻,直接处理
|
|
// TODO 验证redirect_uri,如果有groupid,type=group=>用户入驻,直接处理
|
|
if (groupid) {
|
|
if (groupid) {
|
|
if (type === 'group') {
|
|
if (type === 'group') {
|
|
- // TODO加用户,进组
|
|
|
|
|
|
+ // 加用户,进组
|
|
|
|
+ // 获取微信的用户信息
|
|
|
|
+ const res = await this.httpGet('/api.weixin.qq.com/cgi-bin/user/info?lang=zh_CN', { appid, openid });
|
|
|
|
+ const object = _.pick(res, [ 'nickname', 'headimgurl', 'openid' ]); // 昵称,头像,openid
|
|
|
|
+ console.log('已获取用户信息');
|
|
const udata = { name: object.nickname, icon: object.headimgurl, openid: object.openid, groupid };
|
|
const udata = { name: object.nickname, icon: object.headimgurl, openid: object.openid, groupid };
|
|
try {
|
|
try {
|
|
await this.ctx.service.patient.create(udata);
|
|
await this.ctx.service.patient.create(udata);
|