diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 5e29955..9664d93 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -115,6 +115,10 @@ "useRegionInfo": true, "useUniversityLevel": true, "useNatureList": true, - "useUniversityRank": true + "useUniversityRank": true, + "useCityNewTop": true, + "useCityNewDetail": true, + "newDetail": true, + "newsDetail": true } } diff --git a/src/components/bar/TabBar.vue b/src/components/bar/TabBar.vue index dd78a7c..2c8084a 100644 --- a/src/components/bar/TabBar.vue +++ b/src/components/bar/TabBar.vue @@ -5,7 +5,7 @@ v-for="(item, index) in tabbarList" :key="index" :class="[item.centerItem ? 'center-item' : '']" - @click.stop="changeItem(item)" + @click="changeItem(item)" > - + diff --git a/src/components/home/HotRank.vue b/src/components/home/HotRank.vue index 12e3226..a1694b1 100644 --- a/src/components/home/HotRank.vue +++ b/src/components/home/HotRank.vue @@ -6,7 +6,11 @@ :hover-stop-propagation="false" > 热门排行榜 - + - {{ item.name }} + {{ typeWrap.name }} - {{ index + 1 }} + {{ item.rank }} - 北京大学 北京大学北京大学北京大学 + {{ item.universityName }} + + + {{ item.cityName }}.{{ item.uType }} - 北京.综合类 @@ -51,7 +58,8 @@ diff --git a/src/hooks/useCityInfoHook.ts b/src/hooks/useCityInfoHook.ts index d0c000a..1499ea9 100644 --- a/src/hooks/useCityInfoHook.ts +++ b/src/hooks/useCityInfoHook.ts @@ -1,7 +1,7 @@ -import { getVolunteerInitialization } from '@/service/index/api' +import { getNewsTop, getVolunteerInitialization, getNewsDetailInfo } from '@/service/index/api' import { useCityStore } from '@/store/city' import { useUserStore } from '@/store/user' -import { City } from '@/types/app-type' +import { City, News, NewsDetail } from '@/types/app-type' import { pinyin } from 'pinyin-pro' interface Province { @@ -47,3 +47,45 @@ const groupByFirstLetter = (lis: Province[]): { letter: string; provinces: Provi .sort() .map((key) => ({ letter: key, provinces: grouped[key] })) } + +export const useCityNewTop = () => { + const newsList = ref([]) + + const fetchNewTopFun = (provinceCode) => { + getNewsTop({ Top: 2, CategoryId: 1, provinceCode }).then((res) => { + if (res.code === 200) { + newsList.value = res.result as { title: string }[] + } + }) + } + + if (userStore.userInfo.city.code === '0') { + userStore.$subscribe((mutation, state) => { + if ((mutation.events as { key: string }).key === 'city') { + fetchNewTopFun(state.userInfo.city.code) + } + }) + } else { + fetchNewTopFun(userStore.userInfo.city.code) + } + + return { newsList } +} + +export const newsDetail = ref({ + coverImg: '', + createTime: '', + id: 0, + summary: '', + title: '', + author: '', + click: 0, + detail: '', +}) +export const useCityNewDetail = (id: number) => { + getNewsDetailInfo({ id }).then((res) => { + if (res.code === 200) { + newsDetail.value = res.result as NewsDetail + } + }) +} diff --git a/src/hooks/useUnSortType.ts b/src/hooks/useUnSortType.ts index b26d12e..0671c0d 100644 --- a/src/hooks/useUnSortType.ts +++ b/src/hooks/useUnSortType.ts @@ -26,7 +26,8 @@ export const useUniversityRank = ({ let universityRankList = ref([]) getUniversityRank({ Year, Type, PageSize, PageIndex }).then((res) => { if (res.code === 200) { - console.log(res.result) + const _res = res.result as { rows: any[] } + universityRankList.value = _res.rows } }) diff --git a/src/pages-sub/customerService/index/index.vue b/src/pages-sub/customerService/index/index.vue index 0491aea..4ecf520 100644 --- a/src/pages-sub/customerService/index/index.vue +++ b/src/pages-sub/customerService/index/index.vue @@ -14,11 +14,7 @@ 在线客服 @@ -37,7 +33,7 @@ 400-621-1003 拨打 diff --git a/src/pages-sub/home/city/index.vue b/src/pages-sub/home/city/index.vue index d6f9e87..b132f61 100644 --- a/src/pages-sub/home/city/index.vue +++ b/src/pages-sub/home/city/index.vue @@ -18,7 +18,7 @@ v-for="city in item.provinces" :key="city.id" :title="city.provincename" - @click.stop="chooseCity(city)" + @click="chooseCity(city)" > diff --git a/src/pages-sub/home/news/index.vue b/src/pages-sub/home/news/index.vue new file mode 100644 index 0000000..9b63a83 --- /dev/null +++ b/src/pages-sub/home/news/index.vue @@ -0,0 +1,49 @@ + +{ + layout: 'page', + style: { + navigationStyle: 'custom', + }, +} + + + + + diff --git a/src/pages-sub/home/schoolRank/index.vue b/src/pages-sub/home/schoolRank/index.vue index f9065fc..a078d1e 100644 --- a/src/pages-sub/home/schoolRank/index.vue +++ b/src/pages-sub/home/schoolRank/index.vue @@ -43,21 +43,21 @@ src="@/pages-sub/static/images/schoolRank/trophy.svg" /> - - + - {{ item.name }} - + + + + + + - {{ item.zp_index }} - + {{ item.rank }} + - {{ item.name }} + {{ item.universityName }} + + + {{ item.cityName }}.{{ item.uType }} - 北京.综合类 - 100 + {{ item.score }} 综合得分 @@ -94,6 +93,7 @@ diff --git a/src/pages.json b/src/pages.json index 894a76a..36677ed 100644 --- a/src/pages.json +++ b/src/pages.json @@ -175,6 +175,14 @@ "path": "home/major/index", "type": "page" }, + { + "path": "home/news/index", + "type": "page", + "layout": "page", + "style": { + "navigationStyle": "custom" + } + }, { "path": "home/rank/index", "type": "page" diff --git a/src/service/index/api.ts b/src/service/index/api.ts index c52ed34..f507e6e 100644 --- a/src/service/index/api.ts +++ b/src/service/index/api.ts @@ -47,3 +47,11 @@ export const getUniversityRank = (params: { }) => { return http.get('/api/zhiYuan/universityRank', { ...params }) } + +export const getNewsTop = (params: { Top: number; CategoryId: number; provinceCode: string }) => { + return http.get('/api/ZyNews/top', params) +} + +export const getNewsDetailInfo = (params: { id: number }) => { + return http.get('/api/ZyNews/detail', params) +} diff --git a/src/types/app-type.d.ts b/src/types/app-type.d.ts index 4c2644e..71d25fb 100644 --- a/src/types/app-type.d.ts +++ b/src/types/app-type.d.ts @@ -34,3 +34,23 @@ export type ExtraUserInfo = { cityCode: string } } & IUserInfo + +export type News = { + coverImg: string + createTime: string + id: number + source: string + summary: string + title: string +} + +export type NewsDetail = { + author: string + click: number + coverImg: string + createTime: string + detail: string + id: number + summary: string + title: string +} diff --git a/src/types/auto-import.d.ts b/src/types/auto-import.d.ts index 3b30567..c03e2b9 100644 --- a/src/types/auto-import.d.ts +++ b/src/types/auto-import.d.ts @@ -24,6 +24,8 @@ declare global { const isReadonly: typeof import('vue')['isReadonly'] const isRef: typeof import('vue')['isRef'] const markRaw: typeof import('vue')['markRaw'] + const newDetail: typeof import('../hooks/useCityInfoHook')['newDetail'] + const newsDetail: typeof import('../hooks/useCityInfoHook')['newsDetail'] const nextTick: typeof import('vue')['nextTick'] const onActivated: typeof import('vue')['onActivated'] const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites'] @@ -86,6 +88,8 @@ declare global { const unref: typeof import('vue')['unref'] const useAttrs: typeof import('vue')['useAttrs'] const useCityInfo: typeof import('../hooks/useCityInfoHook')['useCityInfo'] + const useCityNewDetail: typeof import('../hooks/useCityInfoHook')['useCityNewDetail'] + const useCityNewTop: typeof import('../hooks/useCityInfoHook')['useCityNewTop'] const useCssModule: typeof import('vue')['useCssModule'] const useCssVars: typeof import('vue')['useCssVars'] const useId: typeof import('vue')['useId'] @@ -137,6 +141,7 @@ declare module 'vue' { readonly isReadonly: UnwrapRef readonly isRef: UnwrapRef readonly markRaw: UnwrapRef + readonly newsDetail: UnwrapRef readonly nextTick: UnwrapRef readonly onActivated: UnwrapRef readonly onAddToFavorites: UnwrapRef @@ -197,6 +202,8 @@ declare module 'vue' { readonly unref: UnwrapRef readonly useAttrs: UnwrapRef readonly useCityInfo: UnwrapRef + readonly useCityNewDetail: UnwrapRef + readonly useCityNewTop: UnwrapRef readonly useCssModule: UnwrapRef readonly useCssVars: UnwrapRef readonly useId: UnwrapRef diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts index addd9aa..ed4b681 100644 --- a/src/types/uni-pages.d.ts +++ b/src/types/uni-pages.d.ts @@ -21,6 +21,7 @@ interface NavigateToOptions { "/pages-sub/home/inputScore/index" | "/pages-sub/home/line/index" | "/pages-sub/home/major/index" | + "/pages-sub/home/news/index" | "/pages-sub/home/rank/index" | "/pages-sub/home/schoolRank/index" | "/components-sub/FilterMenu/FilterMenu" |