weixin.js 821 B

1234567891011121314151617181920212223242526272829
  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 index() {
  10. console.log(this.ctx.params, this.ctx.query);
  11. this.ctx.ok();
  12. }
  13. async auth() {
  14. await this.service.auth(this.ctx.query);
  15. }
  16. async authBack() {
  17. await this.service.authBack(this.ctx.query);
  18. }
  19. async wxUser() {
  20. const data = await this.service.wxUser(this.ctx.query);
  21. this.ctx.ok({ data });
  22. }
  23. async jsapiAuth() {
  24. const res = await this.service.jsapiAuth(this.ctx.request.body);
  25. this.ctx.ok({ data: res });
  26. }
  27. }
  28. module.exports = CrudController(WeixinController, {});