1 回复
junpan
junpan1 楼6 年前

貌似你哪怕请求一个空的云函数,哪怕下面这样的,比方说这个云函数名是“getOpenId”

exports.main = async (event) => {
    return event.userInfo.openId
}

你在客户端请求云函数

wx.cloud.init()
Page({
    //...其他内容
    onShow(){
        wx.cloud.callFunction({
            name: 'getOpenId',
            success: res => console.log(res.result)
        })
    }
})

你客户端本地的控制台打印结果就是当前用户的openId啊。