From 3e4a30cf1f6e7bf1ec25c2b1c79a687c62c00c73 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Thu, 7 Sep 2023 10:19:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E5=92=8C=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/manage/courseAdmin/components/search.tsx | 13 ++++++++----- .../manage/courseAdmin/courseAdmin.module.scss | 8 ++++++-- src/pages/manage/courseAdmin/courseAdmin.tsx | 10 +++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/pages/manage/courseAdmin/components/search.tsx b/src/pages/manage/courseAdmin/components/search.tsx index 43f9fd7..ca639ea 100644 --- a/src/pages/manage/courseAdmin/components/search.tsx +++ b/src/pages/manage/courseAdmin/components/search.tsx @@ -17,6 +17,7 @@ export const Search: FC = ({param, setParam}) => { const [show, setShow] = useState(false) const [deps, setDeps] = useState([]) const [depId, setDepId] = useState(param.dep_id) + const [title, setTitle] = useState(param.title) async function getDepList() { try { @@ -53,19 +54,21 @@ export const Search: FC = ({param, setParam}) => { <> - + setTitle(e.detail.value)} onConfirm={(e) => setParam({ ...param, title: e.detail.value, page: 1 - })}/> + })} + /> setShow(true)}> 筛选 @@ -99,7 +102,7 @@ export const Search: FC = ({param, setParam}) => { ) } - + setShow(false)}> 取消 diff --git a/src/pages/manage/courseAdmin/courseAdmin.module.scss b/src/pages/manage/courseAdmin/courseAdmin.module.scss index 2267ffa..de29a19 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.module.scss +++ b/src/pages/manage/courseAdmin/courseAdmin.module.scss @@ -3,6 +3,9 @@ padding: 24rpx 30rpx; display: flex; justify-content: space-between; + position: sticky; + top: 0; + border-bottom: 1px solid #F5F8F7; } .searchInput { @@ -13,7 +16,6 @@ padding-left: 24rpx; background: #F5F8F7; border-radius: 32rpx; - color: #909795; overflow: hidden; } @@ -65,7 +67,7 @@ } .curList { - padding-bottom: 100px; + padding-bottom: calc(env(safe-area-inset-bottom) + 63rpx); } .add { @@ -83,4 +85,6 @@ display: flex; justify-content: space-between; padding: 30rpx; + align-items: center; + box-sizing: border-box; } diff --git a/src/pages/manage/courseAdmin/courseAdmin.tsx b/src/pages/manage/courseAdmin/courseAdmin.tsx index ad087dd..b21f706 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.tsx +++ b/src/pages/manage/courseAdmin/courseAdmin.tsx @@ -151,15 +151,15 @@ const CourseAdmin: FC = () => { return ( - - + <> - + { data?.map((d, index) => addCurs(d.id)}> {batch && addCurs(d.id)}/>} @@ -182,13 +182,13 @@ const CourseAdmin: FC = () => { } { batch && - 全选 + 全选 setBatch(false)}>取消 batchChangDep(curs)}>分配部门{curs.length} } - + ) } From 805b47435f0931574a41d2a6f5deb80b409300ea Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Thu, 7 Sep 2023 10:49:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E5=8F=96=E6=B6=88=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=88=86=E9=85=8D=E5=BF=85=E4=BF=AE=E9=80=89?= =?UTF-8?q?=E4=BF=AE=E5=8A=9F=E8=83=BD=202=E5=AD=A6=E4=B9=A0=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8A=A0=E8=BD=BD=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 +- src/api/manage.ts | 1 - src/hooks/storageDep.ts | 25 ---------- src/pages/home/components/curRecommended.tsx | 2 +- src/pages/index/index.tsx | 26 +++++++--- src/pages/manage/courseAdmin/courseAdmin.tsx | 5 +- src/pages/manage/selectDep/selectDep.tsx | 52 ++------------------ 7 files changed, 28 insertions(+), 87 deletions(-) diff --git a/.env b/.env index 86e2b46..3852d45 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/manage.ts b/src/api/manage.ts index ba13c5d..291746b 100644 --- a/src/api/manage.ts +++ b/src/api/manage.ts @@ -46,7 +46,6 @@ export interface depCurProps { interface AddCurProps { course_id: number[] dep_id: number[] - is_required: (1 | 0)[] } diff --git a/src/hooks/storageDep.ts b/src/hooks/storageDep.ts index b0e9c89..bd8283c 100644 --- a/src/hooks/storageDep.ts +++ b/src/hooks/storageDep.ts @@ -1,14 +1,12 @@ import Taro from "@tarojs/taro"; const KET = 'SELECT_DEP' -const KET_REQUIRED = 'SELECT_REQUIRED' /** 部门 */ function set(data: number[]) { Taro.setStorageSync(KET, data) } - function get(): number[] { const deps = Taro.getStorageSync(KET) if (deps && deps.length) { @@ -23,28 +21,7 @@ function removeDeps() { Taro.removeStorageSync(KET) } -/** 必修选修 */ -function removeRequired() { - Taro.removeStorageSync(KET_REQUIRED) -} - -function setRequired(data: number[]) { - Taro.setStorageSync(KET_REQUIRED, data) -} - - -/** getRequired 比 set后调用 */ -function getRequired(): (0 | 1)[] { - const deps = Taro.getStorageSync(KET_REQUIRED) - if (deps && deps.length) { - removeRequired() - return deps - } - return [] -} - function remove() { - removeRequired() removeDeps() } @@ -52,6 +29,4 @@ export default { set, get, remove, - setRequired, - getRequired } diff --git a/src/pages/home/components/curRecommended.tsx b/src/pages/home/components/curRecommended.tsx index e47d4f3..7a638c1 100644 --- a/src/pages/home/components/curRecommended.tsx +++ b/src/pages/home/components/curRecommended.tsx @@ -48,7 +48,7 @@ const CurRecommended: FC = () => { {i > 0 && } {d.title} {(d.intro || '').length > 40 && ( - {d.intro}文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨文章结束阿斯卡极乐空间是你拉卡萨 + {d.intro} {d.cover && } )} diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index d8f88a1..8d70f42 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -5,6 +5,9 @@ import {VideoList} from "@/pages/index/components/videoList"; import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; import {CoursesKey, publicApi} from "@/api/public"; import NavigationBar from "@/components/navigationBar/navigationBar"; +import Spin from "@/components/spinner"; +import Img from "@/components/image/image"; +import {rfc33392time} from "@/utils/day"; // import Taro from "@tarojs/taro"; const category: TabList[] = [ @@ -37,24 +40,35 @@ const Index: FC = () => { const AuditMode: FC = () => { const [auditMode, setAuditMode] = useState(false) const [articles, setArticles] = useState([]) + const [enable, setEnable] = useState(true) useEffect(() => { publicApi.course({page: 1, pageSize: 10}).then(res => { setAuditMode(res.audit_mode) setArticles(res.articles) - // if(res.audit_mode){ - // Taro.setTabBarItem({index: 1, text: '文章'}) - // } + setEnable(false) }) }, []) return ( <> + { auditMode ? <> - - + + { - articles.map(d => {d.title}) + articles.map((d, i) => + {i > 0 && } + {d.title} + {(d.intro || '').length > 40 && ( + {d.intro} + {d.cover && } + )} + + {rfc33392time(d.created_at).split(' ')[0]} + 阅读 {d.page_view || 0} + + ) } diff --git a/src/pages/manage/courseAdmin/courseAdmin.tsx b/src/pages/manage/courseAdmin/courseAdmin.tsx index b21f706..ebcceb7 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.tsx +++ b/src/pages/manage/courseAdmin/courseAdmin.tsx @@ -124,13 +124,12 @@ const CourseAdmin: FC = () => { Taro.useDidShow(useCallback(async () => { const dep_id = storageDep.get() - const is_required = storageDep.getRequired() - if (!dep_id.length || !is_required.length || !curs.length) return; + if (!dep_id.length || !curs.length) return; try { - await ManageApi.addCur({course_id: curs, dep_id, is_required}) + await ManageApi.addCur({course_id: curs, dep_id}) Taro.showToast({title: '修改成功'}) // deps 中没有 筛选条件中的depid 删除已选的课程 if (param.dep_id && dep_id.includes(param.dep_id)) { diff --git a/src/pages/manage/selectDep/selectDep.tsx b/src/pages/manage/selectDep/selectDep.tsx index 72760ce..8a34de9 100644 --- a/src/pages/manage/selectDep/selectDep.tsx +++ b/src/pages/manage/selectDep/selectDep.tsx @@ -1,5 +1,5 @@ import React, {FC, useCallback, useEffect, useState} from "react"; -import {Checkbox, Switch, View} from "@tarojs/components"; +import {Checkbox, View} from "@tarojs/components"; import Taro from "@tarojs/taro"; import {curriculum} from "@/api"; import PopPut from "@/components/popPut/popPut"; @@ -13,10 +13,9 @@ import Spin from "@/components/spinner"; * required 是 必修选修 */ const SelectDep: FC = () => { - const params = Taro.getCurrentInstance()?.router?.params as { depIds: string, required: string | undefined } + const params = Taro.getCurrentInstance()?.router?.params as { depIds: string} const [ids, setIds] = useState([]) const [deps, setDeps] = useState([]) - const [required, setRequired] = useState([]) const [enable, setEnable] = useState(true) useEffect(() => { @@ -25,7 +24,6 @@ const SelectDep: FC = () => { }) setEnable(false) setIds(JSON.parse(params.depIds)) - setRequired(JSON.parse(params.required || "[]")) }, []) const onChange = useCallback((id: number) => { @@ -35,51 +33,19 @@ const SelectDep: FC = () => { ...ids, id ]) - - if (params.required) { - setRequired([...required, 0]) - } } else { const oldIds: number[] = JSON.parse(JSON.stringify(ids)) oldIds.splice(index, 1) setIds(oldIds) - - if (params.required) { - const oldRequired: number[] = JSON.parse(JSON.stringify(required)) - oldRequired.splice(index, 1) - setRequired(oldRequired) - } } }, [ids]) function ok() { storageDep.set(ids) - storageDep.setRequired(required) Taro.navigateBack({delta: 1}) } - function isRequired(dep_id: number): boolean { - const index = ids.indexOf(dep_id) - if (index === -1) { - return false - } else { - return !!required?.[index] - } - } - - function requiredChange(dep_id: number, value: boolean) { - const index = ids.indexOf(dep_id) - if (index === -1) { - setIds([...ids, dep_id]) - setRequired([...required, value ? 1 : 0]) - } else { - const oldRequired: number[] = JSON.parse(JSON.stringify(required)) - oldRequired.splice(index, 1, value ? 1 : 0) - setRequired(oldRequired) - } - } - return ( @@ -90,19 +56,7 @@ const SelectDep: FC = () => { key={d.id} title={d.name} chevron - leftImage={folder} - content={ - params?.required ? - - 必修: event?.stopImmediatePropagation()} - checked={isRequired(d.id)} - onChange={(e) => requiredChange(d.id, e.detail.value)}/> - - : null - } - /> + leftImage={folder}/> )} From 5137d3297f319013df5b7186ded2538f5367ce06 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Thu, 7 Sep 2023 16:37:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=9D=A1=E5=8A=A8=E7=94=BB=E5=92=8C=E6=96=87=E7=AB=A0header?= =?UTF-8?q?=E5=A4=B4=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 +- src/api/brand.ts | 2 + src/app.scss | 2 +- src/pages/home/components/curRecommended.tsx | 22 ++- .../preview/brand/article/article.module.scss | 36 +++- src/pages/preview/brand/article/article.tsx | 32 +++- .../illness/article/article.module.scss | 43 +++-- src/pages/preview/illness/article/article.tsx | 22 ++- .../preview/search/search/components/list.tsx | 162 ++++++++--------- .../preview/search/search/index.config.ts | 5 +- .../preview/search/search/index.module.scss | 48 +++-- src/pages/preview/search/search/index.tsx | 164 ++++++++++-------- src/static/img/del.png | Bin 0 -> 400 bytes src/utils/time.tsx | 19 ++ 14 files changed, 352 insertions(+), 209 deletions(-) create mode 100644 src/static/img/del.png diff --git a/.env b/.env index 3852d45..86e2b46 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/brand.ts b/src/api/brand.ts index fe673cc..4848853 100644 --- a/src/api/brand.ts +++ b/src/api/brand.ts @@ -11,12 +11,14 @@ export type BrandRecord = { introductory_video_resource: any article_count: number created_at: string + page_view:number } export type ArticleRecord = { title: string page_view: number created_at: string content: string + brands: BrandRecord[] } export const brandApi = { diff --git a/src/app.scss b/src/app.scss index 5f2fd71..af88b78 100644 --- a/src/app.scss +++ b/src/app.scss @@ -270,7 +270,7 @@ .text-hover-danger { color: #a71d2a;} .text-light { color: #f8f9fa;} .text-hover-light { color: #cbd3da;} -.text-dark { color: #343a40;} +.text-dark { color: #323635;} .text-hover-dark{ color: #121416;} .text-body { color: #212529;} .text-muted { color: #909795;} diff --git a/src/pages/home/components/curRecommended.tsx b/src/pages/home/components/curRecommended.tsx index 7a638c1..95aa016 100644 --- a/src/pages/home/components/curRecommended.tsx +++ b/src/pages/home/components/curRecommended.tsx @@ -1,13 +1,29 @@ import {FC, ReactNode, useEffect, useState} from "react"; import {Image, View} from "@tarojs/components"; import {HomeApi} from "@/api"; -import {useReachBottom} from "@tarojs/taro"; +import Taro, {useReachBottom} from "@tarojs/taro"; import styles from "../home.module.scss"; import VideoCover from "@/components/videoCover/videoCover"; import courseTag from '@/static/img/courseTag.png' import {rfc33392time} from "@/utils/day"; import Img from "@/components/image/image"; +const toArticlePage = (d: any) => { + console.log({d}) + switch (d.owner_type) { + case 1: + Taro.navigateTo({ + url: `/pages/preview/brand/article/article?id=${d.id}` + }) + return + case 2: + Taro.navigateTo({ + url: `/pages/preview/illness/article/article?id=${d.id}` + }) + return + } +} + const CurRecommended: FC = () => { const [page, setPage] = useState(1) const [data, setData] = useState([]) @@ -44,9 +60,9 @@ const CurRecommended: FC = () => { 推荐文章 - {articles.map((d, i) => + {articles.map((d, i) => toArticlePage(d)}> {i > 0 && } - {d.title} + {d.title} {(d.intro || '').length > 40 && ( {d.intro} {d.cover && } diff --git a/src/pages/preview/brand/article/article.module.scss b/src/pages/preview/brand/article/article.module.scss index e28c2e9..c6d9d5f 100644 --- a/src/pages/preview/brand/article/article.module.scss +++ b/src/pages/preview/brand/article/article.module.scss @@ -1,30 +1,33 @@ -.fixedBox{ +.fixedBox { position: fixed; z-index: 1000; - top:0; + top: 0; width: 100vw; height: 100vh; background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1), rgba(255, 255, 255, 1)); - &-inner{ + + &-inner { position: absolute; width: 100vw; - top:45vh; + top: 45vh; display: flex; flex-direction: column; align-items: center; - &-icon{ - image{ + + &-icon { + image { width: 32rpx; height: 32rpx; } } - &-box{ + + &-box { margin-top: 24rpx; width: 680rpx; - left:35rpx; + left: 35rpx; height: 76rpx; background-color: #45D4A8; - color:#fff; + color: #fff; line-height: 76rpx; text-align: center; font-size: 32rpx; @@ -34,3 +37,18 @@ } } + +.article { + font-size: 30rpx; + display: flex; + margin-bottom: 40rpx; +} + +.articleImag { + border-radius: 100rpx; +} + +.articleTitle { + font-size: 40rpx; + margin-bottom: 50rpx; +} diff --git a/src/pages/preview/brand/article/article.tsx b/src/pages/preview/brand/article/article.tsx index 25da6a9..f8b72a6 100644 --- a/src/pages/preview/brand/article/article.tsx +++ b/src/pages/preview/brand/article/article.tsx @@ -2,12 +2,14 @@ import {FC, useCallback, useEffect, useMemo, useState} from "react"; import {Image, Text, View} from "@tarojs/components"; import Taro, {useRouter} from "@tarojs/taro"; import {ArticleRecord, brandApi} from "@/api"; -import styles from "@/pages/preview/illness/article/article.module.scss"; +import styles from "./article.module.scss"; import down from "@/static/img/doubleDown.png"; import {Profile} from "@/store"; import {parse} from "@/utils/marked/marked"; import Empty from "@/components/empty/empty"; import Spin from "@/components/spinner"; +import {beforeTime} from "@/utils/time"; +import Img from "@/components/image/image"; const article: FC = () => { @@ -25,8 +27,8 @@ const article: FC = () => { const query = Taro.createSelectorQuery() query.select('#childrenNode').boundingClientRect((res) => { if (!Array.isArray(res)) { - console.log({childrenNode: res}) - setUltra(pageHeight * .45 <= res.height) + console.log({childrenNode: res}) + setUltra(pageHeight * .45 <= res.height) } }).exec() }, 300) @@ -59,8 +61,25 @@ const article: FC = () => { overflow: !token ? 'hidden' : 'auto' }}> + {articleInfo?.title} { - children.length > 0 ? children : + children.length > 0 ? + + { + articleInfo?.brands.map(d => + + + {d?.name} + + {beforeTime(articleInfo?.created_at)} . + 阅读 {articleInfo.page_view || 1} + + + ) + } + {children} + + : } @@ -71,9 +90,8 @@ const article: FC = () => { - { - Taro.navigateTo({url: '/pages/login/login'}) - }}> + Taro.navigateTo({url: '/pages/login/login'})}> 登录查看更多内容 diff --git a/src/pages/preview/illness/article/article.module.scss b/src/pages/preview/illness/article/article.module.scss index 6b00ae0..1fbc3f1 100644 --- a/src/pages/preview/illness/article/article.module.scss +++ b/src/pages/preview/illness/article/article.module.scss @@ -1,4 +1,4 @@ -.botmBox{ +.botmBox { z-index: 99; position: fixed; bottom: 0; @@ -10,7 +10,8 @@ justify-content: center; align-items: center; background: #F5F8F7; - view{ + + view { width: 560rpx; height: 76rpx; background: #45D4A8; @@ -22,33 +23,37 @@ line-height: 76rpx; } } -.fixedBox{ + +.fixedBox { position: fixed; z-index: 100; - top:0; + top: 0; width: 100vw; height: 100vh; background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1), rgba(255, 255, 255, 1)); - &-inner{ + + &-inner { position: absolute; width: 100vw; - top:45vh; + top: 45vh; display: flex; flex-direction: column; align-items: center; - &-icon{ - image{ + + &-icon { + image { width: 32rpx; height: 32rpx; } } - &-box{ + + &-box { margin-top: 24rpx; width: 680rpx; - left:35rpx; + left: 35rpx; height: 76rpx; background-color: #45D4A8; - color:#fff; + color: #fff; line-height: 76rpx; text-align: center; font-size: 32rpx; @@ -58,3 +63,19 @@ } } + + +.article { + font-size: 30rpx; + display: flex; + margin-bottom: 40rpx; +} + +.articleImag { + border-radius: 100rpx; +} + +.articleTitle { + font-size: 40rpx; + margin-bottom: 50rpx; +} diff --git a/src/pages/preview/illness/article/article.tsx b/src/pages/preview/illness/article/article.tsx index ba0e38e..172a5c1 100644 --- a/src/pages/preview/illness/article/article.tsx +++ b/src/pages/preview/illness/article/article.tsx @@ -6,7 +6,8 @@ import styles from './article.module.scss' import down from '@/static/img/doubleDown.png' import {Profile} from "@/store"; import {parse} from "@/utils/marked/marked"; -import {formatDate} from "@/utils/time"; +import {beforeTime} from "@/utils/time"; +import Img from "@/components/image/image"; const article: FC = () => { const {token} = Profile.useContainer() @@ -58,9 +59,20 @@ const article: FC = () => { height: !token ? Taro.getWindowInfo().windowHeight - 60 + 'px' : 'auto', overflow: !token ? 'hidden' : 'auto' }}> - - {articleInfo?.title} - {formatDate(new Date(articleInfo?.created_at || 0), "YY-mm-dd hh:mm:dd")} + + {articleInfo?.title} + { + articleInfo?.brands.map(d => + + + {d?.name} + + {beforeTime(articleInfo?.created_at)} . + 阅读 {articleInfo.page_view || 1} + + + ) + } {children} @@ -93,11 +105,9 @@ const article: FC = () => { } - ) } - return helloWorld() } export default article diff --git a/src/pages/preview/search/search/components/list.tsx b/src/pages/preview/search/search/components/list.tsx index e99f42a..d07e620 100644 --- a/src/pages/preview/search/search/components/list.tsx +++ b/src/pages/preview/search/search/components/list.tsx @@ -4,17 +4,16 @@ import styles from './list.module.scss' import Taro from "@tarojs/taro"; import Empty from "@/components/empty/empty"; import Img from "@/components/image/image"; -import { SearchApi } from "@/api/search"; -import { AtLoadMore } from 'taro-ui' +import {SearchApi} from "@/api/search"; +import {AtLoadMore} from 'taro-ui' import {rfc33392time} from "@/utils/day"; import play from "@/static/img/play.png"; type Props = { - name:string - clear:boolean + name: string + clear: boolean } -const SearchList: FC = ({name,clear}) => { - console.log(name,'name') +const SearchList: FC = ({name, clear}) => { const globalData = Taro.getApp().globalData const [page, setPage] = useState(1) const [brands, setBrands] = useState([]) @@ -22,21 +21,21 @@ const SearchList: FC = ({name,clear}) => { const [text, setText] = useState('') const [loading, setLoading] = useState(true) - useEffect(()=>{ - if(!clear){ + useEffect(() => { + if (!clear) { setBrands([]) setLoading(true) } - },[clear]) + }, [clear]) useEffect(() => { - if(name && clear){ + if (name && clear) { getData() } - }, [page,name,clear]) + }, [page, name, clear]) const getData = useCallback(async () => { try { - const data = await SearchApi.list(page, 10,name) + const data = await SearchApi.list(page, 10, name) if (page === 1) { if (data.data.length < 10) { setText('没有更多了~') @@ -46,7 +45,7 @@ const SearchList: FC = ({name,clear}) => { setBrands([ ...data.data ]) - }else{ + } else { setBrands([ ...brands, ...data.data @@ -57,13 +56,13 @@ const SearchList: FC = ({name,clear}) => { } catch (e) { } setLoading(false) - }, [page,name]) + }, [page, name]) - function jumpInfo(id: number,type:string,health:any) { - console.log(type,'type') + function jumpInfo(id: number, type: string, health: any) { + console.log(type, 'type') let url = '' - switch (type){ + switch (type) { case 'brand': url = '/pages/preview/brand/info/info'; break; @@ -74,7 +73,7 @@ const SearchList: FC = ({name,clear}) => { url = '/pages/preview/illness/article/article' break case 'video_records': - return Taro.navigateTo({url: `/pages/preview/videoFull/videoFull?url=${health.resources.url}&poster=${health.url_path}&title=${health.title}`}) + return Taro.navigateTo({url: `/pages/preview/videoFull/videoFull?url=${health.resources.url}&poster=${health.url_path}&title=${health.title}`}) case 'courses': url = '/pages/business/videoInfo/videoInfo' break @@ -83,13 +82,13 @@ const SearchList: FC = ({name,clear}) => { } - function onScrollToLower(){ - if (brands?.length < total) { - setPage(page + 1) - getData().then() - } else { - setText('没有更多了~') - } + function onScrollToLower() { + if (brands?.length < total) { + setPage(page + 1) + getData().then() + } else { + setText('没有更多了~') + } } return ( @@ -97,68 +96,71 @@ const SearchList: FC = ({name,clear}) => { className='scrollview' scrollY scrollWithAnimation - style={{height:`${globalData.windowHeight-60}px`,backgroundColor:`#f5f5f5`}} + style={{height: `${globalData.pageHeight - 20}px`, backgroundColor: `#f5f5f5`}} onScrollToLower={onScrollToLower} > - { loading && } + {loading && } { brands.length >= 1 && !loading && - <> - {brands.map((d) => - jumpInfo(d.data.id,d.data.table,d.data['@data'])} className={styles.box} key={d.data.id}> - { - d.data.table === 'brand' && - <> - - - {d.data.title} - {d.data.content || '暂无品牌简介'} - - - } - { - d.data.table === 'article' && - <> - - {d.data['@data'].title} - {rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}阅读 - - - - } - { - d.data.table === 'video_records' && - <> - - - - {d.data['@data'].title} - {d.data['@data'].introduction} - 播放量: {d.data['@data'].video_view} - - - } - { - d.data.table === 'courses' && - <> - - - {d.data['@data'].title} - 课时:{d.data['@data'].class_hour}节 销量:{d.data['@data'].charge} - - - } - - + <> + {brands.map((d) => + jumpInfo(d.data.id, d.data.table, d.data['@data'])} className={styles.box} + key={d.data.id}> + { + d.data.table === 'brand' && + <> + + + {d.data.title} + {d.data.content || '暂无品牌简介'} + + + } + { + d.data.table === 'article' && + <> + + {d.data['@data'].title} + {rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}阅读 + + + + } + { + d.data.table === 'video_records' && + <> + + + + {d.data['@data'].title} + {d.data['@data'].introduction} + 播放量: {d.data['@data'].video_view} + + + } + { + d.data.table === 'courses' && + <> + + + {d.data['@data'].title} + 课时:{d.data['@data'].class_hour}节 + 销量:{d.data['@data'].charge} + + + } - - ) - } - {text} - + + ) + } + {text} + } - { !loading && brands.length === 0 && } + {!loading && brands.length === 0 && } ) } diff --git a/src/pages/preview/search/search/index.config.ts b/src/pages/preview/search/search/index.config.ts index 4fdde3a..0b7d560 100644 --- a/src/pages/preview/search/search/index.config.ts +++ b/src/pages/preview/search/search/index.config.ts @@ -1,5 +1,6 @@ export default definePageConfig({ navigationBarTitleText: '搜索', - navigationBarBackgroundColor:'#F2F8F6', - onReachBottomDistance: 50 + navigationBarBackgroundColor: '#F2F8F6', + onReachBottomDistance: 50, + navigationStyle: 'custom', }) diff --git a/src/pages/preview/search/search/index.module.scss b/src/pages/preview/search/search/index.module.scss index 9dddadd..fb4571b 100644 --- a/src/pages/preview/search/search/index.module.scss +++ b/src/pages/preview/search/search/index.module.scss @@ -1,42 +1,58 @@ -page{ - background-color:#F2F8F6; - padding-left: 30rpx; - .searchBox{ - width: 690rpx; +page { + background-color: #F2F8F6; + + .searchHeader { + margin-top: 10px; + padding: 0 20rpx; + display: flex; + align-items: center; + justify-content: space-between; + transition: all 200ms; + position: sticky; + z-index: 200 ; + overflow: hidden; + } + + .searchBox { + flex: 1; height: 68rpx; background: #FFFFFF; - border-radius: 32rpx 32rpx 32rpx 32rpx; + border-radius: 32rpx; box-sizing: border-box; display: flex; align-items: center; - padding:0 24rpx; - .input{ + padding: 0 24rpx; + + .input { font-size: 28rpx; - font-weight: 500; - margin-left: 24rpx; - flex:1; + margin-left: 20rpx; + flex: 1; } } - .titleBox{ + + .titleBox { margin-top: 60rpx; width: 100%; display: flex; box-sizing: border-box; padding-right: 30rpx; justify-content: space-between; - .title{ + + .title { font-size: 28rpx; font-weight: bold; color: #323635; } } - .contentBox{ + + .contentBox { display: flex; flex-wrap: wrap; - .items{ + + .items { display: inline-block; background: #FFFFFF; - border-radius:32rpx; + border-radius: 32rpx; padding: 10rpx 24rpx; font-size: 24rpx; font-weight: 500; diff --git a/src/pages/preview/search/search/index.tsx b/src/pages/preview/search/search/index.tsx index 554655f..a854d64 100644 --- a/src/pages/preview/search/search/index.tsx +++ b/src/pages/preview/search/search/index.tsx @@ -1,116 +1,136 @@ -import {Input, View, Text, PageContainer} from "@tarojs/components"; -import {FC, useEffect, useState} from "react"; -import { AtIcon } from 'taro-ui' +import {Input, View, Text, PageContainer, Image} from "@tarojs/components"; +import React, {FC, useEffect, useMemo, useState} from "react"; import styles from './index.module.scss' import Taro from "@tarojs/taro"; -import { useReady, useDidShow } from '@tarojs/taro' +import {useDidShow} from '@tarojs/taro' import SearchList from './components/list' +import search from '@/static/img/search.png' +import NavigationBar from "@/components/navigationBar/navigationBar"; +import del from '@/static/img/del.png' -const Search:FC = () => { +const Search: FC = () => { const [value, setValue] = useState('') const [recentSearch, setRecentSearch] = useState([]) - const [hotSearch,setHotSearch] = useState([]) + const [hotSearch] = useState([]) const [show, setShow] = useState(false) + const [focus, setFocus] = useState(false) - useReady(()=>{ - console.log('onReady') - }) - useDidShow(()=>{ - getRecentSearch() - }) + useDidShow(getRecentSearch) - useEffect(()=>{ - if(!show){ + useEffect(() => { + if (!show) { getRecentSearch() } - },[show]) + }, [show]) - function inpFn(e){ + function inpFn(e) { setValue(e.detail.value) } - function clearSearch(){ + function clearSearch() { Taro.removeStorageSync('recentSearch') getRecentSearch() } - function getRecentSearch () { + function getRecentSearch() { setRecentSearch(Taro.getStorageSync('recentSearch')) } + function getSearchItem(value) { setValue(value) - // Taro.navigateTo({ - // url:`/pages/preview/search/list/index?name=${value}` - // }) setShow(true) } - function searchInput(){ - if (value === "") return; - getSearchItem(value) - //记录最近搜索 - let recentSearch = Taro.getStorageSync('recentSearch') || []; - recentSearch.unshift(value); - Taro.setStorageSync('recentSearch', [...new Set(recentSearch)]) - } - + function searchInput() { + if (value === "") return; + getSearchItem(value) + //记录最近搜索 + let recentSearch = Taro.getStorageSync('recentSearch') || []; + recentSearch.unshift(value); + Taro.setStorageSync('recentSearch', [...new Set(recentSearch)]) + } + const searchStyles = useMemo((): React.CSSProperties | undefined => { + if (focus || show) { + return { + transform: "translateY(-43px)", + width: "70%", + } + } + }, [focus, show]) return ( - + <> + + - - { show ? - {value}: - - } + + setFocus(true)} + onBlur={() => setFocus(false)} + className={styles.input} + placeholder={(focus || show) ? '' : "输入关键字搜索"} + type='text' + confirmType='search' + onInput={inpFn} + onConfirm={searchInput}/> + + {focus || show ? setShow(false)}>取消 : null} + - { - recentSearch.length >= 1 && !show && - <> - - 最近搜索 - - + + { + recentSearch.length >= 1 && !show && + <> + + 搜索历史 + + { recentSearch.length && - recentSearch?.map(d => - - {getSearchItem(d)}} className="font-28" >{d} - ) + recentSearch?.map(d => + getSearchItem(d)} className="font-28">{d} + ) } - - } - { - hotSearch.length >= 1 && !show && - <> - - - 热门搜索 - - - - { - hotSearch.length && - hotSearch.map(d => - - {getSearchItem(d)}} className="font-28" >{d} - ) - } + + } + { + hotSearch.length >= 1 && !show && + <> + + + 热门搜索 - - - } + + + { + hotSearch.length && + hotSearch.map(d => + + { + getSearchItem(d) + }} className="font-28">{d} + ) + } + + + + } - { setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0)'} > - - + setShow(false)} + show={show} + overlay + overlayStyle={'background:rgba(0,0,0,0)'}> + + + + - ) } export default Search diff --git a/src/static/img/del.png b/src/static/img/del.png new file mode 100644 index 0000000000000000000000000000000000000000..d434ff845bb5db385f457bab326f7694093e5af3 GIT binary patch literal 400 zcmV;B0dM|^P)Px$N=ZaPR7gwhmd{SYKoG{i5sw%-D9?h4Mtv79YzbMT9K7w#0~#8_E*IWKj3)Rj z=mA5I#WBUiNZSp&RAXY=<7DRhb^h$`5G;1C1jtrk ztwNq)xFOD7(%%AxMo&R#xRk805Azd+Mn8gZTv*IWfG1x4anju2^!LDUG`#>nltTmG>J%9!qqmQbWGktoB<{) u{(k-NhQLh_)wTjN&lxm+o4s78SN;!-{7obF0O2420000= 365) { + return `${Math.floor(timeDifference / 365)}年前` + } else if (timeDifference >= 31) { + return `${Math.floor(timeDifference / 31)}月前` + } else if (timeDifference >= 7) { + return `${Math.floor(timeDifference / 7)}星期前` + } else { + return `${timeDifference}天前` + } +} From c37e360cb68e00a41ea14e55c5b84d01fb9d1f4c Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Thu, 7 Sep 2023 17:30:51 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=9A=82=E6=97=A0?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E6=95=B0=E6=8D=AE=E5=AD=97=E6=AE=B5=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=20=E5=92=8C=20=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../learningRecord/learningRecord.tsx | 11 +++--- src/pages/business/courType/courType.tsx | 32 +++++++++------ src/pages/business/curHistory/curHistory.tsx | 1 + src/pages/business/history/history.tsx | 39 +++++++++++-------- src/pages/home/components/curRecommended.tsx | 12 +++--- src/pages/home/home.tsx | 6 +-- src/pages/index/index.tsx | 6 +-- src/pages/login/login.tsx | 5 +-- src/pages/manage/courseAdmin/courseAdmin.tsx | 1 + src/pages/manage/depAdmin/depAdmin.tsx | 1 + src/pages/manage/selectDep/selectDep.tsx | 1 + src/pages/manage/userInfo/userInfo.tsx | 3 +- src/pages/preview/brand/info/info.tsx | 13 +++---- src/pages/preview/brand/list/list.tsx | 26 ++++++++----- src/pages/preview/health/health.tsx | 2 +- src/pages/preview/illness/list/list.tsx | 17 ++++---- .../preview/illness/sort/sort.module.scss | 1 + src/pages/preview/illness/sort/sort.tsx | 14 +++---- src/pages/preview/profession/profession.tsx | 1 + src/utils/time.tsx | 3 +- 20 files changed, 110 insertions(+), 85 deletions(-) diff --git a/src/components/learningRecord/learningRecord.tsx b/src/components/learningRecord/learningRecord.tsx index dea1629..54cabdf 100644 --- a/src/components/learningRecord/learningRecord.tsx +++ b/src/components/learningRecord/learningRecord.tsx @@ -5,7 +5,7 @@ import LineChart from "@/components/lineChart/lineChart"; import {CSSProperties, FC, useEffect, useState} from "react"; import {StatisticsParam, userApi} from "@/api"; import styles from './learningRecord.module.scss' -import Spin from "@/components/spinner"; +// import Spin from "@/components/spinner"; import {Profile} from "@/store"; import Taro from "@tarojs/taro"; @@ -43,20 +43,19 @@ interface Props { */ const LearningRecord: FC = ({userId, style, className}) => { const [lineData, setLineData] = useState([]) - const [loading, setLoading] = useState(false) + // const [loading, setLoading] = useState(false) const {token} = Profile.useContainer() async function getStatistics(data: StatisticsParam) { - if (!userId) return; try { - setLoading(true) + if (!userId) return; + setLineData([]) const res = await userApi.statistics(userId, data) const everyDayValue = everyDay(data.start_time, Number(data.end_time), res.data) setLineData(everyDayValue) } catch (e) { setLineData([]) } - setLoading(false) } function tabChange({tab}: OnChangOpt) { @@ -74,7 +73,7 @@ const LearningRecord: FC = ({userId, style, className}) => { return ( - + {/**/} 总共学习 diff --git a/src/pages/business/courType/courType.tsx b/src/pages/business/courType/courType.tsx index cc7cba0..1d6e057 100644 --- a/src/pages/business/courType/courType.tsx +++ b/src/pages/business/courType/courType.tsx @@ -57,17 +57,27 @@ const CourType: FC = () => { }) return ( - - {data.length > 0 ? data.map(c => - ) : } - + <> + { + data.length > 0 ? + <> + + { + data.map(c => ) + } + + 暂无更多 + + : + } + ) } diff --git a/src/pages/business/curHistory/curHistory.tsx b/src/pages/business/curHistory/curHistory.tsx index 0015159..5131f03 100644 --- a/src/pages/business/curHistory/curHistory.tsx +++ b/src/pages/business/curHistory/curHistory.tsx @@ -106,6 +106,7 @@ const CurHistory = () => { /> ) } + 暂无更多 : } diff --git a/src/pages/business/history/history.tsx b/src/pages/business/history/history.tsx index efb372b..8375e73 100644 --- a/src/pages/business/history/history.tsx +++ b/src/pages/business/history/history.tsx @@ -1,7 +1,7 @@ import {Text, View} from "@tarojs/components"; import styles from './history.module.scss' import Taro from "@tarojs/taro"; -import {useEffect, useState} from "react"; +import React, {useEffect, useState} from "react"; import {formatMinute} from "@/utils/time"; import Empty from "@/components/empty/empty"; import {userApi} from "@/api"; @@ -27,21 +27,28 @@ const History = () => { return ( - {data.length ? data.map((d, index) => - jump(d.userCourseRecord.course_id)}> - - - 共{d.userCourseRecord.hour_count}节/已学{d.userCourseRecord.finished_count}节 - - - {d.title} - - 观看{formatMinute(durations[d.id])} - 学习进度:{(d.userCourseRecord.finished_count / d.userCourseRecord.hour_count * 100).toFixed(0)}% - - - ) : } + { + data.length ? <> { + data.map((d, index) => + jump(d.userCourseRecord.course_id)}> + + + 共{d.userCourseRecord.hour_count}节/已学{d.userCourseRecord.finished_count}节 + + + {d.title} + + 观看{formatMinute(durations[d.id])} + 学习进度:{(d.userCourseRecord.finished_count / d.userCourseRecord.hour_count * 100).toFixed(0)}% + + + ) + } + 暂无更多 + + : + } ) } diff --git a/src/pages/home/components/curRecommended.tsx b/src/pages/home/components/curRecommended.tsx index 95aa016..d80a496 100644 --- a/src/pages/home/components/curRecommended.tsx +++ b/src/pages/home/components/curRecommended.tsx @@ -5,8 +5,8 @@ import Taro, {useReachBottom} from "@tarojs/taro"; import styles from "../home.module.scss"; import VideoCover from "@/components/videoCover/videoCover"; import courseTag from '@/static/img/courseTag.png' -import {rfc33392time} from "@/utils/day"; import Img from "@/components/image/image"; +import {beforeTime} from "@/utils/time"; const toArticlePage = (d: any) => { console.log({d}) @@ -60,15 +60,15 @@ const CurRecommended: FC = () => { 推荐文章 - {articles.map((d, i) => toArticlePage(d)}> - {i > 0 && } + {articles.map((d, i) => toArticlePage(d)}> + {i > 0 && } {d.title} {(d.intro || '').length > 40 && ( {d.intro} - {d.cover && } + {d.cover && } )} - {rfc33392time(d.created_at).split(' ')[0]} + {beforeTime(d.created_at)} 阅读 {d.page_view || 0} )} @@ -102,7 +102,7 @@ const CurRecommended: FC = () => { <> {examines} {videos} - - 暂无更多 - + 暂无更多 ) } diff --git a/src/pages/home/home.tsx b/src/pages/home/home.tsx index 5de95de..db3454d 100644 --- a/src/pages/home/home.tsx +++ b/src/pages/home/home.tsx @@ -1,4 +1,4 @@ -import {FC, useEffect, useState} from "react"; +import {FC, useState} from "react"; import {Image, View, Text} from "@tarojs/components"; import styles from "./home.module.scss"; import Adware from "@/pages/home/components/adware"; @@ -27,14 +27,14 @@ const Home: FC = () => { Taro.navigateTo({url: '/pages/login/login'}) } - useEffect(() => { + Taro.useDidShow(() => { HomeApi.home().then(res => { setData(res) }) setTimeout(() => { setEnable(false) }, 600) - }, []) + }) Taro.usePageScroll((e) => { const v = (Math.min(e.scrollTop / navbarHeight, 1) * 0.9).toFixed(6) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 8d70f42..a4d3037 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -7,8 +7,7 @@ import {CoursesKey, publicApi} from "@/api/public"; import NavigationBar from "@/components/navigationBar/navigationBar"; import Spin from "@/components/spinner"; import Img from "@/components/image/image"; -import {rfc33392time} from "@/utils/day"; -// import Taro from "@tarojs/taro"; +import {beforeTime} from "@/utils/time"; const category: TabList[] = [ {title: "企选课程", value: 'is_required'}, @@ -65,12 +64,13 @@ const AuditMode: FC = () => { {d.cover && } )} - {rfc33392time(d.created_at).split(' ')[0]} + {beforeTime(d.created_at)} 阅读 {d.page_view || 0} ) } + 暂无更多 : } diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx index bf19ea2..54a6278 100644 --- a/src/pages/login/login.tsx +++ b/src/pages/login/login.tsx @@ -57,10 +57,8 @@ const Login: FC = () => { setToken(token) setCompany(company) setLoading(false) - Taro.switchTab({url: '/pages/home/home'}) - + Taro.navigateBack() } else { - Taro.setStorageSync('openid', catch_key) Taro.reLaunch({url: '/pages/check/check'}) } @@ -98,7 +96,6 @@ const Login: FC = () => { {error} setError(null)}/> : null} - {/*{process.env.TARO_APP_LGOIN === 'true' && 线下登录}*/} ) diff --git a/src/pages/manage/courseAdmin/courseAdmin.tsx b/src/pages/manage/courseAdmin/courseAdmin.tsx index ebcceb7..70c0a28 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.tsx +++ b/src/pages/manage/courseAdmin/courseAdmin.tsx @@ -171,6 +171,7 @@ const CourseAdmin: FC = () => { ) } + 暂无更多 diff --git a/src/pages/manage/depAdmin/depAdmin.tsx b/src/pages/manage/depAdmin/depAdmin.tsx index 4b558c5..13d3b7f 100644 --- a/src/pages/manage/depAdmin/depAdmin.tsx +++ b/src/pages/manage/depAdmin/depAdmin.tsx @@ -158,6 +158,7 @@ const DepAdmin: FC = () => { onClick={() => Taro.navigateTo({url: '/pages/manage/userInfo/userInfo?userId=' + d.id})} content={['学员', '管理员', '超级管理员'][d.role_type]} />)} + 暂无更多 {!manages.length && !users.length && } diff --git a/src/pages/manage/selectDep/selectDep.tsx b/src/pages/manage/selectDep/selectDep.tsx index 8a34de9..cf1e907 100644 --- a/src/pages/manage/selectDep/selectDep.tsx +++ b/src/pages/manage/selectDep/selectDep.tsx @@ -59,6 +59,7 @@ const SelectDep: FC = () => { leftImage={folder}/> )} + 暂无更多 确定 diff --git a/src/pages/manage/userInfo/userInfo.tsx b/src/pages/manage/userInfo/userInfo.tsx index c9be6c3..eb91867 100644 --- a/src/pages/manage/userInfo/userInfo.tsx +++ b/src/pages/manage/userInfo/userInfo.tsx @@ -58,7 +58,6 @@ const UserInfo: FC = () => { useEffect(() => { - userApi.info(userId).then(res => { setData(res) }) @@ -76,7 +75,7 @@ const UserInfo: FC = () => { - + diff --git a/src/pages/preview/brand/info/info.tsx b/src/pages/preview/brand/info/info.tsx index 8978cf0..b3065cf 100644 --- a/src/pages/preview/brand/info/info.tsx +++ b/src/pages/preview/brand/info/info.tsx @@ -113,11 +113,9 @@ const BrandInfo: FC = () => { { - articleList?.length ? - articleList.map((i: any) => - { - Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${i.id}`}) - }}> + articleList?.length ? <>{ + articleList.map((i: any) => Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${i.id}`})}> {i.title} @@ -127,8 +125,9 @@ const BrandInfo: FC = () => { - - ) + )} + 暂无更多 + : } diff --git a/src/pages/preview/brand/list/list.tsx b/src/pages/preview/brand/list/list.tsx index 006230e..c786088 100644 --- a/src/pages/preview/brand/list/list.tsx +++ b/src/pages/preview/brand/list/list.tsx @@ -5,7 +5,7 @@ import Taro, {useReachBottom} from "@tarojs/taro"; import Empty from "@/components/empty/empty"; import Spinner from "@/components/spinner"; import Img from "@/components/image/image"; -import {formatDate} from "@/utils/time"; +import {beforeTime} from "@/utils/time"; const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onClick}) => { let media: ReactNode @@ -16,7 +16,7 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl /> } else if (data.brand_album) { media = = ({data, onCl return ( - {media} - + - + {data.name} + {beforeTime(data.created_at)}·加入 - + + + {media} + + + {data.graphic_introduction} - {formatDate(new Date(data.created_at), "YY-MM-dd hh:mm:ss")} + 文章:{data.article_count || 0} 点赞:{(Math.random() * 100).toFixed(0)} @@ -105,7 +111,7 @@ const BrandList: FC = () => { content = ( <> {brands.map(d => jumpInfo(d.id)}/>)} - {text} + {text} ) } else { diff --git a/src/pages/preview/health/health.tsx b/src/pages/preview/health/health.tsx index 84b4f7a..fcf18cb 100644 --- a/src/pages/preview/health/health.tsx +++ b/src/pages/preview/health/health.tsx @@ -55,7 +55,7 @@ const Health: FC = () => { )} - 没有更多了 + 暂无更多 : } diff --git a/src/pages/preview/illness/list/list.tsx b/src/pages/preview/illness/list/list.tsx index c1b893a..877995b 100644 --- a/src/pages/preview/illness/list/list.tsx +++ b/src/pages/preview/illness/list/list.tsx @@ -50,13 +50,16 @@ const BrandList: FC = () => { { articles.length > 0 ? - - { - articles.map((d, index) => jump(d.id)}> - {index + 1} . {d.title} - ) - } - + <> + + { + articles.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 2367ac9..ebff4fa 100644 --- a/src/pages/preview/illness/sort/sort.module.scss +++ b/src/pages/preview/illness/sort/sort.module.scss @@ -58,6 +58,7 @@ font-family: PingFang SC-Bold, PingFang SC; font-weight: bold; color: #323635; + position: relative; } .list { diff --git a/src/pages/preview/illness/sort/sort.tsx b/src/pages/preview/illness/sort/sort.tsx index 6ad6f1d..8b0ef59 100644 --- a/src/pages/preview/illness/sort/sort.tsx +++ b/src/pages/preview/illness/sort/sort.tsx @@ -96,14 +96,14 @@ const Sort: FC = () => { scrollY className={styles.tree} scrollWithAnimation> + { - loading ? : <> - { - list.length ? - list.map(d => jump(d.id)}>{d.name}) - : - } - + list.length ? + <> + {list.map(d => jump(d.id)}>{d.name})} + 暂无更多 + + : } diff --git a/src/pages/preview/profession/profession.tsx b/src/pages/preview/profession/profession.tsx index 82ce6bd..7ee3f03 100644 --- a/src/pages/preview/profession/profession.tsx +++ b/src/pages/preview/profession/profession.tsx @@ -104,6 +104,7 @@ const Profession = () => { ) } + 暂无更多 ) } diff --git a/src/utils/time.tsx b/src/utils/time.tsx index 7dd1e6c..d3e9fb0 100644 --- a/src/utils/time.tsx +++ b/src/utils/time.tsx @@ -153,8 +153,7 @@ export function beforeTime(time?: string): string { const initiateTime = new Date(time || 0).getTime() const today = Date.now() const timeDifference = Math.floor((today - initiateTime) / 86400000) - console.log(timeDifference) - if (timeDifference < 0) { + if (timeDifference <= 0) { return '今天' } else if (timeDifference >= 365) { return `${Math.floor(timeDifference / 365)}年前`