weChatNotify.js
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Created by Tommy Huang on 18/04/24.
*/
const axios = require('axios')
const Helper = require('./helper')
async function send(body) {
try {
const {token} = await Helper.getWeChatToken()
console.log(token)
const {data} = await axios.post(`https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=${token}`, body)
console.log('====================')
console.log(data)
console.log('====================')
if (data.errcode === 0) {
return true
} else {
return false
}
} catch (e) {
console.log(e)
}
}
exports.sendListConfirmed = async (userId, borrowListId, borrowListNo) => {
const body = {
touser: userId,
template_id: 'ptEm0-cyd_ty5Wxu2roJEL9Tbs-59lesO5GEAYEhYqo ',
url: `https://www.51liuliang.cc/netiou/borrowContent?id=${borrowListId}`,
data: {
first: {value: '您有一张借条已被确认', color:'#173177'},
OrderSn: {value: borrowListNo, color:'#173177'},
OrderStatus: {value: '已确认', color:'#173177'},
remark: {value: '点击查看详情', color:'#173177'}
}
}
const result = await send(body)
return result
}