品牌模块

main
一杯沧海 1 year ago committed by king
parent 3924f35f18
commit d404784233
  1. 22
      src/api/brand.ts
  2. 1
      src/api/index.ts
  3. 2
      src/pages/brand/list/list.config.ts
  4. 40
      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,4 +5,5 @@ export * from './meeting'
export * from './public'
export * from './manage'
export * from './course'
export * from './brand'
export * from './home'

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

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

Loading…
Cancel
Save