Explorar o código

增加微信端回调地址班主任与教师

liuyu %!s(int64=4) %!d(string=hai) anos
pai
achega
575ee78853
Modificáronse 2 ficheiros con 21 adicións e 6 borrados
  1. 20 5
      app/controller/weixin.js
  2. 1 1
      app/model/leave.js

+ 20 - 5
app/controller/weixin.js

@@ -77,15 +77,30 @@ class WeixinController extends Controller {
       const val = await this.app.redis.get(key);
       const { redirect_uri, type, uid, qrcode } = JSON.parse(val);
       console.log('redirect_uri-->' + redirect_uri);
+      const user = await this.ctx.service.user.findByOpenid(openid);
       if (type === '0') {
         // 通过openid取得用户信息
-        const user = await this.ctx.service.user.findByOpenid(openid);
         if (user) {
           const token = await this.ctx.service.login.createJwt(user);
-          const to_uri = urljoin(redirect_uri, `?token=${token}`);
-          // TODO: 重定性页面
-          console.log('to_uri000-->' + to_uri);
-          this.ctx.redirect(to_uri);
+          if (user.type === '4') {
+            const to_uri = urljoin(redirect_uri, `?token=${token}`);
+            // TODO: 重定性页面
+            console.log('to_uri000-->' + to_uri);
+            this.ctx.redirect(to_uri);
+          } else if (user.type === '1') {
+            const touri = `${this.app.config.baseUrl}/mobiledirtea`;
+            const to_uri = urljoin(touri, `?token=${token}`);
+            // TODO: 重定性页面
+            console.log('to_uri000-->' + to_uri);
+            this.ctx.redirect(to_uri);
+          } else if (user.type === '3') {
+            const touri = `${this.app.config.baseUrl}/mobiledirtea`;
+            const to_uri = urljoin(touri, `?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}/student/bind`;

+ 1 - 1
app/model/leave.js

@@ -13,7 +13,7 @@ const LeaveSchema = {
   starttime: { type: String, required: false, maxLength: 200 }, // 开始时间
   endtime: { type: String, required: false, maxLength: 500 }, // 结束时间
   reason: { type: String, required: false, maxLength: 2000 }, // 请假理由
-  status: { type: String, required: false, maxLength: 200, default: "0" }, // 状态,0-审核中,1-通过,2-未通过
+  status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-审核中,1-通过,2-未通过
   refcause: { type: String, required: false, maxLength: 2000 }, // 拒绝原因
   type: { type: String, required: false, maxLength: 200 }, // 类型,0-请假,1-退出
 };