排名显示错误修复
This commit is contained in:
19
src/store.js
19
src/store.js
@@ -8,15 +8,13 @@ const defaultUser = {
|
||||
lvlName: "",
|
||||
};
|
||||
|
||||
const getLvlName = (score, rankList = []) => {
|
||||
const getLvlName = (rankLvl, rankList = []) => {
|
||||
if (!rankList) return;
|
||||
let lvlName = "";
|
||||
rankList.some((r, index) => {
|
||||
lvlName = rankList[index].name;
|
||||
if (r.upgrade_scores > score) {
|
||||
if (rankList[index - 1]) {
|
||||
lvlName = rankList[index - 1].name;
|
||||
}
|
||||
if (r.rank_id === rankLvl) {
|
||||
lvlName = rankList[index].name;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -62,8 +60,8 @@ export default defineStore("store", {
|
||||
|
||||
// 方法
|
||||
actions: {
|
||||
getLvlName(score) {
|
||||
return getLvlName(score, this.config.randInfos);
|
||||
getLvlName(rankLvl) {
|
||||
return getLvlName(rankLvl, this.config.randInfos);
|
||||
},
|
||||
getLvlImage(rankLvl) {
|
||||
return getLvlImage(rankLvl, this.config.randInfos);
|
||||
@@ -78,8 +76,11 @@ export default defineStore("store", {
|
||||
const imageInfo = await uni.getImageInfo({ src: user.avatar });
|
||||
this.user.avatar = imageInfo.path;
|
||||
}
|
||||
if (this.user.scores !== undefined) {
|
||||
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
|
||||
if (this.user.rankLvl !== undefined) {
|
||||
this.user.lvlName = getLvlName(
|
||||
this.user.rankLvl,
|
||||
this.config.randInfos
|
||||
);
|
||||
}
|
||||
const lvlImage = getLvlImage(this.user.rankLvl, this.config.randInfos);
|
||||
if (lvlImage) {
|
||||
|
||||
Reference in New Issue
Block a user