39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import cloud from '@lafjs/cloud'
|
|
const db = cloud.database();
|
|
import Utils from "@/Utils";
|
|
export default async function (ctx: FunctionContext) {
|
|
let uid=ctx.body.uid;
|
|
const gameName = ctx.body.gameName;
|
|
let res1;
|
|
if (gameName == "iaa") {
|
|
res1 = await db.collection("rank").where({ _id: "68e92b7835004ffb5ab9ee89" }).getOne();
|
|
}else{
|
|
res1 = await db.collection("rank").where({ _id: "689db6c5cc79706182bd6a9f" }).getOne();
|
|
}
|
|
let rank=JSON.parse(res1.data.rank)
|
|
let list=[];
|
|
if(rank.length<200){
|
|
list=rank;
|
|
}else{
|
|
for (let i = 0; i < 200; i++) {
|
|
// if(rank[i].useravatar==""){
|
|
// rank[i].useravatar=Math.floor(Math.random()*4)+"";
|
|
// }
|
|
list.push(rank[i]);
|
|
}
|
|
}
|
|
|
|
let index=-1;
|
|
for(let i=0;i<rank.length;i++){
|
|
if(rank[i]._id==uid){
|
|
index=i+1;
|
|
break;
|
|
}
|
|
}
|
|
return { code: 1, data: { rank: list, index: index }, msg: "成功" };
|
|
if (["69b8dba6b8203b75974cf697","6866ac24a173b1b78d21f8c2"].includes(uid)){
|
|
|
|
}
|
|
return {code:1,data:{rank:[],index:index},msg:"成功" };
|
|
}
|