const app = getApp()
const db = wx.cloud.database()
const DB = wx.cloud.database().collection("xxx")
const conm= db.command
Page({
data: {
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
onLoad: function() {
wx.getSetting({
success (res){
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success: function(res) {
console.log('test--go',res.userInfo)
}
})
}
}
})
this.getOpenid();
},
getOpenid() {
let that = this;
wx.cloud.callFunction({
name: 'gxxxxx',
complete: res => {
console.log('云函数获取到的openid: ', res.result)
var openid = res.result.openId;
var dopenid=openid;
console.log('云函数获取到的openid: -----', res.result.openId)
app.globalData.openid=openid;
DB.add({
data: {
dopenid:openid,
}
})
that.setData({
openid: openid
})
}
})
},
bindGetUserInfo (e) {
console.log('userinfo',e.detail.userInfo)
var userinfo=e.detail.userInfo
if (userinfo==undefined){
wx.showToast({
title: '请授权再试',
icon: 'loading',
duration: 3000
})
}
wx.getSetting({
success (res){
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success: function(res) {
console.log('test--g',res.userInfo)
var nickName=res.userInfo.nickName
console.log('test-',nickName)
app.globalData.nickName=nickName
console.log('test--go',app.globalData.nickName)
var openid=app.globalData.openid
console.log('testickName',nickName)
console.log('testopenid',openid)
if (nickName==null||nickName==undefined){
wx.showToast({
title: '请授权再试',
icon: 'loading',
duration: 3000
})
}
if (nickName!=null){
console.log('nickName',nickName);
db.collection("yxxx").where({
dopenid:openid
}).get({
success: res => {
console.log('res.length',res.data.length)
if(res.data.length>=10){
console.log('lxxx1');
wx.showToast({
title: '预订导常频繁',
icon: 'loading',
duration: 3000
})
}else{
wx.navigateTo({
url: '../index111/index'
})
}
}
})
}
}
})
}
}
})
}
})
整改登录逻辑,查看相关规范
https://developers.weixin.qq.com/community/operate/doc/000640bb8441b82900e89f48351401?blockType=5