Compare commits

...

4 Commits

  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. 16
      src/pages/business/courType/courType.tsx
  7. 1
      src/pages/business/curHistory/curHistory.tsx
  8. 13
      src/pages/business/history/history.tsx
  9. 30
      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. 18
      src/pages/preview/brand/article/article.module.scss
  20. 28
      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. 21
      src/pages/preview/illness/article/article.module.scss
  25. 22
      src/pages/preview/illness/article/article.tsx
  26. 3
      src/pages/preview/illness/list/list.tsx
  27. 1
      src/pages/preview/illness/sort/sort.module.scss
  28. 10
      src/pages/preview/illness/sort/sort.tsx
  29. 1
      src/pages/preview/profession/profession.tsx
  30. 20
      src/pages/preview/search/search/components/list.tsx
  31. 3
      src/pages/preview/search/search/index.config.ts
  32. 26
      src/pages/preview/search/search/index.module.scss
  33. 78
      src/pages/preview/search/search/index.tsx
  34. BIN
      src/static/img/del.png
  35. 18
      src/utils/time.tsx

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

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

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

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

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

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

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

@ -1,7 +1,7 @@
import {Text, View} from "@tarojs/components";
import styles from './history.module.scss'
import Taro from "@tarojs/taro";
import {useEffect, useState} from "react";
import React, {useEffect, useState} from "react";
import {formatMinute} from "@/utils/time";
import Empty from "@/components/empty/empty";
import {userApi} from "@/api";
@ -27,7 +27,9 @@ const History = () => {
return (
<View className='mt-3'>
{data.length ? data.map((d, index) =>
{
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}/>
@ -41,7 +43,12 @@ const History = () => {
<Text>{(d.userCourseRecord.finished_count / d.userCourseRecord.hour_count * 100).toFixed(0)}%</Text>
</View>
</View>
</View>) : <Empty name='无观看记录'/>}
</View>)
}
<View className='text-center font-24 text-dark mt-3'></View>
</>
: <Empty name='无观看记录'/>
}
</View>
)
}

@ -1,12 +1,28 @@
import {FC, ReactNode, useEffect, useState} from "react";
import {Image, View} from "@tarojs/components";
import {HomeApi} from "@/api";
import {useReachBottom} from "@tarojs/taro";
import Taro, {useReachBottom} from "@tarojs/taro";
import styles from "../home.module.scss";
import VideoCover from "@/components/videoCover/videoCover";
import courseTag from '@/static/img/courseTag.png'
import {rfc33392time} from "@/utils/day";
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 [page, setPage] = useState(1)
@ -44,15 +60,15 @@ const CurRecommended: FC = () => {
<View className="mb-5">
<View className='text-center my-2'></View>
<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'/>}
<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'>
<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"/>}
</View>)}
<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>
</View>)}
@ -86,7 +102,7 @@ const CurRecommended: FC = () => {
<>
{examines}
{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 styles from "./home.module.scss";
import Adware from "@/pages/home/components/adware";
@ -27,14 +27,14 @@ const Home: FC = () => {
Taro.navigateTo({url: '/pages/login/login'})
}
useEffect(() => {
Taro.useDidShow(() => {
HomeApi.home().then(res => {
setData(res)
})
setTimeout(() => {
setEnable(false)
}, 600)
}, [])
})
Taro.usePageScroll((e) => {
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 {CoursesKey, publicApi} from "@/api/public";
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[] = [
{title: "企选课程", value: 'is_required'},
@ -37,26 +39,38 @@ const Index: FC = () => {
const AuditMode: FC = () => {
const [auditMode, setAuditMode] = useState(false)
const [articles, setArticles] = useState<any[]>([])
const [enable, setEnable] = useState(true)
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: '文章'})
// }
setEnable(false)
})
}, [])
return (
<>
<Spin enable={enable} overlay/>
{
auditMode ?
<>
<NavigationBar text='文章' cancelBack/>
<View className='p-2'>
<NavigationBar text='文章列表' cancelBack/>
<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 className='text-center font-24 text-dark mt-2'></View>
</>
: <Index/>
}

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

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

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

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

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

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

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

@ -5,6 +5,7 @@
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;
@ -12,12 +13,14 @@
display: flex;
flex-direction: column;
align-items: center;
&-icon {
image {
width: 32rpx;
height: 32rpx;
}
}
&-box {
margin-top: 24rpx;
width: 680rpx;
@ -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 Taro, {useRouter} from "@tarojs/taro";
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 {Profile} from "@/store";
import {parse} from "@/utils/marked/marked";
import Empty from "@/components/empty/empty";
import Spin from "@/components/spinner";
import {beforeTime} from "@/utils/time";
import Img from "@/components/image/image";
const article: FC = () => {
@ -59,8 +61,25 @@ const article: FC = () => {
overflow: !token ? 'hidden' : 'auto'
}}>
<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>
@ -71,9 +90,8 @@ const article: FC = () => {
<View className={styles['fixedBox-inner-icon']}>
<Image src={down}/>
</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>
</View>
</View>

@ -113,11 +113,9 @@ const BrandInfo: FC = () => {
</View>
<View className={styles['bottom']}>
{
articleList?.length ?
articleList.map((i: any) =>
<View className={styles.box} onClick={() => {
Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${i.id}`})
}}>
articleList?.length ? <>{
articleList.map((i: any) => <View className={styles.box}
onClick={() => Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${i.id}`})}>
<View className={styles.inner}>
<View className={styles.leftBox}>
<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}/>
</View>
</View>
</View>
)
</View>)}
<View className='text-center font-24 text-dark'></View>
</>
: <Empty name='空空如也'/>
}
</View>

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

@ -55,7 +55,7 @@ const Health: FC = () => {
</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='暂无数据'/>
}

@ -10,6 +10,7 @@
justify-content: center;
align-items: center;
background: #F5F8F7;
view {
width: 560rpx;
height: 76rpx;
@ -22,6 +23,7 @@
line-height: 76rpx;
}
}
.fixedBox {
position: fixed;
z-index: 100;
@ -29,6 +31,7 @@
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;
@ -36,12 +39,14 @@
display: flex;
flex-direction: column;
align-items: center;
&-icon {
image {
width: 32rpx;
height: 32rpx;
}
}
&-box {
margin-top: 24rpx;
width: 680rpx;
@ -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 {Profile} from "@/store";
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 {token} = Profile.useContainer()
@ -58,9 +59,20 @@ const article: FC = () => {
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 className={styles.articleTitle}>{articleInfo?.title}</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>
{children}
@ -93,11 +105,9 @@ const article: FC = () => {
}
</View>
</PageContainer>
</>
)
}
return helloWorld()
}
export default article

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

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

@ -96,14 +96,14 @@ const Sort: FC = () => {
scrollY
className={styles.tree}
scrollWithAnimation>
{
loading ? <Spin enable={loading}/> : <>
<Spin enable={loading} block/>
{
list.length ?
list.map(d => <View className={styles.list} onClick={() => jump(d.id)}>{d.name}</View>)
: <Empty name='暂无数据'/>
}
<>
{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='暂无数据'/>
}
</ScrollView>
</View>

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

@ -14,7 +14,6 @@ type Props = {
clear: boolean
}
const SearchList: FC<Props> = ({name, clear}) => {
console.log(name,'name')
const globalData = Taro.getApp().globalData
const [page, setPage] = useState(1)
const [brands, setBrands] = useState<any[]>([])
@ -97,7 +96,7 @@ const SearchList: FC<Props> = ({name,clear}) => {
className='scrollview'
scrollY
scrollWithAnimation
style={{height:`${globalData.windowHeight-60}px`,backgroundColor:`#f5f5f5`}}
style={{height: `${globalData.pageHeight - 20}px`, backgroundColor: `#f5f5f5`}}
onScrollToLower={onScrollToLower}
>
{loading && <AtLoadMore status={'loading'}/>}
@ -105,7 +104,8 @@ const SearchList: FC<Props> = ({name,clear}) => {
brands.length >= 1 && !loading &&
<>
{brands.map((d) =>
<View onClick={() => jumpInfo(d.data.id,d.data.table,d.data['@data'])} className={styles.box} key={d.data.id}>
<View onClick={() => jumpInfo(d.data.id, d.data.table, d.data['@data'])} className={styles.box}
key={d.data.id}>
{
d.data.table === 'brand' &&
<>
@ -121,7 +121,8 @@ const SearchList: FC<Props> = ({name,clear}) => {
<>
<View className={styles.articleLeftBox}>
<View className='font-weight mb-2 font-28 lh-40'>{d.data['@data'].title}</View>
<View className={styles.desc}>{rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}</View>
<View
className={styles.desc}>{rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}</View>
</View>
<Img width={172} height={128} src={d.data['@data'].logo} mode='aspectFill' className={styles.image}/>
</>
@ -129,7 +130,8 @@ const SearchList: FC<Props> = ({name,clear}) => {
{
d.data.table === 'video_records' &&
<>
<Img width={192} height={192} src={d.data['@data'].url_path} mode='aspectFill' className={styles.image}/>
<Img width={192} height={192} src={d.data['@data'].url_path} mode='aspectFill'
className={styles.image}/>
<Image src={play} className={styles.play} mode='aspectFit'/>
<View className={styles.videoRightBox}>
<View className='font-weight mb-2 font-28 lh-40'>{d.data['@data'].title}</View>
@ -144,18 +146,18 @@ const SearchList: FC<Props> = ({name,clear}) => {
<Img width={192} height={138} src={d.data['@data'].thumb} mode='aspectFill' className={styles.image}/>
<View className={styles.articleLeftBox}>
<View className='font-weight mb-2 font-28 lh-40'>{d.data['@data'].title}</View>
<View className={styles.desc}>:{d.data['@data'].class_hour} {d.data['@data'].charge}</View>
<View className={styles.desc}>:{d.data['@data'].class_hour}
{d.data['@data'].charge}</View>
</View>
</>
}
</View>
)
}
<View style={{width: '750rpx', textAlign: 'center', color: '#999'}} className="font-28 mt-3 mb-3">{text}</View>
<View style={{width: '750rpx', textAlign: 'center', color: '#999'}}
className="font-28 mt-3 mb-3">{text}</View>
</>
}
{!loading && brands.length === 0 && <Empty name='空空如也'/>}

@ -1,5 +1,6 @@
export default definePageConfig({
navigationBarTitleText: '搜索',
navigationBarBackgroundColor: '#F2F8F6',
onReachBottomDistance: 50
onReachBottomDistance: 50,
navigationStyle: 'custom',
})

@ -1,22 +1,35 @@
page {
background-color: #F2F8F6;
padding-left: 30rpx;
.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;
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 {
font-size: 28rpx;
font-weight: 500;
margin-left: 24rpx;
margin-left: 20rpx;
flex: 1;
}
}
.titleBox {
margin-top: 60rpx;
width: 100%;
@ -24,15 +37,18 @@ page{
box-sizing: border-box;
padding-right: 30rpx;
justify-content: space-between;
.title {
font-size: 28rpx;
font-weight: bold;
color: #323635;
}
}
.contentBox {
display: flex;
flex-wrap: wrap;
.items {
display: inline-block;
background: #FFFFFF;

@ -1,24 +1,22 @@
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 React, {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 search from '@/static/img/search.png'
import NavigationBar from "@/components/navigationBar/navigationBar";
import del from '@/static/img/del.png'
const Search: FC = () => {
const [value, setValue] = useState('')
const [recentSearch, setRecentSearch] = useState<string[]>([])
const [hotSearch,setHotSearch] = useState<any[]>([])
const [hotSearch] = useState<any[]>([])
const [show, setShow] = useState(false)
const [focus, setFocus] = useState(false)
useReady(()=>{
console.log('onReady')
})
useDidShow(()=>{
getRecentSearch()
})
useDidShow(getRecentSearch)
useEffect(() => {
if (!show) {
@ -38,11 +36,9 @@ const Search:FC = () => {
function getRecentSearch() {
setRecentSearch(Taro.getStorageSync('recentSearch'))
}
function getSearchItem(value) {
setValue(value)
// Taro.navigateTo({
// url:`/pages/preview/search/list/index?name=${value}`
// })
setShow(true)
}
@ -55,31 +51,48 @@ const Search:FC = () => {
Taro.setStorageSync('recentSearch', [...new Set(recentSearch)])
}
const searchStyles = useMemo((): React.CSSProperties | undefined => {
if (focus || show) {
return {
transform: "translateY(-43px)",
width: "70%",
}
}
}, [focus, show])
return (
<View className="flex flex-column">
<>
<NavigationBar text='搜索'/>
<View className={styles.searchHeader} style={searchStyles}>
<View className={styles.searchBox}>
<AtIcon value='search' size='20' color='#ccc'></AtIcon>
{ show ?
<Text className={styles.input} >{value}</Text>:
<Input className={styles.input} placeholder="输入关键字搜索" type={'text'} confirmType={'search'} onInput={inpFn} onConfirm={searchInput} />
}
<Image src={search} style={{width: '32rpx', height: '32rpx'}} mode='widthFix'/>
<Input
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
className={styles.input}
placeholder={(focus || show) ? '' : "输入关键字搜索"}
type='text'
confirmType='search'
onInput={inpFn}
onConfirm={searchInput}/>
</View>
{focus || show ? <View className='px-2 text-dark' onClick={() => setShow(false)}></View> : null}
</View>
<View className="flex flex-column px-2">
{
recentSearch.length >= 1 && !show &&
<>
<View className={styles.titleBox}>
<Text className={styles.title}></Text>
<AtIcon onClick={clearSearch} value='trash' size='16' color='#909795'></AtIcon>
<Text className={styles.title}></Text>
<Image src={del} mode='widthFix' style={{width: '16px'}} onClick={clearSearch}/>
</View>
<View className={styles.contentBox}>
{
recentSearch.length &&
recentSearch?.map(d =>
<View className={styles.items}>
<View onClick={()=>{getSearchItem(d)}} className="font-28" >{d}</View>
recentSearch?.map(d => <View className={styles.items}>
<View onClick={() => getSearchItem(d)} className="font-28">{d}</View>
</View>)
}
</View>
@ -98,7 +111,9 @@ const Search:FC = () => {
hotSearch.length &&
hotSearch.map(d =>
<View className="py-1 px-2 rounded-40 mr-2 mb-2 bg-warning text-white">
<View onClick={()=>{getSearchItem(d)}} className="font-28" >{d}</View>
<View onClick={() => {
getSearchItem(d)
}} className="font-28">{d}</View>
</View>)
}
</View>
@ -106,11 +121,16 @@ const Search:FC = () => {
</>
}
<PageContainer onClickOverlay={()=>{ setShow(false)}} show={show} round={true} overlay={true} overlayStyle={'background:rgba(0,0,0,0)'} >
<PageContainer
onClickOverlay={() => setShow(false)}
show={show}
overlay
overlayStyle={'background:rgba(0,0,0,0)'}>
<SearchList name={value} clear={show}/>
</PageContainer>
</View>
</>
)
}
export default Search

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 []
}
}
/** 时间前 */
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