Quellcode durchsuchen

增加绑定方法

liuyu vor 5 Jahren
Ursprung
Commit
a29b05e867
2 geänderte Dateien mit 5 neuen und 11 gelöschten Zeilen
  1. 1 8
      app/controller/weixin.js
  2. 4 3
      app/service/user.js

+ 1 - 8
app/controller/weixin.js

@@ -93,14 +93,7 @@ class WeixinController extends Controller {
           this.ctx.redirect(to_uri);
         }
       } else if (type === '1') {
-        const user = await this.ctx.service.user.fetch({ id: uid });
-        let _type = '';
-        if (user) {
-          _type = user.type;
-        } else {
-          _type = type;
-        }
-        const to_uri = urljoin(redirect_uri, `?openid=${openid}&uid=${uid}&type=${_type}&qrcode=${qrcode}`);
+        const to_uri = urljoin(redirect_uri, `?openid=${openid}&uid=${uid}&type=${type}&qrcode=${qrcode}`);
         // TODO: 重定性页面
         this.ctx.redirect(to_uri);
       } else if (type === '2') {

+ 4 - 3
app/service/user.js

@@ -103,8 +103,8 @@ class UserService extends CrudService {
 
   // 其他用户绑定
   async userbind(data) {
-    const { openid, uid, type } = data;
-    assert(openid && uid, '缺少部分信息项');
+    const { openid, uid, qucode } = data;
+    assert(openid && uid && qucode, '缺少部分信息项');
     const user = await this.model.findById(uid);
     if (!user) {
       throw new BusinessError(ErrorCode.USER_NOT_EXIST);
@@ -119,10 +119,11 @@ class UserService extends CrudService {
           durable: true,
           headers: {
             userid: uid,
+            openid,
           } };
         console.log(parm);
         console.log(msg);
-        await mq.topic('user_bind', uid, msg, parm);
+        await mq.topic('qrcode.bind', qucode, msg, parm);
       } else {
         this.ctx.logger.error('!!!!!!没有配置MQ插件!!!!!!');
       }