1、云函数config.json
{
"triggers": [
{
"name": "myTrigger",
"type": "timer",
"config": "0 */5 9-10 * * * *"
}
]
}
2、云函数index.js
const cloud = require('wx-server-sdk')
cloud.init({
env: 'xxxxxxx'
})
const db= cloud.database()
exports.main = async (event, context) => {
try {
db.collection("txxx").where( {
} )
.count()
.then(res => {
console.log(res);
var le=res.total
cloud.openapi.subscribeMessage.send({
touser:'xxxxxxxx',
data: {
thing4: {
value:le
},
date3: {
value: '2020年11月27日'
},
},
templateId: 'xxxxxxxxxxxxxxxxxxxxxx',
miniprogramState: 'developer'
})
})
} catch (err) {
return err
}
}
--------------------------------------
可以用按键点击发送订阅信息,但是不能用触发器触发?