上线后排行榜bug
1、排序算法
const dataSorter = (gameDatas, field = Consts.OpenDataKeys.LevelKey) => {
let data = []
for (let i = 0; i < gameDatas.length; i++) {
if (gameDatas[i].KVDataList[0]) {
data.push(gameDatas[i])
}
}
// Max_Page = Math.ceil(data.length / PAGE_SIZE) - 1
// console.log(Max_Page, "Max_Page")
// return data
let newData = data.sort((a, b) => {
let va = a.KVDataList[0] ? a.KVDataList[0].value - 0 : 0
let vb = b.KVDataList[0] ? b.KVDataList[0].value - 0 : 0
return va < vb;改成 return vb-va
// const kvDataA = a.KVDataList.find(kvData => kvData.key === field);
// const kvDataB = b.KVDataList.find(kvData => kvData.key === field);
// const gradeA = kvDataA ? parseInt(kvDataA.value || 0) : 0;
// const gradeB = kvDataB ? parseInt(kvDataB.value || 0) : 0;
// return gradeA > gradeB ? -1 : gradeA < gradeB ? 1 : 0;
});
Max_Page = Math.ceil(data.length / PAGE_SIZE) - 1
console.log(Max_Page, "Max_Page")
return newData
}
2、图片显示问题
子域的图片显示加载,模拟器OK,真机测试有问题。上传后再看下。
子域代码目录问题:
rankImg.src = `./wx-open-data-project/No${rank}.png`;
改为
rankImg.src = `wx-open-data-project/No${rank}.png`;