Browse Source

修改模板消息

liuyu 5 years ago
parent
commit
45f557f305
3 changed files with 16 additions and 8 deletions
  1. 0 2
      app/router.js
  2. 8 6
      app/service/wechat.js
  3. 8 0
      config/config.default.js

+ 0 - 2
app/router.js

@@ -6,8 +6,6 @@
 module.exports = app => {
   const { router, controller } = app;
   router.get('/', controller.home.index);
-  router.get('/api/test', controller.home.test);
-  router.get('/api/sendmq', controller.home.sendmq);
   // 待办事项
   router.resources('message', '/api/message', controller.message); // index、create、show、destroy
 

+ 8 - 6
app/service/wechat.js

@@ -11,11 +11,11 @@ class WechatService extends Service {
 
   // 发送微信模板消息
   async sendTemplateMsg(templateid, openid, first, keyword1, keyword2, keyword3, remark) {
-    const url = this.ctx.app.config.sendDir + this.appid;
+    const url = this.ctx.app.config.sendDirMq + this.ctx.app.config.appid;
     const requestData = { // 发送模板消息的数据
       touser: openid,
       template_id: templateid,
-      url: 'http://weixin.qq.com/download',
+      url: '',
       data: {
         first: {
           value: first,
@@ -39,12 +39,14 @@ class WechatService extends Service {
         },
       },
     };
-    const result = await this.ctx.curl(url, {
+    await this.ctx.curl(url, {
       method: 'post',
-      body: requestData,
+      headers: {
+        'content-type': 'application/json',
+      },
+      dataType: 'json',
+      data: JSON.stringify(requestData),
     });
-    console.log(result);
-
   }
 
 }

+ 8 - 0
config/config.default.js

@@ -39,6 +39,12 @@ module.exports = appInfo => {
     },
   };
 
+  config.multipart = {
+    fileSize: '50mb', // 文件大小
+    mode: 'file', // 文件模式
+    whitelist: [ '.xlsx' ], // 文件类型白名单
+  };
+
   // mongoose config
   // config.mongoose = {
   //   url: 'mongodb://127.0.0.1:27017/smart',
@@ -52,6 +58,8 @@ module.exports = appInfo => {
   // };
   // base路径
   config.sendDirMq = 'http://wx.cc-lotus.info/api.weixin.qq.com/cgi-bin/message/template/send?appid=';
+  // appID
+  config.appid = 'wxdf3ed83c095be97a';
   // base路径
   config.baseDirMq = 'http://smart.cc-lotus.info';
   // 企业信息url