liuyu 4 年之前
父节点
当前提交
123b610ea2
共有 1 个文件被更改,包括 34 次插入5 次删除
  1. 34 5
      app/controller/weixin.js

+ 34 - 5
app/controller/weixin.js

@@ -135,11 +135,38 @@ class WeixinController extends Controller {
           console.log('to_uri000-->' + to_uri);
           this.ctx.redirect(to_uri);
         } else {
-          console.log('rrr0000--->' + redirect_uri);
-          const touri = `${this.app.config.baseUrl}/platmobile/error`;
-          const to_uri = urljoin(touri, `?openid=${openid}`);
-          // TODO: 重定性页面
-          this.ctx.redirect(to_uri);
+          const url = 'http://127.0.0.1:9008/api/live/dock/dockopenid?openid=' + openid;
+          const dockuser = await this.ctx.curl(url, {
+            method: 'post',
+            headers: {
+              'content-type': 'application/json',
+            },
+            dataType: 'json',
+          });
+          const user_ = {};
+          if (dockuser.status === 200) {
+            if (dockuser.data.errcode === 0) {
+              const vd = dockuser.data.res;
+              user_.id = vd.id;
+              user_.name = vd.adminuser;
+              user_.role = vd.role;
+              user_.phone = vd.phone;
+            }
+          }
+          if (user_) {
+            const token = await this.ctx.service.login.createJwt(user_);
+            console.log('token--->' + token);
+            const to_uri = urljoin(redirect_uri, `?token=${token}`);
+            // TODO: 重定性页面
+            console.log('to_uri000-->' + to_uri);
+            this.ctx.redirect(to_uri);
+          } else {
+            console.log('rrr0000--->' + redirect_uri);
+            const touri = `${this.app.config.baseUrl}/platmobile/error`;
+            const to_uri = urljoin(touri, `?openid=${openid}`);
+            // TODO: 重定性页面
+            this.ctx.redirect(to_uri);
+          }
         }
       } else if (type === '1') {
         const to_uri = urljoin(
@@ -186,6 +213,8 @@ class WeixinController extends Controller {
           console.log('to_uri000-->' + to_uri);
           this.ctx.redirect(to_uri);
         } else {
+
+
           console.log('rrr0000--->' + redirect_uri);
           const touri = `${this.app.config.baseUrl}/platmobile/error`;
           const to_uri = urljoin(touri, `?openid=${openid}`);