@cloudbase/weda-ui 0.2.15 → 0.2.16
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/package.json +10 -7
- package/src/configs/components/calendar.json +75 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/statisticsCard.json +331 -0
- package/src/configs/components/dataView.json +139 -0
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +399 -0
- package/src/configs/components/link.json +2 -2
- package/src/configs/components/listView.json +230 -0
- package/src/configs/components/navLayout.json +350 -0
- package/src/configs/components/swiper.json +3 -3
- package/src/configs/index.js +16 -0
- package/src/mp/components/button/index.js +12 -13
- package/src/mp/components/button/index.wxml +1 -1
- package/src/mp/components/calendar/arrowright--line.svg +11 -0
- package/src/mp/components/calendar/index.js +238 -0
- package/src/mp/components/calendar/index.json +4 -0
- package/src/mp/components/calendar/index.wxml +37 -0
- package/src/mp/components/calendar/index.wxss +178 -0
- package/src/mp/components/carousel/index.js +88 -0
- package/src/mp/components/carousel/index.json +7 -0
- package/src/mp/components/carousel/index.wxml +6 -0
- package/src/mp/components/chart/statisticsCard/index.js +226 -0
- package/src/mp/components/chart/statisticsCard/index.json +4 -0
- package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
- package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
- package/src/mp/components/dataView/index.js +34 -0
- package/src/mp/components/dataView/index.json +7 -0
- package/src/mp/components/dataView/index.wxml +15 -0
- package/src/mp/components/dataView/index.wxss +0 -0
- package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
- package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
- package/src/mp/components/form/location/index.js +341 -0
- package/src/mp/components/form/location/index.json +6 -0
- package/src/mp/components/form/location/index.wxml +25 -0
- package/src/mp/components/form/location/index.wxss +91 -0
- package/src/mp/components/form/uploader/index.js +39 -35
- package/src/mp/components/form/uploaderFile/index.js +61 -14
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +205 -0
- package/src/mp/components/graphicCard/index.json +4 -0
- package/src/mp/components/graphicCard/index.wxml +29 -0
- package/src/mp/components/graphicCard/index.wxss +157 -0
- package/src/mp/components/image/index.js +0 -1
- package/src/mp/components/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/listView/index.js +286 -0
- package/src/mp/components/listView/index.json +4 -0
- package/src/mp/components/listView/index.wxml +40 -0
- package/src/mp/components/listView/index.wxss +150 -0
- package/src/mp/components/listView/more-line.svg +3 -0
- package/src/mp/components/navLayout/index.js +123 -0
- package/src/mp/components/navLayout/index.json +7 -0
- package/src/mp/components/navLayout/index.wxml +25 -0
- package/src/mp/components/navLayout/index.wxss +1193 -0
- package/src/mp/components/swiper/index.wxml +2 -0
- package/src/mp/index.json +9 -1
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
- package/src/mp/utils/spark-md5.js +776 -0
- package/src/mp/utils/tcb.js +18 -0
- package/src/web/components/calendar/index.css +382 -0
- package/src/web/components/calendar/index.jsx +312 -0
- package/src/web/components/calendar/util.js +90 -0
- package/src/web/components/carousel/index.css +119 -0
- package/src/web/components/carousel/index.tsx +417 -0
- package/src/web/components/chart/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +286 -0
- package/src/web/components/chart/statisticsCard/interface.ts +14 -0
- package/src/web/components/dataView/index.tsx +20 -0
- package/src/web/components/dataView/interface.ts +6 -0
- package/src/web/components/form/location/common/mapChoose.css +178 -0
- package/src/web/components/form/location/common/mapChoose.jsx +343 -0
- package/src/web/components/form/location/common/mapView.jsx +190 -0
- package/src/web/components/form/location/common/propsConfig.js +54 -0
- package/src/web/components/form/location/common/selectModal.css +44 -0
- package/src/web/components/form/location/common/selectModal.jsx +82 -0
- package/src/web/components/form/location/common/useLocationInfo.js +100 -0
- package/src/web/components/form/location/components/LocationH5/index.css +243 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
- package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
- package/src/web/components/form/location/components/LocationPC/index.css +44 -0
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
- package/src/web/components/form/location/constants.js +4 -0
- package/src/web/components/form/location/index.css +0 -0
- package/src/web/components/form/location/index.jsx +25 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +16 -10
- package/src/web/components/form/uploader/uploader.pc.tsx +15 -11
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +122 -107
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +22 -19
- package/src/web/components/graphicCard/index.css +163 -0
- package/src/web/components/graphicCard/index.tsx +309 -0
- package/src/web/components/image/image.tsx +0 -1
- package/src/web/components/index.js +12 -0
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +139 -0
- package/src/web/components/listView/index.tsx +354 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- package/src/web/components/tabs/index.tsx +2 -2
- package/src/web/components/tabs/tabs.h5.tsx +7 -4
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +31 -0
- package/src/web/utils/tcb.js +35 -0
- package/src/web/utils/tmap.js +4 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取一个日期是周几(1~7)
|
|
5
|
+
*/
|
|
6
|
+
export const getDay = (dt) => {
|
|
7
|
+
let day = dayjs(dt).day();
|
|
8
|
+
if (day === 0) {
|
|
9
|
+
day = 7;
|
|
10
|
+
}
|
|
11
|
+
return day;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 创建日历单元格数据
|
|
16
|
+
* @param year 日历年份
|
|
17
|
+
* @param month 日历月份
|
|
18
|
+
* @param firstDayOfWeek 周起始日(1~7)
|
|
19
|
+
* @param currentValue 当前日期
|
|
20
|
+
* @param format 日期格式
|
|
21
|
+
*/
|
|
22
|
+
export const createDateList = (
|
|
23
|
+
year,
|
|
24
|
+
month,
|
|
25
|
+
firstDayOfWeek,
|
|
26
|
+
currentValue,
|
|
27
|
+
format
|
|
28
|
+
) => {
|
|
29
|
+
const createCellData = (belongTo, isCurrent, date, weekOrder) => {
|
|
30
|
+
const day = getDay(date);
|
|
31
|
+
return {
|
|
32
|
+
mode: 'month',
|
|
33
|
+
belongTo,
|
|
34
|
+
isCurrent,
|
|
35
|
+
day,
|
|
36
|
+
weekOrder,
|
|
37
|
+
date,
|
|
38
|
+
formattedDate: dayjs(date).format(format),
|
|
39
|
+
filterDate: null,
|
|
40
|
+
formattedFilterDate: null,
|
|
41
|
+
isShowWeekend: true,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const monthFirstDay = dayjs(`${year}-${month}`);
|
|
46
|
+
const rowList = [];
|
|
47
|
+
let list = [];
|
|
48
|
+
let weekCount = 1;
|
|
49
|
+
|
|
50
|
+
// 添加上个月中会在本月显示的最后几天日期
|
|
51
|
+
// getDay(monthFirstDay.toDate()) 获取每月第一天是周几
|
|
52
|
+
const lastMonthDaysCount =
|
|
53
|
+
(getDay(monthFirstDay.toDate()) - firstDayOfWeek + 7) % 7;
|
|
54
|
+
for (let i = 0; i < lastMonthDaysCount; i++) {
|
|
55
|
+
// 获取显示在当前月的日历中,上月日期数据
|
|
56
|
+
// monthFirstDay.subtract(num, 'day' | 'month' | 'year') 表示以当月第一天日期为基准,在 日|月|年 数字上减去num
|
|
57
|
+
const dayObj = monthFirstDay.subtract(i + 1, 'day');
|
|
58
|
+
list.unshift(createCellData(-1, false, dayObj.toDate(), weekCount));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 添加本月日期
|
|
62
|
+
// 获取本月最后一天是几号
|
|
63
|
+
const monthDaysCount = monthFirstDay.endOf('month').daysInMonth();
|
|
64
|
+
for (let i = 0; i < monthDaysCount; i++) {
|
|
65
|
+
const dayObj = monthFirstDay.add(i, 'day');
|
|
66
|
+
list.push(
|
|
67
|
+
createCellData(0, currentValue.isSame(dayObj), dayObj.toDate(), weekCount)
|
|
68
|
+
);
|
|
69
|
+
if (list.length === 7) {
|
|
70
|
+
rowList.push(list);
|
|
71
|
+
list = [];
|
|
72
|
+
weekCount += 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 添加下月日期
|
|
77
|
+
if (list.length) {
|
|
78
|
+
// 获取当月最后一天
|
|
79
|
+
const monthLastDay = dayjs(`${year}-${month}`).endOf('month');
|
|
80
|
+
// 获取下月在当月日历中的天数
|
|
81
|
+
const nextMonthDaysCount = 7 - list.length;
|
|
82
|
+
for (let i = 0; i < nextMonthDaysCount; i++) {
|
|
83
|
+
const dayObj = monthLastDay.add(i + 1, 'day');
|
|
84
|
+
list.push(createCellData(1, false, dayObj.toDate(), weekCount));
|
|
85
|
+
}
|
|
86
|
+
rowList.push(list);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return rowList;
|
|
90
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.g-swiper {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
margin: auto;
|
|
4
|
+
width: 100%;
|
|
5
|
+
transition: height 0.15s ease-in;
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.g-carousel {
|
|
10
|
+
height: 320px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.g-swiper-list {
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
display: flex;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.g-swiper-item {
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
flex-flow: column;
|
|
24
|
+
min-width: 100%;
|
|
25
|
+
max-height: 100%;
|
|
26
|
+
margin: 0;
|
|
27
|
+
text-align: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.g-swiper.vertical {
|
|
31
|
+
display: flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.g-swiper.vertical .g-swiper-list {
|
|
35
|
+
display: block;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.g-swiper.vertical .g-swiper-item {
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.g-swiper-item > div > * {
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: auto;
|
|
45
|
+
max-width: 100%;
|
|
46
|
+
max-height: 100%;
|
|
47
|
+
object-fit: cover;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* .g-swiper-item > div,
|
|
51
|
+
.g-swiper-item > div > .weda-image {
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
max-height: 100%;
|
|
56
|
+
} */
|
|
57
|
+
|
|
58
|
+
.g-swiper__pagination {
|
|
59
|
+
position: absolute;
|
|
60
|
+
bottom: 0;
|
|
61
|
+
margin: 10px 0;
|
|
62
|
+
padding: 0;
|
|
63
|
+
text-align: center;
|
|
64
|
+
width: 100%;
|
|
65
|
+
z-index: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.g-swiper__pagination-bulletm {
|
|
69
|
+
background: #fff;
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
box-shadow: 1px 1px 2px rgb(0 0 0 / 70%);
|
|
72
|
+
width: 8px;
|
|
73
|
+
height: 8px;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
margin: 0 8px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (max-width: 1024px) {
|
|
79
|
+
.g-swiper .g-swiper__turn-pre,
|
|
80
|
+
.g-swiper .g-swiper__turn-next {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.g-swiper__turn-pre,
|
|
86
|
+
.g-swiper__turn-next {
|
|
87
|
+
position: absolute;
|
|
88
|
+
box-sizing: content-box;
|
|
89
|
+
display: block;
|
|
90
|
+
top: 50%;
|
|
91
|
+
transform: translate3d(0, -50%, 0);
|
|
92
|
+
font-size: 0;
|
|
93
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
94
|
+
padding: 20px 10px;
|
|
95
|
+
width: 23px;
|
|
96
|
+
height: 41px;
|
|
97
|
+
background-position: center;
|
|
98
|
+
background-repeat: no-repeat;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.g-swiper__turn-pre {
|
|
102
|
+
left: 20px;
|
|
103
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAApCAYAAADeWrJ9AAAABGdBTUEAALGPC/xhBQAAAbpJREFUSA2t178rxHEcx/E7p/MrP9KRRbFcMZHBIBkMSjYyKEpXJIMkww3KcIOkxKAsBmWQDEQSgyRJUkKZFANJRBLy4+v51udT/oDXp569660e32933X1PKCQ8QRCEaZa6hWwo5OAZpp05GQ5mdzxtKmeBIkp88o8NgkU1POHgJTU85uBlZlT5UqQcvKKGRx28roZHHLzBzFC+FEkHbzKzlPCwg7eZ2Up40ME7angA8Id2KUd5x/0O3mPmKuFeB+8z85VwwsGHargb8JuOqEB5x12AX3RMhUq4w8EnzJgSbnfwKbNICbcBftI5FctgoDRqpXSyR5PuiwjMHqxRWiU7l1Rme9kBtAv00AddUVyGewi0md7ohir8XjZBG+mV7qhKBnsItJ6e6YFq/F42QWvpkZ6oTgZ7CLSa7umFGvxeNkEr6ZbsfWiSwR4CjdM1vVOL38smaDnZh8w+C20y2EOgpXRB9rXc4feyCVpCZ+4CCRnsIeAY2QPFfhX0+b1sghbQgbvAkAz2EHAe2e8ZO0m/l03QbNoynZOSwR4CzaQ10znjFPZ/k0xAeybYfxh2piTofwQ0QvPUaftfzME87zp8MlQAAAAASUVORK5CYII=);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.g-swiper__turn-next {
|
|
107
|
+
right: 20px;
|
|
108
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAApCAYAAADeWrJ9AAAABGdBTUEAALGPC/xhBQAAAZpJREFUSA21l7ErhHEYgO9cznUR6ZTBcAvFRMpCGQxKxstwJV1XlJQkyw0y3CJJLDJYZJEMSCKDJEmSQpkUA0lEEko+z3u9/oP3fevp1y3P87uv7/t+d6EQEwRBBhYgLJ9NB+kiyMyDbQBhBJZBZg5cAisFfRDMmF4akSGWb7CqgWmPQDHyNQ1MegSiyNc1kPcKbGlgwiuwrYFxj0AM+Y4Gch6BOPI9DYx5BfY1MOIVONDAsEegFPkh/MKQR6Ac8ZEGBrwCJxrIegVONZDxCFQiP4Mf6PMIJBCfayDtEahCfqGBHq/AlQZSRcaFEnwRJWXmZrdJuAGZDYiayBHVwi18Qz+YieuR3cMndJnsViTIGuERPqDDUtyM8BneoM1S3IrwFV6gxVLcjvAdnqDJUtyJUK7vAzRYirsRfsEd1FmKUwjlHpaHJGkpTiOU1+k11FiKsyq+ZK22FA8ilENYDoKEpXhUxcesFZbiHEIZ+X1SZinOF7RBsMsaNxEjCsOUijdZYyZikSCbVbH8o7B5F//vDmEvLIEcUWbzB99VPOowvSXGAAAAAElFTkSuQmCC);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.g-swiper__turn-pre:hover,
|
|
112
|
+
.g-swiper__turn-next:hover {
|
|
113
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
._editor-iframe
|
|
117
|
+
._wa-comp-container-empty-children:not(._wa-comp-slot-wrapper):after {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import classNames from '../../utils/classnames';
|
|
4
|
+
import Swipe from 'react-easy-swipe';
|
|
5
|
+
import {
|
|
6
|
+
useDebouncedCallback,
|
|
7
|
+
useEventListener,
|
|
8
|
+
useResizeObserver,
|
|
9
|
+
} from '@react-hookz/web';
|
|
10
|
+
|
|
11
|
+
import './index.css';
|
|
12
|
+
import { CommonPropsType } from '../../types';
|
|
13
|
+
|
|
14
|
+
import Image from '../image';
|
|
15
|
+
interface imagesItem {
|
|
16
|
+
image: string;
|
|
17
|
+
title: string;
|
|
18
|
+
tapMode: 'tap' | 'inside' | 'outer';
|
|
19
|
+
fit: React.CSSProperties['objectFit'];
|
|
20
|
+
height: string;
|
|
21
|
+
width: string;
|
|
22
|
+
insideUrl?: string;
|
|
23
|
+
outerUrl?: string;
|
|
24
|
+
newPage?: boolean;
|
|
25
|
+
params?: { key: string; value: string }[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PropsType extends CommonPropsType {
|
|
29
|
+
/**
|
|
30
|
+
* 是否启用指示点
|
|
31
|
+
*/
|
|
32
|
+
indicatorDots: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 是否自动切换
|
|
35
|
+
*/
|
|
36
|
+
autoplay: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 当前索引值
|
|
39
|
+
*/
|
|
40
|
+
current: number;
|
|
41
|
+
interval: number;
|
|
42
|
+
duration: number;
|
|
43
|
+
circular: boolean;
|
|
44
|
+
vertical: boolean;
|
|
45
|
+
indicatorColor: string;
|
|
46
|
+
indicatorActiveColor: string;
|
|
47
|
+
images: Array<imagesItem>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default function Carousel({
|
|
51
|
+
className,
|
|
52
|
+
style = {},
|
|
53
|
+
autoplay = true,
|
|
54
|
+
circular = true,
|
|
55
|
+
vertical = false,
|
|
56
|
+
indicatorDots,
|
|
57
|
+
indicatorColor = 'rgba(200, 200, 200, 0.9)',
|
|
58
|
+
indicatorActiveColor = 'rgba(0, 0, 0, 0.9)',
|
|
59
|
+
duration = 500,
|
|
60
|
+
interval = 5000,
|
|
61
|
+
current = 0,
|
|
62
|
+
events = {},
|
|
63
|
+
id,
|
|
64
|
+
images,
|
|
65
|
+
}: PropsType) {
|
|
66
|
+
const itemCount = images.length;
|
|
67
|
+
current = Math.max(0, Math.min(itemCount - 1, current));
|
|
68
|
+
|
|
69
|
+
const [currentIndex, setCurrentIndex] = useState(current);
|
|
70
|
+
const [swipeStyle, setSwipeStyle] = useState(null);
|
|
71
|
+
const [height, setHeight] = useState(0);
|
|
72
|
+
|
|
73
|
+
const { change = () => {} } = events;
|
|
74
|
+
|
|
75
|
+
// 自动切换
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (autoplay) {
|
|
78
|
+
const timer = setInterval(() => {
|
|
79
|
+
setIndex(currentIndex + 1);
|
|
80
|
+
}, interval);
|
|
81
|
+
|
|
82
|
+
return () => clearInterval(timer);
|
|
83
|
+
}
|
|
84
|
+
}, [currentIndex, autoplay]);
|
|
85
|
+
|
|
86
|
+
// 触发切换
|
|
87
|
+
const pre = useRef({ index: currentIndex }).current;
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
updateSwipeStyle(currentIndex, pre.index, itemCount);
|
|
90
|
+
change({
|
|
91
|
+
current: currentIndex,
|
|
92
|
+
});
|
|
93
|
+
return () => {
|
|
94
|
+
pre.index = currentIndex;
|
|
95
|
+
};
|
|
96
|
+
}, [currentIndex, vertical]);
|
|
97
|
+
|
|
98
|
+
const outerWrapRef = useRef<HTMLDivElement>();
|
|
99
|
+
useEventListener(outerWrapRef, 'load', (e) => {
|
|
100
|
+
setHeight(e.target.clientHeight);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const itemsClone = images.map((x, i) => {
|
|
104
|
+
return (
|
|
105
|
+
<div className="g-swiper-item" data-index={i} key={i}>
|
|
106
|
+
<Image
|
|
107
|
+
mode={'scaleToFill'}
|
|
108
|
+
lazyLoad={false}
|
|
109
|
+
maskClosable={false}
|
|
110
|
+
imgPreview={false}
|
|
111
|
+
src={x.image}
|
|
112
|
+
alt={'图片'}
|
|
113
|
+
fit={x.fit}
|
|
114
|
+
style={{
|
|
115
|
+
height: x.height ? x.height : 'auto',
|
|
116
|
+
width: x.width ? x.width : '100%',
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const setIndex = (index) => {
|
|
124
|
+
if (index >= itemCount) {
|
|
125
|
+
index = 0;
|
|
126
|
+
}
|
|
127
|
+
if (index < 0) {
|
|
128
|
+
index = itemCount - 1;
|
|
129
|
+
}
|
|
130
|
+
setCurrentIndex(index);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// 设置容器样式、动画
|
|
134
|
+
// TODO fix settimeout mess
|
|
135
|
+
const updateSwipeStyle = (to, cur, length) => {
|
|
136
|
+
let style;
|
|
137
|
+
// 最后向前到最开始
|
|
138
|
+
if (to === 0 && cur === length - 1) {
|
|
139
|
+
circular &&
|
|
140
|
+
setSwipeStyle({
|
|
141
|
+
transform: `translate3d(0, 0, 0)`,
|
|
142
|
+
});
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
setSwipeStyle({
|
|
145
|
+
transform: vertical
|
|
146
|
+
? `translate3d(0, -100%, 0)`
|
|
147
|
+
: `translate3d(-100%, 0, 0)`,
|
|
148
|
+
transitionDuration: `${duration}ms`,
|
|
149
|
+
});
|
|
150
|
+
}, 50);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 第一个后退到最后
|
|
155
|
+
if (to === length - 1 && cur === 0) {
|
|
156
|
+
circular &&
|
|
157
|
+
setSwipeStyle({
|
|
158
|
+
transform: vertical
|
|
159
|
+
? `translate3d(0, -${(to + 2) * 100}%, 0)`
|
|
160
|
+
: `translate3d(-${(to + 2) * 100}%, 0, 0)`,
|
|
161
|
+
});
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
setSwipeStyle({
|
|
164
|
+
transform: vertical
|
|
165
|
+
? `translate3d(0, -${(to + 1) * 100}%, 0)`
|
|
166
|
+
: `translate3d(-${(to + 1) * 100}%, 0, 0)`,
|
|
167
|
+
transitionDuration: `${duration}ms`,
|
|
168
|
+
});
|
|
169
|
+
}, 50);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
style = {
|
|
174
|
+
transform: vertical
|
|
175
|
+
? `translate3d(0, -${(to + 1) * 100}%, 0)`
|
|
176
|
+
: `translate3d(-${(to + 1) * 100}%, 0, 0)`,
|
|
177
|
+
};
|
|
178
|
+
if (to !== cur) {
|
|
179
|
+
style.transitionDuration = `${duration}ms`;
|
|
180
|
+
}
|
|
181
|
+
setSwipeStyle(style);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<div
|
|
186
|
+
className={classNames('g-swiper weda-ui g-carousel', className, {
|
|
187
|
+
vertical: vertical,
|
|
188
|
+
})}
|
|
189
|
+
style={{ height: height ? height : 'auto', ...style }}
|
|
190
|
+
ref={outerWrapRef}
|
|
191
|
+
id={id}
|
|
192
|
+
data-testid="carousel"
|
|
193
|
+
>
|
|
194
|
+
{itemCount > 0 ? (
|
|
195
|
+
<Swipe
|
|
196
|
+
className="g-swiper-list"
|
|
197
|
+
style={swipeStyle}
|
|
198
|
+
tolerance={20}
|
|
199
|
+
onSwipeLeft={() => {
|
|
200
|
+
vertical || setIndex(currentIndex + 1);
|
|
201
|
+
}}
|
|
202
|
+
onSwipeRight={() => {
|
|
203
|
+
vertical || setIndex(currentIndex - 1);
|
|
204
|
+
}}
|
|
205
|
+
onSwipeDown={() => {
|
|
206
|
+
vertical && setIndex(currentIndex - 1);
|
|
207
|
+
}}
|
|
208
|
+
onSwipeUp={() => {
|
|
209
|
+
vertical && setIndex(currentIndex + 1);
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
{itemsClone[itemCount - 1]}
|
|
213
|
+
{images.map((x, i) => {
|
|
214
|
+
return (
|
|
215
|
+
<SwiperItem
|
|
216
|
+
setHeight={setHeight}
|
|
217
|
+
currentIndex={currentIndex}
|
|
218
|
+
index={i}
|
|
219
|
+
key={i}
|
|
220
|
+
imagesValue={x}
|
|
221
|
+
>
|
|
222
|
+
<Image
|
|
223
|
+
mode={'scaleToFill'}
|
|
224
|
+
lazyLoad={false}
|
|
225
|
+
maskClosable={false}
|
|
226
|
+
imgPreview={false}
|
|
227
|
+
fit={x.fit}
|
|
228
|
+
src={x.image}
|
|
229
|
+
alt={'图片'}
|
|
230
|
+
style={{
|
|
231
|
+
height: x.height ? x.height : 'auto',
|
|
232
|
+
width: x.width ? x.width : '100%',
|
|
233
|
+
}}
|
|
234
|
+
/>
|
|
235
|
+
</SwiperItem>
|
|
236
|
+
);
|
|
237
|
+
})}
|
|
238
|
+
{itemsClone[0]}
|
|
239
|
+
</Swipe>
|
|
240
|
+
) : null}
|
|
241
|
+
|
|
242
|
+
{indicatorDots ? (
|
|
243
|
+
<div className="g-swiper__pagination">
|
|
244
|
+
{images.map((x, i) => {
|
|
245
|
+
return (
|
|
246
|
+
<a
|
|
247
|
+
key={i}
|
|
248
|
+
href="#"
|
|
249
|
+
className="g-swiper__pagination-bulletm"
|
|
250
|
+
data-testid="g-swiper__pagination-bulletm"
|
|
251
|
+
style={{
|
|
252
|
+
backgroundColor:
|
|
253
|
+
currentIndex === i ? indicatorActiveColor : indicatorColor,
|
|
254
|
+
}}
|
|
255
|
+
onClick={(e) => {
|
|
256
|
+
setIndex(i);
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
}}
|
|
259
|
+
data-index={i}
|
|
260
|
+
></a>
|
|
261
|
+
);
|
|
262
|
+
})}
|
|
263
|
+
</div>
|
|
264
|
+
) : (
|
|
265
|
+
false
|
|
266
|
+
)}
|
|
267
|
+
<a
|
|
268
|
+
href="#"
|
|
269
|
+
className="g-swiper__turn-pre"
|
|
270
|
+
onClick={(ev) => {
|
|
271
|
+
ev.preventDefault();
|
|
272
|
+
setIndex(currentIndex - 1);
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
上一页
|
|
276
|
+
</a>
|
|
277
|
+
<a
|
|
278
|
+
href="#"
|
|
279
|
+
className="g-swiper__turn-next"
|
|
280
|
+
onClick={(ev) => {
|
|
281
|
+
ev.preventDefault();
|
|
282
|
+
setIndex(currentIndex + 1);
|
|
283
|
+
}}
|
|
284
|
+
>
|
|
285
|
+
下一页
|
|
286
|
+
</a>
|
|
287
|
+
</div>
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const SwiperItem: React.FC<{
|
|
292
|
+
setHeight: React.Dispatch<React.SetStateAction<number>>;
|
|
293
|
+
currentIndex: number;
|
|
294
|
+
index: number;
|
|
295
|
+
children?: React.ReactNode;
|
|
296
|
+
imagesValue: imagesItem;
|
|
297
|
+
}> = ({ setHeight, children, currentIndex, index, imagesValue }) => {
|
|
298
|
+
const firstChildRef = useRef<HTMLDivElement>(null);
|
|
299
|
+
const syncHeight = useDebouncedCallback(
|
|
300
|
+
(e) => {
|
|
301
|
+
// console.log('e.contentRect.height', e.contentRect.height);
|
|
302
|
+
setHeight(e.contentRect.height);
|
|
303
|
+
},
|
|
304
|
+
[setHeight],
|
|
305
|
+
500,
|
|
306
|
+
2000
|
|
307
|
+
); // 必须debounce延迟,让resize完成后再设置高度
|
|
308
|
+
|
|
309
|
+
// 因为有loading 所以得用resizeobserver
|
|
310
|
+
// @ts-ignore
|
|
311
|
+
useResizeObserver(firstChildRef, (e) => {
|
|
312
|
+
if (currentIndex === index) {
|
|
313
|
+
syncHeight(e);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
const getLinkUrl = (url, params) => {
|
|
318
|
+
// URL 构造函数不支持 '//xxx.com' 的格式
|
|
319
|
+
if (url && url.indexOf('//') === 0) {
|
|
320
|
+
url = location.protocol + url;
|
|
321
|
+
}
|
|
322
|
+
// "proto:" 或 "//" 起头的是绝对路径
|
|
323
|
+
let isAbosolutePath = /^(?:[a-z]+:)/i.test(url);
|
|
324
|
+
let base,
|
|
325
|
+
path,
|
|
326
|
+
href,
|
|
327
|
+
paramObj = {},
|
|
328
|
+
urlObj;
|
|
329
|
+
if (!isAbosolutePath) {
|
|
330
|
+
// 相对地址使用站位域名,不实际使用
|
|
331
|
+
base =
|
|
332
|
+
location.origin && location.origin !== 'null'
|
|
333
|
+
? location.origin
|
|
334
|
+
: 'https://we.da';
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
try {
|
|
338
|
+
urlObj = new URL(url, base);
|
|
339
|
+
params.forEach((x) => {
|
|
340
|
+
urlObj.searchParams.append(x.key, x.value);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
href = urlObj.href;
|
|
344
|
+
path = urlObj.pathname;
|
|
345
|
+
|
|
346
|
+
for (const [key, value] of urlObj.searchParams) {
|
|
347
|
+
paramObj[key] = value;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// 相对地址去掉站位域名
|
|
351
|
+
if (!isAbosolutePath) {
|
|
352
|
+
href = urlObj.pathname + urlObj.search + urlObj.hash;
|
|
353
|
+
href = href.replace(/^\//, '');
|
|
354
|
+
}
|
|
355
|
+
} catch (e) {
|
|
356
|
+
// 非法 url
|
|
357
|
+
isAbosolutePath = true;
|
|
358
|
+
href = url;
|
|
359
|
+
path = '';
|
|
360
|
+
paramObj = params.reduce((p, x) => {
|
|
361
|
+
p[x.key] = x.value;
|
|
362
|
+
return p;
|
|
363
|
+
}, {});
|
|
364
|
+
}
|
|
365
|
+
let res = {
|
|
366
|
+
path,
|
|
367
|
+
isAbosolutePath,
|
|
368
|
+
href,
|
|
369
|
+
};
|
|
370
|
+
return res;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const handleImage = (e) => {
|
|
374
|
+
const { insideUrl, outerUrl, tapMode, params, newPage } = imagesValue;
|
|
375
|
+
if (tapMode === 'tap') {
|
|
376
|
+
return;
|
|
377
|
+
} else if (tapMode === 'inside' && !insideUrl) {
|
|
378
|
+
return;
|
|
379
|
+
} else if (tapMode === 'outer' && !outerUrl) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
let selectedUrl = tapMode === 'inside' ? insideUrl : outerUrl;
|
|
383
|
+
let { path, isAbosolutePath, href } = getLinkUrl(selectedUrl, []);
|
|
384
|
+
let paramObj =
|
|
385
|
+
params &&
|
|
386
|
+
params.length > 0 &&
|
|
387
|
+
params.reduce((p, x) => {
|
|
388
|
+
p[x.key] = x.value;
|
|
389
|
+
return p;
|
|
390
|
+
}, {});
|
|
391
|
+
if (tapMode === 'inside') {
|
|
392
|
+
if (!isAbosolutePath) {
|
|
393
|
+
e.preventDefault();
|
|
394
|
+
app.navigateTo({
|
|
395
|
+
pageId: path,
|
|
396
|
+
packageName: '',
|
|
397
|
+
mode: 'weDa',
|
|
398
|
+
params: paramObj,
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
} else if (tapMode === 'outer') {
|
|
402
|
+
newPage ? window.open(href) : (location.href = href);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
return (
|
|
406
|
+
<div
|
|
407
|
+
className={classNames('g-swiper-item', {
|
|
408
|
+
current: index === currentIndex,
|
|
409
|
+
})}
|
|
410
|
+
data-index={index}
|
|
411
|
+
onClick={handleImage}
|
|
412
|
+
data-testid="swiper-item"
|
|
413
|
+
>
|
|
414
|
+
<div ref={firstChildRef}>{children}</div>
|
|
415
|
+
</div>
|
|
416
|
+
);
|
|
417
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* pc style */
|
|
2
|
+
.weda-statistics-card {
|
|
3
|
+
background: #ffffff;
|
|
4
|
+
border: 1px solid #f1f2f5;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1);
|
|
7
|
+
border-radius: 6px;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
.weda-statistics-card.weda-statistics-card-pc {
|
|
11
|
+
width: 276px;
|
|
12
|
+
min-height: 128px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.weda-statistics-card .weda-statistics-card__wrapper {
|
|
16
|
+
width: 100%;
|
|
17
|
+
padding: 28px 24px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.weda-statistics-card .weda-statistics-card__title {
|
|
21
|
+
font-size: 14px;
|
|
22
|
+
line-height: 22px;
|
|
23
|
+
color: rgba(0, 0, 0, 0.6);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.weda-statistics-card .weda-statistics-card__detail {
|
|
27
|
+
margin-top: 8px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.weda-statistics-card .weda-statistics-card__count {
|
|
31
|
+
font-size: 32px;
|
|
32
|
+
line-height: 44px;
|
|
33
|
+
color: rgba(0, 0, 0, 0.9);
|
|
34
|
+
word-break: break-all;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.weda-statistics-card .weda-statistics-card__unit {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
line-height: 22px;
|
|
40
|
+
color: rgba(0, 0, 0, 0.4);
|
|
41
|
+
margin-left: 4px;
|
|
42
|
+
vertical-align: middle;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* h5 style */
|
|
46
|
+
.weda-statistics-card.weda-statistics-card-mobile {
|
|
47
|
+
max-width: 100%;
|
|
48
|
+
min-height: 140px;
|
|
49
|
+
}
|
|
50
|
+
.weda-statistics-card-mobile .weda-statistics-card__wrapper {
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: 40px 24px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.weda-statistics-card-mobile .weda-statistics-card__detail {
|
|
56
|
+
margin-top: 4px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.weda-statistics-card-mobile .weda-statistics-card__count {
|
|
60
|
+
font-size: 28px;
|
|
61
|
+
line-height: 34px;
|
|
62
|
+
}
|