diff --git a/.env b/.env index ae7ac6e..a11710a 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -TARO_APP_API=https://yjx.dev.yaojiankang.top -#TARO_APP_API=https://mooc.yaojiankang.top +#TARO_APP_API=https://yjx.dev.yaojiankang.top +TARO_APP_API=https://mooc.yaojiankang.top #TARO_APP_API=https://shopfix.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top TARO_APP_LGOIN=true diff --git a/src/api/illness.ts b/src/api/illness.ts index 7e1aa21..ab0f905 100644 --- a/src/api/illness.ts +++ b/src/api/illness.ts @@ -3,13 +3,10 @@ import {request} from "@/api/request"; export const illnessApi = { /** 疾病列表 */ - list(id:number,page: number , page_size: number) { - return request<{ - list: any[], - total: number, - }>(`/home/v1/illness/list?page=${page}&page_size=${page_size}&id=${id}` , "GET") + list(id: number, page: number, page_size: number) { + return request<{ list: any[], total: number }>(`/home/v1/illness/list`, "GET", {page, page_size, id}) }, - articleInfo(id: number ) { - return request<{ content: string }>(`/home/v1/article/${id}` , "GET") + articleInfo(owner_id: number, page: number, page_size: number) { + return request<{ list: any[], total: number }>(`/home/v1/article/illness_list`, "GET", {page, page_size, owner_id}) }, } diff --git a/src/app.config.ts b/src/app.config.ts index db352ba..4001fc0 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -45,6 +45,10 @@ export default defineAppConfig({ 'pages/my/my': { network: 'all', packages: ['pages/manage'] + }, + 'pages/home/home': { + network: 'all', + packages: ['pages/preview'] } }, subpackages: [ @@ -57,8 +61,7 @@ export default defineAppConfig({ 'history/history', 'curHistory/curHistory', 'hourHistory/hourHistory', - 'courType/courType', - 'sort/sort', // 公共二级分类 + 'courType/courType' ] }, { diff --git a/src/pages/business/sort/sort.config.ts b/src/pages/business/sort/sort.config.ts deleted file mode 100644 index f54b62b..0000000 --- a/src/pages/business/sort/sort.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '分类' -}) diff --git a/src/pages/business/sort/sort.tsx b/src/pages/business/sort/sort.tsx deleted file mode 100644 index e2cd428..0000000 --- a/src/pages/business/sort/sort.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {FC} from "react"; -import {View} from "@tarojs/components"; -import {useRouter} from "@tarojs/taro"; - -type SortType = '' - -interface Params { - id: number - type: SortType - jumpUrl: (data:Record) => void -} - -const Sort: FC = () => { - const params = useRouter().params as unknown as Params - - return ( - ds - ) -} - -export default Sort diff --git a/src/pages/check/check.tsx b/src/pages/check/check.tsx index b461897..da26136 100644 --- a/src/pages/check/check.tsx +++ b/src/pages/check/check.tsx @@ -50,7 +50,7 @@ const Bing: FC = () => { setCompany(res.company) setUser(res.user) setToken(res.token) - Taro.switchTab({url: '/pages/index/index'}) + Taro.switchTab({url: '/pages/home/home'}) } } catch (e) { } diff --git a/src/pages/home/components/feature_recommended.tsx b/src/pages/home/components/feature_recommended.tsx index b251b88..8de747f 100644 --- a/src/pages/home/components/feature_recommended.tsx +++ b/src/pages/home/components/feature_recommended.tsx @@ -80,7 +80,7 @@ const FeatureRecommended: FC = () => { title: d.title, imageUrl: d.url_path, description: d.introduction, - path: `?url=${d.resource?.url}&poster=${d.url_path}&title=${d.resource?.name}` + path: `?url=${d.resource?.url}&poster=${d.url_path}&title=${d.title}` })) } catch (e) { } @@ -95,8 +95,8 @@ const FeatureRecommended: FC = () => { id: d.id, imageUrl: d.url_path, description: d.introduction, - title: d.resource?.name, - path: `?url=${d.resource?.url}&poster=${d.url_path}&title=${d.resource?.name}` + title: d.title, + path: `?url=${d.resource?.url}&poster=${d.url_path}&title=${d.title}` })) } catch (e) { } diff --git a/src/pages/home/home.module.scss b/src/pages/home/home.module.scss index c36351d..6fd3f7d 100644 --- a/src/pages/home/home.module.scss +++ b/src/pages/home/home.module.scss @@ -75,7 +75,7 @@ } .featureTitle { - height: 50rpx; + height: 42rpx; padding-bottom: 30rpx; } diff --git a/src/pages/index/components/videoList.tsx b/src/pages/index/components/videoList.tsx index 4352a77..002975c 100644 --- a/src/pages/index/components/videoList.tsx +++ b/src/pages/index/components/videoList.tsx @@ -1,4 +1,4 @@ -import {FC, useEffect, useState} from "react"; +import {FC, useEffect, useMemo, useState} from "react"; import {useDidShow} from "@tarojs/taro"; import {ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; import {Courses, CoursesKey, publicApi} from "@/api/public"; @@ -16,9 +16,9 @@ interface Props { export const VideoList: FC = ({categoryKey, setCategoryKey}) => { const [data, setData] = useState({ - is_finished: [], - is_not_required: [], is_required: [], + is_not_required: [], + is_finished: [], is_not_finished: [], }) const [page, setPage] = useState(1) @@ -105,9 +105,15 @@ export const VideoList: FC = ({categoryKey, setCategoryKey}) => { setCategoryKey(categoryKeys[index]) } + const categoryIndex = useMemo(() => { + const index = Object.keys(data).findIndex(d => d === categoryKey) + return index < 0 ? 0 : index + }, [data, categoryKey]) + return ( - d === categoryKey)}> + { Object.values(data).map((value) => setPage(page + 1)}> diff --git a/src/pages/preview/illness/article/article.config.ts b/src/pages/preview/illness/article/article.config.ts index 2a0a86b..6901b40 100644 --- a/src/pages/preview/illness/article/article.config.ts +++ b/src/pages/preview/illness/article/article.config.ts @@ -1,4 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '', - onReachBottomDistance: 30 + onReachBottomDistance: 50 }) diff --git a/src/pages/preview/illness/article/article.tsx b/src/pages/preview/illness/article/article.tsx index 3670f1a..45f3250 100644 --- a/src/pages/preview/illness/article/article.tsx +++ b/src/pages/preview/illness/article/article.tsx @@ -13,7 +13,6 @@ const article:FC = () => { const [show,setShow] = useState(false) const [articleInfo,setArticleInfo] = useState() const { children, headings } = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) - console.log(headings,'headings') const query = Taro.createSelectorQuery() diff --git a/src/pages/preview/illness/list/list.config.ts b/src/pages/preview/illness/list/list.config.ts index 9fe364f..2881f86 100644 --- a/src/pages/preview/illness/list/list.config.ts +++ b/src/pages/preview/illness/list/list.config.ts @@ -1,4 +1,4 @@ export default definePageConfig({ - navigationBarTitleText: '疾病知识列表', - onReachBottomDistance: 30 + navigationBarTitleText: '文章列表', + onReachBottomDistance: 50 }) diff --git a/src/pages/preview/illness/list/list.module.scss b/src/pages/preview/illness/list/list.module.scss index a232e59..1665d7f 100644 --- a/src/pages/preview/illness/list/list.module.scss +++ b/src/pages/preview/illness/list/list.module.scss @@ -1,34 +1,8 @@ -page{ - background-color: #fff !important; -} -.box { - display: flex; - margin-bottom: 20rpx; - background-color: #fff; - border-radius: 16rpx; - box-sizing: border-box; -} -.image{ - width: 128rpx; - height:128rpx; - background-color: pink; - border-radius: 8rpx; -} -.rightBox{ - padding-left: 24rpx; - box-sizing: border-box; - flex: 1; -} -.desc{ - font-size: 24rpx; +.brands { + font-size: 28rpx; + font-family: PingFang SC-Medium, PingFang SC; font-weight: 500; - color: #909795; - line-height: 34rpx; - display: -webkit-box; - word-break: break-all; - text-overflow: ellipsis; - overflow: hidden; - -webkit-box-orient:vertical; - -webkit-line-clamp:2; + color: #323635; + padding: 30rpx; + border-bottom: 1px solid #F5F8F7; } - diff --git a/src/pages/preview/illness/list/list.tsx b/src/pages/preview/illness/list/list.tsx index 2fae725..4064d2b 100644 --- a/src/pages/preview/illness/list/list.tsx +++ b/src/pages/preview/illness/list/list.tsx @@ -2,7 +2,6 @@ import {FC, useCallback, useEffect, useState} from "react"; import {View} from "@tarojs/components"; import styles from './list.module.scss' import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; -import Collapse from "@/components/collapse/collapse"; import {illnessApi} from "@/api/illness"; import Empty from "@/components/empty/empty"; @@ -11,32 +10,28 @@ const BrandList: FC = () => { const [page, setPage] = useState(1) const [brands, setBrands] = useState([]) const [total, setTotal] = useState(0) - const [fetchDone,setFetchDone] = useState(false) + const [fetchDone, setFetchDone] = useState(false) useEffect(() => { - Taro.showLoading({ - title: '加载中', - mask: true - }) - setTimeout(function () { - Taro.hideLoading() - setFetchDone(true) - }, 800) - getData() + Taro.showLoading({title: '加载中', mask: true}) + getData().then() }, [page]) const getData = useCallback(async () => { try { - const data = await illnessApi.list(params.id, 1, 100) + const data = await illnessApi.articleInfo(params.id, page, 20) setTotal(data.total) - setBrands([ - ...data.list - ]) - Taro.setNavigationBarTitle({title: data.list?.[0].resourceCategories?.[0]?.name ?? '文章列表'}) + setBrands([...brands, ...data.list]) } catch (e) { } + setFetchDone(true) + Taro.hideLoading() }, [page]) + function jump(id: number) { + Taro.navigateTo({url: '/pages/preview/illness/article/article?id=' + id}) + } + useReachBottom(useCallback(() => { if (brands?.length < total) { @@ -46,29 +41,13 @@ const BrandList: FC = () => { return ( - + { brands.length > 0 ? - brands.map((d) => - - - - { - d.articles?.map((d) => { - Taro.navigateTo({url: `/pages/preview/illness/article/article?id=${d.id}`}) - }} - className='py-3 font-36' - style={{borderBottom: "1px solid #ddd"}} - >{d.title} - ) - } - - }> - - - ) : + brands.map((d, index) => jump(d.id)}> + {index + 1} . {d.title} + ) + : } ) diff --git a/src/pages/preview/illness/sort/sort.module.scss b/src/pages/preview/illness/sort/sort.module.scss index 3e4d4fa..f5319b6 100644 --- a/src/pages/preview/illness/sort/sort.module.scss +++ b/src/pages/preview/illness/sort/sort.module.scss @@ -1,6 +1,16 @@ +.scrollView{ + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: auto; + display: flex; +} + .firstOrder { width: 300rpx; - height: calc(100vh - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 200rpx); + height: 100%; View { width: 100%; @@ -54,10 +64,16 @@ padding: 0 15rpx; background: #fff; box-sizing: border-box; - height: calc(100vh - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 200rpx) + height: 100%; } .list { padding: 20rpx; border-bottom: 1px solid #F5F8F7; + width: 100%; + min-height: 100rpx; + color: #323635; + box-sizing: border-box; + display: flex; + align-items: center; } diff --git a/src/pages/preview/illness/sort/sort.tsx b/src/pages/preview/illness/sort/sort.tsx index 230971e..3812077 100644 --- a/src/pages/preview/illness/sort/sort.tsx +++ b/src/pages/preview/illness/sort/sort.tsx @@ -4,7 +4,6 @@ import {Category, HomeApi} from "@/api"; import Taro from "@tarojs/taro"; import styles from './sort.module.scss' import Tabs, {TabList} from "@/components/tabs/tabs"; -import {Search} from "@/pages/home/components/search"; import {illnessApi} from "@/api/illness"; import Empty from "@/components/empty/empty"; import leftArrow from "@/static/img/leftArrow.png" @@ -16,10 +15,10 @@ const Sort: FC = () => { const [secondId, setSecondId] = useState(undefined) const [list, setList] = useState([]) - const globalData = Taro.getApp().globalData const menu = Taro.getMenuButtonBoundingClientRect() + async function getData() { const res = await HomeApi.category(3) setData(res) @@ -30,7 +29,7 @@ const Sort: FC = () => { } function jump(id: number) { - Taro.navigateTo({url: '/pages/preview/illness/article/article?id=' + id}) + Taro.navigateTo({url: '/pages/preview/illness/list/list?id=' + id}) } const getTabList = useMemo((): TabList[] => { @@ -48,10 +47,6 @@ const Sort: FC = () => { paddingLeft: '10px' } - function onConfirm(value: string) { - console.log(value) - } - function firstIdChange(id: number) { setFirstId(id) const resource_category = data.find(d => d.id === id)?.resource_category @@ -64,16 +59,14 @@ const Sort: FC = () => { if (secondId) { Taro.showLoading({title: '加载中'}) illnessApi.list(secondId, 1, 100).then(res => { - const data = [] - res.list.forEach(d => { - data.push(...d.articles as []) - }) - setList(data) + setList(res.list) }).finally(() => { Taro.hideLoading() }).catch(() => { setList([]) }) + } else { + setList([]) } }, [secondId]) @@ -86,13 +79,11 @@ const Sort: FC = () => { onClick={() => Taro.navigateBack()}/> firstIdChange(data.tab?.value as number)}/> - - - + + {/**/} + + + { data.find(d => d.id === firstId)?.resource_category?.map(d => { scrollWithAnimation> { list.length ? - list.map(d => jump(d.id)}>{d.title}) + list.map(d => jump(d.id)}>{d.name}) : } diff --git a/src/pages/preview/videoFull/videoFull.tsx b/src/pages/preview/videoFull/videoFull.tsx index 6c7bdba..6651cd1 100644 --- a/src/pages/preview/videoFull/videoFull.tsx +++ b/src/pages/preview/videoFull/videoFull.tsx @@ -34,10 +34,22 @@ const VideoFull: FC = () => { } } + function onError() { + Taro.showModal({ + title: '视频播放错误', + confirmText: '退出', + showCancel: true, + success() { + Taro.navigateBack() + } + }) + } + return ( <> {params.title && {params.title}}