diff --git a/src/composables/useScore.ts b/src/composables/useScore.ts new file mode 100644 index 0000000..3a59a88 --- /dev/null +++ b/src/composables/useScore.ts @@ -0,0 +1,24 @@ +import api from "@/api/customAxios"; + +export const useScore = (provinceCode:string, batchName:string, requireSubject:string) => { + const score = ref(0) + const minScore = ref(0) + const maxScore = ref(0) + api.get(`https://api.v3.ycymedu.com/api/busBatchBase/batch`,{ LocationCode: provinceCode, Course: requireSubject ?? '' },(resp:any)=>{ + if (resp.code === 200) { + const _result = resp.result as { batches: any[]; maxScore: number; minScore: number } + if (_result.batches.length > 0) { + const _score = _result.batches.find((item) => item.batch === batchName)?.score || 0 + score.value = _score + } + + minScore.value = _result.minScore + maxScore.value = _result.maxScore + } + + },(error:any)=>{ + console.log(error); + }) + return { score, minScore, maxScore } + } + \ No newline at end of file diff --git a/src/views/sort-college.vue b/src/views/sort-college.vue index f6c1fb7..6668428 100644 --- a/src/views/sort-college.vue +++ b/src/views/sort-college.vue @@ -4,21 +4,28 @@
- np-data + np-data 没有数据哦~
-
- -
@@ -32,6 +39,7 @@ import CollegeItem from "@/components/sort-college/CollegeItem.vue"; import api from "@/api/customAxios"; + import { useScore } from "@/composables/useScore"; const userStore = useUserStore(); @@ -42,31 +50,28 @@ const locationCode = ref(""); const wishList = ref([]); - const handleSave = () => { - uni.postMessage({ data: { action: "message", message: JSON.stringify(wishList.value), }, }); - uni.reLaunch({ url: '/pages-sub/ucenter/wishList/wishList' }) + uni.reLaunch({ url: "/pages-sub/ucenter/wishList/wishList" }); }; - const removeCollege = (index:number) => { - wishList.value.splice(index,1) - } - const removeMajor = (index:number,mIndex:number) => { - (wishList.value[index] as {vItems:any[]}).vItems.splice(mIndex,1) - } + const removeCollege = (index: number) => { + wishList.value.splice(index, 1); + }; + const removeMajor = (index: number, mIndex: number) => { + (wishList.value[index] as { vItems: any[] }).vItems.splice(mIndex, 1); + }; - provide("sort",{ + provide("sort", { removeCollege, - removeMajor - }) + removeMajor, + }); - const getWishList = () => { api.get( `https://api.v3.ycymedu.com/api/volunTb/get/${locationCode.value}`, @@ -82,46 +87,48 @@ ); }; - const aiFlag = ref(true) - const showAi = () =>{ - api.get(`https://api.v3.ycymedu.com/api/sysDictData/dicStatus`,{ id: 619330547859525 },(resp:any)=>{ - console.log(resp); - if(resp.code === 200){ - aiFlag.value = resp.result.status !== 1 - } - - },(error:any)=>{ - console.log(error); - }) - } + const aiFlag = ref(true); + const showAi = () => { + api.get( + `https://api.v3.ycymedu.com/api/sysDictData/dicStatus`, + { id: 619330547859525 }, + (resp: any) => { + if (resp.code === 200) { + aiFlag.value = resp.result.status !== 1; + } + }, + (error: any) => { + console.log(error); + }, + ); + }; const handleReport = () => { - uni.navigateTo({ url: `/aiService-sub/index/index?fileId=${vId.value}&locationCode=${locationCode.value}` }) - } + uni.navigateTo({ url: `/aiService-sub/index/index?fileId=${vId.value}&locationCode=${locationCode.value}` }); + }; - onBeforeMount(() => { - let _mapParams: { [key: string]: any } = {}; - let params = decodeURIComponent(location.search).slice(1, location.search.length).split("&"); - params.forEach((param) => { - let _param = param.split("="); - _mapParams[_param[0]] = _param[1]; - }); - vId.value = _mapParams.id; - userStore.setToken(_mapParams.token); - - score.value = +_mapParams.score; - batchName.value = _mapParams.batchName; - subjectGroup.value = _mapParams.subjectGroup; - locationCode.value = _mapParams.location; - - getWishList(); - showAi(); + let _mapParams: { [key: string]: any } = {}; + let params = decodeURIComponent(location.search).slice(1, location.search.length).split("&"); + params.forEach((param) => { + let _param = param.split("="); + _mapParams[_param[0]] = _param[1]; }); + vId.value = _mapParams.id; + + userStore.setToken(_mapParams.token); + + score.value = +_mapParams.score; + batchName.value = _mapParams.batchName; + subjectGroup.value = _mapParams.subjectGroup; + locationCode.value = _mapParams.location; + const { score: lineScore } = useScore(_mapParams.location, _mapParams.batchName, _mapParams.requreSubject); + getWishList(); + showAi();