以下代码红色部分时不是的调用几次后就无法获取到openid了?
云函数部分代码如下:
const cloud = require('wx-server-sdk'
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
let _openid = wxContext.OPENID;
let action = event.action
let taskClassNumber, record_date;
if (action === 'get_status') {
return getTaskStatus(_openid);
} else if (action == 'get_task_Answer') {
taskClassNumber = event.taskClassNumber
record_date = await getToday()
//这里获取openid失败了
console.log("wxContext.OPENID:",wxContext.OPENID)
return getTaskAnswer(wxContext.OPENID, taskClassNumber, record_date)
} else if (action == 'add_answer_record') {
let recordObj = event.recordObj
return addTaskAnswerRecord(_openid, recordObj)
}