123456789101112131415161718192021222324252627282930313233 |
- 'use strict';
- const Controller = require('egg').Controller;
- class YunjiuyeController extends Controller {
- constructor(ctx) {
- super(ctx);
- this.service = this.ctx.service.yunjiuye;
- }
- // http://127.0.0.1:7001/api/train/y/login?code=中心&org=0
- async login() {
- const query = this.ctx.query;
- const { code, org } = query;
- const res = await this.service.checkUserIsConnect(query);
- const { toBindPage, toDealTokenPage } = this.app.config.yunjiuye;
- // 没关联,转到登录页面
- if (!res) {
- this.ctx.redirect(`${toBindPage}?code=${code}&org=${org}`);
- } else {
- // 已关联,转到加载token页面
- const token = await this.service.userToken(res);
- this.ctx.redirect(`${toDealTokenPage}?token=${token}`);
- }
- }
- async userBind() {
- const body = this.ctx.request.body;
- // 成功返回suid
- const res = await this.service.userBind(body);
- // 请求token,返回token
- const token = await this.service.userToken(res);
- this.ctx.ok({ data: token });
- }
- }
- module.exports = YunjiuyeController;
|