Bladeren bron

college index - init

abpcoder 1 week geleden
bovenliggende
commit
f51a8d3edb

+ 11 - 1
src/api/modules/university.ts

@@ -1,5 +1,11 @@
-import { ApiResponse } from "@/types";
+import {ApiResponse, ApiResponseList} from "@/types";
 import flyio from "../flyio";
+import {University} from "@/types/university";
+
+// 院校库 01 院校列表
+export function universityList(params: Record<string, any>) {
+  return flyio.get('/front/university/list', params) as Promise<ApiResponseList<University>>
+}
 
 /**
  * 获取院校列表
@@ -19,3 +25,7 @@ export function getUniversityMajorList(params: { universityId: string }) {
   return flyio.get('/front/student/university/major', params) as Promise<ApiResponse<any>>;
 }
 
+/*院校筛选条件*/
+export function getUniversityFilters() {
+  return flyio.get('/front/university/filters') as Promise<ApiResponse<Record<string, string[]>>>
+}

+ 4 - 0
src/common/routes.ts

@@ -19,6 +19,10 @@ export const routes = {
    * 专业列表
    */
   majorIndex: '/pagesOther/pages/major/index/index',
+  /**
+   * 院校库
+   */
+  universityIndex: '/pagesOther/pages/university/index/index',
   /**
    * 大学详情
    */

+ 4 - 3
src/pagesMain/pages/index/components/index-banner.vue

@@ -18,6 +18,7 @@ import { useTransferPage } from '@/hooks/useTransferPage';
 const { transferTo } = useTransferPage();
 import { useUserStore } from '@/store/userStore';
 import { Transfer } from '@/types';
+import {routes} from "@/common/routes";
 const userStore = useUserStore();
 type MenuItem = {
   name: string;
@@ -59,18 +60,18 @@ const validMenus = computed(() => {
     {
       name: '找院校',
       icon: '/menu/menu-college.png',
-      pageUrl: '/pagesOther/pages/college-library/index/index',
+      pageUrl: routes.universityIndex,
     },
     {
       name: '查专业',
       icon: '/menu/menu-major.png',
-      pageUrl: '/pagesOther/pages/major/index/index',
+      pageUrl: routes.majorIndex,
       noLogin: true
     },
     {
       name: '看职业',
       icon: '/menu/menu-work.png',
-      pageUrl: '/pagesOther/pages/career/index/index',
+      pageUrl: routes.careerIndex,
       noLogin: true
     },
     {

+ 10 - 5
src/pagesMain/pages/volunteer/components/volunteer-menu.vue

@@ -1,11 +1,15 @@
 <template>
     <view class="pt-20 pb-30 px-50 flex justify-between items-center">
-        <volunteer-menu-item v-for="m in menus" :key="m.title" :title="m.title" :icon="m.icon" @click="goPage(m)" />
+        <volunteer-menu-item v-for="m in menus" :key="m.title" :title="m.title" :icon="m.icon" @click="goPage(m)"/>
     </view>
 </template>
 
 <script setup lang="ts" name="VolunteerMenu">
 import VolunteerMenuItem from "@/pagesMain/pages/volunteer/components/volunteer-menu-item.vue";
+import {routes} from "@/common/routes";
+import {useTransferPage} from "@/hooks/useTransferPage";
+
+const {transferTo} = useTransferPage()
 
 type Menu = {
     title: string
@@ -15,15 +19,15 @@ type Menu = {
 const menus: Menu[] = [{
     title: '找院校',
     icon: '/volunteer/index/menu_college.png',
-    pagePath: ''
+    pagePath: routes.universityIndex
 }, {
     title: '查专业',
     icon: '/volunteer/index/menu_major.png',
-    pagePath: ''
+    pagePath: routes.majorIndex
 }, {
     title: '看职业',
     icon: '/volunteer/index/menu_vocation.png',
-    pagePath: ''
+    pagePath: routes.careerIndex
 }, {
     title: '志愿分析',
     icon: '/volunteer/index/menu_analysis.png',
@@ -31,7 +35,8 @@ const menus: Menu[] = [{
 }]
 
 const goPage = function (menu: Menu) {
-    console.log('goPage', menu)
+    if (menu.pagePath) transferTo(menu.pagePath)
+    else uni.$ie.showModal({title: '提示', content: '开发中,敬请期待', showCancel: false})
 }
 </script>
 

+ 64 - 0
src/pagesOther/pages/university/index/components/college-list.vue

@@ -0,0 +1,64 @@
+<template>
+    <view class="h-full">
+        <z-paging ref="paging" @query="handleQuery">
+            <template #top>
+                <college-conditions-picker :options="filter"/>
+                <ie-search v-model="queryParams.name" placeholder="输入院校名称" @search="handleSearch"
+                           @clear="handleSearch"/>
+            </template>
+        </z-paging>
+    </view>
+</template>
+
+<script setup lang="ts">
+import {useTransferPage} from "@/hooks/useTransferPage";
+import {getUniversityFilters, universityList} from "@/api/modules/university";
+import {UniversityQueryDto} from "@/types/university";
+import {UNIVERSITY_FILTER} from "@/types/injectionSymbols";
+import CollegeConditionsPicker from "@/pagesOther/pages/university/index/components/plus/college-conditions-picker.vue";
+
+const {transferTo} = useTransferPage()
+const paging = ref<ZPagingInstance>()
+const list = ref([])
+const filter = ref({})
+const queryParams = ref<UniversityQueryDto>({
+    name: '',
+    features: [],
+    type: [],
+    natureTypeCN: [],
+    location: [],
+    level: [],
+    tier: []
+})
+
+const handleSearch = async () => {
+    paging.value?.reload();
+}
+
+const handleQuery = (pageNum: number, pageSize: number) => {
+    const query = {pageNum, pageSize, ...queryParams.value}
+    universityList(query)
+        .then(res => paging.value?.completeByTotal(res.rows, res.total))
+        .catch(e => paging.value?.complete(false))
+}
+
+provide(UNIVERSITY_FILTER, queryParams)
+
+watch([
+    () => queryParams.value.features,
+    () => queryParams.value.type,
+    () => queryParams.value.natureTypeCN,
+    () => queryParams.value.location,
+    () => queryParams.value.level,
+    () => queryParams.value.tier
+], () => handleSearch())
+
+onMounted(async () => {
+    const {data} = await getUniversityFilters()
+})
+
+</script>
+
+<style scoped>
+
+</style>

+ 10 - 0
src/pagesOther/pages/university/index/components/college-rank.vue

@@ -0,0 +1,10 @@
+<template>
+    <view>rank</view>
+</template>
+
+<script setup lang="ts">
+</script>
+
+<style scoped>
+
+</style>

+ 26 - 0
src/pagesOther/pages/university/index/components/plus/college-conditions-picker.vue

@@ -0,0 +1,26 @@
+<template>
+</template>
+
+<script setup lang="ts">
+
+import {UNIVERSITY_FILTER} from "@/types/injectionSymbols";
+import {UniversityQueryDto} from "@/types/university";
+
+const props = defineProps<{
+    options: Record<string, string[]>;
+}>()
+const filter = inject(UNIVERSITY_FILTER) || ref({} as UniversityQueryDto)
+
+const config = [
+    // 用optionKey在props.options中取出选项,选择后的赋值给filter[prop]
+    {label: '院校层次', optionKey: 'features', prop: 'features'},
+    {label: '院校类型', optionKey: 'types', prop: 'type'},
+    {label: '办学类型', optionKey: 'natureTypes', prop: 'natureType'},
+    {label: '院校省份', optionKey: 'locations', prop: 'location'},
+    {label: '院校梯队', optionKey: 'tiers', prop: 'tier'},
+]
+</script>
+
+<style scoped>
+
+</style>

+ 28 - 1
src/pagesOther/pages/university/index/index.vue

@@ -1,7 +1,34 @@
 <template>
-<view>123</view>
+    <ie-page fix-height bg-color="#F6F8FA" :safe-area-inset-bottom="false">
+        <ie-navbar title="院校库"/>
+        <ie-auto-resizer>
+            <ie-tabs-swiper v-model="current" :list="tabs" :scrollable="false">
+                <swiper class="swiper h-full" :current="current" @change="handleChangeSwiper">
+                    <swiper-item v-for="(item, index) in tabs" :key="index" class="h-full">
+                        <college-list v-if="item.slot==='list'"/>
+                        <college-rank v-if="item.slot==='rank'"/>
+                    </swiper-item>
+                </swiper>
+            </ie-tabs-swiper>
+        </ie-auto-resizer>
+    </ie-page>
 </template>
 <script lang="ts" setup>
+import {SwiperTabItem} from "@/types";
+import CollegeList from "@/pagesOther/pages/university/index/components/college-list.vue";
+import CollegeRank from "@/pagesOther/pages/university/index/components/college-rank.vue";
 
+const current = ref(0);
+const tabs = ref<SwiperTabItem[]>([{
+    name: '院校库',
+    slot: 'list'
+}, {
+    name: '院校排名',
+    slot: 'rank'
+}]);
+
+const handleChangeSwiper = function (e: any) {
+    current.value = e.detail.current;
+}
 </script>
 <style lang="scss" scoped></style>

+ 1 - 1
src/pagesOther/pages/voluntary/list/list.vue

@@ -1,6 +1,6 @@
 <template>
     <ie-page>
-        <z-paging ref="paging" v-model="list" :safe-area-inset-bottom="true" @query="handleQuery">
+        <z-paging ref="paging" v-model="list" safe-area-inset-bottom @query="handleQuery">
             <template #top>
                 <ie-navbar title="志愿表"/>
                 <view class="bg-warning-light p-28 text-20 text-fore-tip">

+ 4 - 1
src/types/index.ts

@@ -7,6 +7,7 @@ import * as Major from "./major";
 import * as Career from "./career";
 import * as Tree from "./tree";
 import * as Voluntary from "./voluntary";
+import * as University from "./university";
 import { VipCardInfo } from "./user";
 import { EnumExamMode, EnumExamType, EnumReviewMode } from "@/common/enum";
 
@@ -128,6 +129,8 @@ export interface SwiperTabItem {
   value?: string;
   slot?: string;
   params?: any;
+
+  component?: any;
 }
 
 export interface Entity {
@@ -142,4 +145,4 @@ export interface Entity {
 
 
 
-export { Study, User, News, Transfer, System, Major, Career, Tree, Voluntary };
+export { Study, User, News, Transfer, System, Major, Career, Tree, Voluntary, University };

+ 4 - 2
src/types/injectionSymbols.ts

@@ -1,6 +1,6 @@
 import type {InjectionKey} from 'vue'
 import {StudyPlan, StudyPlanStats} from './study';
-import {Study, Transfer, Voluntary} from '.';
+import {Study, Transfer, University, Voluntary} from '.';
 import {useExam} from '@/composables/useExam';
 
 /**
@@ -47,4 +47,6 @@ export const CLOSE_VIP_POPUP = Symbol('CLOSE_VIP_POPUP') as InjectionKey<() => v
 * */
 export const VOLUNTARY_FORM = Symbol('VOLUNTARY_FORM') as InjectionKey<Ref<Voluntary.SelectedCollegeMajorWithRules>>
 export const VOLUNTARY_MODEL = Symbol('VOLUNTARY_MODEL') as InjectionKey<Ref<Voluntary.VoluntaryModel>>
-export const VOLUNTARY_RESULT = Symbol('VOLUNTARY_RESULT') as InjectionKey<Ref<Voluntary.VoluntaryResult>>
+export const VOLUNTARY_RESULT = Symbol('VOLUNTARY_RESULT') as InjectionKey<Ref<Voluntary.VoluntaryResult>>
+
+export const UNIVERSITY_FILTER = Symbol('UNIVERSITY_FILTER') as InjectionKey<Ref<University.UniversityQueryDto>>

+ 30 - 0
src/types/university.ts

@@ -0,0 +1,30 @@
+export interface University {
+    address: string;
+    area: string | number;
+    bxLevel: string;
+    cityName: string;
+    code: string;
+    collect: string | number;
+    comScore: string | number;
+    enrollLocation: string;
+    features: string;
+    hits: number;
+    id: number;
+    location: string;
+    logo: string;
+    name: string;
+    natureTypeCN: string;
+    star: string;
+    type: string;
+    webSite: string;
+}
+
+export interface UniversityQueryDto {
+    name: string | null;
+    features: string[] | null;
+    type: string[] | null;
+    natureTypeCN: string[] | null;
+    location: string[] | null;
+    level: string[] | null;
+    tier: string[] | null;
+}