2
0

home.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. class HomeController extends Controller {
  4. async index() {
  5. const { ctx } = this;
  6. ctx.body = '111';
  7. }
  8. async test() {
  9. const { ctx } = this;
  10. const url = 'https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=26_ltUEKUrKLYOaiDQ0s6H0L3Mis1A4xQEuYElcRrU93k9k8h0g_Eya349E-hwS9pRd66SxVnmIPVdkwfPN1OL4_kpMJdcwNUs2mo5vfBEeM0CPYNhWXdWM4mcsewDVQDoq0SNCkUqIxM4yLMqKWKHiAGACQN';
  11. const stus = await this.ctx.curl(url, {
  12. method: 'POST',
  13. body: { tagid: 100, next_openid: '' },
  14. });
  15. console.log('111--' + stus.toString());
  16. const res = JSON.stringify(stus);
  17. const obj2 = JSON.parse(res);
  18. console.log(obj2);
  19. console.log('111--' + obj2.data.data.toString());
  20. ctx.body = obj2.data.data.toString();
  21. }
  22. async sendmq() {
  23. // const msg = { userid: ctx.body.userid, name: ctx.body.name, createtime: ctx.body.createtime, type: ctx.body.type, content: ctx.body.content, remark: ctx.body.remark };
  24. const ex = 'sch_review';
  25. const routekey = '11';
  26. const parm = { durable: true, headers: { userId: '5da47c54a24aa17d33309ead', type: '1', name: '哈哈' } };
  27. await this.service.rabbitmq.sendQueueMsg(ex, routekey, 'hhhsss', parm);
  28. this.ctx.body = '发送成功';
  29. }
  30. }
  31. module.exports = HomeController;