'use strict';
module.exports = {
/**
- 此函数名称
- @url user/pub/test1 前端调用的url参数地址
- data 请求参数
-
@param {String} params1 参数1
*/
main: async (event) => {
let {
data = {}, userInfo, util, originalParam
} = event;
let {
customUtil,
config,
pubFun,
vk,
db,
_
} = util;
let {
uid,
id
} = data;
// 业务逻辑开始-----------------------------------------------------------
//执行业务逻辑
let res = await sendSms(id)
if (res.errCode<0) {
return res
}else{
console.log("34行=》",res.id);
vk.callFunction({
url: 'admin/pages/pub/digui',
title: '请求中...',
data: {
id: res.id
}
}).catch(e=>{
console.log(e);
}).then(e=>{
console.log(e);
});
// let aiqiyiurl =
// "https://yhs.zzhz.cn/hd/admin/pages/pub/digui"
// let aiqiyihuichuan_result = await uniCloud.httpclient.request(aiqiyiurl, {
// method: 'GET',
// data: {
// id: res.id
// },
// contentType: 'json',
// dataType: 'json'
// })
// 如果没有报错,就让当前云函数 调用当前云函数(云对象同理)。注意:这里是异步的// 等待500毫秒,给一个请求发出去的时间 return await new Promise((resolve, reject) => { setTimeout(() => { resolve(res) }, 500) }) } // 业务逻辑结束----------------------------------------------------------- async function sendSms(id) { console.log('id', id); id = id - 1; if (id < 0) { return { errCode: -1, id: id } } return { errCode: 0, id: id } }
},
}
y***@163.com (作者)
好的,请问一下,我配置了那个参数"keepRunningAfterReturn":true之后,在云函数中return之后,在return后面的语句还会执行吗?
2023-04-21 10:17
DCloud_uniCloud_CRL
回复 y***@163.com: return之后的语句不会执行,keepRunningAfterReturn 的意思是 return 之后不会立即冻结云函数,还会等待其他逻辑执行完才会冻结。keepRunningAfterReturn 只有腾讯云 nodejs12 支持。
2023-04-21 17:03