数据调整

This commit is contained in:
kron
2025-07-22 00:01:29 +08:00
parent b030452161
commit cbf83952d7
6 changed files with 45 additions and 29 deletions

View File

@@ -2,13 +2,13 @@ const BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
function request(method, url, data = {}) {
const token = uni.getStorageSync("token");
const header = {};
if (token) header.Authorization = `Bearer ${token || ""}`;
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}${url}`,
method,
header: {
Authorization: `Bearer ${token || ""}`,
},
header,
data,
success: (res) => {
if (res.data) {

View File

@@ -2,6 +2,10 @@
import { ref, onMounted, onUnmounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const props = defineProps({
signin: {
type: Function,
@@ -10,8 +14,10 @@ const props = defineProps({
});
const show = ref(false);
onShow(async () => {
const isGaming = await isGamingAPI();
show.value = isGaming;
if (user.value.id) {
const isGaming = await isGamingAPI();
show.value = isGaming;
}
});
const onClick = async () => {
const isGaming = await isGamingAPI();

View File

@@ -14,7 +14,7 @@ const playerNames = [
"彭妮·希利",
"埃琳娜·奥西波娃",
"凯西·考夫霍尔德",
"鼓相当的对手",
"鼓相当的对手",
"马乌罗·内斯波利",
"埃琳娜·奥西波娃",
"凯西·考夫霍尔德",

View File

@@ -9,7 +9,12 @@ import SModal from "@/components/SModal.vue";
import Signin from "@/components/Signin.vue";
import BubbleTip from "@/components/BubbleTip.vue";
import BackToGame from "@/components/BackToGame.vue";
import { getAppConfig, getHomeData, getMyDevicesAPI } from "@/apis";
import {
getAppConfig,
getRankListAPI,
getHomeData,
getMyDevicesAPI,
} from "@/apis";
import { topThreeColors } from "@/constants";
import useStore from "@/store";
import { storeToRefs } from "pinia";
@@ -54,24 +59,29 @@ const toRankListPage = () => {
};
onShow(async () => {
const result = await getHomeData();
updateRank(result);
console.log("首页数据:", result);
if (result.user) {
updateUser(result.user);
if (result.user.trio <= 0) {
showGuide.value = true;
setTimeout(() => {
showGuide.value = false;
}, 3000);
}
const devices = await getMyDevicesAPI();
if (devices.bindings && devices.bindings.length) {
updateDevice(
devices.bindings[0].deviceId,
devices.bindings[0].deviceName
);
if (user.value.id) {
const result = await getHomeData();
updateRank(result);
console.log("首页数据:", result);
if (result.user) {
updateUser(result.user);
if (result.user.trio <= 0) {
showGuide.value = true;
setTimeout(() => {
showGuide.value = false;
}, 3000);
}
const devices = await getMyDevicesAPI();
if (devices.bindings && devices.bindings.length) {
updateDevice(
devices.bindings[0].deviceId,
devices.bindings[0].deviceName
);
}
}
} else {
const result = await getRankListAPI();
updateRank(result);
}
});

View File

@@ -17,17 +17,18 @@ onMounted(async () => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
currentList.value = rankData.value.rank;
myData.value = rankData.value.myRankPos;
if (rankData.value.myRankPos) myData.value = rankData.value.myRankPos;
});
const handleSelect = (index) => {
selectedIndex.value = index;
if (index === 0) {
myData.value = rankData.value.myRankPos;
currentList.value = rankData.value.rank;
if (rankData.value.myRankPos) myData.value = rankData.value.myRankPos;
} else if (index === 2) {
currentList.value = rankData.value.ringRank;
myData.value = rankData.value.myRingRankPos;
if (rankData.value.myRingRankPos)
myData.value = rankData.value.myRingRankPos;
} else {
myData.value = {};
currentList.value = [];

View File

@@ -3,9 +3,8 @@ import { ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue";
import Avatar from "@/components/Avatar.vue";
import { getRankListAPI, isGamingAPI } from "@/apis";
import { topThreeColors } from "@/constants";
import { getHomeData } from "@/apis";
import { isGamingAPI, getHomeData } from "@/apis";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();