1.添加文章标题和创建时间

2.未登录情况下显示我的页面功能区应用
v2
xing 1 year ago
parent ae57654a46
commit 4d2b83b950
  1. 11
      src/components/learningRecord/learningRecord.tsx
  2. 6
      src/components/spinner/index.tsx
  3. 11
      src/pages/my/my.tsx
  4. 2
      src/pages/preview/brand/article/article.tsx
  5. 60
      src/pages/preview/illness/article/article.tsx

@ -6,6 +6,8 @@ import {FC, useEffect, useState} from "react";
import {StatisticsParam, userApi} from "@/api"; import {StatisticsParam, userApi} from "@/api";
import styles from './learningRecord.module.scss' 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";
const tabList: TabList<any>[] = [ const tabList: TabList<any>[] = [
{ {
@ -30,7 +32,7 @@ const tabList: TabList<any>[] = [
] ]
interface Props { interface Props {
userId: string | number userId?: string | number
} }
@ -40,9 +42,10 @@ interface Props {
const LearningRecord: FC<Props> = ({userId}) => { const LearningRecord: FC<Props> = ({userId}) => {
const [lineData, setLineData] = useState<any[]>([]) const [lineData, setLineData] = useState<any[]>([])
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const {token} = Profile.useContainer()
async function getStatistics(data: StatisticsParam) { async function getStatistics(data: StatisticsParam) {
if (!userId) return;
try { try {
setLoading(true) setLoading(true)
const res = await userApi.statistics(userId, data) const res = await userApi.statistics(userId, data)
@ -55,6 +58,10 @@ const LearningRecord: FC<Props> = ({userId}) => {
} }
function tabChange({tab}: OnChangOpt<StatisticsParam>) { function tabChange({tab}: OnChangOpt<StatisticsParam>) {
if (!token) {
Taro.navigateTo({url: '/pages/login/login'})
return
}
getStatistics(tab?.value! as StatisticsParam) getStatistics(tab?.value! as StatisticsParam)
} }

@ -138,9 +138,9 @@ export default class Spin extends Component<Props, State> {
this.setState((s) => ({...s, ...state})) this.setState((s) => ({...s, ...state}))
} }
// componentDidMount(): void { componentDidMount(): void {
// this.controller.setTick(this.props.enable) this.controller.setTick(this.props.enable)
// } }
componentDidUpdate(): void { componentDidUpdate(): void {
this.controller.setTick(this.props.enable) this.controller.setTick(this.props.enable)

@ -84,12 +84,11 @@ const My: FC = () => {
</View> </View>
<Time/> <Time/>
{ <View>
token && user && <View> <LearningRecord userId={user?.id}/>
<LearningRecord userId={user.id}/> <Service/>
<Service/> </View>
</View>
}
<PageContainer <PageContainer
overlayStyle={'background:rgba(0,0,0,0.3)'} overlayStyle={'background:rgba(0,0,0,0.3)'}
position='bottom' position='bottom'

@ -25,10 +25,8 @@ const article: FC = () => {
const query = Taro.createSelectorQuery() const query = Taro.createSelectorQuery()
query.select('#childrenNode').boundingClientRect((res) => { query.select('#childrenNode').boundingClientRect((res) => {
if (!Array.isArray(res)) { if (!Array.isArray(res)) {
if (res.height !== 240) {
console.log({childrenNode: res}) console.log({childrenNode: res})
setUltra(pageHeight * .45 <= res.height) setUltra(pageHeight * .45 <= res.height)
}
} }
}).exec() }).exec()
}, 300) }, 300)

@ -6,56 +6,64 @@ import styles from './article.module.scss'
import down from '@/static/img/doubleDown.png' import down from '@/static/img/doubleDown.png'
import {Profile} from "@/store"; import {Profile} from "@/store";
import {parse} from "@/utils/marked/marked"; import {parse} from "@/utils/marked/marked";
import {formatDate} from "@/utils/time";
const article:FC = () => { const article: FC = () => {
const {token} = Profile.useContainer() const {token} = Profile.useContainer()
const {id} = useRouter().params as unknown as { id: number} const {id} = useRouter().params as unknown as { id: number }
const [show,setShow] = useState(false) const [show, setShow] = useState(false)
const [articleInfo,setArticleInfo] = useState<ArticleRecord>() const [articleInfo, setArticleInfo] = useState<ArticleRecord>()
const { children, headings } = useMemo(() => parse(articleInfo?.content || ''), [articleInfo]) const {children, headings} = useMemo(() => parse(articleInfo?.content || ''), [articleInfo])
const query = Taro.createSelectorQuery() const query = Taro.createSelectorQuery()
useEffect(() => { useEffect(() => {
getData() getData()
}, [id]) }, [id])
const getData = async () => { const getData = async () => {
Taro.setNavigationBarTitle({title:'疾病文章详情'}) Taro.setNavigationBarTitle({title: '疾病文章详情'})
try { try {
const data = await brandApi.articleInfo(id) const data = await brandApi.articleInfo(id)
Taro.setNavigationBarTitle({title:data.title}) Taro.setNavigationBarTitle({title: data.title})
setArticleInfo(data) setArticleInfo(data)
} catch (e) { } catch (e) {
} }
} }
function mao(id: string){
function mao(id: string) {
console.log(id) console.log(id)
setShow(false) setShow(false)
Taro.nextTick(() => { Taro.nextTick(() => {
query.select(`#${id}`).boundingClientRect() query.select(`#${id}`).boundingClientRect()
query.exec((res) => { query.exec((res) => {
if(res.length){ if (res.length) {
Taro.pageScrollTo({ Taro.pageScrollTo({
scrollTop: res[res.length-1].top, scrollTop: res[res.length - 1].top,
duration: 300} duration: 300
}
) )
} }
}) })
}) })
} }
function helloWorld() { function helloWorld() {
return ( return (
<> <>
{/*<View style={{padding:'10px'}}>*/} <View className={styles.botmBox} style={{display: show ? 'none' : 'flex'}} onClick={() => setShow(true)}>
{/* { children }*/}
{/*</View>*/}
<View className={styles.botmBox} style={{display:show?'none':'flex'}} onClick={()=>{setShow(true)}}>
<View></View> <View></View>
</View> </View>
<View style={{padding:'10px',height:!token ? Taro.getWindowInfo().windowHeight-60+'px' : 'auto',overflow:!token ? 'hidden':'auto'}}> <View style={{
{ children } padding: '10px',
height: !token ? Taro.getWindowInfo().windowHeight - 60 + 'px' : 'auto',
overflow: !token ? 'hidden' : 'auto'
}}>
<View className='text-center'>
<View className='font-50 font-weight '>{articleInfo?.title}</View>
<View className='mt-2'>{formatDate(new Date(articleInfo?.created_at || 0), "YY-mm-dd hh:mm:dd")}</View>
</View>
<View></View>
{children}
</View> </View>
{ {
!token && !token &&
@ -64,18 +72,23 @@ const article:FC = () => {
<View className={styles['fixedBox-inner-icon']}> <View className={styles['fixedBox-inner-icon']}>
<Image src={down}></Image> <Image src={down}></Image>
</View> </View>
<View className={styles['fixedBox-inner-box']} onClick={ ()=> Taro.navigateTo({url: '/pages/login/login'})}> <View className={styles['fixedBox-inner-box']}
onClick={() => Taro.navigateTo({url: '/pages/login/login'})}>
<Text></Text> <Text></Text>
</View> </View>
</View> </View>
</View> </View>
} }
<PageContainer onClickOverlay={()=>{ setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0.3)'} > <PageContainer onClickOverlay={() => {
setShow(false)
}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0.3)'}>
<View className="px-3 py-5"> <View className="px-3 py-5">
{headings.length > 0 && {headings.length > 0 &&
headings.map((d) => headings.map((d) =>
<View className="pb-3" style={{fontSize:'28rpx',fontWeight: '500',color: '#323635'}} onClick={()=>{mao(d.id)}}>{d.text}</View> <View className="pb-3" style={{fontSize: '28rpx', fontWeight: '500', color: '#323635'}} onClick={() => {
mao(d.id)
}}>{d.text}</View>
) )
} }
</View> </View>
@ -84,6 +97,7 @@ const article:FC = () => {
</> </>
) )
} }
return helloWorld() return helloWorld()
} }
export default article export default article

Loading…
Cancel
Save