|
|
@ -25,9 +25,17 @@ interface Data { |
|
|
|
url: string |
|
|
|
url: string |
|
|
|
detailsUrl: string |
|
|
|
detailsUrl: string |
|
|
|
data: DataContent[] |
|
|
|
data: DataContent[] |
|
|
|
|
|
|
|
type?: 'health' | 'kill' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const FeatureRecommended: FC = () => { |
|
|
|
interface Props { |
|
|
|
|
|
|
|
skill: Kill[] // 技能
|
|
|
|
|
|
|
|
health: Health[] // 健康
|
|
|
|
|
|
|
|
brand: Brand[] // 品牌
|
|
|
|
|
|
|
|
illness: Illness[] // 疾病
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const FeatureRecommended: FC<Props> = (props) => { |
|
|
|
const [data, setData] = useState<Data[]>([ |
|
|
|
const [data, setData] = useState<Data[]>([ |
|
|
|
{ |
|
|
|
{ |
|
|
|
titleUrl: brandTop, |
|
|
|
titleUrl: brandTop, |
|
|
@ -39,13 +47,15 @@ const FeatureRecommended: FC = () => { |
|
|
|
titleUrl: healthTop, |
|
|
|
titleUrl: healthTop, |
|
|
|
url: '/pages/preview/health/health', |
|
|
|
url: '/pages/preview/health/health', |
|
|
|
detailsUrl: '/pages/preview/videoFull/videoFull', |
|
|
|
detailsUrl: '/pages/preview/videoFull/videoFull', |
|
|
|
data: [] |
|
|
|
data: [], |
|
|
|
|
|
|
|
type: "health" |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
titleUrl: professionTop, |
|
|
|
titleUrl: professionTop, |
|
|
|
url: '/pages/preview/profession/profession', |
|
|
|
url: '/pages/preview/profession/profession', |
|
|
|
detailsUrl: '/pages/preview/videoFull/videoFull', |
|
|
|
detailsUrl: '/pages/preview/videoFull/videoFull', |
|
|
|
data: [] |
|
|
|
data: [], |
|
|
|
|
|
|
|
type: 'kill' |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
titleUrl: illnessTop, |
|
|
|
titleUrl: illnessTop, |
|
|
@ -58,8 +68,7 @@ const FeatureRecommended: FC = () => { |
|
|
|
/** 品牌 */ |
|
|
|
/** 品牌 */ |
|
|
|
async function getBrand(): Promise<DataContent[]> { |
|
|
|
async function getBrand(): Promise<DataContent[]> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await HomeApi.brand(1, 3) |
|
|
|
return props.brand.map<DataContent>(d => ({ |
|
|
|
return res.list.map<DataContent>(d => ({ |
|
|
|
|
|
|
|
id: d.id, |
|
|
|
id: d.id, |
|
|
|
title: d.name, |
|
|
|
title: d.name, |
|
|
|
imageUrl: d.brand_album, |
|
|
|
imageUrl: d.brand_album, |
|
|
@ -67,6 +76,7 @@ const FeatureRecommended: FC = () => { |
|
|
|
path: `?id=${d.id}`, |
|
|
|
path: `?id=${d.id}`, |
|
|
|
})) |
|
|
|
})) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log(e) |
|
|
|
} |
|
|
|
} |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
} |
|
|
|
} |
|
|
@ -74,8 +84,7 @@ const FeatureRecommended: FC = () => { |
|
|
|
/** 健康知识 */ |
|
|
|
/** 健康知识 */ |
|
|
|
async function getHealth(): Promise<DataContent[]> { |
|
|
|
async function getHealth(): Promise<DataContent[]> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await HomeApi.healthTop(3) |
|
|
|
return props.health?.map<DataContent>(d => ({ |
|
|
|
return res.map<DataContent>(d => ({ |
|
|
|
|
|
|
|
id: d.id, |
|
|
|
id: d.id, |
|
|
|
title: d.title, |
|
|
|
title: d.title, |
|
|
|
imageUrl: d.url_path, |
|
|
|
imageUrl: d.url_path, |
|
|
@ -90,8 +99,7 @@ const FeatureRecommended: FC = () => { |
|
|
|
/** 技能 */ |
|
|
|
/** 技能 */ |
|
|
|
async function getKill(): Promise<DataContent[]> { |
|
|
|
async function getKill(): Promise<DataContent[]> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await HomeApi.skillTop(3) |
|
|
|
return props.skill.map<DataContent>(d => ({ |
|
|
|
return res.map<DataContent>(d => ({ |
|
|
|
|
|
|
|
id: d.id, |
|
|
|
id: d.id, |
|
|
|
imageUrl: d.url_path, |
|
|
|
imageUrl: d.url_path, |
|
|
|
description: d.introduction, |
|
|
|
description: d.introduction, |
|
|
@ -106,12 +114,11 @@ const FeatureRecommended: FC = () => { |
|
|
|
/** 疾病 */ |
|
|
|
/** 疾病 */ |
|
|
|
async function getIllness(): Promise<DataContent[]> { |
|
|
|
async function getIllness(): Promise<DataContent[]> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await HomeApi.illness(1, 3) |
|
|
|
return props.illness.map<DataContent>(d => ({ |
|
|
|
return res.list.map<DataContent>(d => ({ |
|
|
|
|
|
|
|
id: d.id, |
|
|
|
id: d.id, |
|
|
|
imageUrl: '', |
|
|
|
imageUrl: '', |
|
|
|
description: d.content, |
|
|
|
description: d.description, |
|
|
|
title: d.title, |
|
|
|
title: d.name, |
|
|
|
path: `?id=${d.id}` |
|
|
|
path: `?id=${d.id}` |
|
|
|
})) |
|
|
|
})) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
@ -128,15 +135,23 @@ const FeatureRecommended: FC = () => { |
|
|
|
oldData[3].data = illness |
|
|
|
oldData[3].data = illness |
|
|
|
setData(oldData) |
|
|
|
setData(oldData) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, []) |
|
|
|
}, [props]) |
|
|
|
|
|
|
|
|
|
|
|
function jump(url: string) { |
|
|
|
// TODO 后续增加播放量使用公共接口
|
|
|
|
|
|
|
|
function jump(url: string, playId?: number, type?: 'health' | 'kill') { |
|
|
|
|
|
|
|
if (playId && type) { |
|
|
|
|
|
|
|
if (type === 'health') { |
|
|
|
|
|
|
|
HomeApi.healthSetPlay(playId) |
|
|
|
|
|
|
|
} else if (type === 'kill') { |
|
|
|
|
|
|
|
HomeApi.skillSetPlay(playId) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
Taro.navigateTo({url}) |
|
|
|
Taro.navigateTo({url}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View className={styles.feature}> |
|
|
|
<View className={styles.feature}> |
|
|
|
<Swiper nextMargin='30px' style={{height: '250px'}}> |
|
|
|
<Swiper nextMargin='30px' style={{height: '263px'}}> |
|
|
|
{ |
|
|
|
{ |
|
|
|
data.map(d => <SwiperItem key={d.url}> |
|
|
|
data.map(d => <SwiperItem key={d.url}> |
|
|
|
<Image |
|
|
|
<Image |
|
|
@ -147,14 +162,14 @@ const FeatureRecommended: FC = () => { |
|
|
|
d.data.map((c, index) => <View |
|
|
|
d.data.map((c, index) => <View |
|
|
|
className='flex mb-3' |
|
|
|
className='flex mb-3' |
|
|
|
key={c.id} |
|
|
|
key={c.id} |
|
|
|
onClick={() => jump(d.detailsUrl + c.path)}> |
|
|
|
onClick={() => jump(d.detailsUrl + c.path, c.id, d.type)}> |
|
|
|
<View> |
|
|
|
<View> |
|
|
|
<Image src={c.imageUrl} className={styles.featureImage} mode='aspectFill'/> |
|
|
|
<Image src={c.imageUrl} className={styles.featureImage} mode='aspectFill'/> |
|
|
|
<Image src={[first, second, third][index]} className={styles.ranking} mode='aspectFill'/> |
|
|
|
<Image src={[first, second, third][index]} className={styles.ranking} mode='aspectFill'/> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
<View className={styles.featureText}> |
|
|
|
<View className={styles.featureText}> |
|
|
|
<View className='text-ellipsis text-secondary'>{c.title}</View> |
|
|
|
<View className={styles.featureTextTitle}>{c.title}</View> |
|
|
|
<View className='font-26 mt-1 text-muted text-ellipsis'>{c.description}</View> |
|
|
|
<View className={styles.featureTextDescription}>{c.description}</View> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</View>) |
|
|
|
</View>) |
|
|
|
} |
|
|
|
} |
|
|
|