收藏
回答

微信小程序审核不过,提示登陆不合格?

// pages/log page/index.js
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')
  },
  onLoadfunction() {
    // 查看是否授权
    wx.getSetting({
      success (res){
        if (res.authSetting['scope.userInfo']) {
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称
          wx.getUserInfo({
            successfunction(res{
              console.log('test--go',res.userInfo)
             
                         }
          })
        }
       
      }
    })
    //-----------------------
      this.getOpenid();
        
  },
 // 获取用户openid
 getOpenid() {
  let that = this;
  wx.cloud.callFunction({
   name'gxxxxx',
   completeres => {
     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',


duration3000


})
    }
    // 查看是否授权
    wx.getSetting({
      success (res){
        if (res.authSetting['scope.userInfo']) {
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称
          wx.getUserInfo({
            successfunction(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){                           //读取不到nickName时,提示让准许读取信息
  wx.showToast({


title'请授权再试',


icon'loading',


duration3000


})
}



    if (nickName!=null){                                   //判断是否获取了nickName,没有,不让跳转      
          
     console.log('nickName',nickName);
     
    db.collection("yxxx").where({    
           dopenid:openid
    }).get({
      successres => {
        console.log('res.length',res.data.length)
       
        //---------------------------跳转前 检测黑名单数据库,有10次记录的,不让跳转-----begin
        if(res.data.length>=10){
     
        console.log('lxxx1');
        wx.showToast({


       title'预订导常频繁',


        icon'loading',


        duration3000


        })
        
        }else{
           


        //wx.switchTab({
          wx.navigateTo({
        url'../index111/index'
        })
  


        }


        }
      })




//---------------------------跳转前 检测黑名单数据库,有10次记录的,不让跳转-----end
    }


}
 })
        }






 }
    })
  
  }
})
最后一次编辑于  2020-07-15
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签