大家好,我这个小程序端函数似乎没有实现调用云函数端的程序,大家帮忙看下是哪的问题,谢谢
login() {
wx.cloud.callFunction({
name: "getopenid",
success(res) {
let openid = res.result.openid
let that = this;
//登陆获取用户信息
admin.get({
success: (res) => {
let user = res.data;
console.log(res.data);
for (let i = 0; i < user.length; i++) { //遍历数据库对象集合
if (openid !== user[i]._openid) {
wx.showToast({
title: '您的账号已被禁',
icon: 'none',
duration: 1500
})
} else {
wx.navigateTo({
url: '/pages/test/test', //这里是成功登录后跳转的页面
})
break
}
}
}
})
},
})
},
云函数端的程序为:
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
return {
event,
openid: wxContext.OPENID,
appid: wxContext.APPID,
unionid: wxContext.UNIONID,
}
}