代码段:
getOpenId(e) {
let that = this;
if(that.data.name == "" || that.data.num == "") {
wx.showModal({
title: '提示',
content: '请检查姓名和学号',
showCancel:false,
confirmText:"晓得啦~",
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
}else{
console.log('用户点击取消')
}
}
})
return
}
wx.showLoading({
title: '',
})
let cloudID = e.detail.cloudID
wx.cloud.callFunction({
name:'getopenid',
data:{
cloudID:wx.cloud.CloudID(cloudID)
}
}).then(res=>{
db.collection('student').where({
openid: res.result.event.userInfo.openId
}).get({success:dat => {
console.log("res")
console.log(dat.data.length)
if( dat.data.length == 0){
that.adduser(res)
}else{
wx.showModal({
title: '提示',
content: '你已经填写过信息啦~',
showCancel:false,
confirmText:"晓得啦~",
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
}else{
console.log('用户点击取消')
}
}
})
}
}
})
wx.hideLoading({
success: (res) => {},
})
})
},