数据调整
This commit is contained in:
@@ -2,13 +2,13 @@ const BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
|
|||||||
|
|
||||||
function request(method, url, data = {}) {
|
function request(method, url, data = {}) {
|
||||||
const token = uni.getStorageSync("token");
|
const token = uni.getStorageSync("token");
|
||||||
|
const header = {};
|
||||||
|
if (token) header.Authorization = `Bearer ${token || ""}`;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.request({
|
uni.request({
|
||||||
url: `${BASE_URL}${url}`,
|
url: `${BASE_URL}${url}`,
|
||||||
method,
|
method,
|
||||||
header: {
|
header,
|
||||||
Authorization: `Bearer ${token || ""}`,
|
|
||||||
},
|
|
||||||
data,
|
data,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
import { ref, onMounted, onUnmounted } from "vue";
|
import { ref, onMounted, onUnmounted } from "vue";
|
||||||
import { onShow } from "@dcloudio/uni-app";
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
|
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
|
||||||
|
import useStore from "@/store";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
const store = useStore();
|
||||||
|
const { user } = storeToRefs(store);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
signin: {
|
signin: {
|
||||||
type: Function,
|
type: Function,
|
||||||
@@ -10,8 +14,10 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
const isGaming = await isGamingAPI();
|
if (user.value.id) {
|
||||||
show.value = isGaming;
|
const isGaming = await isGamingAPI();
|
||||||
|
show.value = isGaming;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const onClick = async () => {
|
const onClick = async () => {
|
||||||
const isGaming = await isGamingAPI();
|
const isGaming = await isGamingAPI();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const playerNames = [
|
|||||||
"彭妮·希利",
|
"彭妮·希利",
|
||||||
"埃琳娜·奥西波娃",
|
"埃琳娜·奥西波娃",
|
||||||
"凯西·考夫霍尔德",
|
"凯西·考夫霍尔德",
|
||||||
"起鼓相当的对手",
|
"旗鼓相当的对手",
|
||||||
"马乌罗·内斯波利",
|
"马乌罗·内斯波利",
|
||||||
"埃琳娜·奥西波娃",
|
"埃琳娜·奥西波娃",
|
||||||
"凯西·考夫霍尔德",
|
"凯西·考夫霍尔德",
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ import SModal from "@/components/SModal.vue";
|
|||||||
import Signin from "@/components/Signin.vue";
|
import Signin from "@/components/Signin.vue";
|
||||||
import BubbleTip from "@/components/BubbleTip.vue";
|
import BubbleTip from "@/components/BubbleTip.vue";
|
||||||
import BackToGame from "@/components/BackToGame.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 { topThreeColors } from "@/constants";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
@@ -54,24 +59,29 @@ const toRankListPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
const result = await getHomeData();
|
if (user.value.id) {
|
||||||
updateRank(result);
|
const result = await getHomeData();
|
||||||
console.log("首页数据:", result);
|
updateRank(result);
|
||||||
if (result.user) {
|
console.log("首页数据:", result);
|
||||||
updateUser(result.user);
|
if (result.user) {
|
||||||
if (result.user.trio <= 0) {
|
updateUser(result.user);
|
||||||
showGuide.value = true;
|
if (result.user.trio <= 0) {
|
||||||
setTimeout(() => {
|
showGuide.value = true;
|
||||||
showGuide.value = false;
|
setTimeout(() => {
|
||||||
}, 3000);
|
showGuide.value = false;
|
||||||
}
|
}, 3000);
|
||||||
const devices = await getMyDevicesAPI();
|
}
|
||||||
if (devices.bindings && devices.bindings.length) {
|
const devices = await getMyDevicesAPI();
|
||||||
updateDevice(
|
if (devices.bindings && devices.bindings.length) {
|
||||||
devices.bindings[0].deviceId,
|
updateDevice(
|
||||||
devices.bindings[0].deviceName
|
devices.bindings[0].deviceId,
|
||||||
);
|
devices.bindings[0].deviceName
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const result = await getRankListAPI();
|
||||||
|
updateRank(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,17 +17,18 @@ onMounted(async () => {
|
|||||||
const deviceInfo = uni.getDeviceInfo();
|
const deviceInfo = uni.getDeviceInfo();
|
||||||
isIos.value = deviceInfo.osName === "ios";
|
isIos.value = deviceInfo.osName === "ios";
|
||||||
currentList.value = rankData.value.rank;
|
currentList.value = rankData.value.rank;
|
||||||
myData.value = rankData.value.myRankPos;
|
if (rankData.value.myRankPos) myData.value = rankData.value.myRankPos;
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSelect = (index) => {
|
const handleSelect = (index) => {
|
||||||
selectedIndex.value = index;
|
selectedIndex.value = index;
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
myData.value = rankData.value.myRankPos;
|
|
||||||
currentList.value = rankData.value.rank;
|
currentList.value = rankData.value.rank;
|
||||||
|
if (rankData.value.myRankPos) myData.value = rankData.value.myRankPos;
|
||||||
} else if (index === 2) {
|
} else if (index === 2) {
|
||||||
currentList.value = rankData.value.ringRank;
|
currentList.value = rankData.value.ringRank;
|
||||||
myData.value = rankData.value.myRingRankPos;
|
if (rankData.value.myRingRankPos)
|
||||||
|
myData.value = rankData.value.myRingRankPos;
|
||||||
} else {
|
} else {
|
||||||
myData.value = {};
|
myData.value = {};
|
||||||
currentList.value = [];
|
currentList.value = [];
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ import { ref } from "vue";
|
|||||||
import { onShow } from "@dcloudio/uni-app";
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
import Avatar from "@/components/Avatar.vue";
|
import Avatar from "@/components/Avatar.vue";
|
||||||
import { getRankListAPI, isGamingAPI } from "@/apis";
|
|
||||||
import { topThreeColors } from "@/constants";
|
import { topThreeColors } from "@/constants";
|
||||||
import { getHomeData } from "@/apis";
|
import { isGamingAPI, getHomeData } from "@/apis";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|||||||
Reference in New Issue
Block a user