锦水居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

68 lines
1.6 KiB

const api = require("../../../../utils/api")
Page({
data: {
datalenght:0,
loveRankingList: [],
preloadVisible: true,
first: {
nickname: "",
faceImg: "",
kindnessTime: "",
participationNum: ""
},
second: {
nickname: "",
faceImg: "",
kindnessTime: "",
participationNum: ""
},
third: {
nickname: "",
faceImg: "",
kindnessTime: "",
participationNum: ""
}
},
onLoad () {
this.loadLoveRanking()
},
// 加载 爱心互助排行榜
loadLoveRanking () {
api.leaderboard().then(res => {
this.setData({
datalenght: res.data.length
})
console.log("爱心互助排行榜", res+":::::::::"+this.data.datalenght)
res.data.forEach((item,index) => {
if (index === 0) {
for(const key in this.data.first) {
this.data.first[key] = item[key]
}
} else if (index === 1) {
for(const key in this.data.second) {
this.data.second[key] = item[key]
}
} else if (index === 2) {
for(const key in this.data.third) {
this.data.third[key] = item[key]
}
} else {
this.data.loveRankingList.push(item)
}
})
this.setData({
loveRankingList: this.data.loveRankingList,
first: this.data.first,
second: this.data.second,
third: this.data.third,
preloadVisible: false
})
}).catch(() => {
this.setData({
loveRankingList: [],
preloadVisible: false
})
})
}
})