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 )
if( getcode==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)后的语句 打印code==getcode是false
大佬,其中一个有空格吧,没事好好学学js
单独打印code和getcode是一样的,但是打印code == getcode是false