package.json
{
"name": "autoFreshPayStatus",
"main": "index.js",
"version": "1.0.0",
"description": "",
"cloudfunction-config": {
"concurrency": 1,
"memorySize": 128,
"path": "",
"timeout": 10,
"triggers": [{
"config": "0 0 3 * * * *",
"name": "autoFreshPayStatus",
"type": "timer"
}],
"runtime": "Nodejs12"
}
}
index.js
'use strict';
exports.main = async (event, context) => {
/**
* 定时器 - 自动更新付款状态
*/
let res = { code:0, msg:"" };
res.callFunctionResult = await uniCloud.callFunction({
name: "autoFreshPayStatus",
data: {
// 需要执行的云函数路径
$url: "client/timer/pub/fresh_pay_status" ,
// 请求参数,这里加个key可以有效防止云函数被直接访问,云函数中加判断条件,如果key不是666666,则不运行。
data:{
key:"666666"
}
}
});
return res;
};