在编译的过程中,点击注册/登录,出现问题,错误结果显示‘could’未被声明。
WAServiceMainContext.js?t=wechat&s=1685572854519&v=2.32.0:1 Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: ReferenceError: could is not defined
at Runtime.exports.main [as handler] (:19202/var/user/index.js:13)
at Runtime.handleOnce (:19202/var/runtime/node12/Runtime.engine.js:219)
at Timeout._onTimeout (:19202/var/runtime/node12/Runtime.engine.js:56)
at listOnTimeout (:19202/appservice/internal/timers.js:549)
at processTimers (:19202/appservice/internal/timers.js:492) (callId: 1685686549514-0.5596697852395012) (trace: 14:15:49 start->14:15:49 system error (Error: errCode: -504002 functions execute fail | errMsg: ReferenceError: could is not defined
at Runtime.exports.main [as handler] (:19202/var/user/index.js:13)
at Runtime.handleOnce (:19202/var/runtime/node12/Runtime.engine.js:219)
at Timeout._onTimeout (:19202/var/runtime/node12/Runtime.engine.js:56)
at listOnTimeout (:19202/appservice/internal/timers.js:549)
at processTimers (:19202/appservice/internal/timers.js:492)), abort)
at R (<anonymous>:1:163208)
at <anonymous>:1:195110(env: Windows,mp,1.06.2303220; lib: 2.32.0)
errorReport @ WAServiceMainContext.js?t=wechat&s=1685572854519&v=2.32.0:1
thirdErrorReport @ WAServiceMainContext.js?t=wechat&s=1685572854519&v=2.32.0:1
(anonymous) @ WAServiceMainContext.js?t=wechat&s=1685572854519&v=2.32.0:1
i @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
(anonymous) @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
_privEmit @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
emit @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
(anonymous) @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
Ne @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
je @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
Y @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
(anonymous) @ WASubContext.js?t=wechat&s=1685572854519&v=2.32.0:1
云函数文件夹cloud中的login.js文件部分代码:
// 云函数入口函数
exports.main = async (event) => {
const { nickName, avatarUrl } = event
const {OPENID} = cloud.getWXContext()
/**对用户信息进行判断,有则用户则登录,反之注册 */
/**1.初始化集合 */
const db =could.database()
/**2.指定集合 */
const userInfo = db.collection('userInfo')
/**数据库内新增数据 */
const data = await userInfo.add({
data:{
nickName,
avatarUrl,
money: 0,
loveValue: 0,
message: 0,
_openid:OPENID
}
})
return {
data,
// event,
// openid: wxContext.OPENID,
// appid: wxContext.APPID,
// unionid: wxContext.UNIONID,
}
}
小程序中me.js文件部分代码:
/**用户授权 */
async getUserInfo() {
/**1.用户授权获取信息 */
const {
userInfo:{ nickName,avatarUrl }
} = await wx.getUserProfile({
desc: '用于完善用户信息',
})
/**2.把当前用户信息交付给后端,存储生成账号 */
wx.cloud.callFunction({
name:'login',
data:{
nickName,
avatarUrl
}
})
},