部分代码,加载时使用了异步等待,断点测试发现是这个返回查询函数中无法运行if,其他测试号就可以正常运行,主账号开始可以用,点了清除缓存后也无法运行了,有些测试号就可以运行
queryplayer() {
return new Promise((resolve, reject) => {
var _this=this
const db = wx.cloud.database()
// 查询当前用户所有的 counters
db.collection('room').where({
room_number: this.data.room_number,
room_password: this.data.room_password
}).get({
success: res => {
console.log(' 返回数据queryplayer', res)
// this.setData({
// queryback: res.data[0],
// avatarUrl: res.data[0].playercard,
// select_card: res.data[0].select_card
// })
var queryback = res.data[0]
var avatarUrl = res.data[0].playercard
var select_card = res.data[0].select_card
var index_check_seat = wx.getStorageSync('index_check_seat')
if (index_check_seat > avatarUrl.length){
var index_check_seat=0
}
if (index_check_seat < avatarUrl.length) {
var check_card = avatarUrl[index_check_seat][0].check_card
var seatup_state = avatarUrl[index_check_seat][0].peopleseat
if (seatup_state) {
_this.setData({
game_start: avatarUrl[index_check_seat][0].start,
jn: avatarUrl[index_check_seat][0].jn,
gamelist: queryback.gamelist,
qbtqr: avatarUrl[index_check_seat][0].qbtqr
})
}
_this.setData({
check_card: check_card,
nextseat_number: index_check_seat,
})
}
_this.setData({
queryback: queryback,
avatarUrl: avatarUrl,
select_card:select_card,
select_rule: queryback.select_rule,
select_card_source: queryback.select_card_source,
dayopen_steta: avatarUrl[index_check_seat][0].dayopen_steta,
music_index: queryback.music_index,
})
for (let i = 0; i < queryback.select_card_source.length; i++) {
if (queryback.select_card_source[i].name == '丘比特') {
this.setData({
qbt_qlqr_show: true
})
break
}
}
console.log(' 返回数据this.data.queryback ', this.data.queryback)
resolve("ok")
},
fail: err => {
wx.showToast({
icon: 'none',
title: '网络错误'
})
console.error('[数据库] [查询记录] 失败:', err)
}
})
})
},
解决了,把setdata分开写两次就好了,可能是数据大的原因吧,当检测到未运行时,在调用这个函数,就可以了
未复现问题,麻烦更新工具版本再重试