From 353e1d51e00c72b4547a6ef1d60ee6e95551fcb4 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Fri, 8 Sep 2023 10:16:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preview/search/search/components/list.tsx | 166 +++++++++--------- .../preview/search/search/index.module.scss | 52 +++--- src/pages/preview/search/search/index.tsx | 159 +++++++++-------- 3 files changed, 204 insertions(+), 173 deletions(-) diff --git a/src/pages/preview/search/search/components/list.tsx b/src/pages/preview/search/search/components/list.tsx index 88c0e32..b2be759 100644 --- a/src/pages/preview/search/search/components/list.tsx +++ b/src/pages/preview/search/search/components/list.tsx @@ -4,17 +4,17 @@ 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}) => { + console.log(name, 'name') const globalData = Taro.getApp().globalData const [page, setPage] = useState(1) const [brands, setBrands] = useState([]) @@ -22,31 +22,31 @@ 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('没有更多了~') + setText('没有更多了') } else { - setText('上拉加载更多~') + setText('上拉加载更多') } setBrands([ ...data.data ]) - }else{ + } else { setBrands([ ...brands, ...data.data @@ -57,13 +57,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 +74,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 +83,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 +97,70 @@ const SearchList: FC = ({name,clear}) => { className='scrollview' scrollY scrollWithAnimation - style={{height:`${globalData.windowHeight-140}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.module.scss b/src/pages/preview/search/search/index.module.scss index 88d34c3..3ead51e 100644 --- a/src/pages/preview/search/search/index.module.scss +++ b/src/pages/preview/search/search/index.module.scss @@ -1,46 +1,58 @@ -page{ - background-color:#F2F8F6; +page { + background-color: #F2F8F6; - .navBox{ - position: fixed; - width:750rpx; + .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{ - width: 690rpx; + + .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{ - margin-top: 60rpx; + + .titleBox { + margin-top: 40rpx; width: 100%; display: flex; box-sizing: border-box; padding-right: 30rpx; justify-content: space-between; - .title{ - font-size: 28rpx; + + .title { + font-size: 30rpx; 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 4641474..f68dbaa 100644 --- a/src/pages/preview/search/search/index.tsx +++ b/src/pages/preview/search/search/index.tsx @@ -1,110 +1,121 @@ -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 {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 NavigationBar from "@/components/navigationBar/navigationBar"; +import search from '@/static/img/search.png' +import del from '@/static/img/del.png' -const Search:FC = () => { - const globalData = Taro.getApp().globalData +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() - }) - useEffect(()=>{ - if(!show){ - getRecentSearch() - } - },[show]) + useDidShow(getRecentSearch) - function inpFn(e){ + useEffect(() => { + !show && getRecentSearch() + }, [show]) + + function inpFn(e) { setValue(e.detail.value) } - function clearSearch(){ + function clearSearch() { Taro.removeStorageSync('recentSearch') getRecentSearch() + Taro.showToast({title: '删除成功'}) } - 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)]) + } - function navBack(){ - Taro.navigateBack() - } + function cancelSearch(){ + setValue('') + setShow(false) + setFocus(false) + } + + + 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' + value={value} + confirmType='search' + onInput={inpFn} + onConfirm={searchInput}/> + + {focus || show ? 取消 : null} + + { recentSearch.length >= 1 && !show && - <> - + + 最近搜索 - + - - { - recentSearch.length && - recentSearch?.map(d => - - {getSearchItem(d)}} className="font-28" >{d} - ) - } - - + + { + recentSearch.length > 0 && + recentSearch?.map(d => + + getSearchItem(d)} className="font-28">{d} + ) + } + + } { hotSearch.length >= 1 && !show && <> - + 热门搜索 @@ -114,7 +125,9 @@ const Search:FC = () => { hotSearch.length && hotSearch.map(d => - {getSearchItem(d)}} className="font-28" >{d} + { + getSearchItem(d) + }} className="font-28">{d} ) } @@ -122,11 +135,15 @@ const Search:FC = () => { } - {setShow(false)}} onClickOverlay={()=>{ setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0)'} > - + + - - ) } From ae52d73588ba27604d6f9d77218c2d675a393885 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Fri, 8 Sep 2023 14:52:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=93=81=E7=89=8C=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 +- src/api/brand.ts | 3 +- src/api/user.ts | 8 +- src/components/collect/collect.module.scss | 65 ++++++++++++- src/components/collect/collect.tsx | 45 ++++++++- .../videoInfo/components/catalogue.tsx | 17 ++-- src/pages/business/videoInfo/videoInfo.scss | 3 + src/pages/index/index.tsx | 3 +- src/pages/preview/brand/article/article.tsx | 2 +- src/pages/preview/brand/info/info.tsx | 2 +- src/pages/preview/brand/list/list.tsx | 89 ++++++++++-------- .../illness/article/article.module.scss | 23 +++-- src/pages/preview/illness/article/article.tsx | 51 ++++++---- src/static/img/catalogue.png | Bin 0 -> 424 bytes src/static/img/omit.png | Bin 0 -> 324 bytes types/user.d.ts | 14 +++ 16 files changed, 234 insertions(+), 95 deletions(-) create mode 100644 src/static/img/catalogue.png create mode 100644 src/static/img/omit.png diff --git a/.env b/.env index 86e2b46..51b63d7 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://shopfix.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 4848853..5c767ff 100644 --- a/src/api/brand.ts +++ b/src/api/brand.ts @@ -11,7 +11,8 @@ export type BrandRecord = { introductory_video_resource: any article_count: number created_at: string - page_view:number + page_view: number + collect: boolean } export type ArticleRecord = { title: string diff --git a/src/api/user.ts b/src/api/user.ts index 6d7996a..a7baa9b 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -94,8 +94,8 @@ export const userApi = { companyReplace(id: number) { return request(`/api/v1/company/replace/${id}`, "PATCH") }, - // /** 上传头像 */ - // putAvatar(file: string) { - // return request('/api/v1/user/avatar', "PUT", {file}) - // } + /** 收藏 */ + create(data: Create) { + return request("/api/v1/collect/create", "POST", data) + } } diff --git a/src/components/collect/collect.module.scss b/src/components/collect/collect.module.scss index 3262142..5ac8c34 100644 --- a/src/components/collect/collect.module.scss +++ b/src/components/collect/collect.module.scss @@ -3,11 +3,68 @@ align-items: center; color: #909795; font-size: 24rpx; + padding: 0 10rpx; +} + +.collectImage { + position: relative; + width: 32rpx; + height: 32rpx; + margin-right: 10rpx; Image { - width: 32rpx; - height: 32rpx; - margin-right: 10rpx; - //vertical-align: middle; + width: 100%; + height: 100%; + } +} + +.zoom { + top: 0; + left: 0; + position: absolute; + content: ''; + width: 32rpx; + height: 32rpx; + border-radius: 50%; + border: 1px solid #FF9E5F; + animation: Zooms 300ms ease forwards; + opacity: 1; + transform-origin: -100%, -100% 0; +} + +.pulse { + animation: Pulse 300ms; +} + +@keyframes Zooms { + 0% { + transform: scale(1); + } + 30% { + transform: scale(1.5); + left: -5%; + top: -5%; + opacity: 1; + } + 100% { + transform: scale(1.5); + left: -5%; + top: -5%; + opacity: 0; + } +} + +@keyframes Pulse { + 0% { + transform: scale(.2); + } + 60% { + transform: scale(1.2); + } + 80% { + transform: scale(.8); + } + 100% { + transform: scale(1); } } diff --git a/src/components/collect/collect.tsx b/src/components/collect/collect.tsx index 3c000a6..78c90fc 100644 --- a/src/components/collect/collect.tsx +++ b/src/components/collect/collect.tsx @@ -1,20 +1,57 @@ -import {FC} from "react"; +import {CSSProperties, FC, useCallback, useEffect, useState} from "react"; import star from '@/static/img/star.png' import starLine from '@/static/img/starLine.png' import {Image, View} from "@tarojs/components"; import styles from './collect.module.scss' +import {Profile} from "@/store" +import Taro from "@tarojs/taro"; +import {userApi} from "@/api"; interface Props { onClick?: () => void select?: boolean + stylesImage?: CSSProperties + styles?: CSSProperties + owner_id: number + owner_type: CreateOwnerType + textHidden?: boolean } /** 收藏 */ const Collect: FC = (props) => { + const {token} = Profile.useContainer() + const [loading, setLoading] = useState(false) + const [select, setSelect] = useState(props.select) + + useEffect(() => { + setSelect(props.select) + }, [props]) + + const change = useCallback(async () => { + if (!token) { + Taro.navigateTo({url: '/pages/login/login'}) + return + } + if (loading) return; + props.onClick?.() + console.log(select) + setSelect(!select) + setLoading(true) + await userApi.create({owner_id: props.owner_id, owner_type: props.owner_type}) + setTimeout(() => { + setLoading(false) + }, 300) + }, [loading, token, select]) + return ( - - - {props.select ? '已收藏' : '收藏'} + + + + + + {!props.textHidden && (select ? '已收藏' : '收藏')} ) } diff --git a/src/pages/business/videoInfo/components/catalogue.tsx b/src/pages/business/videoInfo/components/catalogue.tsx index 55a1a5b..fe66310 100644 --- a/src/pages/business/videoInfo/components/catalogue.tsx +++ b/src/pages/business/videoInfo/components/catalogue.tsx @@ -12,6 +12,8 @@ import hourRecord from "@/static/img/hourRecord.png" import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; import {Profile} from "@/store"; import LoginView from "@/components/loginView"; +import Collect from "@/components/collect/collect"; +import omit from '@/static/img/omit.png' interface Props { data: CourseDepData | null @@ -45,11 +47,6 @@ const Catalogue: FC = ({data, setHors, id, playId}) => { } }) - - // function onPause() { - // videoEvents.setVideoState('pause') - // } - function jumCurHistory() { if (playId) { Taro.navigateTo({url: `/pages/business/hourHistory/hourHistory?courseId=${id}&hourId=${playId}`}) @@ -195,7 +192,15 @@ const Catalogue: FC = ({data, setHors, id, playId}) => { playing ? 播放中 : 立即学习 } - setShow(true)}>... + + setShow(true)}> + + 更多 + } diff --git a/src/pages/business/videoInfo/videoInfo.scss b/src/pages/business/videoInfo/videoInfo.scss index 1874753..ce38d75 100644 --- a/src/pages/business/videoInfo/videoInfo.scss +++ b/src/pages/business/videoInfo/videoInfo.scss @@ -76,6 +76,7 @@ } .Videobutton { + align-items: center; display: flex; background: #fff; position: fixed; @@ -84,6 +85,8 @@ bottom: env(safe-area-inset-bottom); box-sizing: border-box; padding: 10px 20px; + color: #909795; + font-size: 24rpx; } .more { diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 91bbaad..65c7e62 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -8,6 +8,7 @@ import NavigationBar from "@/components/navigationBar/navigationBar"; import Spin from "@/components/spinner"; import Img from "@/components/image/image"; import {beforeTime} from "@/utils/time"; +import {isBoolean} from "@tarojs/shared"; const category: TabList[] = [ {title: "企选课程", value: 'is_required'}, @@ -42,7 +43,7 @@ const AuditMode: FC = () => { const [enable, setEnable] = useState(true) useEffect(() => { publicApi.course({page: 1, pageSize: 10}).then(res => { - setAuditMode(res.audit_mode) + setAuditMode(isBoolean(res.audit_mode) ? res.audit_mode : res.audit_mode === 'true') setArticles(res.articles) setEnable(false) }) diff --git a/src/pages/preview/brand/article/article.tsx b/src/pages/preview/brand/article/article.tsx index f8b72a6..bc7f5c5 100644 --- a/src/pages/preview/brand/article/article.tsx +++ b/src/pages/preview/brand/article/article.tsx @@ -20,7 +20,7 @@ const article: FC = () => { const [ultra, setUltra] = useState(true) const globalData = Taro.getApp().globalData const pageHeight = globalData.windowHeight - globalData.textBarHeight - globalData.statusBarHeight - const {children} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) + const {children, headings} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) useEffect(() => { setTimeout(() => { diff --git a/src/pages/preview/brand/info/info.tsx b/src/pages/preview/brand/info/info.tsx index b824190..f8d2413 100644 --- a/src/pages/preview/brand/info/info.tsx +++ b/src/pages/preview/brand/info/info.tsx @@ -111,7 +111,7 @@ const BrandInfo: FC = () => { {brandInfo?.name} - + diff --git a/src/pages/preview/brand/list/list.tsx b/src/pages/preview/brand/list/list.tsx index 1ccaf2b..ab1e9ba 100644 --- a/src/pages/preview/brand/list/list.tsx +++ b/src/pages/preview/brand/list/list.tsx @@ -19,40 +19,40 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl /> } else if (data.brand_album) { media = } return ( - - - - - {data.name} - {beforeTime(data.created_at)}·加入 + + + + + + {data.name} + {beforeTime(data.created_at)}·加入 + - - - {media} - + + {media} + - - {data.graphic_introduction} + + {data.graphic_introduction} + @@ -60,7 +60,8 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl {data.article_count || 0} - + {JSON.stringify(data.collect)} + @@ -78,9 +79,13 @@ const BrandList: FC = () => { getData() }, [page]) - const getData = useCallback(async () => { + Taro.useDidShow(() => { + brands.length && getData(true) + }) + + const getData = useCallback(async (replace = false) => { try { - const res = await brandApi.list(page, 10) + const res = await brandApi.list(replace ? 1 : page, replace ? 10 * page : 10) if (page === 1) { if (res.list.length < 10) { setText('暂无更多') @@ -89,10 +94,16 @@ const BrandList: FC = () => { } } setTotal(res.total) - setBrands([ - ...brands, - ...res.list - ]) + const data = res.list.reduce((pre, cur) => { + const index = pre.findIndex(d => d.id === cur.id) + if (index > -1) { + pre.splice(index, 1, cur) + } else { + pre.push(cur) + } + return pre + }, JSON.parse(JSON.stringify(brands))) + setBrands(data) } catch (e) { } setLoading(false) @@ -111,22 +122,18 @@ const BrandList: FC = () => { } }, [total, brands])) - let content: ReactNode - if (brands.length) { - content = ( - <> - {brands.map(d => jumpInfo(d.id)}/>)} - {text} - - ) - } else { - content = - } return ( - {content} + { + brands.length ? + <> + {brands.map(d => jumpInfo(d.id)}/>)} + {text} + + : + } ) } diff --git a/src/pages/preview/illness/article/article.module.scss b/src/pages/preview/illness/article/article.module.scss index 1fbc3f1..0c16607 100644 --- a/src/pages/preview/illness/article/article.module.scss +++ b/src/pages/preview/illness/article/article.module.scss @@ -4,26 +4,25 @@ bottom: 0; width: 750rpx; box-sizing: border-box; - height: 180rpx; - padding-bottom: 60rpx; + height: 150rpx; + padding-bottom: env(safe-area-inset-bottom); display: flex; - justify-content: center; + justify-content: flex-end; align-items: center; background: #F5F8F7; + color: #909795; + font-size: 26rpx; - view { - width: 560rpx; - height: 76rpx; - background: #45D4A8; - border-radius: 38rpx 38rpx 38rpx 38rpx; - color: #fff; - font-weight: 500; - font-size: 40rpx; + View { + padding: 0 10px; text-align: center; - line-height: 76rpx; } } +.articleBox { + padding: 30rpx 30rpx calc(env(safe-area-inset-bottom) + 150rpx) 30rpx; +} + .fixedBox { position: fixed; z-index: 100; diff --git a/src/pages/preview/illness/article/article.tsx b/src/pages/preview/illness/article/article.tsx index 172a5c1..ce221d6 100644 --- a/src/pages/preview/illness/article/article.tsx +++ b/src/pages/preview/illness/article/article.tsx @@ -8,6 +8,8 @@ import {Profile} from "@/store"; import {parse} from "@/utils/marked/marked"; import {beforeTime} from "@/utils/time"; import Img from "@/components/image/image"; +import catalogue from '@/static/img/catalogue.png' +import Collect from "@/components/collect/collect"; const article: FC = () => { const {token} = Profile.useContainer() @@ -32,7 +34,6 @@ const article: FC = () => { } function mao(id: string) { - console.log(id) setShow(false) Taro.nextTick(() => { query.select(`#${id}`).boundingClientRect() @@ -52,13 +53,24 @@ const article: FC = () => { return ( <> setShow(true)}> - 文章导航 + + + + + + 目录 + - + {articleInfo?.title} { @@ -74,7 +86,6 @@ const article: FC = () => { ) } - {children} { @@ -92,22 +103,26 @@ const article: FC = () => { } - { - setShow(false) - }} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0.3)'}> + setShow(false)} + show={show} + round + overlay + overlayStyle={'background:rgba(0,0,0,0.3)'}> - {headings.length > 0 && - headings.map((d) => - { - mao(d.id) - }}>{d.text} - ) - } + {headings.length > 0 && headings.map((d) => mao(d.id)}> + {d.text} + + )} ) } + return helloWorld() } export default article diff --git a/src/static/img/catalogue.png b/src/static/img/catalogue.png new file mode 100644 index 0000000000000000000000000000000000000000..fe7be4333c1b481203924fdf39674fcd8bbfd545 GIT binary patch literal 424 zcmV;Z0ayNsP)Px$Vo5|nR9Hvtm%mEGP!z_$lWIXw7j>|>>SC;e;4C!V1))ZCbm{2m3%EJ-0mMZ# zzJQAhys&v*X(PBjb@4 zPzP{IgelYHY4i;Anfa)>ws-bh_h-dkJLnTIohG@(*xs${&m}fkZ3Pb?Y*;Khaw-Oz zq3e5z4Q@SNEKNGjE<1&cDRM7{a~`eMJ`)=pdEATw<;<9Z7J@?1lz^#z{Qkk*dvUcL zyaSjuU5$>Ofo|yf3wie9`_T0_)m}VNsDr7bLqS)=#N9X^G@|u`7x7|UivQ`x@66bo z-bOAVXi8BCS|?cPTyN8mPY4;mi2j<|!)61|#A5nN_Xy$f7T+}=OnWZ_q+5So4Er(~gGZ;Nk2 zM2Er3&t~%Z`)4X_`EzjEb7syHdld~e*mkn**i#a~Q^Z?P`Er586R8KERyFUoco*qv z=DuK`)r1FABhOX7-1S~f-r(fp?*+R(^cgPv<(!-%n;s;7$)x}HiydwY5|?T=xj*wj~@@&Z4B$9o0BGFH=Oon-^pelbaE^E U&XqgP14Dwr)78&qol`;+0I2qekpKVy literal 0 HcmV?d00001 diff --git a/types/user.d.ts b/types/user.d.ts index cf2ba55..17120db 100644 --- a/types/user.d.ts +++ b/types/user.d.ts @@ -95,5 +95,19 @@ interface HourHistory extends Curriculum { } } +/** + * 收藏类型,收藏类型 1文章 2视频 3课程 4其他(品牌) + */ +type CreateOwnerType = 1 | 2 | 3 | 4 + +/** 收藏 */ +interface Create { + /** + * 收藏id + */ + owner_id: number + owner_type: CreateOwnerType +} + From 86bc1a4cc03e45b443094c23f5f9d3aa5046b281 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Fri, 8 Sep 2023 15:30:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/brand.ts | 1 + src/app.config.ts | 1 - src/pages/home/components/curRecommended.tsx | 16 +-- .../preview/brand/article/article.module.scss | 27 ++++ src/pages/preview/brand/article/article.tsx | 72 ++++++++-- src/pages/preview/brand/list/list.tsx | 1 - .../preview/illness/article/article.config.ts | 4 - .../illness/article/article.module.scss | 80 ----------- src/pages/preview/illness/article/article.tsx | 128 ------------------ src/pages/preview/illness/list/list.tsx | 2 +- .../preview/search/search/components/list.tsx | 2 +- 11 files changed, 97 insertions(+), 237 deletions(-) delete mode 100644 src/pages/preview/illness/article/article.config.ts delete mode 100644 src/pages/preview/illness/article/article.module.scss delete mode 100644 src/pages/preview/illness/article/article.tsx diff --git a/src/api/brand.ts b/src/api/brand.ts index 5c767ff..2ee9b29 100644 --- a/src/api/brand.ts +++ b/src/api/brand.ts @@ -20,6 +20,7 @@ export type ArticleRecord = { created_at: string content: string brands: BrandRecord[] + collect:boolean } export const brandApi = { diff --git a/src/app.config.ts b/src/app.config.ts index a71824d..cb521c0 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -91,7 +91,6 @@ export default defineAppConfig({ 'videoFull/videoFull', // 资源id 视频全屏 'illness/sort/sort', 'illness/list/list', - 'illness/article/article', 'webView/webView', 'search/search/index', ] diff --git a/src/pages/home/components/curRecommended.tsx b/src/pages/home/components/curRecommended.tsx index d80a496..700786d 100644 --- a/src/pages/home/components/curRecommended.tsx +++ b/src/pages/home/components/curRecommended.tsx @@ -9,19 +9,9 @@ import Img from "@/components/image/image"; import {beforeTime} from "@/utils/time"; 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 - } + Taro.navigateTo({ + url: `/pages/preview/brand/article/article?id=${d.id}` + }) } const CurRecommended: FC = () => { diff --git a/src/pages/preview/brand/article/article.module.scss b/src/pages/preview/brand/article/article.module.scss index c6d9d5f..f88807c 100644 --- a/src/pages/preview/brand/article/article.module.scss +++ b/src/pages/preview/brand/article/article.module.scss @@ -38,6 +38,26 @@ } } +.botmBox { + z-index: 99; + position: fixed; + bottom: 0; + width: 690rpx; + height: 100rpx; + padding: 0 30rpx env(safe-area-inset-bottom); + display: flex; + justify-content: flex-end; + align-items: center; + background: #F5F8F7; + color: #909795; + + View { + font-size: 26rpx; + padding: 0 10px; + text-align: center; + } +} + .article { font-size: 30rpx; display: flex; @@ -52,3 +72,10 @@ font-size: 40rpx; margin-bottom: 50rpx; } + +.articleBox { + background: #fff; + min-height: calc(100vh - env(safe-area-inset-bottom) + 180rpx); + box-sizing: border-box; + padding: 30rpx 30rpx calc(env(safe-area-inset-bottom) + 150rpx) 30rpx; +} diff --git a/src/pages/preview/brand/article/article.tsx b/src/pages/preview/brand/article/article.tsx index bc7f5c5..9b41257 100644 --- a/src/pages/preview/brand/article/article.tsx +++ b/src/pages/preview/brand/article/article.tsx @@ -1,5 +1,5 @@ import {FC, useCallback, useEffect, useMemo, useState} from "react"; -import {Image, Text, View} from "@tarojs/components"; +import {Image, PageContainer, Text, View} from "@tarojs/components"; import Taro, {useRouter} from "@tarojs/taro"; import {ArticleRecord, brandApi} from "@/api"; import styles from "./article.module.scss"; @@ -10,6 +10,8 @@ import Empty from "@/components/empty/empty"; import Spin from "@/components/spinner"; import {beforeTime} from "@/utils/time"; import Img from "@/components/image/image"; +import Collect from "@/components/collect/collect"; +import catalogue from "@/static/img/catalogue.png"; const article: FC = () => { @@ -18,9 +20,12 @@ const article: FC = () => { const {id} = useRouter().params as unknown as { id: number } const [articleInfo, setArticleInfo] = useState() const [ultra, setUltra] = useState(true) + const [show, setShow] = useState(false) const globalData = Taro.getApp().globalData const pageHeight = globalData.windowHeight - globalData.textBarHeight - globalData.statusBarHeight const {children, headings} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) + const query = Taro.createSelectorQuery() + useEffect(() => { setTimeout(() => { @@ -34,6 +39,22 @@ const article: FC = () => { }, 300) }, [children]) + function mao(id: string) { + setShow(false) + Taro.nextTick(() => { + query.select(`#${id}`).boundingClientRect() + query.exec((res) => { + if (res.length) { + Taro.pageScrollTo({ + scrollTop: res[res.length - 1].top, + duration: 300 + } + ) + } + }) + }) + } + Taro.useReady(() => { getData().then() }) @@ -54,12 +75,30 @@ const article: FC = () => { function helloWorld() { return ( <> + + + + + { + headings.length > 0 && setShow(true)}> + + 目录 + + } + + - + {articleInfo?.title} { @@ -67,7 +106,7 @@ const article: FC = () => { { articleInfo?.brands.map(d => - + {d?.name} @@ -97,9 +136,26 @@ const article: FC = () => { } + setShow(false)} + show={show} + round + overlay + overlayStyle={'background:rgba(0,0,0,0.3)'}> + + { + headings.length > 0 && headings.map((d) => mao(d.id)}> + {d.text} + + ) + } + + ) - } return helloWorld() diff --git a/src/pages/preview/brand/list/list.tsx b/src/pages/preview/brand/list/list.tsx index ab1e9ba..dc43706 100644 --- a/src/pages/preview/brand/list/list.tsx +++ b/src/pages/preview/brand/list/list.tsx @@ -60,7 +60,6 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl {data.article_count || 0} - {JSON.stringify(data.collect)} diff --git a/src/pages/preview/illness/article/article.config.ts b/src/pages/preview/illness/article/article.config.ts deleted file mode 100644 index 6901b40..0000000 --- a/src/pages/preview/illness/article/article.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '', - onReachBottomDistance: 50 -}) diff --git a/src/pages/preview/illness/article/article.module.scss b/src/pages/preview/illness/article/article.module.scss deleted file mode 100644 index 0c16607..0000000 --- a/src/pages/preview/illness/article/article.module.scss +++ /dev/null @@ -1,80 +0,0 @@ -.botmBox { - z-index: 99; - position: fixed; - bottom: 0; - width: 750rpx; - box-sizing: border-box; - height: 150rpx; - padding-bottom: env(safe-area-inset-bottom); - display: flex; - justify-content: flex-end; - align-items: center; - background: #F5F8F7; - color: #909795; - font-size: 26rpx; - - View { - padding: 0 10px; - text-align: center; - } -} - -.articleBox { - padding: 30rpx 30rpx calc(env(safe-area-inset-bottom) + 150rpx) 30rpx; -} - -.fixedBox { - position: fixed; - z-index: 100; - 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 { - position: absolute; - width: 100vw; - top: 45vh; - display: flex; - flex-direction: column; - align-items: center; - - &-icon { - image { - width: 32rpx; - height: 32rpx; - } - } - - &-box { - margin-top: 24rpx; - width: 680rpx; - left: 35rpx; - height: 76rpx; - background-color: #45D4A8; - color: #fff; - line-height: 76rpx; - text-align: center; - font-size: 32rpx; - font-weight: 500; - border-radius: 8rpx 8rpx 8rpx 8rpx; - } - - } -} - - -.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 deleted file mode 100644 index ce221d6..0000000 --- a/src/pages/preview/illness/article/article.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import {FC, useEffect, useMemo, useState} from "react"; -import {Image, PageContainer, Text, View} from "@tarojs/components"; -import Taro, {useRouter} from "@tarojs/taro"; -import {ArticleRecord, brandApi} from "@/api"; -import styles from './article.module.scss' -import down from '@/static/img/doubleDown.png' -import {Profile} from "@/store"; -import {parse} from "@/utils/marked/marked"; -import {beforeTime} from "@/utils/time"; -import Img from "@/components/image/image"; -import catalogue from '@/static/img/catalogue.png' -import Collect from "@/components/collect/collect"; - -const article: FC = () => { - const {token} = Profile.useContainer() - const {id} = useRouter().params as unknown as { id: number } - const [show, setShow] = useState(false) - const [articleInfo, setArticleInfo] = useState() - const {children, headings} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) - const query = Taro.createSelectorQuery() - - useEffect(() => { - getData() - }, [id]) - - const getData = async () => { - Taro.setNavigationBarTitle({title: '疾病文章详情'}) - try { - const data = await brandApi.articleInfo(id) - Taro.setNavigationBarTitle({title: data.title}) - setArticleInfo(data) - } catch (e) { - } - } - - function mao(id: string) { - setShow(false) - Taro.nextTick(() => { - query.select(`#${id}`).boundingClientRect() - query.exec((res) => { - if (res.length) { - Taro.pageScrollTo({ - scrollTop: res[res.length - 1].top, - duration: 300 - } - ) - } - }) - }) - } - - function helloWorld() { - return ( - <> - setShow(true)}> - - - - - - 目录 - - - - - {articleInfo?.title} - { - articleInfo?.brands.map(d => - - - {d?.name} - - {beforeTime(articleInfo?.created_at)} . - 阅读 {articleInfo.page_view || 1} - - - ) - } - - {children} - - { - !token && - - - - - - Taro.navigateTo({url: '/pages/login/login'})}> - 登录查看更多内容 - - - - } - - setShow(false)} - show={show} - round - overlay - overlayStyle={'background:rgba(0,0,0,0.3)'}> - - {headings.length > 0 && headings.map((d) => mao(d.id)}> - {d.text} - - )} - - - - ) - } - - return helloWorld() -} -export default article diff --git a/src/pages/preview/illness/list/list.tsx b/src/pages/preview/illness/list/list.tsx index 877995b..7089638 100644 --- a/src/pages/preview/illness/list/list.tsx +++ b/src/pages/preview/illness/list/list.tsx @@ -34,7 +34,7 @@ const BrandList: FC = () => { }, [page]) function jump(id: number) { - Taro.navigateTo({url: '/pages/preview/illness/article/article?id=' + id}) + Taro.navigateTo({url: '/pages/preview/brand/article/article?id=' + id}) } diff --git a/src/pages/preview/search/search/components/list.tsx b/src/pages/preview/search/search/components/list.tsx index b2be759..791ba0b 100644 --- a/src/pages/preview/search/search/components/list.tsx +++ b/src/pages/preview/search/search/components/list.tsx @@ -71,7 +71,7 @@ const SearchList: FC = ({name, clear}) => { url = '/pages/preview/illness/list/list'; break; case 'article': - url = '/pages/preview/illness/article/article' + url = '/pages/preview/brand/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}`})