const uid = 'xx'
const appId = '__UNI_xxx'
const wxPlatform = 'mp' // mp:小程序,h5:公众号,web:web页面,app:App微信登录
const db = uniCloud.database()
const getUserRes = await db.collection('uni-id-users').doc(uid).get()
const userRecord = getUserRes.data[0]
if(!userRecord) {
throw new Error('未匹配到此用户')
}
const wxOpenid = userRecord.wxopenid || {}
const openid = wxOpenid[wxPlatform + '' + appId] || wxOpenid[wxPlatform]