weixin.js 760 B

12345678910111213141516171819202122232425
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  4. class WeixinController extends Controller {
  5. constructor(ctx) {
  6. super(ctx);
  7. this.service = this.ctx.service.weixin;
  8. }
  9. async auth() {
  10. await this.service.auth(this.ctx.params, this.ctx.query);
  11. }
  12. async authBack() {
  13. await this.service.authBack(this.ctx.query);
  14. }
  15. async wxUser() {
  16. const data = await this.service.wxUser(this.ctx.params, this.ctx.query);
  17. this.ctx.ok({ data });
  18. }
  19. async jsapiAuth() {
  20. const res = await this.service.jsapiAuth(this.ctx.request.body);
  21. this.ctx.ok({ data: res });
  22. }
  23. }
  24. module.exports = CrudController(WeixinController, {});