接入练习数据接口
This commit is contained in:
30
src/apis.js
30
src/apis.js
@@ -14,7 +14,8 @@ export const getAppConfig = () => {
|
|||||||
url: `${BASE_URL}/index/appConfig`,
|
url: `${BASE_URL}/index/appConfig`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve(res.data);
|
const { code, data } = res.data;
|
||||||
|
if (code === 0) resolve(data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
reject(err);
|
reject(err);
|
||||||
@@ -33,7 +34,8 @@ export const getHomeData = () => {
|
|||||||
url: `${BASE_URL}/user/myHome`,
|
url: `${BASE_URL}/user/myHome`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve(res.data);
|
const { code, data } = res.data;
|
||||||
|
if (code === 0) resolve(data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
reject(err);
|
reject(err);
|
||||||
@@ -53,7 +55,8 @@ export const getProvinceData = () => {
|
|||||||
url: `${BASE_URL}/index/provinces/list`,
|
url: `${BASE_URL}/index/provinces/list`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve(res.data);
|
const { code, data } = res.data;
|
||||||
|
if (code === 0) resolve(data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
reject(err);
|
reject(err);
|
||||||
@@ -306,3 +309,24 @@ export const startRoomAPI = (number) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getPractiseResultListAPI = (page = 1, page_size = 10) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: `${BASE_URL}/user/practice/list?page=${page}&page_size=${page_size}`,
|
||||||
|
method: "GET",
|
||||||
|
header: getAuthHeader(),
|
||||||
|
success: (res) => {
|
||||||
|
const { code, data } = res.data;
|
||||||
|
if (code === 0) resolve(data);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
reject(err);
|
||||||
|
uni.showToast({
|
||||||
|
title: "获取数据失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Container from "@/components/Container.vue";
|
import Container from "@/components/Container.vue";
|
||||||
|
import useStore from "@/store";
|
||||||
const grade = 7;
|
import { storeToRefs } from "pinia";
|
||||||
|
const store = useStore();
|
||||||
|
const { user } = storeToRefs(store);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -13,12 +15,12 @@ const grade = 7;
|
|||||||
<view
|
<view
|
||||||
:style="{
|
:style="{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
index + 1 < grade
|
index + 1 < user.lvl
|
||||||
? '#fff9'
|
? '#fff9'
|
||||||
: index + 1 === grade
|
: index + 1 === user.lvl
|
||||||
? '#fed847'
|
? '#fed847'
|
||||||
: 'transparent',
|
: 'transparent',
|
||||||
borderColor: index + 1 === grade ? '#fed847' : '#fff9',
|
borderColor: index + 1 === user.lvl ? '#fed847' : '#fff9',
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<view />
|
<view />
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
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 { getPractiseResultListAPI } from "@/apis";
|
||||||
|
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
const selectedIndex = ref(0);
|
const selectedIndex = ref(0);
|
||||||
|
const practiseList = ref([]);
|
||||||
|
|
||||||
const handleSelect = (index) => {
|
const handleSelect = async (index) => {
|
||||||
|
if (index === 2) {
|
||||||
|
const result = await getPractiseResultListAPI();
|
||||||
|
practiseList.value = result.list;
|
||||||
|
}
|
||||||
selectedIndex.value = index;
|
selectedIndex.value = index;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -104,11 +110,11 @@ const handleSelect = (index) => {
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
v-for="(_, index) in new Array(6).fill(0)"
|
v-for="(item, index) in practiseList"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="practice-record"
|
class="practice-record"
|
||||||
>
|
>
|
||||||
<text>单组练习 2025.01.21 14:09:23</text>
|
<text>单组练习 {{ item.createdAt }}</text>
|
||||||
<image src="../static/back.png" mode="widthFix" />
|
<image src="../static/back.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
Reference in New Issue
Block a user