自定义首页头部

v2
king 1 year ago
parent bcbf3b8e41
commit d742560fb2
  1. 2
      src/components/image/image.tsx
  2. 5
      src/pages/business/history/history.module.scss
  3. 35
      src/pages/business/history/history.tsx
  4. 6
      src/pages/business/videoInfo/components/catalogue.tsx
  5. 2
      src/pages/home/home.config.ts
  6. 9
      src/pages/home/home.module.scss
  7. 8
      src/pages/home/home.tsx
  8. BIN
      src/static/img/logo.png

@ -38,7 +38,7 @@ const Img: FC<Props> = ({src, mode = 'aspectFill', width, height, fallback = sha
return (
<View
style={{width: `${width}rpx`, height: `${height}rpx`, backgroundColor: '#F8F8F8'}}
className={`${props.className} ${styles.imgBox}`}>
className={`${props?.className} ${styles.imgBox}`}>
{!isError &&
<View animation={animationData}>
<Image

@ -6,11 +6,6 @@
background: #fff;
}
.image {
width: 100%;
height: 100%;
display: block;
}
.thumb {
background: #ddd;

@ -1,10 +1,11 @@
import {Image, Text, View} from "@tarojs/components";
import {Text, View} from "@tarojs/components";
import styles from './history.module.scss'
import Taro from "@tarojs/taro";
import {useEffect, useState} from "react";
import {formatMinute} from "@/utils/time";
import Empty from "@/components/empty/empty";
import {userApi} from "@/api";
import Img from "@/components/image/image";
const History = () => {
const [data, setData] = useState<HourHistory[]>([])
@ -25,24 +26,22 @@ const History = () => {
}, [])
return (
<View>
<View className='mt-3'>
{data.length ? data.map((d, index) =>
<View key={index} className={styles.category} onClick={() => jump(d.userCourseRecord.course_id)}>
<View className={styles.thumb}>
<Image src={d.thumb} className={styles.image}/>
<View
className={styles.count}>{d.userCourseRecord.hour_count}/{d.userCourseRecord.finished_count}</View>
<View className='mt-3'>
{data.length ? data.map((d, index) =>
<View key={index} className={styles.category} onClick={() => jump(d.userCourseRecord.course_id)}>
<View className={styles.thumb}>
<Img src={d.thumb} className={styles.image} width={300} height={188}/>
<View
className={styles.count}>{d.userCourseRecord.hour_count}/{d.userCourseRecord.finished_count}</View>
</View>
<View className={styles.text}>
<View>{d.title}</View>
<View className={styles.describe}>
<Text className='mr-4'>{formatMinute(durations[d.id])}</Text>
<Text>{(d.userCourseRecord.finished_count / d.userCourseRecord.hour_count * 100).toFixed(0)}%</Text>
</View>
<View className={styles.text}>
<View>{d.title}</View>
<View className={styles.describe}>
<Text className='mr-4'>{formatMinute(durations[d.id])}</Text>
<Text>{(d.userCourseRecord.finished_count / d.userCourseRecord.hour_count * 100).toFixed(0)}%</Text>
</View>
</View>
</View>) : <Empty name='无观看记录'/>}
</View>
</View>
</View>) : <Empty name='无观看记录'/>}
</View>
)
}

@ -9,7 +9,7 @@ import MyButton from "@/components/button/MyButton";
import videoEvents from "@/hooks/videoEvents";
import curRecord from '@/static/img/curRecord.png'
import hourRecord from "@/static/img/hourRecord.png"
import {PageContainerInner} from "@/components/custom-page-container/custom-page-container";
import CustomPageContainer from "@/components/custom-page-container/custom-page-container";
interface Props {
data: CourseDepData | null
@ -181,7 +181,7 @@ const Catalogue: FC<Props> = ({data, setHors, id, playId}) => {
<View className='px-3' onClick={() => setShow(true)}>...</View>
</View>
<PageContainerInner
<CustomPageContainer
show={show}
position='bottom'
onClickOverlay={() => setShow(false)}>
@ -199,7 +199,7 @@ const Catalogue: FC<Props> = ({data, setHors, id, playId}) => {
</View>
<MyButton onClick={() => setShow(false)} type='default' fillet></MyButton>
</View>
</PageContainerInner>
</CustomPageContainer>
</>
);
}

@ -1,6 +1,6 @@
export default definePageConfig({
navigationBarTitleText: '康一诺',
// navigationStyle: 'custom',
navigationStyle: 'custom',
navigationBarBackgroundColor: '#92ecc5',
navigationBarTextStyle: 'white',
onReachBottomDistance: 50

@ -15,6 +15,15 @@
font-weight: 500;
}
.header{
}
.logo{
width: 80rpx;
height: 80rpx;
}
.content {
position: relative;

@ -1,5 +1,5 @@
import {FC, useState} from "react";
import {View} from "@tarojs/components";
import {Image, View} from "@tarojs/components";
import styles from "./home.module.scss";
import Adware from "@/pages/home/components/adware";
import Feature from "@/pages/home/components/feature";
@ -9,11 +9,14 @@ import MyButton from "@/components/button/MyButton";
import {Profile} from "@/store";
import Taro from "@tarojs/taro";
import {HomeApi, HomeData} from "@/api";
import logo from '@/static/img/logo.png'
const Home: FC = () => {
const globalData = Taro.getApp().globalData
const {token} = Profile.useContainer()
const [data, setData] = useState<null | HomeData>(null)
console.log(globalData)
function unLogin() {
Taro.removeStorageSync('profile')
@ -28,6 +31,9 @@ const Home: FC = () => {
return (
<View className={styles.content}>
<View className={styles.header} style={{padding: `${globalData.statusBarHeight}px 0 10px 0`}}>
<Image src={logo} className={styles.logo} mode='aspectFit'/>
</View>
<Adware data={data?.adverts || []} only_flag='routine_home_top_banner' width={710}/>
<Feature/>
<FeatureRecommended

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Loading…
Cancel
Save