接入两个接口

This commit is contained in:
kron
2025-08-13 17:11:30 +08:00
parent f388270fff
commit cf318bc552
5 changed files with 57 additions and 18 deletions

View File

@@ -433,6 +433,14 @@ export const getPointBookDetailAPI = async (id) => {
return request("GET", `/user/score/sheet/detail?id=${id}`); return request("GET", `/user/score/sheet/detail?id=${id}`);
}; };
export const getPractiseDataAPI = async () => { export const getPointBookDataAPI = async () => {
return request("GET", "/user/score/sheet/statistics"); return request("GET", "/user/score/sheet/statistics");
}; };
export const getPractiseDataAPI = async () => {
return request("GET", "/user/practice/statistics");
};
export const getBattleDataAPI = async () => {
return request("GET", "/user/fight/statistics");
};

View File

@@ -1,12 +1,13 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue"; import Container from "@/components/Container.vue";
import Guide from "@/components/Guide.vue"; import Guide from "@/components/Guide.vue";
import SButton from "@/components/SButton.vue"; import SButton from "@/components/SButton.vue";
import SModal from "@/components/SModal.vue"; import SModal from "@/components/SModal.vue";
import CreateRoom from "@/components/CreateRoom.vue"; import CreateRoom from "@/components/CreateRoom.vue";
import Avatar from "@/components/Avatar.vue"; import Avatar from "@/components/Avatar.vue";
import { getRoomAPI, joinRoomAPI, isGamingAPI } from "@/apis"; import { getRoomAPI, joinRoomAPI, isGamingAPI, getBattleDataAPI } from "@/apis";
import useStore from "@/store"; import useStore from "@/store";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
const store = useStore(); const store = useStore();
@@ -16,6 +17,7 @@ import { debounce } from "@/util";
const showModal = ref(false); const showModal = ref(false);
const warnning = ref(""); const warnning = ref("");
const roomNumber = ref(""); const roomNumber = ref("");
const data = ref({});
const enterRoom = debounce(async () => { const enterRoom = debounce(async () => {
const isGaming = await isGamingAPI(); const isGaming = await isGamingAPI();
@@ -60,6 +62,10 @@ const onCreateRoom = async () => {
warnning.value = ""; warnning.value = "";
showModal.value = true; showModal.value = true;
}; };
onShow(async () => {
const result = await getBattleDataAPI();
data.value = result;
});
</script> </script>
<template> <template>
@@ -79,23 +85,33 @@ const onCreateRoom = async () => {
<view> <view>
<view> <view>
<view> <view>
<text>1111</text> <text>{{ data.TotalBattle }}</text>
<text></text> <text></text>
</view> </view>
<text>约战数量</text> <text>约战数量</text>
</view> </view>
<view> <view>
<view> <view>
<text>1111</text> <text>{{ data.totalArrow }}</text>
<text></text> <text></text>
</view> </view>
<text>射箭量</text> <text>射箭量</text>
</view> </view>
<view> <view>
<view class="stars"> <view class="stars">
<image src="../static/star-full.png" mode="widthFix" /> <block v-for="i in 5" :key="i">
<image src="../static/star-full.png" mode="widthFix" /> <image
<image src="../static/star-half.png" mode="widthFix" /> v-if="data.totalWinningRate >= i * 0.2"
src="../static/star-full.png"
mode="widthFix"
/>
<image
v-else-if="data.totalWinningRate >= (i - 1) * 0.2 + 0.1"
src="../static/star-half.png"
mode="widthFix"
/>
<image v-else src="../static/star-empty.png" mode="widthFix" />
</block>
</view> </view>
<text>挑战难度</text> <text>挑战难度</text>
</view> </view>
@@ -279,9 +295,9 @@ const onCreateRoom = async () => {
} }
.my-data > view:last-child > view > view > text:first-child { .my-data > view:last-child > view > view > text:first-child {
color: #fff; color: #fff;
font-size: 17px; font-size: 20px;
margin-right: 5px; margin-right: 5px;
transform: translateY(3px); transform: translateY(4px);
} }
.my-data > view:last-child > view:nth-child(2) { .my-data > view:last-child > view:nth-child(2) {
border-left: 1px solid #48494e; border-left: 1px solid #48494e;
@@ -293,7 +309,7 @@ const onCreateRoom = async () => {
height: 20px; height: 20px;
} }
.stars > image { .stars > image {
width: 5vw; width: 4vw;
margin: 0 1px; margin: 0 1px;
} }
</style> </style>

View File

@@ -4,7 +4,7 @@ import { onShow } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue"; import Container from "@/components/Container.vue";
import EditOption from "@/components/EditOption.vue"; import EditOption from "@/components/EditOption.vue";
import SButton from "@/components/SButton.vue"; import SButton from "@/components/SButton.vue";
import { getPractiseDataAPI } from "@/apis"; import { getPointBookDataAPI } from "@/apis";
const expandIndex = ref(0); const expandIndex = ref(0);
const bowType = ref({}); const bowType = ref({});
@@ -60,7 +60,7 @@ const toEditPage = () => {
} }
}; };
onShow(async () => { onShow(async () => {
const result = await getPractiseDataAPI(); const result = await getPointBookDataAPI();
if (result) { if (result) {
days.value = result.total_day || 0; days.value = result.total_day || 0;
arrows.value = result.total_arrow || 0; arrows.value = result.total_arrow || 0;

View File

@@ -1,12 +1,16 @@
<script setup> <script setup>
import { ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue"; import Container from "@/components/Container.vue";
import Guide from "@/components/Guide.vue"; import Guide from "@/components/Guide.vue";
import Avatar from "@/components/Avatar.vue"; import Avatar from "@/components/Avatar.vue";
import { getPractiseDataAPI } from "@/apis";
import useStore from "@/store"; import useStore from "@/store";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
const store = useStore(); const store = useStore();
const { user } = storeToRefs(store); const { user } = storeToRefs(store);
const data = ref({});
const toPractiseOne = () => { const toPractiseOne = () => {
uni.navigateTo({ uni.navigateTo({
@@ -19,6 +23,11 @@ const toPractiseTwo = () => {
url: "/pages/practise-two", url: "/pages/practise-two",
}); });
}; };
onShow(async () => {
const result = await getPractiseDataAPI();
data.value = result;
});
</script> </script>
<template> <template>
@@ -40,17 +49,23 @@ const toPractiseTwo = () => {
</view> </view>
<view> <view>
<text>已练习打卡</text> <text>已练习打卡</text>
<text>12121</text> <text>{{ data.totalDay }}</text>
<text></text> <text></text>
</view> </view>
</view> </view>
<view> <view>
<view> <view>
<view><text>1111</text><text></text></view> <view>
<text>{{ data.totalGroup }}</text>
<text></text>
</view>
<text>个人练习量</text> <text>个人练习量</text>
</view> </view>
<view> <view>
<view><text>1111</text><text></text></view> <view>
<text>{{ data.totalArrow }}</text>
<text></text>
</view>
<text>射箭量</text> <text>射箭量</text>
</view> </view>
<view> <view>
@@ -116,7 +131,7 @@ const toPractiseTwo = () => {
.practise-data > view:first-child > view:last-child > text:nth-child(2) { .practise-data > view:first-child > view:last-child > text:nth-child(2) {
color: #f7d247; color: #f7d247;
margin: 0 3px; margin: 0 3px;
font-size: 18px; font-size: 20px;
font-weight: 600; font-weight: 600;
transform: translateY(3px); transform: translateY(3px);
} }
@@ -139,11 +154,11 @@ const toPractiseTwo = () => {
align-items: flex-end; align-items: flex-end;
} }
.practise-data > view:last-child > view > view > text:nth-last-child(2) { .practise-data > view:last-child > view > view > text:nth-last-child(2) {
font-size: 18px; font-size: 20px;
font-weight: 600; font-weight: 600;
color: #fff; color: #fff;
margin: 0 3px; margin: 0 3px;
transform: translateY(3px); transform: translateY(5px);
} }
.practise-data > view:last-child > view > text { .practise-data > view:last-child > view > text {
margin-top: 5px; margin-top: 5px;

BIN
src/static/star-empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B