@tbox.cn/app-card-assets 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/SOURCE.md +5 -0
- package/assets.json +239 -0
- package/components/Banner/index.module.less +11 -0
- package/components/Banner/index.tsx +36 -0
- package/components/BlockAnimal/LottiePlayer/index.module.less +11 -0
- package/components/BlockAnimal/LottiePlayer/index.tsx +24 -0
- package/components/BlockAnimal/LottiePlayer/utils.ts +72 -0
- package/components/BlockAnimal/index.module.less +78 -0
- package/components/BlockAnimal/index.tsx +120 -0
- package/components/BlockBarrage/index.module.less +101 -0
- package/components/BlockBarrage/index.tsx +98 -0
- package/components/BlockFanSwiper/index.module.less +89 -0
- package/components/BlockFanSwiper/index.tsx +56 -0
- package/components/BlockIntro/index.module.less +31 -0
- package/components/BlockIntro/index.tsx +21 -0
- package/components/BlockIntroCenter/index.module.less +30 -0
- package/components/BlockIntroCenter/index.tsx +22 -0
- package/components/BlockNowList/index.module.less +72 -0
- package/components/BlockNowList/index.tsx +54 -0
- package/components/BlockQuestionList/index.module.less +113 -0
- package/components/BlockQuestionList/index.tsx +107 -0
- package/components/BlockServiceIconList/index.module.less +62 -0
- package/components/BlockServiceIconList/index.tsx +83 -0
- package/components/BlockServiceList/index.module.less +89 -0
- package/components/BlockServiceList/index.tsx +88 -0
- package/components/BlockTravelCarousel/index.module.less +125 -0
- package/components/BlockTravelCarousel/index.tsx +101 -0
- package/components/BlockTravelCarousel/tags/Tags.module.less +20 -0
- package/components/BlockTravelCarousel/tags/Tags.tsx +20 -0
- package/components/OneCol/index.module.less +158 -0
- package/components/OneCol/index.tsx +83 -0
- package/components/TwoCol/index.module.less +191 -0
- package/components/TwoCol/index.tsx +82 -0
- package/docs/Banner.md +17 -0
- package/docs/BlockAnimal.md +17 -0
- package/docs/BlockBarrage.md +17 -0
- package/docs/BlockFanSwiper.md +17 -0
- package/docs/BlockIntro.md +17 -0
- package/docs/BlockIntroCenter.md +17 -0
- package/docs/BlockNowList.md +17 -0
- package/docs/BlockQuestionList.md +17 -0
- package/docs/BlockServiceIconList.md +17 -0
- package/docs/BlockServiceList.md +17 -0
- package/docs/BlockTravelCarousel.md +17 -0
- package/docs/OneCol.md +17 -0
- package/docs/TwoCol.md +17 -0
- package/examples/Banner.json +5 -0
- package/examples/BlockAnimal.json +22 -0
- package/examples/BlockBarrage.json +26 -0
- package/examples/BlockFanSwiper.json +23 -0
- package/examples/BlockIntro.json +4 -0
- package/examples/BlockIntroCenter.json +4 -0
- package/examples/BlockNowList.json +36 -0
- package/examples/BlockQuestionList.json +25 -0
- package/examples/BlockServiceIconList.json +36 -0
- package/examples/BlockServiceList.json +36 -0
- package/examples/BlockTravelCarousel.json +37 -0
- package/examples/OneCol.json +49 -0
- package/examples/TwoCol.json +49 -0
- package/package.json +39 -3
- package/shared/actions.ts +38 -0
- package/shared/home-integration.md +47 -0
- package/shared/types.ts +10 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import styles from './index.module.less';
|
|
4
|
+
|
|
5
|
+
interface ArticleListProps extends ICardProps {
|
|
6
|
+
/** 后端下发的卡片渲染相关的所有字段 */
|
|
7
|
+
cardData: {
|
|
8
|
+
title?: string;
|
|
9
|
+
list?: Array<{
|
|
10
|
+
content?: string;
|
|
11
|
+
query?: string;
|
|
12
|
+
}>;
|
|
13
|
+
defaultNum?: number;
|
|
14
|
+
} & ICardProps['cardData'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const EMPTY_LIST: NonNullable<ArticleListProps['cardData']['list']> = [];
|
|
18
|
+
|
|
19
|
+
interface ArticleItemProps {
|
|
20
|
+
content?: string;
|
|
21
|
+
onClick?: () => void;
|
|
22
|
+
index?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ArticleItem: React.FC<ArticleItemProps> = ({ content, onClick, index = 0 }) => {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className={styles.articleItem}
|
|
29
|
+
style={{
|
|
30
|
+
marginTop: index === 0 ? '0.0rem' : '0.16rem',
|
|
31
|
+
}}
|
|
32
|
+
onClick={onClick}
|
|
33
|
+
>
|
|
34
|
+
<img
|
|
35
|
+
src="https://mdn.alipayobjects.com/huamei_frp8ut/afts/img/A*WkE1Rasmfk4AAAAAAAAAAAAAet-KAQ/original"
|
|
36
|
+
className={styles.itemThumbnail}
|
|
37
|
+
alt="thumbnail"
|
|
38
|
+
/>
|
|
39
|
+
<span className={styles.itemDescription}>{content}</span>
|
|
40
|
+
<img
|
|
41
|
+
src="https://mdn.alipayobjects.com/huamei_frp8ut/afts/img/A*-4_2QZGFzLsAAAAAAAAAAAAAet-KAQ/original"
|
|
42
|
+
className={styles.navigationIcon}
|
|
43
|
+
alt="navigation"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const ArticleList: React.FC<ArticleListProps> = ({ cardData = {}, bridgeAPI }) => {
|
|
50
|
+
const { title, list = EMPTY_LIST, defaultNum = 4 } = cardData;
|
|
51
|
+
const [displayedList, setDisplayedList] = useState<Array<{ content?: string; query?: string }>>([]);
|
|
52
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
53
|
+
const pageSize = Number.isFinite(defaultNum) ? Math.max(1, Math.floor(defaultNum)) : 4;
|
|
54
|
+
|
|
55
|
+
const formatData = () => {
|
|
56
|
+
if (!list || list.length === 0) { setDisplayedList([]); return; }
|
|
57
|
+
|
|
58
|
+
const displayedItems: Array<{ content?: string; query?: string }> = [];
|
|
59
|
+
for (let i = 0; i < Math.min(pageSize, list.length); i++) {
|
|
60
|
+
const index = (currentPage + i) % list.length;
|
|
61
|
+
displayedItems.push(list[index]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setDisplayedList(displayedItems);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
formatData();
|
|
69
|
+
}, [currentPage, list, pageSize]);
|
|
70
|
+
|
|
71
|
+
const handleRefresh = () => {
|
|
72
|
+
if (list.length) setCurrentPage((prevPage) => (prevPage + pageSize) % list.length);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const handleItemClick = (item: any) => {
|
|
76
|
+
if (item?.query) {
|
|
77
|
+
bridgeAPI?.sendQuery({
|
|
78
|
+
question_content: item.query,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className={styles.articleList}>
|
|
85
|
+
<div className={styles.headerSection}>
|
|
86
|
+
<div className={styles.titleWrapper}>
|
|
87
|
+
<span className={styles.articleTitle}>{title}</span>
|
|
88
|
+
<div className={styles.actionBar} onClick={handleRefresh}>
|
|
89
|
+
<img
|
|
90
|
+
src="https://mdn.alipayobjects.com/huamei_frp8ut/afts/img/A*kDzsRblLTOYAAAAAAAAAAAAAet-KAQ/original"
|
|
91
|
+
className={styles.loadingIndicator}
|
|
92
|
+
alt="refresh"
|
|
93
|
+
/>
|
|
94
|
+
<span className={styles.refreshButton}>换一换</span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
<div className={styles.contentArea}>
|
|
98
|
+
{displayedList.map((item, index) => (
|
|
99
|
+
<ArticleItem key={index} content={item.content} onClick={() => handleItemClick(item)} index={index} />
|
|
100
|
+
))}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default ArticleList;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.serviceList {
|
|
2
|
+
margin-bottom: 28px;
|
|
3
|
+
border-radius: 24px;
|
|
4
|
+
background-color: rgba(255, 255, 255, 0.5);
|
|
5
|
+
padding: 24px;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.servers {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
}
|
|
16
|
+
.serversTitle {
|
|
17
|
+
color: #1f3b63;
|
|
18
|
+
font-size: 30px;
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.serversListBox {
|
|
23
|
+
margin-top: 24px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.serversList {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: row;
|
|
33
|
+
flex-wrap: wrap;
|
|
34
|
+
width: 622px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.serversItem {
|
|
38
|
+
display: flex;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
align-items: center;
|
|
41
|
+
width: 155px;
|
|
42
|
+
height: 86px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
.serversItemBox {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
align-items: center;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.serversIcon {
|
|
53
|
+
width: 48px;
|
|
54
|
+
height: 48px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.serversText {
|
|
58
|
+
font-size: 22px;
|
|
59
|
+
color: #1f3b63;
|
|
60
|
+
margin-top: 8px;
|
|
61
|
+
text-align: center;
|
|
62
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { runCardClick } from '../../shared/actions';
|
|
2
|
+
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styles from './index.module.less';
|
|
5
|
+
import { PictureWrongOutline } from 'antd-mobile-icons';
|
|
6
|
+
|
|
7
|
+
interface BlockServiceIconListProps extends ICardProps {
|
|
8
|
+
/** 后端下发的卡片渲染相关的所有字段 */
|
|
9
|
+
cardData: {
|
|
10
|
+
title?: string;
|
|
11
|
+
list?: Array<{
|
|
12
|
+
icon?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
clickAction?: string;
|
|
15
|
+
query?: string;
|
|
16
|
+
jumpUrl?: string;
|
|
17
|
+
}>;
|
|
18
|
+
} & ICardProps['cardData'];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ServiceItemProps {
|
|
22
|
+
icon?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
onClick?: () => void;
|
|
25
|
+
index?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const ServiceItem: React.FC<ServiceItemProps> = ({ icon, title, onClick, index = 0 }) => {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
className={styles.serversItem}
|
|
32
|
+
style={{
|
|
33
|
+
marginTop: index > 3 ? '0.28rem' : 0,
|
|
34
|
+
}}
|
|
35
|
+
onClick={onClick}
|
|
36
|
+
>
|
|
37
|
+
<div className={styles.serversItemBox}>
|
|
38
|
+
{icon ? (
|
|
39
|
+
<img className={styles.serversIcon} src={icon} alt={title} />
|
|
40
|
+
) : (
|
|
41
|
+
<PictureWrongOutline
|
|
42
|
+
style={{
|
|
43
|
+
color: '#333',
|
|
44
|
+
fontSize: '0.24rem',
|
|
45
|
+
}}
|
|
46
|
+
className={styles.serversIcon}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
<span className={styles.serversText}>{title}</span>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const BlockServiceIconList: React.FC<BlockServiceIconListProps> = ({ cardData = {}, bridgeAPI }) => {
|
|
56
|
+
const { title, list = [] } = cardData;
|
|
57
|
+
const serviceList = list.slice(0, 8);
|
|
58
|
+
|
|
59
|
+
const handleServiceClick = (item: any) => runCardClick(bridgeAPI, item);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className={styles.serviceList}>
|
|
63
|
+
<div className={styles.servers}>
|
|
64
|
+
<span className={styles.serversTitle}>{title}</span>
|
|
65
|
+
<div className={styles.serversListBox}>
|
|
66
|
+
<div className={styles.serversList}>
|
|
67
|
+
{serviceList.map((item, index) => (
|
|
68
|
+
<ServiceItem
|
|
69
|
+
key={index}
|
|
70
|
+
icon={item.icon}
|
|
71
|
+
title={item.title}
|
|
72
|
+
onClick={() => handleServiceClick(item)}
|
|
73
|
+
index={index}
|
|
74
|
+
/>
|
|
75
|
+
))}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default BlockServiceIconList;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.travelType {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
margin-bottom: 28px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.serviceHeader {
|
|
7
|
+
border-radius: 24px;
|
|
8
|
+
background-color: rgba(255, 255, 255, 0.5);
|
|
9
|
+
padding: 0 24px 28px;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.mainTitle {
|
|
16
|
+
font-size: 30px;
|
|
17
|
+
color: #1f3b63;
|
|
18
|
+
line-height: 40px;
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
margin: 24px 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.transportOptions {
|
|
24
|
+
width: 100%;
|
|
25
|
+
display: flex;
|
|
26
|
+
height: 164px;
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
overflow-x: auto;
|
|
29
|
+
gap: 12px;
|
|
30
|
+
// 隐藏滚动条width: 0;
|
|
31
|
+
scrollbar-width: none;
|
|
32
|
+
}
|
|
33
|
+
.optionsContainer {
|
|
34
|
+
position: relative;
|
|
35
|
+
width: 280px;
|
|
36
|
+
height: 164px;
|
|
37
|
+
padding: 20px 24px;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
align-items: flex-start;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
background-size: cover;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
flex-shrink: 0;
|
|
45
|
+
flex-grow: 0;
|
|
46
|
+
border-radius: 16px;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.optionsMark {
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 100%;
|
|
56
|
+
}
|
|
57
|
+
.optionsMarkWrap {
|
|
58
|
+
position: relative;
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 100%;
|
|
61
|
+
z-index: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.guideTitle {
|
|
65
|
+
color: rgb(255, 255, 255);
|
|
66
|
+
font-size: 26px;
|
|
67
|
+
white-space: nowrap;
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
margin-bottom: 30px;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.descWrap {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.freeTourOption {
|
|
81
|
+
margin-bottom: 12px;
|
|
82
|
+
color: rgb(237, 238, 239);
|
|
83
|
+
font-size: 22px;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
white-space: nowrap;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
text-overflow: ellipsis;
|
|
88
|
+
width: 100%;
|
|
89
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { runCardClick } from '../../shared/actions';
|
|
2
|
+
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styles from './index.module.less';
|
|
5
|
+
|
|
6
|
+
interface BlockServiceListProps extends ICardProps {
|
|
7
|
+
/** 后端下发的卡片渲染相关的所有字段 */
|
|
8
|
+
cardData: {
|
|
9
|
+
title?: string;
|
|
10
|
+
list?: Array<{
|
|
11
|
+
imageUrl?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
clickAction?: string;
|
|
14
|
+
tags?: string[];
|
|
15
|
+
jumpUrl?: string;
|
|
16
|
+
query?: string;
|
|
17
|
+
}>;
|
|
18
|
+
} & ICardProps['cardData'];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ScenicCardProps {
|
|
22
|
+
imageUrl?: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
onClick?: () => void;
|
|
26
|
+
index?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ScenicCard: React.FC<ScenicCardProps> = ({ imageUrl, title, tags = [], onClick, index = 0 }) => {
|
|
30
|
+
const showMaskFlag = tags?.length > 0 || title;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
className={styles.optionsContainer}
|
|
35
|
+
style={{
|
|
36
|
+
backgroundImage: `url(${imageUrl})`,
|
|
37
|
+
marginLeft: index > 0 ? '0.12rem' : '0',
|
|
38
|
+
}}
|
|
39
|
+
onClick={onClick}
|
|
40
|
+
>
|
|
41
|
+
{showMaskFlag && (
|
|
42
|
+
<img
|
|
43
|
+
src="https://mdn.alipayobjects.com/huamei_frp8ut/afts/img/A*EngjSaAIWqgAAAAAAAAAAAAAet-KAQ/original"
|
|
44
|
+
className={styles.optionsMark}
|
|
45
|
+
alt="mask"
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
<div className={styles.optionsMarkWrap}>
|
|
49
|
+
<div className={styles.guideTitle}>{title}</div>
|
|
50
|
+
<div className={styles.descWrap}>
|
|
51
|
+
{tags.map((tag, tagIndex) => (
|
|
52
|
+
<div key={tagIndex} className={styles.freeTourOption}>
|
|
53
|
+
{tag}
|
|
54
|
+
</div>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const BlockServiceList: React.FC<BlockServiceListProps> = ({ cardData = {}, bridgeAPI }) => {
|
|
63
|
+
const { title, list = [] } = cardData;
|
|
64
|
+
|
|
65
|
+
const handleItemClick = (item: any) => runCardClick(bridgeAPI, item);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className={styles.travelType}>
|
|
69
|
+
<div className={styles.serviceHeader}>
|
|
70
|
+
<span className={styles.mainTitle}>{title}</span>
|
|
71
|
+
<div className={styles.transportOptions}>
|
|
72
|
+
{list.map((item, index) => (
|
|
73
|
+
<ScenicCard
|
|
74
|
+
key={index}
|
|
75
|
+
imageUrl={item.imageUrl}
|
|
76
|
+
title={item.title}
|
|
77
|
+
tags={item.tags}
|
|
78
|
+
onClick={() => handleItemClick(item)}
|
|
79
|
+
index={index}
|
|
80
|
+
/>
|
|
81
|
+
))}
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default BlockServiceList;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
.escortList {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
position: relative;
|
|
4
|
+
border-radius: 24px;
|
|
5
|
+
height: 448px;
|
|
6
|
+
margin-bottom: 28px;
|
|
7
|
+
line-height: 1.5;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.swiper {
|
|
11
|
+
border-radius: 24px;
|
|
12
|
+
height: 448px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.infoCard {
|
|
16
|
+
height: 448px;
|
|
17
|
+
width: 100%;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
position: relative;
|
|
20
|
+
background-position: center;
|
|
21
|
+
background-size: cover;
|
|
22
|
+
background-repeat: no-repeat;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.escortMark {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 224px;
|
|
28
|
+
left: 0;
|
|
29
|
+
height: 224px;
|
|
30
|
+
width: 100%;
|
|
31
|
+
border-radius: 0 0 24px 24px;
|
|
32
|
+
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.titleTag {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 24px;
|
|
38
|
+
left: 24px;
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
border-radius: 8px;
|
|
41
|
+
padding: 0 10px;
|
|
42
|
+
font-size: 22px;
|
|
43
|
+
color: #fff;
|
|
44
|
+
text-align: center;
|
|
45
|
+
font-weight: 500;
|
|
46
|
+
background-image: linear-gradient(90deg, #fe5500 0%, #ff8e00 100%);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.infoBox {
|
|
50
|
+
position: absolute;
|
|
51
|
+
padding: 0 24px;
|
|
52
|
+
bottom: 32px;
|
|
53
|
+
width: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.infoContainer {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
flex-direction: row;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.titleText {
|
|
64
|
+
color: rgb(255, 255, 255);
|
|
65
|
+
font-size: 40px;
|
|
66
|
+
font-weight: 500;
|
|
67
|
+
line-height: 48px;
|
|
68
|
+
white-space: nowrap;
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
margin-bottom: 12px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.infoDesc {
|
|
74
|
+
font-size: 24px;
|
|
75
|
+
color: #fff;
|
|
76
|
+
letter-spacing: 1px;
|
|
77
|
+
font-weight: 500;
|
|
78
|
+
opacity: 0.7;
|
|
79
|
+
text-overflow: ellipsis;
|
|
80
|
+
margin-top: 16px;
|
|
81
|
+
line-height: 32px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.dotsBox {
|
|
85
|
+
position: absolute;
|
|
86
|
+
bottom: 12px;
|
|
87
|
+
left: 0;
|
|
88
|
+
width: 100%;
|
|
89
|
+
display: flex;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
align-items: center;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.dotsBox2 {
|
|
95
|
+
position: absolute;
|
|
96
|
+
bottom: 32px;
|
|
97
|
+
right: 24px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.customDots {
|
|
101
|
+
display: flex;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
flex-direction: row;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.indicatorDot {
|
|
107
|
+
width: 8px;
|
|
108
|
+
height: 8px;
|
|
109
|
+
border-radius: 4px;
|
|
110
|
+
background-color: rgba(255, 255, 255, 0.4);
|
|
111
|
+
margin: 0 4px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.active {
|
|
115
|
+
background-color: #fff;
|
|
116
|
+
width: 23px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.tagsBox1 {
|
|
120
|
+
margin-left: 16px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.tagsBox2 {
|
|
124
|
+
margin-top: 12px;
|
|
125
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { runCardClick } from '../../shared/actions';
|
|
2
|
+
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { Swiper } from 'antd-mobile';
|
|
5
|
+
import styles from './index.module.less';
|
|
6
|
+
import Tags from './tags/Tags';
|
|
7
|
+
|
|
8
|
+
interface BlockTravelCarouselProps extends ICardProps {
|
|
9
|
+
/** 后端下发的卡片渲染相关的所有字段 */
|
|
10
|
+
cardData: {
|
|
11
|
+
title?: string;
|
|
12
|
+
hotTitle?: string;
|
|
13
|
+
list?: Array<{
|
|
14
|
+
imageUrl?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
desc?: string;
|
|
17
|
+
tags?: string[];
|
|
18
|
+
clickAction?: string;
|
|
19
|
+
jumpUrl?: string;
|
|
20
|
+
query?: string;
|
|
21
|
+
}>;
|
|
22
|
+
} & ICardProps['cardData'];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface CarouselItemProps {
|
|
26
|
+
item: any;
|
|
27
|
+
hotTitle?: string;
|
|
28
|
+
hasDesc: boolean;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const CarouselItem: React.FC<CarouselItemProps> = ({ item, hotTitle, hasDesc, onClick }) => {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
className={styles.infoCard}
|
|
36
|
+
style={{
|
|
37
|
+
backgroundImage: `url(${item.imageUrl})`,
|
|
38
|
+
}}
|
|
39
|
+
onClick={onClick}
|
|
40
|
+
>
|
|
41
|
+
<div className={styles.escortMark} />
|
|
42
|
+
<span className={styles.titleTag}>{hotTitle}</span>
|
|
43
|
+
<div className={styles.infoBox}>
|
|
44
|
+
<div className={styles.infoContainer}>
|
|
45
|
+
<span className={styles.titleText}>{item.title}</span>
|
|
46
|
+
{hasDesc && item.tags && (
|
|
47
|
+
<div className={styles.tagsBox1}>
|
|
48
|
+
<Tags tags={item.tags} />
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
{!hasDesc && item.tags && (
|
|
53
|
+
<div className={styles.tagsBox2}>
|
|
54
|
+
<Tags tags={item.tags} />
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
{hasDesc && item.desc && <span className={styles.infoDesc}>{item.desc}</span>}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const BlockTravelCarousel: React.FC<BlockTravelCarouselProps> = ({ cardData = {}, bridgeAPI }) => {
|
|
64
|
+
const { hotTitle, list = [] } = cardData;
|
|
65
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
66
|
+
const hasDesc = !!list[0]?.desc;
|
|
67
|
+
|
|
68
|
+
const handleClick = (item: any) => runCardClick(bridgeAPI, item);
|
|
69
|
+
|
|
70
|
+
if (!list.length) return null;
|
|
71
|
+
|
|
72
|
+
const dotsBoxClass = hasDesc ? styles.dotsBox : styles.dotsBox2;
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div className={styles.escortList}>
|
|
76
|
+
<Swiper
|
|
77
|
+
className={styles.swiper}
|
|
78
|
+
autoplay={list.length > 1}
|
|
79
|
+
autoplayInterval={3000}
|
|
80
|
+
onIndexChange={setCurrentIndex}
|
|
81
|
+
loop={list.length > 1}
|
|
82
|
+
indicator={false}
|
|
83
|
+
>
|
|
84
|
+
{list.map((item, index) => (
|
|
85
|
+
<Swiper.Item key={index}>
|
|
86
|
+
<CarouselItem item={item} hotTitle={hotTitle} hasDesc={hasDesc} onClick={() => handleClick(item)} />
|
|
87
|
+
</Swiper.Item>
|
|
88
|
+
))}
|
|
89
|
+
</Swiper>
|
|
90
|
+
<div className={dotsBoxClass}>
|
|
91
|
+
<div className={styles.customDots}>
|
|
92
|
+
{list.map((_, index) => (
|
|
93
|
+
<div key={index} className={`${styles.indicatorDot} ${currentIndex === index ? styles.active : ''}`} />
|
|
94
|
+
))}
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default BlockTravelCarousel;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.buttonGroup {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
.button {
|
|
7
|
+
margin-right: 12px;
|
|
8
|
+
padding: 0 12px;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
height: 38px;
|
|
14
|
+
background-color: rgba(255, 255, 255, 0.14);
|
|
15
|
+
font-size: 24px;
|
|
16
|
+
color: #fff;
|
|
17
|
+
border: 1.5px solid #6c6e7e;
|
|
18
|
+
border-radius: 19px;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './Tags.module.less';
|
|
3
|
+
|
|
4
|
+
interface TagsProps {
|
|
5
|
+
tags?: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Tags: React.FC<TagsProps> = ({ tags = [] }) => {
|
|
9
|
+
return (
|
|
10
|
+
<div className={styles.buttonGroup}>
|
|
11
|
+
{tags.map((tag, index) => (
|
|
12
|
+
<span key={index} className={styles.button}>
|
|
13
|
+
{tag}
|
|
14
|
+
</span>
|
|
15
|
+
))}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default Tags;
|