lrf402788946 4 years ago
parent
commit
433e46de8d
1 changed files with 5 additions and 5 deletions
  1. 5 5
      app/service/weixin.js

+ 5 - 5
app/service/weixin.js

@@ -62,10 +62,6 @@ class WeixinAuthService extends AxiosService {
       this.ctx.logger.error(JSON.stringify(req.data));
       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结束,接下来应该返回前端
     const key = `${this.prefix}${state}`;
     let fqueries = await this.app.redis.get(key);
@@ -75,7 +71,11 @@ class WeixinAuthService extends AxiosService {
     // TODO 验证redirect_uri,如果有groupid,type=group=>用户入驻,直接处理
     if (groupid) {
       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 };
         try {
           await this.ctx.service.patient.create(udata);