feat: 新闻总页面及逻辑
parent
e38180cd4b
commit
b7f984161b
|
|
@ -119,6 +119,8 @@
|
||||||
"useCityNewTop": true,
|
"useCityNewTop": true,
|
||||||
"useCityNewDetail": true,
|
"useCityNewDetail": true,
|
||||||
"newDetail": true,
|
"newDetail": true,
|
||||||
"newsDetail": true
|
"newsDetail": true,
|
||||||
|
"useNewsList": true,
|
||||||
|
"newsList": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<wd-fab :draggable="true" :expandable="false" :gap="{ bottom: 170 }">
|
<wd-fab :draggable="true" :expandable="false" :gap="{ bottom: 100 }">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<view class="btn-wrapper" @click="handleClick">
|
<view class="btn-wrapper" @click="handleClick">
|
||||||
<image
|
<image
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@
|
||||||
:hover-stop-propagation="false"
|
:hover-stop-propagation="false"
|
||||||
>
|
>
|
||||||
<text class="text-[32rpx] text-[#333333] font-semibold">高考资讯</text>
|
<text class="text-[32rpx] text-[#333333] font-semibold">高考资讯</text>
|
||||||
<image class="w-[40rpx] h-[40rpx]" src="/static/images/home/right.svg"></image>
|
<image
|
||||||
|
class="w-[40rpx] h-[40rpx]"
|
||||||
|
src="/static/images/home/right.svg"
|
||||||
|
@click="toNewsPage"
|
||||||
|
></image>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="my-[30rpx]" hover-class="none" :hover-stop-propagation="false">
|
<view class="my-[30rpx]" hover-class="none" :hover-stop-propagation="false">
|
||||||
|
|
@ -27,14 +31,22 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useCityNewTop } from '@/hooks/useCityInfoHook'
|
import { useCityNewTop, newsList } from '@/hooks/useCityInfoHook'
|
||||||
import { News } from '@/types/app-type'
|
import { News } from '@/types/app-type'
|
||||||
|
|
||||||
const { newsList } = useCityNewTop()
|
onShow(() => {
|
||||||
|
useCityNewTop()
|
||||||
|
})
|
||||||
|
|
||||||
const handleClick = (item: News) => {
|
const handleClick = (item: News) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages-sub/home/news/index?newsId=${item.id}`,
|
url: `/pages-sub/home/news/index?newsId=${item.id}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const toNewsPage = () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages-sub/home/news/newsList',
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
import { getNewsTop, getVolunteerInitialization, getNewsDetailInfo } from '@/service/index/api'
|
import {
|
||||||
|
getNewsTop,
|
||||||
|
getVolunteerInitialization,
|
||||||
|
getNewsDetailInfo,
|
||||||
|
getNewsList,
|
||||||
|
} from '@/service/index/api'
|
||||||
import { useCityStore } from '@/store/city'
|
import { useCityStore } from '@/store/city'
|
||||||
import { useUserStore } from '@/store/user'
|
import { useUserStore } from '@/store/user'
|
||||||
import { City, News, NewsDetail } from '@/types/app-type'
|
import { City, News, NewsDetail } from '@/types/app-type'
|
||||||
|
|
@ -48,9 +53,8 @@ const groupByFirstLetter = (lis: Province[]): { letter: string; provinces: Provi
|
||||||
.map((key) => ({ letter: key, provinces: grouped[key] }))
|
.map((key) => ({ letter: key, provinces: grouped[key] }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const newsList = ref([])
|
||||||
export const useCityNewTop = () => {
|
export const useCityNewTop = () => {
|
||||||
const newsList = ref([])
|
|
||||||
|
|
||||||
const fetchNewTopFun = (provinceCode) => {
|
const fetchNewTopFun = (provinceCode) => {
|
||||||
getNewsTop({ Top: 2, CategoryId: 1, provinceCode }).then((res) => {
|
getNewsTop({ Top: 2, CategoryId: 1, provinceCode }).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
|
|
@ -68,8 +72,6 @@ export const useCityNewTop = () => {
|
||||||
} else {
|
} else {
|
||||||
fetchNewTopFun(userStore.userInfo.city.code)
|
fetchNewTopFun(userStore.userInfo.city.code)
|
||||||
}
|
}
|
||||||
|
|
||||||
return { newsList }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const newsDetail = ref<NewsDetail>({
|
export const newsDetail = ref<NewsDetail>({
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<route lang="json5" type="page">
|
||||||
|
{
|
||||||
|
layout: 'page',
|
||||||
|
style: {
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</route>
|
||||||
|
<template></template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
<route lang="json5" type="page">
|
||||||
|
{
|
||||||
|
layout: 'page',
|
||||||
|
style: {
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</route>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="flex flex-col h-screen">
|
||||||
|
<z-paging
|
||||||
|
ref="paging"
|
||||||
|
use-virtual-list
|
||||||
|
:force-close-inner-list="true"
|
||||||
|
cell-height-mode="dynamic"
|
||||||
|
@virtualListChange="virtualListChange"
|
||||||
|
@query="queryList"
|
||||||
|
>
|
||||||
|
<!-- 需要固定在顶部不滚动的view放在slot="top"的view中,如果需要跟着滚动,则不要设置slot="top" -->
|
||||||
|
<template #top>
|
||||||
|
<view class="relative h-max" hover-class="none" :hover-stop-propagation="false">
|
||||||
|
<wd-navbar
|
||||||
|
title="高考头条"
|
||||||
|
left-arrow
|
||||||
|
@click-left="navigatorBack"
|
||||||
|
safeAreaInsetTop
|
||||||
|
:bordered="false"
|
||||||
|
custom-class="bg-transparent! z-[99]"
|
||||||
|
></wd-navbar>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<view
|
||||||
|
class="item-wrapper"
|
||||||
|
:id="`zp-id-${item.zp_index}`"
|
||||||
|
:key="item.zp_index"
|
||||||
|
v-for="item in newsList"
|
||||||
|
@click="itemClick(item, item.zp_index)"
|
||||||
|
>
|
||||||
|
<view class="flex flex-col items-left p-[32rpx] w-full">
|
||||||
|
<text class="font-semibold text-[28rpx] text-[#1F2329] max-w-full text-left">
|
||||||
|
{{ item.title }}
|
||||||
|
</text>
|
||||||
|
<view
|
||||||
|
class="mt-[24rpx] flex justify-between items-center text-[#8F959E] font-normal font-normal w-full"
|
||||||
|
>
|
||||||
|
<text class="text-[24rpx]">来源: {{ item.source }}</text>
|
||||||
|
<text class="text-[22rpx]">{{ item.createTime }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="w-full h-[2rpx] bg-[#eee]" hover-class="none"></view>
|
||||||
|
</view>
|
||||||
|
</z-paging>
|
||||||
|
|
||||||
|
<view class="flex-1 overflow-auto pb-safe"></view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import useNavbarWeixin from '@/hooks/useNavbarWeixin'
|
||||||
|
import { getNewsList } from '@/service/index/api'
|
||||||
|
import { useUserStore } from '@/store/user'
|
||||||
|
|
||||||
|
const { safeAreaInsets } = useNavbarWeixin()
|
||||||
|
|
||||||
|
const navigatorBack = () => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}
|
||||||
|
|
||||||
|
const userStore = useUserStore()
|
||||||
|
|
||||||
|
const newsList = ref([])
|
||||||
|
const paging = ref(null)
|
||||||
|
|
||||||
|
const virtualListChange = (_vList) => {
|
||||||
|
newsList.value = _vList
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemClick = (item, index) => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-sub/home/news/index?newsId=${item.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryList = (page: number, pageSize: number) => {
|
||||||
|
getNewsList({
|
||||||
|
CategoryId: 1,
|
||||||
|
provinceCode: userStore.userInfo.city.code,
|
||||||
|
PageIndex: page,
|
||||||
|
PageSize: pageSize,
|
||||||
|
}).then((res) => {
|
||||||
|
paging.value?.complete((res.result as { data: any[] }).data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.item-wrapper {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0 32rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
@change="tabsChange"
|
@change="tabsChange"
|
||||||
ref="tabsRef"
|
ref="tabsRef"
|
||||||
>
|
>
|
||||||
<block v-for="item in unSortTypeList" :key="item.type" :name="item.type">
|
<block v-for="item in unSortTypeList" :key="item.type">
|
||||||
<wd-tab :title="`${item.name}`" :name="item.type">
|
<wd-tab :title="`${item.name}`" :name="item.type">
|
||||||
<!-- <view class="content">内容{{ item}}</view> -->
|
<!-- <view class="content">内容{{ item}}</view> -->
|
||||||
</wd-tab>
|
</wd-tab>
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<view
|
<view
|
||||||
class="item"
|
class="item-wrapper"
|
||||||
:id="`zp-id-${item.zp_index}`"
|
:id="`zp-id-${item.zp_index}`"
|
||||||
:key="item.zp_index"
|
:key="item.zp_index"
|
||||||
v-for="(item, index) in schoolList"
|
v-for="(item, index) in schoolList"
|
||||||
|
|
@ -160,7 +160,7 @@ const virtualListChange = (_vList) => {
|
||||||
background: linear-gradient(270deg, #f2ce95 0%, #f8deba 100%);
|
background: linear-gradient(270deg, #f2ce95 0%, #f8deba 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
@ -170,28 +170,6 @@ const virtualListChange = (_vList) => {
|
||||||
padding: 0 32rpx;
|
padding: 0 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-content {
|
|
||||||
flex: 1;
|
|
||||||
margin-left: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-detail {
|
|
||||||
margin-top: 10rpx;
|
|
||||||
border-radius: 10rpx;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #aaaaaa;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-line {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0rpx;
|
|
||||||
left: 0rpx;
|
|
||||||
height: 1px;
|
|
||||||
width: 100%;
|
|
||||||
background-color: #eeeeee;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
:deep(.uni-scroll-view-content) {
|
:deep(.uni-scroll-view-content) {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,14 @@
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "home/aiAutoFill/index",
|
||||||
|
"type": "page",
|
||||||
|
"layout": "page",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "home/autoFill/index",
|
"path": "home/autoFill/index",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
|
|
@ -183,6 +191,14 @@
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "home/news/newsList",
|
||||||
|
"type": "page",
|
||||||
|
"layout": "page",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "home/rank/index",
|
"path": "home/rank/index",
|
||||||
"type": "page"
|
"type": "page"
|
||||||
|
|
|
||||||
|
|
@ -55,3 +55,12 @@ export const getNewsTop = (params: { Top: number; CategoryId: number; provinceCo
|
||||||
export const getNewsDetailInfo = (params: { id: number }) => {
|
export const getNewsDetailInfo = (params: { id: number }) => {
|
||||||
return http.get('/api/ZyNews/detail', params)
|
return http.get('/api/ZyNews/detail', params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getNewsList = (params: {
|
||||||
|
CategoryId: number
|
||||||
|
provinceCode: string
|
||||||
|
PageIndex: number
|
||||||
|
PageSize: number
|
||||||
|
}) => {
|
||||||
|
return http.get('/api/ZyNews/newsPage', params)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ declare global {
|
||||||
const markRaw: typeof import('vue')['markRaw']
|
const markRaw: typeof import('vue')['markRaw']
|
||||||
const newDetail: typeof import('../hooks/useCityInfoHook')['newDetail']
|
const newDetail: typeof import('../hooks/useCityInfoHook')['newDetail']
|
||||||
const newsDetail: typeof import('../hooks/useCityInfoHook')['newsDetail']
|
const newsDetail: typeof import('../hooks/useCityInfoHook')['newsDetail']
|
||||||
|
const newsList: typeof import('../hooks/useCityInfoHook')['newsList']
|
||||||
const nextTick: typeof import('vue')['nextTick']
|
const nextTick: typeof import('vue')['nextTick']
|
||||||
const onActivated: typeof import('vue')['onActivated']
|
const onActivated: typeof import('vue')['onActivated']
|
||||||
const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites']
|
const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites']
|
||||||
|
|
@ -96,6 +97,7 @@ declare global {
|
||||||
const useModel: typeof import('vue')['useModel']
|
const useModel: typeof import('vue')['useModel']
|
||||||
const useNatureList: typeof import('../hooks/useFilterSchool')['useNatureList']
|
const useNatureList: typeof import('../hooks/useFilterSchool')['useNatureList']
|
||||||
const useNavbarWeixin: typeof import('../hooks/useNavbarWeixin')['default']
|
const useNavbarWeixin: typeof import('../hooks/useNavbarWeixin')['default']
|
||||||
|
const useNewsList: typeof import('../hooks/useCityInfoHook')['useNewsList']
|
||||||
const useRegionInfo: typeof import('../hooks/useFilterSchool')['useRegionInfo']
|
const useRegionInfo: typeof import('../hooks/useFilterSchool')['useRegionInfo']
|
||||||
const useRequest: typeof import('../hooks/useRequest')['default']
|
const useRequest: typeof import('../hooks/useRequest')['default']
|
||||||
const useRules: typeof import('../hooks/useRules')['useRules']
|
const useRules: typeof import('../hooks/useRules')['useRules']
|
||||||
|
|
@ -142,6 +144,7 @@ declare module 'vue' {
|
||||||
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
|
readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
|
||||||
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
|
readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
|
||||||
readonly newsDetail: UnwrapRef<typeof import('../hooks/useCityInfoHook')['newsDetail']>
|
readonly newsDetail: UnwrapRef<typeof import('../hooks/useCityInfoHook')['newsDetail']>
|
||||||
|
readonly newsList: UnwrapRef<typeof import('../hooks/useCityInfoHook')['newsList']>
|
||||||
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
|
readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
|
||||||
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
|
readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
|
||||||
readonly onAddToFavorites: UnwrapRef<typeof import('@dcloudio/uni-app')['onAddToFavorites']>
|
readonly onAddToFavorites: UnwrapRef<typeof import('@dcloudio/uni-app')['onAddToFavorites']>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ interface NavigateToOptions {
|
||||||
"/pages/place/index/index" |
|
"/pages/place/index/index" |
|
||||||
"/pages/ucenter/index/index" |
|
"/pages/ucenter/index/index" |
|
||||||
"/pages-sub/customerService/index/index" |
|
"/pages-sub/customerService/index/index" |
|
||||||
|
"/pages-sub/home/aiAutoFill/index" |
|
||||||
"/pages-sub/home/autoFill/index" |
|
"/pages-sub/home/autoFill/index" |
|
||||||
"/pages-sub/home/career/index" |
|
"/pages-sub/home/career/index" |
|
||||||
"/pages-sub/home/city/index" |
|
"/pages-sub/home/city/index" |
|
||||||
|
|
@ -22,6 +23,7 @@ interface NavigateToOptions {
|
||||||
"/pages-sub/home/line/index" |
|
"/pages-sub/home/line/index" |
|
||||||
"/pages-sub/home/major/index" |
|
"/pages-sub/home/major/index" |
|
||||||
"/pages-sub/home/news/index" |
|
"/pages-sub/home/news/index" |
|
||||||
|
"/pages-sub/home/news/newsList" |
|
||||||
"/pages-sub/home/rank/index" |
|
"/pages-sub/home/rank/index" |
|
||||||
"/pages-sub/home/schoolRank/index" |
|
"/pages-sub/home/schoolRank/index" |
|
||||||
"/components-sub/FilterMenu/FilterMenu" |
|
"/components-sub/FilterMenu/FilterMenu" |
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue