31 lines
807 B
TypeScript
31 lines
807 B
TypeScript
import cloud from '@lafjs/cloud'
|
|
const db = cloud.database();
|
|
import Utils from "@/Utils";
|
|
export default async function (ctx: FunctionContext) {
|
|
const uid = ctx.body.uid;
|
|
if (!uid) {
|
|
return { code: 0, data: null, msg: "未获取到uid" };
|
|
}
|
|
let dbname = "users";
|
|
const gameName = ctx.body.gameName;
|
|
if (gameName == "iaa") {
|
|
dbname = "usersAd";
|
|
}
|
|
let res = await db.collection(dbname).where({ _id: uid }).getOne();
|
|
if (!res.data) {
|
|
return {
|
|
code: 0, data: { id: null, name: null, useravatar: null, useravatarIcon: null }, msg: "未获取到玩家信息"
|
|
}
|
|
}
|
|
return {
|
|
code: 1,
|
|
data: {
|
|
id: res.data._id,
|
|
name: res.data.username,
|
|
useravatar: res.data.useravatar,
|
|
useravatarIcon: res.data.useravatarIcon
|
|
},
|
|
msg: "成功"
|
|
}
|
|
}
|