|
@@ -139,6 +139,45 @@ class WeixinAuthService extends AxiosService {
|
|
|
const [ status ] = val.split(':', 2);
|
|
|
return { status };
|
|
|
}
|
|
|
+
|
|
|
+ // 发送微信模板消息
|
|
|
+ async sendTemplateMsg(templateid, openid, first, keyword1, keyword2, remark) {
|
|
|
+ const url = this.ctx.app.config.sendDirMq + this.ctx.app.config.appid;
|
|
|
+ const requestData = { // 发送模板消息的数据
|
|
|
+ touser: openid,
|
|
|
+ template_id: templateid,
|
|
|
+ url: '',
|
|
|
+ data: {
|
|
|
+ first: {
|
|
|
+ value: first,
|
|
|
+ color: '#173177',
|
|
|
+ },
|
|
|
+ keyword1: {
|
|
|
+ value: keyword1,
|
|
|
+ color: '#1d1d1d',
|
|
|
+ },
|
|
|
+ keyword2: {
|
|
|
+ value: keyword2,
|
|
|
+ color: '#1d1d1d',
|
|
|
+ },
|
|
|
+ remark: {
|
|
|
+ value: remark,
|
|
|
+ color: '#173177',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ console.log('templateid---' + templateid);
|
|
|
+ console.log('openid---' + openid);
|
|
|
+ console.log('requestData---' + JSON.stringify(requestData));
|
|
|
+ await this.ctx.curl(url, {
|
|
|
+ method: 'post',
|
|
|
+ headers: {
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ },
|
|
|
+ dataType: 'json',
|
|
|
+ data: JSON.stringify(requestData),
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = WeixinAuthService;
|