|
@@ -34,14 +34,16 @@ class WX {
|
|
|
async Send(wx_openid, template, data) {
|
|
|
let flag = false;
|
|
|
try {
|
|
|
- const templateId = template;
|
|
|
+ // const templateId = template;
|
|
|
+ let templateId = '';
|
|
|
const sck = 'https://scn.ink/';
|
|
|
for (const openid of wx_openid) {
|
|
|
let url = '';
|
|
|
let msgData = '';
|
|
|
let remark = '';
|
|
|
- switch (templateId) {
|
|
|
+ switch (template) {
|
|
|
case wxConst.template.stage :
|
|
|
+ templateId = wxConst.templateId.stage;
|
|
|
url = this.ctx.protocol + '://' + this.ctx.host + '/wx/url2wap?project=' + data.code + '&url=' + sck + data.wap_url;
|
|
|
msgData = {
|
|
|
first: {
|
|
@@ -65,6 +67,7 @@ class WX {
|
|
|
};
|
|
|
break;
|
|
|
case wxConst.template.change:
|
|
|
+ templateId = wxConst.templateId.change;
|
|
|
url = this.ctx.protocol + '://' + this.ctx.host + '/wx/url2wap?project=' + data.code + '&url=' + sck + data.wap_url;
|
|
|
remark = data.status === wxConst.status.check ? '微信可快速审批,如需进行详细审批' :
|
|
|
(data.status === wxConst.status.success ? '审批已通过,查看审批结果' : '审批被退回,查看退回结果');
|
|
@@ -87,6 +90,7 @@ class WX {
|
|
|
};
|
|
|
break;
|
|
|
case wxConst.template.ledger:
|
|
|
+ templateId = wxConst.templateId.ledger;
|
|
|
remark = data.status === wxConst.status.check ? '微信暂无法在线审批' :
|
|
|
(data.status === wxConst.status.success ? '审批已通过,查看审批结果' : '审批被退回,查看退回结果');
|
|
|
msgData = {
|
|
@@ -108,6 +112,7 @@ class WX {
|
|
|
};
|
|
|
break;
|
|
|
case wxConst.template.revise:
|
|
|
+ templateId = wxConst.templateId.revise;
|
|
|
remark = data.status === wxConst.status.check ? '微信暂无法在线审批' :
|
|
|
(data.status === wxConst.status.success ? '审批已通过,查看审批结果' :
|
|
|
(data.status === wxConst.status.back ? '审批被退回,查看退回结果' : '审批已上报,查看审批结果'));
|
|
@@ -130,6 +135,7 @@ class WX {
|
|
|
};
|
|
|
break;
|
|
|
case wxConst.template.material:
|
|
|
+ templateId = wxConst.templateId.material;
|
|
|
remark = data.status === wxConst.status.check ? '微信暂无法在线审批' :
|
|
|
(data.status === wxConst.status.success ? '审批已通过,查看审批结果' : '审批被退回,查看退回结果');
|
|
|
msgData = {
|
|
@@ -158,7 +164,7 @@ class WX {
|
|
|
break;
|
|
|
default:break;
|
|
|
}
|
|
|
- if (msgData !== '') {
|
|
|
+ if (msgData !== '' && templateId) {
|
|
|
// console.log(openid, templateId, url, msgData);
|
|
|
await this.ctx.app.wechat.api.sendTemplate(openid, templateId, url, '', msgData);
|
|
|
}
|