(title, content, uid)
| 772 | } |
| 773 | |
| 774 | function wxpusher(title, content, uid) { |
| 775 | return new Promise(resolve => { |
| 776 | $.post({ |
| 777 | url: 'http://wxpusher.zjiecode.com/api/send/message', |
| 778 | body: JSON.stringify({ |
| 779 | "appToken": appToken, |
| 780 | "content": `${title}\n\n${content}`, |
| 781 | "summary": title,//消息摘要,显示在微信聊天页面或者模版消息卡片上,限制长度100,可以不传,不传默认截取content前面的内容。 |
| 782 | "contentType": 1,//内容类型 1表示文字 2表示html(只发送body标签内部的数据即可,不包括body标签) 3表示markdown |
| 783 | "topicIds": [ //发送目标的topicId,是一个数组!!!,也就是群发,使用uids单发的时候, 可以不传。 |
| 784 | ], |
| 785 | "uids": [uid],//发送目标的UID,是一个数组。注意uids和topicIds可以同时填写,也可以只填写一个。 |
| 786 | "url": "" //原文链接,可选参数 |
| 787 | }), |
| 788 | headers: { |
| 789 | 'Content-Type': 'application/json' |
| 790 | } |
| 791 | }, (err, resp, data) => { |
| 792 | try { |
| 793 | if (!err) { |
| 794 | data = $.toObj(data) |
| 795 | if (data.code === 1000) { |
| 796 | console.log(`wxpusher: ${uid} 发送成功`) |
| 797 | } else { |
| 798 | console.log(`wxpusher: ${uid} 发送失败\n${data}`) |
| 799 | } |
| 800 | } else { |
| 801 | console.log('wxpusher Error1:', err) |
| 802 | } |
| 803 | } catch (e) { |
| 804 | console.log('wxpusher Error2:', e) |
| 805 | } finally { |
| 806 | resolve() |
| 807 | } |
| 808 | }) |
| 809 | }) |
| 810 | } |
| 811 | |
| 812 | module.exports = { |
| 813 | sendNotify, |
no test coverage detected