# Conflicts:
#	src/pages/preview/search/search/components/list.tsx
#	src/pages/preview/search/search/index.config.ts
#	src/pages/preview/search/search/index.module.scss
#	src/pages/preview/search/search/index.tsx
v2
一杯沧海 1 year ago
commit 29006f34f3
  1. 2
      src/api/brand.ts
  2. 1
      src/api/manage.ts
  3. 2
      src/app.scss
  4. 11
      src/components/learningRecord/learningRecord.tsx
  5. 25
      src/hooks/storageDep.ts
  6. 32
      src/pages/business/courType/courType.tsx
  7. 1
      src/pages/business/curHistory/curHistory.tsx
  8. 39
      src/pages/business/history/history.tsx
  9. 34
      src/pages/home/components/curRecommended.tsx
  10. 6
      src/pages/home/home.tsx
  11. 28
      src/pages/index/index.tsx
  12. 5
      src/pages/login/login.tsx
  13. 13
      src/pages/manage/courseAdmin/components/search.tsx
  14. 8
      src/pages/manage/courseAdmin/courseAdmin.module.scss
  15. 16
      src/pages/manage/courseAdmin/courseAdmin.tsx
  16. 1
      src/pages/manage/depAdmin/depAdmin.tsx
  17. 53
      src/pages/manage/selectDep/selectDep.tsx
  18. 3
      src/pages/manage/userInfo/userInfo.tsx
  19. 36
      src/pages/preview/brand/article/article.module.scss
  20. 32
      src/pages/preview/brand/article/article.tsx
  21. 13
      src/pages/preview/brand/info/info.tsx
  22. 26
      src/pages/preview/brand/list/list.tsx
  23. 2
      src/pages/preview/health/health.tsx
  24. 43
      src/pages/preview/illness/article/article.module.scss
  25. 22
      src/pages/preview/illness/article/article.tsx
  26. 17
      src/pages/preview/illness/list/list.tsx
  27. 1
      src/pages/preview/illness/sort/sort.module.scss
  28. 14
      src/pages/preview/illness/sort/sort.tsx
  29. 1
      src/pages/preview/profession/profession.tsx
  30. BIN
      src/static/img/del.png
  31. 18
      src/utils/time.tsx

@ -11,12 +11,14 @@ export type BrandRecord = {
introductory_video_resource: any introductory_video_resource: any
article_count: number article_count: number
created_at: string created_at: string
page_view:number
} }
export type ArticleRecord = { export type ArticleRecord = {
title: string title: string
page_view: number page_view: number
created_at: string created_at: string
content: string content: string
brands: BrandRecord[]
} }
export const brandApi = { export const brandApi = {

@ -46,7 +46,6 @@ export interface depCurProps {
interface AddCurProps { interface AddCurProps {
course_id: number[] course_id: number[]
dep_id: number[] dep_id: number[]
is_required: (1 | 0)[]
} }

@ -270,7 +270,7 @@
.text-hover-danger { color: #a71d2a;} .text-hover-danger { color: #a71d2a;}
.text-light { color: #f8f9fa;} .text-light { color: #f8f9fa;}
.text-hover-light { color: #cbd3da;} .text-hover-light { color: #cbd3da;}
.text-dark { color: #343a40;} .text-dark { color: #323635;}
.text-hover-dark{ color: #121416;} .text-hover-dark{ color: #121416;}
.text-body { color: #212529;} .text-body { color: #212529;}
.text-muted { color: #909795;} .text-muted { color: #909795;}

@ -5,7 +5,7 @@ import LineChart from "@/components/lineChart/lineChart";
import {CSSProperties, FC, useEffect, useState} from "react"; import {CSSProperties, 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 {Profile} from "@/store";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import debounce from "@/utils/debounce"; import debounce from "@/utils/debounce";
@ -44,20 +44,19 @@ interface Props {
*/ */
const LearningRecord: FC<Props> = ({userId, style, className}) => { const LearningRecord: FC<Props> = ({userId, style, className}) => {
const [lineData, setLineData] = useState<any[]>([]) const [lineData, setLineData] = useState<any[]>([])
const [loading, setLoading] = useState(false) // const [loading, setLoading] = useState(false)
const {token} = Profile.useContainer() const {token} = Profile.useContainer()
async function getStatistics(data: StatisticsParam) { async function getStatistics(data: StatisticsParam) {
if (!userId) return;
try { try {
setLoading(true) if (!userId) return;
setLineData([])
const res = await userApi.statistics(userId, data) const res = await userApi.statistics(userId, data)
const everyDayValue = everyDay(data.start_time, Number(data.end_time), res.data) const everyDayValue = everyDay(data.start_time, Number(data.end_time), res.data)
setLineData(everyDayValue) setLineData(everyDayValue)
} catch (e) { } catch (e) {
setLineData([]) setLineData([])
} }
setLoading(false)
} }
function tabChange({tab}: OnChangOpt<StatisticsParam>) { function tabChange({tab}: OnChangOpt<StatisticsParam>) {
@ -79,7 +78,7 @@ const LearningRecord: FC<Props> = ({userId, style, className}) => {
return (<View className={[styles.box, className].filter(Boolean).join(' ')} style={{display: 'block', ...style}}> return (<View className={[styles.box, className].filter(Boolean).join(' ')} style={{display: 'block', ...style}}>
<Tabs tabList={tabList} onChange={tabChange} backMode/> <Tabs tabList={tabList} onChange={tabChange} backMode/>
<View style={{position: "relative"}}> <View style={{position: "relative"}}>
<Spin enable={loading} block/> {/*<Spin enable={loading} block/>*/}
<View className={styles.total}> <View className={styles.total}>
<Text style={{margin: '0 10px', color: '#00D6AC'}}> <Text style={{margin: '0 10px', color: '#00D6AC'}}>

@ -1,14 +1,12 @@
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
const KET = 'SELECT_DEP' const KET = 'SELECT_DEP'
const KET_REQUIRED = 'SELECT_REQUIRED'
/** 部门 */ /** 部门 */
function set(data: number[]) { function set(data: number[]) {
Taro.setStorageSync(KET, data) Taro.setStorageSync(KET, data)
} }
function get(): number[] { function get(): number[] {
const deps = Taro.getStorageSync(KET) const deps = Taro.getStorageSync(KET)
if (deps && deps.length) { if (deps && deps.length) {
@ -23,28 +21,7 @@ function removeDeps() {
Taro.removeStorageSync(KET) 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() { function remove() {
removeRequired()
removeDeps() removeDeps()
} }
@ -52,6 +29,4 @@ export default {
set, set,
get, get,
remove, remove,
setRequired,
getRequired
} }

@ -57,17 +57,27 @@ const CourType: FC = () => {
}) })
return ( return (
<View className='py-2 flex justify-between flex-wrap '> <>
{data.length > 0 ? data.map(c => {
<VideoCover data.length > 0 ?
thumb={c.thumb} <>
title={c.title} <View className='py-2 flex justify-between flex-wrap'>
id={c.id} {
depId={c.id} data.map(c => <VideoCover
key={c.id} thumb={c.thumb}
time={formatMinute(c.course_duration)} title={c.title}
/>) : <Empty name='暂无数据'/>} id={c.id}
</View> depId={c.id}
key={c.id}
time={formatMinute(c.course_duration)}
/>)
}
</View>
<View className='text-center font-24 text-dark'></View>
</>
: <Empty name='暂无数据'/>
}
</>
) )
} }

@ -106,6 +106,7 @@ const CurHistory = () => {
/> />
</View>) </View>)
} }
<View className='text-center font-24 text-dark mt-3'></View>
</View> </View>
: <Empty name='暂无学习记录'/> : <Empty name='暂无学习记录'/>
} }

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

@ -1,12 +1,28 @@
import {FC, ReactNode, useEffect, useState} from "react"; import {FC, ReactNode, 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'
import {rfc33392time} from "@/utils/day";
import Img from "@/components/image/image"; 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
}
}
const CurRecommended: FC = () => { const CurRecommended: FC = () => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
@ -44,15 +60,15 @@ const CurRecommended: FC = () => {
<View className="mb-5"> <View className="mb-5">
<View className='text-center my-2'></View> <View className='text-center my-2'></View>
<View className='bg-white rounded-20 clip'> <View className='bg-white rounded-20 clip'>
{articles.map((d, i) => <View className='p-3 relative'> {articles.map((d, i) => <View className='p-3 relative' onClick={() => toArticlePage(d)}>
{i > 0 && <View className='absolute top left right divided ml-3 mr-3' />} {i > 0 && <View className='absolute top left right divided ml-3 mr-3'/>}
<View className="font-34 bold text-black">{d.title}</View> <View className="font-34 text-black">{d.title}</View>
{(d.intro || '').length > 40 && (<View className='flex mt-1'> {(d.intro || '').length > 40 && (<View className='flex mt-1'>
<View className="flex-1 font-24 lh1_5">{d.intro}</View> <View className="flex-1 font-24 lh1_5">{d.intro}</View>
{d.cover && <Img className='ml-l' width={140} height={100} src={d.cover} errorType="acquiesce" />} {d.cover && <Img className='ml-l' width={140} height={100} src={d.cover} errorType="acquiesce"/>}
</View>)} </View>)}
<View className="flex mt-3 justify-between font-24 text-muted"> <View className="flex mt-3 justify-between font-24 text-muted">
<View>{rfc33392time(d.created_at).split(' ')[0]}</View> <View>{beforeTime(d.created_at)}</View>
<View> {d.page_view || 0}</View> <View> {d.page_view || 0}</View>
</View> </View>
</View>)} </View>)}
@ -86,7 +102,7 @@ const CurRecommended: FC = () => {
<> <>
{examines} {examines}
{videos} {videos}
<View className='text-center text-muted font-28'>- -</View> <View className='text-center font-24 text-dark'></View>
</> </>
) )
} }

@ -1,4 +1,4 @@
import {FC, useEffect, useState} from "react"; import {FC, useState} from "react";
import {Image, View, Text} from "@tarojs/components"; import {Image, View, Text} from "@tarojs/components";
import styles from "./home.module.scss"; import styles from "./home.module.scss";
import Adware from "@/pages/home/components/adware"; import Adware from "@/pages/home/components/adware";
@ -27,14 +27,14 @@ const Home: FC = () => {
Taro.navigateTo({url: '/pages/login/login'}) Taro.navigateTo({url: '/pages/login/login'})
} }
useEffect(() => { Taro.useDidShow(() => {
HomeApi.home().then(res => { HomeApi.home().then(res => {
setData(res) setData(res)
}) })
setTimeout(() => { setTimeout(() => {
setEnable(false) setEnable(false)
}, 600) }, 600)
}, []) })
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) * 0.9).toFixed(6)

@ -5,7 +5,9 @@ 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, publicApi} 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"; import Spin from "@/components/spinner";
import Img from "@/components/image/image";
import {beforeTime} from "@/utils/time";
const category: TabList[] = [ const category: TabList[] = [
{title: "企选课程", value: 'is_required'}, {title: "企选课程", value: 'is_required'},
@ -37,26 +39,38 @@ const Index: FC = () => {
const AuditMode: FC = () => { const AuditMode: FC = () => {
const [auditMode, setAuditMode] = useState(false) const [auditMode, setAuditMode] = useState(false)
const [articles, setArticles] = useState<any[]>([]) const [articles, setArticles] = useState<any[]>([])
const [enable, setEnable] = useState(true)
useEffect(() => { useEffect(() => {
publicApi.course({page: 1, pageSize: 10}).then(res => { publicApi.course({page: 1, pageSize: 10}).then(res => {
setAuditMode(res.audit_mode) setAuditMode(res.audit_mode)
setArticles(res.articles) setArticles(res.articles)
// if(res.audit_mode){ setEnable(false)
// Taro.setTabBarItem({index: 1, text: '文章'})
// }
}) })
}, []) }, [])
return ( return (
<> <>
<Spin enable={enable} overlay/>
{ {
auditMode ? auditMode ?
<> <>
<NavigationBar text='文章' cancelBack/> <NavigationBar text='文章列表' cancelBack/>
<View className='p-2'> <View className='bg-white rounded-20 clip'>
{ {
articles.map(d => <View className='mb-2 p-2 bg-white'>{d.title}</View>) articles.map((d, i) => <View className='p-3 relative'>
{i > 0 && <View className='absolute top left right divided ml-3 mr-3'/>}
<View className="font-34 bold text-black">{d.title}</View>
{(d.intro || '').length > 40 && (<View className='flex mt-1'>
<View className="flex-1 font-24 lh1_5">{d.intro}</View>
{d.cover && <Img className='ml-l' width={140} height={100} src={d.cover} errorType="acquiesce"/>}
</View>)}
<View className="flex mt-3 justify-between font-24 text-muted">
<View>{beforeTime(d.created_at)}</View>
<View> {d.page_view || 0}</View>
</View>
</View>)
} }
</View> </View>
<View className='text-center font-24 text-dark mt-2'></View>
</> </>
: <Index/> : <Index/>
} }

@ -57,10 +57,8 @@ const Login: FC = () => {
setToken(token) setToken(token)
setCompany(company) setCompany(company)
setLoading(false) setLoading(false)
Taro.switchTab({url: '/pages/home/home'}) Taro.navigateBack()
} else { } else {
Taro.setStorageSync('openid', catch_key) Taro.setStorageSync('openid', catch_key)
Taro.reLaunch({url: '/pages/check/check'}) Taro.reLaunch({url: '/pages/check/check'})
} }
@ -98,7 +96,6 @@ const Login: FC = () => {
<View style={{flex: 1}}>{error}</View> <View style={{flex: 1}}>{error}</View>
<Icon name={'close'} onClick={() => setError(null)}/> <Icon name={'close'} onClick={() => setError(null)}/>
</View> : null} </View> : null}
{/*{process.env.TARO_APP_LGOIN === 'true' && <MyButton onClick={TESTLOGIN}>线下登录</MyButton>}*/} {/*{process.env.TARO_APP_LGOIN === 'true' && <MyButton onClick={TESTLOGIN}>线下登录</MyButton>}*/}
</View> </View>
) )

@ -17,6 +17,7 @@ export const Search: FC<Props> = ({param, setParam}) => {
const [show, setShow] = useState(false) const [show, setShow] = useState(false)
const [deps, setDeps] = useState<Manage[]>([]) const [deps, setDeps] = useState<Manage[]>([])
const [depId, setDepId] = useState<number>(param.dep_id) const [depId, setDepId] = useState<number>(param.dep_id)
const [title, setTitle] = useState(param.title)
async function getDepList() { async function getDepList() {
try { try {
@ -53,19 +54,21 @@ export const Search: FC<Props> = ({param, setParam}) => {
<> <>
<View className={styles.searchBox}> <View className={styles.searchBox}>
<View className={styles.searchInput}> <View className={styles.searchInput}>
<Icon name='search' size={18}/> <Icon name='search' size={18} color='#909795'/>
<Input <Input
adjustPosition={false} adjustPosition={false}
type='text' type='text'
confirmType='search' confirmType='search'
placeholder='搜索名称' placeholder='搜索课程名称'
className='ml-1 flex-1' className='ml-1 flex-1'
value={param.title} value={title}
onInput={(e) => setTitle(e.detail.value)}
onConfirm={(e) => setParam({ onConfirm={(e) => setParam({
...param, ...param,
title: e.detail.value, title: e.detail.value,
page: 1 page: 1
})}/> })}
/>
</View> </View>
<View onClick={() => setShow(true)}> <View onClick={() => setShow(true)}>
<Text></Text> <Text></Text>
@ -99,7 +102,7 @@ export const Search: FC<Props> = ({param, setParam}) => {
</View>) </View>)
} }
<View className='flex justify-around mt-2'> <View className='flex justify-around mt-2 align-center'>
<View onClick={() => setShow(false)}> <View onClick={() => setShow(false)}>
<MyButton type='default' fillet width={150}></MyButton> <MyButton type='default' fillet width={150}></MyButton>
</View> </View>

@ -3,6 +3,9 @@
padding: 24rpx 30rpx; padding: 24rpx 30rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
position: sticky;
top: 0;
border-bottom: 1px solid #F5F8F7;
} }
.searchInput { .searchInput {
@ -13,7 +16,6 @@
padding-left: 24rpx; padding-left: 24rpx;
background: #F5F8F7; background: #F5F8F7;
border-radius: 32rpx; border-radius: 32rpx;
color: #909795;
overflow: hidden; overflow: hidden;
} }
@ -65,7 +67,7 @@
} }
.curList { .curList {
padding-bottom: 100px; padding-bottom: calc(env(safe-area-inset-bottom) + 63rpx);
} }
.add { .add {
@ -83,4 +85,6 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 30rpx; padding: 30rpx;
align-items: center;
box-sizing: border-box;
} }

@ -124,13 +124,12 @@ const CourseAdmin: FC = () => {
Taro.useDidShow(useCallback(async () => { Taro.useDidShow(useCallback(async () => {
const dep_id = storageDep.get() 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 { try {
await ManageApi.addCur({course_id: curs, dep_id, is_required}) await ManageApi.addCur({course_id: curs, dep_id})
Taro.showToast({title: '修改成功'}) Taro.showToast({title: '修改成功'})
// deps 中没有 筛选条件中的depid 删除已选的课程 // deps 中没有 筛选条件中的depid 删除已选的课程
if (param.dep_id && dep_id.includes(param.dep_id)) { if (param.dep_id && dep_id.includes(param.dep_id)) {
@ -151,15 +150,15 @@ const CourseAdmin: FC = () => {
return ( return (
<View> <>
<Spin enable={enable} overlay/>
<Search param={param} setParam={setParam}/> <Search param={param} setParam={setParam}/>
<Spin enable={enable} overlay/>
<View className={styles.curList}> <View className={styles.curList}>
{ {
data?.map((d, index) => <View key={d.id} className={styles.curBox}> data?.map((d, index) => <View key={d.id} className={styles.curBox}>
<View className={styles.curTitle} onClick={() => addCurs(d.id)}> <View className={styles.curTitle} onClick={() => addCurs(d.id)}>
{batch && <Radio {batch && <Radio
color='#45D4A8'
checked={curs.includes(d.id)} checked={curs.includes(d.id)}
style={{marginTop: '30px'}} style={{marginTop: '30px'}}
onClick={() => addCurs(d.id)}/>} onClick={() => addCurs(d.id)}/>}
@ -172,6 +171,7 @@ const CourseAdmin: FC = () => {
</View> </View>
</View>) </View>)
} }
<View className='text-center font-24 text-dark mt-3'></View>
</View> </View>
<View className={styles.add}> <View className={styles.add}>
@ -182,13 +182,13 @@ const CourseAdmin: FC = () => {
} }
{ {
batch && <View className={styles.addBatch}> batch && <View className={styles.addBatch}>
<Radio onClick={all} checked={data.length === curs.length}> </Radio> <Radio onClick={all} checked={data.length === curs.length} color='#45D4A8'> </Radio>
<Text onClick={() => setBatch(false)}></Text> <Text onClick={() => setBatch(false)}></Text>
<MyButton size='mini' onClick={() => batchChangDep(curs)}>{curs.length}</MyButton> <MyButton size='mini' onClick={() => batchChangDep(curs)}>{curs.length}</MyButton>
</View> </View>
} }
</View> </View>
</View> </>
) )
} }

@ -158,6 +158,7 @@ const DepAdmin: FC = () => {
onClick={() => Taro.navigateTo({url: '/pages/manage/userInfo/userInfo?userId=' + d.id})} onClick={() => Taro.navigateTo({url: '/pages/manage/userInfo/userInfo?userId=' + d.id})}
content={['学员', '管理员', '超级管理员'][d.role_type]} content={['学员', '管理员', '超级管理员'][d.role_type]}
/>)} />)}
<View className='text-center font-24 text-dark mt-3'></View>
{!manages.length && !users.length && <Empty name='暂无数据'/>} {!manages.length && !users.length && <Empty name='暂无数据'/>}

@ -1,5 +1,5 @@
import React, {FC, useCallback, useEffect, useState} from "react"; 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 Taro from "@tarojs/taro";
import {curriculum} from "@/api"; import {curriculum} from "@/api";
import PopPut from "@/components/popPut/popPut"; import PopPut from "@/components/popPut/popPut";
@ -13,10 +13,9 @@ import Spin from "@/components/spinner";
* required * required
*/ */
const SelectDep: FC = () => { 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<number[]>([]) const [ids, setIds] = useState<number[]>([])
const [deps, setDeps] = useState<Manage[]>([]) const [deps, setDeps] = useState<Manage[]>([])
const [required, setRequired] = useState<number[]>([])
const [enable, setEnable] = useState(true) const [enable, setEnable] = useState(true)
useEffect(() => { useEffect(() => {
@ -25,7 +24,6 @@ const SelectDep: FC = () => {
}) })
setEnable(false) setEnable(false)
setIds(JSON.parse(params.depIds)) setIds(JSON.parse(params.depIds))
setRequired(JSON.parse(params.required || "[]"))
}, []) }, [])
const onChange = useCallback((id: number) => { const onChange = useCallback((id: number) => {
@ -35,51 +33,19 @@ const SelectDep: FC = () => {
...ids, ...ids,
id id
]) ])
if (params.required) {
setRequired([...required, 0])
}
} else { } else {
const oldIds: number[] = JSON.parse(JSON.stringify(ids)) const oldIds: number[] = JSON.parse(JSON.stringify(ids))
oldIds.splice(index, 1) oldIds.splice(index, 1)
setIds(oldIds) setIds(oldIds)
if (params.required) {
const oldRequired: number[] = JSON.parse(JSON.stringify(required))
oldRequired.splice(index, 1)
setRequired(oldRequired)
}
} }
}, [ids]) }, [ids])
function ok() { function ok() {
storageDep.set(ids) storageDep.set(ids)
storageDep.setRequired(required)
Taro.navigateBack({delta: 1}) 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 ( return (
<View className='px-2 bg-white'> <View className='px-2 bg-white'>
<Spin overlay enable={enable}/> <Spin overlay enable={enable}/>
@ -90,21 +56,10 @@ const SelectDep: FC = () => {
key={d.id} key={d.id}
title={d.name} title={d.name}
chevron chevron
leftImage={folder} leftImage={folder}/>
content={
params?.required ?
<View className='flex align-center'>
<Switch
color='#45d4a8'
onClick={() => event?.stopImmediatePropagation()}
checked={isRequired(d.id)}
onChange={(e) => requiredChange(d.id, e.detail.value)}/>
</View>
: null
}
/>
</View> </View>
</View>)} </View>)}
<View className='text-center font-24 text-dark mt-3'></View>
<View className={'my-3'}> <View className={'my-3'}>
<MyButton onClick={ok}></MyButton> <MyButton onClick={ok}></MyButton>

@ -58,7 +58,6 @@ const UserInfo: FC = () => {
useEffect(() => { useEffect(() => {
userApi.info(userId).then(res => { userApi.info(userId).then(res => {
setData(res) setData(res)
}) })
@ -76,7 +75,7 @@ const UserInfo: FC = () => {
<View className={styles.page}> <View className={styles.page}>
<Info data={data}/> <Info data={data}/>
<LearningRecord userId={userId}/> <LearningRecord userId={userId} style={{padding: '20px'}}/>
<View className='mt-2'> <View className='mt-2'>

@ -1,30 +1,33 @@
.fixedBox{ .fixedBox {
position: fixed; position: fixed;
z-index: 1000; z-index: 1000;
top:0; top: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1), rgba(255, 255, 255, 1)); background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1), rgba(255, 255, 255, 1));
&-inner{
&-inner {
position: absolute; position: absolute;
width: 100vw; width: 100vw;
top:45vh; top: 45vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
&-icon{
image{ &-icon {
image {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
} }
} }
&-box{
&-box {
margin-top: 24rpx; margin-top: 24rpx;
width: 680rpx; width: 680rpx;
left:35rpx; left: 35rpx;
height: 76rpx; height: 76rpx;
background-color: #45D4A8; background-color: #45D4A8;
color:#fff; color: #fff;
line-height: 76rpx; line-height: 76rpx;
text-align: center; text-align: center;
font-size: 32rpx; 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;
}

@ -2,12 +2,14 @@ import {FC, useCallback, useEffect, useMemo, useState} from "react";
import {Image, Text, View} from "@tarojs/components"; import {Image, Text, View} from "@tarojs/components";
import Taro, {useRouter} from "@tarojs/taro"; import Taro, {useRouter} from "@tarojs/taro";
import {ArticleRecord, brandApi} from "@/api"; 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 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 Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner"; import Spin from "@/components/spinner";
import {beforeTime} from "@/utils/time";
import Img from "@/components/image/image";
const article: FC = () => { const article: FC = () => {
@ -25,8 +27,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)) {
console.log({childrenNode: res}) console.log({childrenNode: res})
setUltra(pageHeight * .45 <= res.height) setUltra(pageHeight * .45 <= res.height)
} }
}).exec() }).exec()
}, 300) }, 300)
@ -59,8 +61,25 @@ const article: FC = () => {
overflow: !token ? 'hidden' : 'auto' overflow: !token ? 'hidden' : 'auto'
}}> }}>
<View id="childrenNode"> <View id="childrenNode">
<View className={styles.articleTitle}>{articleInfo?.title}</View>
{ {
children.length > 0 ? children : <Empty name='暂无数据'/> children.length > 0 ?
<View>
{
articleInfo?.brands.map(d => <View className={styles.article}>
<Img src={d.logo} width={80} height={80} className={styles.articleImag}/>
<View className='ml-2'>
<View>{d?.name}</View>
<View className='flex mt-1 text-muted font-24'>
<View className='mr-2'>{beforeTime(articleInfo?.created_at)} . </View>
<View> {articleInfo.page_view || 1}</View>
</View>
</View>
</View>)
}
{children}
</View>
: <Empty name='暂无数据'/>
} }
</View> </View>
</View> </View>
@ -71,9 +90,8 @@ const article: FC = () => {
<View className={styles['fixedBox-inner-icon']}> <View className={styles['fixedBox-inner-icon']}>
<Image src={down}/> <Image src={down}/>
</View> </View>
<View className={styles['fixedBox-inner-box']} onClick={() => { <View className={styles['fixedBox-inner-box']}
Taro.navigateTo({url: '/pages/login/login'}) onClick={() => Taro.navigateTo({url: '/pages/login/login'})}>
}}>
<Text></Text> <Text></Text>
</View> </View>
</View> </View>

@ -113,11 +113,9 @@ const BrandInfo: FC = () => {
</View> </View>
<View className={styles['bottom']}> <View className={styles['bottom']}>
{ {
articleList?.length ? articleList?.length ? <>{
articleList.map((i: any) => articleList.map((i: any) => <View className={styles.box}
<View className={styles.box} onClick={() => { onClick={() => Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${i.id}`})}>
Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${i.id}`})
}}>
<View className={styles.inner}> <View className={styles.inner}>
<View className={styles.leftBox}> <View className={styles.leftBox}>
<View className='font-weight mb-2 font-28 lh-40'>{i.title}</View> <View className='font-weight mb-2 font-28 lh-40'>{i.title}</View>
@ -127,8 +125,9 @@ const BrandInfo: FC = () => {
<Img width={172} height={128} src={i.cover}/> <Img width={172} height={128} src={i.cover}/>
</View> </View>
</View> </View>
</View> </View>)}
) <View className='text-center font-24 text-dark'></View>
</>
: <Empty name='空空如也'/> : <Empty name='空空如也'/>
} }
</View> </View>

@ -5,7 +5,7 @@ import Taro, {useReachBottom} from "@tarojs/taro";
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import Spinner from "@/components/spinner"; import Spinner from "@/components/spinner";
import Img from "@/components/image/image"; 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}) => { const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onClick}) => {
let media: ReactNode let media: ReactNode
@ -16,7 +16,7 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl
/> />
} else if (data.brand_album) { } else if (data.brand_album) {
media = <Img media = <Img
width={712} // width={712}
height={320} height={320}
src={data.brand_album.split(",")[0]} src={data.brand_album.split(",")[0]}
mode="aspectFill" mode="aspectFill"
@ -27,26 +27,32 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl
return ( return (
<View className="bg-white flex flex-column justify-stretch mb-2_4 rounded-10 clip"> <View className="bg-white flex flex-column justify-stretch mb-2_4 rounded-10 clip">
{media}
<View className="p-3" onClick={onClick}> <View className="p-3" onClick={onClick}>
<View className='font-weight mb-2 font-32 flex align-center'> <View className='mb-2 font-32 flex'>
<Img <Img
width={32} width={76}
height={32} height={76}
src={data.logo} src={data.logo}
mode='aspectFill' mode='aspectFill'
errorType='avatar'
className="rounded-10 clip" className="rounded-10 clip"
style={{background: '#ededed'}} style={{background: '#ededed'}}
/> />
<View className="ml-1 flex-1"> <View className="ml-2 flex-1">
<View className="text-row1 font-28">{data.name}</View> <View className="text-row1 font-28">{data.name}</View>
<View className='font-24 mt-1 text-dark'>{beforeTime(data.created_at)}·</View>
</View> </View>
</View> </View>
<View className="font-24 text-muted mb-4 text-row3" style={{lineHeight: 1.4}}>
<View>
{media}
</View>
<View className="font-24 text-muted mb-4 text-row3 mt-2" style={{lineHeight: 1.4}}>
{data.graphic_introduction} {data.graphic_introduction}
</View> </View>
<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 className="flex-1"></View> <View className="flex-1"></View>
<View>{data.article_count || 0}</View> <View>{data.article_count || 0}</View>
<View>{(Math.random() * 100).toFixed(0)}</View> <View>{(Math.random() * 100).toFixed(0)}</View>
@ -105,7 +111,7 @@ const BrandList: FC = () => {
content = ( content = (
<> <>
{brands.map(d => <BrandItem data={d} key={d.id} onClick={() => jumpInfo(d.id)}/>)} {brands.map(d => <BrandItem data={d} key={d.id} onClick={() => jumpInfo(d.id)}/>)}
<View style={{width: '710rpx', textAlign: 'center', color: '#999'}} className="font-28 mt-3">{text}</View> <View className='text-center font-24 text-dark mt-3'>{text}</View>
</> </>
) )
} else { } else {

@ -55,7 +55,7 @@ const Health: FC = () => {
</View> </View>
</View>)} </View>)}
</View> </View>
<View className="font-28 mt-3 text-center text-muted"></View> <View className='text-center font-24 text-dark mt-2'></View>
</> </>
: <Empty name='暂无数据'/> : <Empty name='暂无数据'/>
} }

@ -1,4 +1,4 @@
.botmBox{ .botmBox {
z-index: 99; z-index: 99;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
@ -10,7 +10,8 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background: #F5F8F7; background: #F5F8F7;
view{
view {
width: 560rpx; width: 560rpx;
height: 76rpx; height: 76rpx;
background: #45D4A8; background: #45D4A8;
@ -22,33 +23,37 @@
line-height: 76rpx; line-height: 76rpx;
} }
} }
.fixedBox{
.fixedBox {
position: fixed; position: fixed;
z-index: 100; z-index: 100;
top:0; top: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1), rgba(255, 255, 255, 1)); background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1), rgba(255, 255, 255, 1));
&-inner{
&-inner {
position: absolute; position: absolute;
width: 100vw; width: 100vw;
top:45vh; top: 45vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
&-icon{
image{ &-icon {
image {
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
} }
} }
&-box{
&-box {
margin-top: 24rpx; margin-top: 24rpx;
width: 680rpx; width: 680rpx;
left:35rpx; left: 35rpx;
height: 76rpx; height: 76rpx;
background-color: #45D4A8; background-color: #45D4A8;
color:#fff; color: #fff;
line-height: 76rpx; line-height: 76rpx;
text-align: center; text-align: center;
font-size: 32rpx; 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;
}

@ -6,7 +6,8 @@ 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"; import {beforeTime} from "@/utils/time";
import Img from "@/components/image/image";
const article: FC = () => { const article: FC = () => {
const {token} = Profile.useContainer() const {token} = Profile.useContainer()
@ -58,9 +59,20 @@ const article: FC = () => {
height: !token ? Taro.getWindowInfo().windowHeight - 60 + 'px' : 'auto', height: !token ? Taro.getWindowInfo().windowHeight - 60 + 'px' : 'auto',
overflow: !token ? 'hidden' : 'auto' overflow: !token ? 'hidden' : 'auto'
}}> }}>
<View className='text-center'> <View>
<View className='font-50 font-weight '>{articleInfo?.title}</View> <View className={styles.articleTitle}>{articleInfo?.title}</View>
<View className='mt-2'>{formatDate(new Date(articleInfo?.created_at || 0), "YY-mm-dd hh:mm:dd")}</View> {
articleInfo?.brands.map(d => <View className={styles.article}>
<Img src={d.logo} width={80} height={80} className={styles.articleImag} errorType="avatar"/>
<View className='ml-2'>
<View>{d?.name}</View>
<View className='flex mt-1 text-muted font-24'>
<View className='mr-2'>{beforeTime(articleInfo?.created_at)} . </View>
<View> {articleInfo.page_view || 1}</View>
</View>
</View>
</View>)
}
</View> </View>
<View></View> <View></View>
{children} {children}
@ -93,11 +105,9 @@ const article: FC = () => {
} }
</View> </View>
</PageContainer> </PageContainer>
</> </>
) )
} }
return helloWorld() return helloWorld()
} }
export default article export default article

@ -50,13 +50,16 @@ const BrandList: FC = () => {
<Spin enable={enable} overlay/> <Spin enable={enable} overlay/>
{ {
articles.length > 0 ? articles.length > 0 ?
<View className='bg-white'> <>
{ <View className='bg-white'>
articles.map((d, index) => <View key={d.id} className={styles.articles} onClick={() => jump(d.id)}> {
{index + 1} . {d.title} articles.map((d, index) => <View key={d.id} className={styles.articles} onClick={() => jump(d.id)}>
</View>) {index + 1} . {d.title}
} </View>)
</View> }
</View>
<View className='text-center font-24 text-dark mt-3'></View>
</>
: <Empty name='暂无文章'/> : <Empty name='暂无文章'/>
} }
</View> </View>

@ -58,6 +58,7 @@
font-family: PingFang SC-Bold, PingFang SC; font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold; font-weight: bold;
color: #323635; color: #323635;
position: relative;
} }
.list { .list {

@ -96,14 +96,14 @@ const Sort: FC = () => {
scrollY scrollY
className={styles.tree} className={styles.tree}
scrollWithAnimation> scrollWithAnimation>
<Spin enable={loading} block/>
{ {
loading ? <Spin enable={loading}/> : <> list.length ?
{ <>
list.length ? {list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>)}
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>) <View className='text-center font-24 text-dark mt-3'></View>
: <Empty name='暂无数据'/> </>
} : <Empty name='暂无数据'/>
</>
} }
</ScrollView> </ScrollView>
</View> </View>

@ -104,6 +104,7 @@ const Profession = () => {
</View> </View>
) )
} }
<View className='text-center font-24 text-dark mt-2'></View>
</ScrollView> </ScrollView>
) )
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

@ -147,3 +147,21 @@ export function everyDay(start_time: number, end_time: number, data: Record<numb
return [] return []
} }
} }
/** 时间前 */
export function beforeTime(time?: string): string {
const initiateTime = new Date(time || 0).getTime()
const today = Date.now()
const timeDifference = Math.floor((today - initiateTime) / 86400000)
if (timeDifference <= 0) {
return '今天'
} else if (timeDifference >= 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}天前`
}
}

Loading…
Cancel
Save