添加审核

v2
king 1 year ago
parent fa81566f32
commit adc5d17a5d
  1. 4
      .env
  2. 8
      src/api/home.ts
  3. 13
      src/api/public.ts
  4. 1
      src/components/learningRecord/learningRecord.module.scss
  5. 14
      src/components/lineChart/lineChart.module.scss
  6. 17
      src/components/lineChart/lineChart.tsx
  7. 4
      src/components/navigationBar/navigationBar.tsx
  8. 25
      src/pages/home/components/curRecommended.tsx
  9. 2
      src/pages/home/components/feature_recommended.tsx
  10. 14
      src/pages/home/home.module.scss
  11. 4
      src/pages/index/components/videoList.tsx
  12. 37
      src/pages/index/index.tsx
  13. 10
      src/pages/my/my.tsx
  14. 4
      src/pages/preview/brand/list/list.tsx
  15. 13
      src/pages/preview/health/health.tsx
  16. 4
      src/utils/time.tsx
  17. 1
      types/home.d.ts

@ -1,5 +1,5 @@
#TARO_APP_API=https://yjx.dev.yaojiankang.top TARO_APP_API=https://yjx.dev.yaojiankang.top
TARO_APP_API=https://mooc.yaojiankang.top #TARO_APP_API=https://mooc.yaojiankang.top
#TARO_APP_API=https://shopfix.yaojiankang.top #TARO_APP_API=https://shopfix.yaojiankang.top
#TARO_APP_API=https://playedu.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top
TARO_APP_LGOIN=true TARO_APP_LGOIN=true

@ -41,12 +41,18 @@ export interface HomeData {
} }
} }
interface Course {
articles:any[]
audit_mode:boolean
course:{ data: Curriculum[], total: number }
}
export const HomeApi = { export const HomeApi = {
advert(only_flag: string) { advert(only_flag: string) {
return request<AdwareType[]>("/home/v1/advert/unique?only_flag=" + only_flag, "GET") return request<AdwareType[]>("/home/v1/advert/unique?only_flag=" + only_flag, "GET")
}, },
course(page: number, page_size: number) { course(page: number, page_size: number) {
return request<{ data: Curriculum[], total: number }>('/home/v1/course/course', "GET", {page, page_size}) return request<Course>('/home/v1/course/course', "GET", {page, page_size})
}, },
/** 健康管理 */ /** 健康管理 */
healthTop(count: number) { healthTop(count: number) {

@ -13,11 +13,14 @@ interface CategoryList {
categories: Record<number, Category[]> categories: Record<number, Category[]>
} }
export interface CoursesMode {
articles: any[]
audit_mode: boolean
course: Courses
}
export interface Courses { export interface Courses {
/** 已完成 */
// is_finished: Curriculum[]
/** 未完成 */
// is_not_finished: Curriculum[]
/** 选秀 */ /** 选秀 */
is_not_required: Curriculum[] is_not_required: Curriculum[]
/** 必修 */ /** 必修 */
@ -36,6 +39,6 @@ export const publicApi = {
}, },
/** 课程 */ /** 课程 */
course(data: { page: number, pageSize: number }) { course(data: { page: number, pageSize: number }) {
return request<Courses>('/api/v1/category/course/index', "GET", data) return request<CoursesMode>('/api/v1/category/course/index', "GET", data)
} }
} }

@ -1,7 +1,6 @@
.box { .box {
background: #fff; background: #fff;
border-radius: 20rpx; border-radius: 20rpx;
padding: 40rpx;
display: flex; display: flex;
align-items: center; align-items: center;
box-sizing: border-box; box-sizing: border-box;

@ -3,7 +3,7 @@
align-items: flex-end; align-items: flex-end;
justify-content: left; justify-content: left;
flex-wrap: nowrap; flex-wrap: nowrap;
height: 420px; height: 380px;
position: relative; position: relative;
} }
@ -13,12 +13,22 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
border-radius: 10rpx;
color: #00D6AC; color: #00D6AC;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background: rgba(#fff, .9); background: rgba(#fff, .9);
view{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
}
} }
.records { .records {

@ -1,7 +1,8 @@
import {ScrollView, Text, View} from "@tarojs/components"; import {Image, ScrollView, Text, View} from "@tarojs/components";
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import style from './lineChart.module.scss' import style from './lineChart.module.scss'
import {formatDateTime, formatTime} from "@/utils/time"; import {formatDateTime, formatTime} from "@/utils/time";
import emptyLineChart from '@/static/img/emptyLineChart.png'
export interface lineData { export interface lineData {
time: string time: string
@ -12,7 +13,7 @@ interface Props {
data: lineData[] data: lineData[]
} }
const height = 180 const height = 150
const LineChart: FC<Props> = ({data}) => { const LineChart: FC<Props> = ({data}) => {
const [maxHeight, setMaxHeight] = useState<lineData>({time: '', value: 0}) const [maxHeight, setMaxHeight] = useState<lineData>({time: '', value: 0})
const [lineChartList, setLineChartList] = useState(data) const [lineChartList, setLineChartList] = useState(data)
@ -31,17 +32,21 @@ const LineChart: FC<Props> = ({data}) => {
<> <>
<View className={style.records}> <View className={style.records}>
<Text>{formatDateTime(new Date(maxHeight.time), 'MM月dd日')}</Text> <Text>{formatDateTime(new Date(maxHeight.time), 'MM月dd日')}</Text>
{maxHeight.value > 0 ? `日最努力` : `期间没有学习记录`}{formatTime(maxHeight.value)} {maxHeight.value > 0 ? `日最努力` : `期间没有学习记录`}{formatTime(maxHeight.value, 0)}
</View> </View>
<ScrollView scrollX={!!maxHeight.value} enhanced showScrollbar={false}> <ScrollView scrollX={!!maxHeight.value} enhanced showScrollbar={false}>
<View className={style.lineChart}> <View className={style.lineChart}>
{!maxHeight.value && <View className={style.empty}></View>} {
!maxHeight.value && <View className={style.empty}>
<View></View>
<Image src={emptyLineChart} mode='widthFix' style={{width: '100%'}}/>
</View>
}
{ {
!!maxHeight.value !!maxHeight.value
&& lineChartList.map(d => <View key={d.time}> && lineChartList.map(d => <View key={d.time}>
<View className={style.columnBox} style={{width: "100px"}}> <View className={style.columnBox} style={{width: "100px"}}>
<View className={style.line} <View className={style.line} style={{height: height - 10 - (d.value / maxHeight.value * height) + "px"}}/>
style={{height: height - 10 - (d.value / maxHeight.value * height) + "px"}}></View>
{ {
d.value > 0 && <View style={{whiteSpace: "nowrap"}}>{formatTime(d.value, 0)}</View> d.value > 0 && <View style={{whiteSpace: "nowrap"}}>{formatTime(d.value, 0)}</View>
} }

@ -1,5 +1,5 @@
import {Image, View} from "@tarojs/components"; import {Image, View} from "@tarojs/components";
import React, {FC, ReactNode, useMemo} from "react"; import React, {CSSProperties, FC, ReactNode, useMemo} from "react";
import styles from './navigationBar.module.scss' import styles from './navigationBar.module.scss'
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import leftArrow from '@/static/img/leftArrow.png' import leftArrow from '@/static/img/leftArrow.png'
@ -19,6 +19,7 @@ interface Props {
// 跟随页面滚动 // 跟随页面滚动
inherit?: boolean inherit?: boolean
className?: string className?: string
style?: CSSProperties
} }
const NavigationBar: FC<Props> = (props) => { const NavigationBar: FC<Props> = (props) => {
@ -29,6 +30,7 @@ const NavigationBar: FC<Props> = (props) => {
paddingTop: globalData.statusBarHeight + 'px', paddingTop: globalData.statusBarHeight + 'px',
height: globalData.textBarHeight + globalData.statusBarHeight + 'px', height: globalData.textBarHeight + globalData.statusBarHeight + 'px',
boxSizing: 'border-box', boxSizing: 'border-box',
...props.style
}), [props]) }), [props])

@ -1,7 +1,7 @@
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import {Image, View} from "@tarojs/components"; import {Image, View} from "@tarojs/components";
import {HomeApi} from "@/api"; import {HomeApi} from "@/api";
import {useReachBottom} from "@tarojs/taro"; import Taro, {useReachBottom} from "@tarojs/taro";
import styles from "../home.module.scss"; import styles from "../home.module.scss";
import VideoCover from "@/components/videoCover/videoCover"; import VideoCover from "@/components/videoCover/videoCover";
import courseTag from '@/static/img/courseTag.png' import courseTag from '@/static/img/courseTag.png'
@ -10,11 +10,19 @@ const CurRecommended: FC = () => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [data, setData] = useState<Curriculum[]>([]) const [data, setData] = useState<Curriculum[]>([])
const [total, setTotal] = useState(0) const [total, setTotal] = useState(0)
const [examine, setExamine] = useState(false)
const [articles, setArticles] = useState<any[]>([])
async function getData() { async function getData() {
const res = await HomeApi.course(page, 4) const res = await HomeApi.course(page, 4)
setTotal(res.total) if (res.audit_mode) {
const newData = res.data.reduce((pre, cut) => { Taro.setTabBarItem({index: 1, text: '文章'})
setArticles(res.articles)
setExamine(res.audit_mode)
return
}
setTotal(res.course.total)
const newData = res.course.data.reduce((pre, cut) => {
const index = pre.findIndex(d => d.id === cut.id) const index = pre.findIndex(d => d.id === cut.id)
if (index === -1) { if (index === -1) {
pre.push(cut) pre.push(cut)
@ -37,7 +45,14 @@ const CurRecommended: FC = () => {
return ( return (
<> <>
{ {
data.length > 0 && <View> examine ?
<>
<View className='text-center my-2'></View>
{
articles.map(d => <View className='bg-white p-2 mb-2'>{d.title}</View>)
}
</>
: data.length > 0 && <View>
<Image src={courseTag} mode='widthFix' className={styles.courseTag}/> <Image src={courseTag} mode='widthFix' className={styles.courseTag}/>
<View className={'pb-2 flex justify-between flex-wrap ' + styles.videoListBox}> <View className={'pb-2 flex justify-between flex-wrap ' + styles.videoListBox}>
{ {
@ -53,7 +68,7 @@ const CurRecommended: FC = () => {
</View> </View>
</View> </View>
} }
<View className='text-center text-muted pb-3 font-28'>- -</View> <View className='text-center text-muted font-28'>- -</View>
</> </>
) )
} }

@ -153,7 +153,7 @@ const FeatureRecommended: FC<Props> = (props) => {
<View className={styles.feature}> <View className={styles.feature}>
<Swiper nextMargin='30px' style={{height: '390rpx'}} circular autoplay> <Swiper nextMargin='30px' style={{height: '390rpx'}} circular autoplay>
{ {
data.map(d => <SwiperItem key={d.url}> data.filter(d=>d.data.length === 3).map(d => <SwiperItem key={d.url}>
<Image <Image
mode='heightFix' mode='heightFix'
className={styles.featureTitle} className={styles.featureTitle}

@ -23,20 +23,6 @@
margin-bottom: 20rpx; margin-bottom: 20rpx;
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
//&:after {
// min-height: 100vh;
// position: absolute;
// top: 0;
// left: 0;
// width: 100%;
// content: '';
// display: block;
// background: linear-gradient(to right, #DBF3F5, #B9ECD7, #C1EEDA) no-repeat;
// min-height: 100vh;
// background-size: 100% 600rpx;
// z-index: -1;
//}
} }
.headerDivider { .headerDivider {

@ -43,8 +43,8 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => {
const res = await publicApi.course({page: page, pageSize: 10}) const res = await publicApi.course({page: page, pageSize: 10})
const old: Courses = JSON.parse(JSON.stringify(data)) const old: Courses = JSON.parse(JSON.stringify(data))
setData({ setData({
is_required: screen(old.is_required, res.is_required || []), is_required: screen(old.is_required, res.course.is_required || []),
is_not_required: screen(old.is_not_required, res.is_not_required || []), is_not_required: screen(old.is_not_required, res.course.is_not_required || []),
}) })
} catch (e) { } catch (e) {
} }

@ -1,10 +1,11 @@
import {FC, useState} from "react"; import {FC, useEffect, useState} from "react";
import {View} from "@tarojs/components"; import {View} from "@tarojs/components";
import styles from './index.module.scss' import styles from './index.module.scss'
import {VideoList} from "@/pages/index/components/videoList"; import {VideoList} from "@/pages/index/components/videoList";
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs";
import {CoursesKey} from "@/api/public"; import {CoursesKey, publicApi} from "@/api/public";
import NavigationBar from "@/components/navigationBar/navigationBar"; import NavigationBar from "@/components/navigationBar/navigationBar";
import Taro from "@tarojs/taro";
const category: TabList[] = [ const category: TabList[] = [
{title: "企选课程", value: 'is_required'}, {title: "企选课程", value: 'is_required'},
@ -33,4 +34,34 @@ const Index: FC = () => {
) )
} }
export default Index const AuditMode: FC = () => {
const [auditMode, setAuditMode] = useState(false)
const [articles, setArticles] = useState<any[]>([])
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: '文章'})
}
})
}, [])
return (
<>
{
auditMode ?
<>
<NavigationBar text='文章' cancelBack/>
<View className='p-2'>
{
articles.map(d => <View className='mb-2 p-2 bg-white'>{d.title}</View>)
}
</View>
</>
: <Index/>
}
</>
)
}
export default AuditMode

@ -39,8 +39,6 @@ const My: FC = () => {
const [navbarOpacity, setNavbarOpacity] = useState('0') const [navbarOpacity, setNavbarOpacity] = useState('0')
const navbarHeight = globalData.statusBarHeight + globalData.textBarHeight; const navbarHeight = globalData.statusBarHeight + globalData.textBarHeight;
console.log(globalData)
Taro.useDidShow(() => { Taro.useDidShow(() => {
token && userApi.companyList().then(res => { token && userApi.companyList().then(res => {
setCompanyList(res as Company[]) setCompanyList(res as Company[])
@ -48,7 +46,7 @@ const My: FC = () => {
}) })
Taro.usePageScroll((e) => { Taro.usePageScroll((e) => {
const v = (Math.min(e.scrollTop / navbarHeight, 1) * 0.9).toFixed(6) const v = (Math.min(e.scrollTop / navbarHeight, 1)).toFixed(6)
if (v != navbarOpacity) { if (v != navbarOpacity) {
setNavbarOpacity(v) setNavbarOpacity(v)
} }
@ -73,8 +71,9 @@ const My: FC = () => {
return ( return (
<View> <View>
<NavigationBar <NavigationBar
style={{opacity: navbarOpacity}}
className={styles.navbar} className={styles.navbar}
backgroundColor={`rgba(255,255,255,${navbarOpacity})`} backgroundColor={`rgba(255,255,255,${Number(navbarOpacity) * .9})`}
cancelBack cancelBack
leftNode={ leftNode={
<View className={styles.navigation} <View className={styles.navigation}
@ -83,8 +82,7 @@ const My: FC = () => {
errorType='avatar'/> errorType='avatar'/>
<Text className='pl-2'>{token ? user?.name : '请登录'}</Text> <Text className='pl-2'>{token ? user?.name : '请登录'}</Text>
</View> </View>
} }/>
/>
<View className={styles.bg}/> <View className={styles.bg}/>

@ -48,7 +48,7 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl
<View className="flex gap20rpx font-24 text-muted"> <View className="flex gap20rpx font-24 text-muted">
<View>{formatDate(new Date(data.created_at), "YY-MM-dd hh:mm:ss")}</View> <View>{formatDate(new Date(data.created_at), "YY-MM-dd hh:mm:ss")}</View>
<View className="flex-1"></View> <View className="flex-1"></View>
<View>{data.article_count}</View> <View>{data.article_count || 0}</View>
<View>{(Math.random() * 100).toFixed(0)}</View> <View>{(Math.random() * 100).toFixed(0)}</View>
</View> </View>
</View> </View>
@ -72,7 +72,7 @@ const BrandList: FC = () => {
const res = await brandApi.list(page, 10) const res = await brandApi.list(page, 10)
if (page === 1) { if (page === 1) {
if (res.list.length < 10) { if (res.list.length < 10) {
setText('没有更多了~') setText('- 暂无更多 -')
} else { } else {
setText('上拉加载更多~') setText('上拉加载更多~')
} }

@ -1,12 +1,13 @@
import {FC, useEffect, useState} from "react"; import {FC, useEffect, useState} from "react";
import {Image, View} from "@tarojs/components"; import {Image, Text, View} from "@tarojs/components";
import {HomeApi} from "@/api"; import {HomeApi} from "@/api";
import Taro, {useReachBottom} from "@tarojs/taro"; import Taro, {useReachBottom} from "@tarojs/taro";
import styles from './health.module.scss' import styles from './health.module.scss'
import play from '@/static/img/play.png' import play from '@/static/img/play-back.png'
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner"; import Spin from "@/components/spinner";
import Img from "@/components/image/image"; import Img from "@/components/image/image";
import {formatDate} from "@/utils/time";
const Health: FC = () => { const Health: FC = () => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
@ -42,14 +43,16 @@ const Health: FC = () => {
<Spin enable={enable} overlay/> <Spin enable={enable} overlay/>
<View> <View>
{ {
data.length > 0 data.length > 0 ? <>
? <>
<View className={styles.container}> <View className={styles.container}>
{data.map(d => <View key={d.id} className={styles.health} onClick={() => jump(d)}> {data.map(d => <View key={d.id} className={styles.health} onClick={() => jump(d)}>
<Img width={370} height={345} src={d.url_path} mode='widthFix'/> <Img width={370} height={345} src={d.url_path} mode='widthFix'/>
<Image src={play} className={styles.play} mode='aspectFit'/> <Image src={play} className={styles.play} mode='aspectFit'/>
<View className='text-ellipsis-2 m-2 text-dark'>{d.title}</View> <View className='text-ellipsis-2 m-2 text-dark'>{d.title}</View>
<View className='font-26 text-muted mx-2 mb-2'>{d.video_view}</View> <View className='font-26 text-muted mx-2 mb-2 flex justify-between'>
<Text>{formatDate(new Date(d.publish_time), "YY-MM-dd")}</Text>
<Text>{d.video_view}</Text>
</View>
</View>)} </View>)}
</View> </View>
<View className="font-28 mt-3 text-center text-muted"></View> <View className="font-28 mt-3 text-center text-muted"></View>

@ -33,12 +33,12 @@ export function formatTime(time: number, padding = 10): JSX.Element {
</>) </>)
} else if (time >= 60 && time < 3600) { } else if (time >= 60 && time < 3600) {
return (<> return (<>
{(time / 60).toFixed(2)} {(time / 60).toFixed(1)}
<Text style={{color: '#000', paddingLeft: `${padding}px`}}></Text> <Text style={{color: '#000', paddingLeft: `${padding}px`}}></Text>
</>) </>)
} else if (time >= 3600) { } else if (time >= 3600) {
return (<> return (<>
{(time / 3600).toFixed(2)} {(time / 3600).toFixed(1)}
<Text style={{color: '#000', paddingLeft: `${padding}px`}}></Text> <Text style={{color: '#000', paddingLeft: `${padding}px`}}></Text>
</>) </>)
} }

1
types/home.d.ts vendored

@ -6,6 +6,7 @@ interface Health {
resource: Resource resource: Resource
/** 播放量 */ /** 播放量 */
video_view: number video_view: number
publish_time:string
} }
interface Brand { interface Brand {

Loading…
Cancel
Save