品牌模块

main
一杯沧海 1 year ago
parent 648198d368
commit 1d054012bb
  1. 22
      src/api/brand.ts
  2. 1
      src/api/index.ts
  3. 2
      src/pages/brand/list/list.config.ts
  4. 42
      src/pages/brand/list/list.tsx

@ -0,0 +1,22 @@
import {request} from "@/api/request";
export type BrandRecord = {
id: number
introductory_video: string[]
brand_album: string[]
graphic_introduction: string
disabled: number
}
export const brandApi = {
list(page: number , page_size: number) {
return request<{
data: BrandRecord[],
total: number
}>(`/api/v1/department/index?page=${page}&page_size=${page_size}` , "GET")
},
/** 学习记录 */
info(id: number) {
return request<BrandRecord>(`/api/v1/user/record/${id}`, "GET")
},
}

@ -5,3 +5,4 @@ export * from './meeting'
export * from './public' export * from './public'
export * from './manage' export * from './manage'
export * from './course' export * from './course'
export * from './brand'

@ -1,4 +1,4 @@
export default definePageConfig({ export default definePageConfig({
navigationBarTitleText: '见面会记录', navigationBarTitleText: '品牌列表',
onReachBottomDistance: 30 onReachBottomDistance: 30
}) })

@ -1,24 +1,28 @@
import {FC, useCallback, useEffect, useState} from "react"; import {FC, useCallback, useEffect, useState} from "react";
import {View} from "@tarojs/components"; import {View} from "@tarojs/components";
import {Meeting, meetingAPi} from "@/api"; import {brandApi, BrandRecord, Meeting} from "@/api";
import styles from './meetings.module.scss' import styles from './list.module.scss'
import Taro, {useReachBottom} from "@tarojs/taro"; import Taro, {useReachBottom} from "@tarojs/taro";
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
import {formatDate} from "@/utils/time"; import {formatDate} from "@/utils/time";
import brandView from "@/pages/brand/list/components/BrandView";
const MeetingsConfig: FC = () => { const MeetingsConfig: FC = () => {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [meeting, setMeeting] = useState<Meeting[]>([]) const [brands, setBrands] = useState<BrandRecord[]>([])
const [total, setTotal] = useState(0) const [total, setTotal] = useState(0)
const getData = useCallback(async () => { useEffect(() => {
getData()
}, [page])
const getData = useCallback( async () => {
try { try {
const res = await meetingAPi.setList(1, 10) // const res = await brandApi.list(1, 10)
setTotal(res.total) // setTotal(res.total)
setMeeting([ // setBrands([
...(meeting || []), // ...res.data
...res.data // ])
])
} catch (e) { } catch (e) {
} }
}, [page]) }, [page])
@ -31,9 +35,9 @@ const MeetingsConfig: FC = () => {
if (confirm) { if (confirm) {
await meetingAPi.del(id) await meetingAPi.del(id)
const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(meeting)) const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(brandView))
oldMeeting.splice(index, 1) oldMeeting.splice(index, 1)
setMeeting(oldMeeting) setBrands(oldMeeting)
} }
} }
}) })
@ -49,21 +53,19 @@ const MeetingsConfig: FC = () => {
} }
useReachBottom(useCallback(() => { useReachBottom(useCallback(() => {
if (meeting?.length < total) { if (brands?.length < total) {
setPage(page + 1) setPage(page + 1)
} }
}, [total, meeting])) }, [total, brands]))
useEffect(() => {
getData()
}, [page])
return ( return (
<View className='p-2'> <View className='p-2'>
{ {
meeting.length ? brands.length ?
meeting.map((d, index) => <View className={styles.meeting} key={d.id}> brands.map((d, index) => <View className={styles.meeting} key={d.id}>
<View className={styles.title} onClick={() => jumpInfo(d)}> <View className={styles.title} onClick={() => jumpInfo(d)}>
<View className='font-weight mb-1'>{d.name}</View> <View className='font-weight mb-1'>{d.name}</View>
<View>{formatDate(new Date(d.estimate_start_time), "MM-dd")} {formatDate(new Date(d.estimate_start_time), "MM-dd")}</View> <View>{formatDate(new Date(d.estimate_start_time), "MM-dd")} {formatDate(new Date(d.estimate_start_time), "MM-dd")}</View>
@ -75,7 +77,7 @@ const MeetingsConfig: FC = () => {
</View> </View>
<View className={styles.del} onClick={() => del(d.id, index)}></View> <View className={styles.del} onClick={() => del(d.id, index)}></View>
</View>) </View>)
: <Empty name='无历史记录'/> : <Empty name='空空如也'/>
} }
</View> </View>
) )

Loading…
Cancel
Save