weChatNotify.js
1 KB
/**
* 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()
const {data} = await axios.post(`https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=${token}`, body)
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
}