收藏
回答

wx.scancode返回值不执行判断语句?已经返回结果了

getscancode:function(){

  var that=this

db.collection("Ringscancode").where({admincompany:that.data.usercompany}).get({

  success:function(res){

    if(res.data.length>0){

      console.log("Ringscancodedata",res.data)

      var code=res.data[0].code

      wx.scanCode({

        onlyFromCamera: true,

        success (re) {

          let getcode=re.result

          console.log('getcode',re.result)

          console.log("code",code )

          ifgetcode==code ){

            db.collection("usersRing").where({ today: util.formatDate(new Date()), _openid: that.data.openid  }).get({

              success: function (res) {

                console.log("查询有无打卡数据", res)

                 if(res.data.length==0){

                   db.collection("usersRing").add({

                     data: {

                       usernickName: that.data.usernickName,

                       usercompany: that.data.usercompany,

                       username: that.data.username,

                       today: util.formatDate(new Date()),

                       MRinguptime: new Date(0),

                       MRingdowntime: new Date(0),

                       ARinguptime: new Date(0),

                       ARingdowntime: new Date(0),

                       ERinguptime: new Date(0),

                       ERingdowntime: new Date(0),

                       URinguptime: new Date(0),

                       URingdowntime: new Date(0)

                     },

                     success: res =>{

                       wx.navigateTo({

                         url: '../userpage1-1/userpage1-1',

                       },console.log("创建数据成功", res)

                     },

                     fail: err => {

                       wx.showToast({

                         title: '程序出错',

                         icon: '',

                       })

                     }

                   })

                 }

                 else {

                   console.log("直接跳转")

                   wx.navigateTo({

                     url: '../userpage1-1/userpage1-1',         

                   })  

                 }            

              }

            })

          }else{

            wx.showToast({

              title: '无效二维码',

              icon:"none"

            })

          }

  

        }

      })

    }else{

      console.log("Ringscancodedata",res.data)

   wx.showToast({

     title: '管理员未开启此功能',

     icon:"none",

   })

    }

  },

})

},

code 和 getcode打印出来的是一样的,就是执行函数后不执行if(code==getcode)后的语句


回答关注问题邀请回答
收藏

1 个回答

  • Lgh_13150849294
    Lgh_13150849294
    2020-05-01

    已解决,不知道为啥,今天编译通过了,代码啥都没动。

    2020-05-01
    有用
    回复 1
    • Lgh_13150849294
      Lgh_13150849294
      2020-05-04
      又不能用了
      2020-05-04
      回复
登录 后发表内容
问题标签