|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import {Image, ScrollView, Swiper, SwiperItem, View} from "@tarojs/components"; |
|
|
|
|
import {HomeApi, userApi} from "@/api"; |
|
|
|
|
import {useEffect, useState} from "react"; |
|
|
|
|
import {userApi} from "@/api"; |
|
|
|
|
import {useCallback, useEffect, useState} from "react"; |
|
|
|
|
import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; |
|
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
@ -11,7 +11,7 @@ import {rfc33392time} from "@/utils/day"; |
|
|
|
|
import play from "@/static/img/play.png"; |
|
|
|
|
|
|
|
|
|
interface KillData { |
|
|
|
|
data: Kill[] |
|
|
|
|
data: any[] |
|
|
|
|
total: number |
|
|
|
|
page: number |
|
|
|
|
} |
|
|
|
@ -37,20 +37,20 @@ const Profession = () => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const res = await userApi.collectList(categoryId!, page, 10) |
|
|
|
|
const dataList = res.data.reduce((pre, cur) => { |
|
|
|
|
const index = pre.findIndex(d => d.id === cur.id) |
|
|
|
|
if (index === -1) { |
|
|
|
|
pre.push(cur) |
|
|
|
|
} else { |
|
|
|
|
pre.splice(index, 1, cur) |
|
|
|
|
} |
|
|
|
|
return pre |
|
|
|
|
}, categoryData?.data || []) |
|
|
|
|
const data = await userApi.collectList(categoryId!, page, 10) |
|
|
|
|
// const dataList = data.list.reduce((pre, cur) => {
|
|
|
|
|
// const index = pre.findIndex(d => d.id === cur.id)
|
|
|
|
|
// if (index === -1) {
|
|
|
|
|
// pre.push(cur)
|
|
|
|
|
// } else {
|
|
|
|
|
// pre.splice(index, 1, cur)
|
|
|
|
|
// }
|
|
|
|
|
// return pre
|
|
|
|
|
// }, categoryData?.data || [])
|
|
|
|
|
oldData.delete(categoryId) |
|
|
|
|
oldData.set(categoryId, { |
|
|
|
|
data: dataList, |
|
|
|
|
total: res.total, |
|
|
|
|
data: data.list, |
|
|
|
|
total: data.total, |
|
|
|
|
page: page |
|
|
|
|
}) |
|
|
|
|
setData(oldData) |
|
|
|
@ -58,6 +58,19 @@ const Profession = () => { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Taro.useDidShow(useCallback(() => { |
|
|
|
|
if(categoryId){ |
|
|
|
|
let tempMap = new Map() |
|
|
|
|
tempMap.set(categoryId, { |
|
|
|
|
data: [], |
|
|
|
|
total: undefined, |
|
|
|
|
page: 1 |
|
|
|
|
}) |
|
|
|
|
setData(tempMap) |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
},[data])) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
categoryId && getData() |
|
|
|
|
}, [categoryId]) |
|
|
|
@ -76,33 +89,17 @@ const Profession = () => { |
|
|
|
|
function tabsChange(tab: OnChangOpt) { |
|
|
|
|
setCategoryId(tab.tab?.value as number) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// function jump(kill: Kill) {
|
|
|
|
|
// HomeApi.skillSetPlay(kill.id)
|
|
|
|
|
// Taro.navigateTo({url: `/pages/preview/videoFull/videoFull?url=${kill.resource.url}&poster=${kill.url_path}&title=${kill.resource.name}`})
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
function jumpInfo(id: number,type:string,health:any) { |
|
|
|
|
console.log(type,'type') |
|
|
|
|
let url = '' |
|
|
|
|
switch (type){ |
|
|
|
|
case 'brand': |
|
|
|
|
url = '/pages/preview/brand/info/info'; |
|
|
|
|
break; |
|
|
|
|
case 'illness': |
|
|
|
|
url = '/pages/preview/illness/list/list'; |
|
|
|
|
break; |
|
|
|
|
case 'article': |
|
|
|
|
url = '/pages/preview/illness/article/article' |
|
|
|
|
break |
|
|
|
|
case 'video_records': |
|
|
|
|
return Taro.navigateTo({url: `/pages/preview/videoFull/videoFull?url=${health.resources.url}&poster=${health.url_path}&title=${health.title}`}) |
|
|
|
|
case 'courses': |
|
|
|
|
url = '/pages/business/videoInfo/videoInfo' |
|
|
|
|
break |
|
|
|
|
function jumpInfo(info: any) { |
|
|
|
|
console.log(info,'info') |
|
|
|
|
if(info.article){ |
|
|
|
|
Taro.navigateTo({url: `/pages/preview/brand/article/article?id=${info.owner_id}`}) |
|
|
|
|
}else if(info.course){ |
|
|
|
|
Taro.navigateTo({url: `/pages/business/videoInfo/videoInfo?id=${info.owner_id}`}) |
|
|
|
|
}else if(info.video_records){ |
|
|
|
|
Taro.navigateTo({url: `/pages/preview/videoFull/videoFull?id=${info.owner_id}`}) |
|
|
|
|
}else if(info.brand){ |
|
|
|
|
Taro.navigateTo({url: `/pages/preview/brand/info/info?id=${info.owner_id}`}) |
|
|
|
|
} |
|
|
|
|
Taro.navigateTo({url: `${url}?id=${id}`}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function swiperChange(e) { |
|
|
|
@ -123,53 +120,50 @@ const Profession = () => { |
|
|
|
|
className={styles.height}> |
|
|
|
|
{ |
|
|
|
|
data.data.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)} className={styles.box} key={d.id}> |
|
|
|
|
{ |
|
|
|
|
d.data.table === 'brand' && |
|
|
|
|
d.brand && |
|
|
|
|
<> |
|
|
|
|
<Img width={128} height={128} src={d.data?.logo} mode='aspectFill' className={styles.image}/> |
|
|
|
|
<Img width={128} height={128} src={d.brand.logo} mode='aspectFill' className={styles.image}/> |
|
|
|
|
<View className={styles.rightBox}> |
|
|
|
|
<View className='font-weight mb-2 font-28'>{d.data.title}</View> |
|
|
|
|
<View className={styles.desc}>{d.data.content || '暂无品牌简介'}</View> |
|
|
|
|
<View className='font-weight mb-2 font-28'>{d.brand.name}</View> |
|
|
|
|
<View className={styles.desc}>{d.brand.graphic_introduction || '暂无品牌简介'}</View> |
|
|
|
|
</View> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
d.data.table === 'article' && |
|
|
|
|
d.article && |
|
|
|
|
<> |
|
|
|
|
<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='font-weight mb-2 font-28 lh-40'>{d.article.title}</View> |
|
|
|
|
<View className={styles.desc}>{rfc33392time(d.article.created_at)} {d.article.page_view}阅读</View> |
|
|
|
|
</View> |
|
|
|
|
<Img width={172} height={128} src={d.data['@data'].logo} mode='aspectFill' className={styles.image}/> |
|
|
|
|
<Img width={172} height={128} src={d.article.logo} mode='aspectFill' className={styles.image}/> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
d.data.table === 'video_records' && |
|
|
|
|
d.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.video_records.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> |
|
|
|
|
<View className={styles.desc}>{d.data['@data'].introduction}</View> |
|
|
|
|
<View className={`${styles.desc} mt-2`}>播放量: {d.data['@data'].video_view}</View> |
|
|
|
|
<View className='font-weight mb-2 font-28 lh-40'>{d.video_records.title}</View> |
|
|
|
|
<View className={styles.desc}>{d.video_records.introduction}</View> |
|
|
|
|
<View className={`${styles.desc} mt-2`}>播放量: {d.video_records.video_view}</View> |
|
|
|
|
</View> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
d.data.table === 'courses' && |
|
|
|
|
d.course && |
|
|
|
|
<> |
|
|
|
|
<Img width={192} height={138} src={d.data['@data'].thumb} mode='aspectFill' className={styles.image}/> |
|
|
|
|
<Img width={192} height={138} src={d.course.thumb} mode='aspectFill' className={styles.image}/> |
|
|
|
|
<View className={styles.courseRightBox}> |
|
|
|
|
<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='font-weight mb-2 font-28 lh-40'>{d.course.title}</View> |
|
|
|
|
<View className={styles.desc}>课时:{d.course.class_hour}节 销量:{d.course.charge}</View> |
|
|
|
|
</View> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|