@cloudbase/weda-ui 0.2.17 → 1.0.21
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/README.md +3 -0
- package/package.json +6 -3
- package/src/configs/components/calendar.json +4 -1
- package/src/configs/components/chart/bar.json +19 -6
- package/src/configs/components/chart/line.json +19 -6
- package/src/configs/components/chart/pie.json +14 -4
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +21 -6
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/graphicCard.json +84 -73
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +19 -3
- package/src/configs/components/listView.json +63 -17
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +87 -75
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +4 -1
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +11 -0
- package/src/mp/components/chart/bar/index.js +6 -2
- package/src/mp/components/chart/common/core/eChartBar.js +9 -8
- package/src/mp/components/chart/common/core/eChartBase.js +20 -16
- package/src/mp/components/chart/common/core/eChartLine.js +6 -5
- package/src/mp/components/chart/line/index.js +10 -6
- package/src/mp/components/chart/pie/index.js +6 -2
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/dataView/index.json +1 -1
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/radio/index.js +34 -1
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +17 -2
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/uploader/index.js +39 -27
- package/src/mp/components/form/uploaderFile/index.js +10 -6
- package/src/mp/components/listView/index.js +33 -27
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/{internals/listView → wxOpenApi/phone}/index.json +0 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +7 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/platform.js +10 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/chart/bar/index.tsx +40 -39
- package/src/web/components/chart/common/core/eChartBar.js +7 -6
- package/src/web/components/chart/common/core/eChartBase.ts +20 -16
- package/src/web/components/chart/common/core/eChartLine.js +8 -6
- package/src/web/components/chart/line/index.tsx +40 -39
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +388 -72
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +404 -144
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +89 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +9 -2
- package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +7 -0
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +6 -1
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/platform.js +9 -0
- package/src/web/utils/tcb.js +26 -0
- package/src/web/weda-ui.css +2 -0
- package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
- package/src/mp/components/internals/listView/index.js +0 -286
- package/src/mp/components/internals/listView/index.wxml +0 -40
- package/src/mp/components/internals/listView/index.wxss +0 -150
- package/src/mp/components/internals/listView/more-line.svg +0 -3
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -1,30 +1,43 @@
|
|
|
1
|
+
import { useCustomCompareEffect, useMountEffect, useSyncedRef } from '@react-hookz/web';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { Tabs as TeaTabs, TabPanel, ConfigProvider } from 'tea-component';
|
|
3
4
|
import classNames from '../../utils/classnames';
|
|
5
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
4
6
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
5
7
|
import { PropsType } from './index';
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
export default function TabsPc({
|
|
9
|
-
tabs,
|
|
11
|
+
tabs = [],
|
|
10
12
|
selectedIndex,
|
|
11
13
|
events,
|
|
12
14
|
className,
|
|
13
15
|
style,
|
|
16
|
+
isMultipleSlot = true,
|
|
14
17
|
...restProps
|
|
15
18
|
}: PropsType) {
|
|
16
19
|
|
|
17
20
|
const [activeIndex, setActiveIndex] = useSyncValue(selectedIndex);
|
|
18
|
-
const _tabs =
|
|
19
|
-
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const _tabs = React.useMemo(() => {
|
|
22
|
+
return Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
|
|
23
|
+
return {
|
|
24
|
+
id: index.toString(),
|
|
25
|
+
label: item.title,
|
|
26
|
+
value: item.value
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}, [tabs]);
|
|
24
30
|
|
|
31
|
+
const eventsRef = useSyncedRef(events);
|
|
32
|
+
useCustomCompareEffect(() => {
|
|
33
|
+
eventsRef.current && eventsRef.current.change({
|
|
34
|
+
id: _tabs[activeIndex]?.id,
|
|
35
|
+
label: _tabs[activeIndex]?.label,
|
|
36
|
+
value: _tabs[activeIndex]?.value,
|
|
37
|
+
});
|
|
38
|
+
}, [activeIndex, _tabs], isObjectEqual);
|
|
25
39
|
const onActive = (e) => {
|
|
26
40
|
setActiveIndex(e.id);
|
|
27
|
-
events && events.change(e);
|
|
28
41
|
};
|
|
29
42
|
return (
|
|
30
43
|
<ConfigProvider classPrefix="wedatea2td">
|
|
@@ -40,11 +53,11 @@ export default function TabsPc({
|
|
|
40
53
|
key={item.id}
|
|
41
54
|
id={item.id}
|
|
42
55
|
>
|
|
43
|
-
{restProps[`panel${index + 1}`]}
|
|
56
|
+
{isMultipleSlot ? restProps[`panel${index + 1}`] : restProps['panel1']}
|
|
44
57
|
</TabPanel>
|
|
45
58
|
)
|
|
46
59
|
)}
|
|
47
60
|
</TeaTabs>
|
|
48
61
|
</ConfigProvider>
|
|
49
62
|
);
|
|
50
|
-
}
|
|
63
|
+
}
|
|
@@ -21,8 +21,6 @@ export default function Text({
|
|
|
21
21
|
maxLines = 2,
|
|
22
22
|
space = false,
|
|
23
23
|
userSelect = true,
|
|
24
|
-
textAlign = '',
|
|
25
|
-
textColor = '',
|
|
26
24
|
style = {},
|
|
27
25
|
className,
|
|
28
26
|
events,
|
|
@@ -42,23 +40,17 @@ export default function Text({
|
|
|
42
40
|
}
|
|
43
41
|
const levelName = level === '0' ? '' : `level_${level}`;
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 添加对齐属性
|
|
52
|
-
if (textAlign !== "") {
|
|
53
|
-
style2 = {...style2, textAlign};
|
|
54
|
-
}
|
|
43
|
+
const inlineStyle = React.useMemo(
|
|
44
|
+
() => ({ ...textStyle, ...style }),
|
|
45
|
+
[textStyle, style]
|
|
46
|
+
);
|
|
55
47
|
return (
|
|
56
48
|
<p
|
|
57
49
|
//@ts-expect-error contentEditable type def sucks
|
|
58
50
|
contentEditable={contenteditable}
|
|
59
51
|
onInput={onInput}
|
|
60
52
|
onBlur={onBlur}
|
|
61
|
-
style={
|
|
53
|
+
style={inlineStyle}
|
|
62
54
|
className={classNames('weda-text', 'weda-ui', className, levelName)}
|
|
63
55
|
id={id}
|
|
64
56
|
onClick={(e) => events.tap({}, { originEvent: e })}
|
|
@@ -66,4 +58,4 @@ export default function Text({
|
|
|
66
58
|
{text}
|
|
67
59
|
</p>
|
|
68
60
|
);
|
|
69
|
-
}
|
|
61
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Button from '../../components/button';
|
|
3
|
+
import { CommonPropsType } from '../../types';
|
|
4
|
+
|
|
5
|
+
const UserInfo = (props: PropsType) => <Button {...props} />;
|
|
6
|
+
|
|
7
|
+
export interface PropsType extends CommonPropsType {
|
|
8
|
+
/**
|
|
9
|
+
* 按钮标题
|
|
10
|
+
*/
|
|
11
|
+
text?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按钮风格
|
|
14
|
+
*/
|
|
15
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
16
|
+
/**
|
|
17
|
+
* 按钮大小
|
|
18
|
+
*/
|
|
19
|
+
size?: 'default' | 'mini' | 'large';
|
|
20
|
+
/**
|
|
21
|
+
* 信息用途
|
|
22
|
+
*/
|
|
23
|
+
usage?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 语言
|
|
26
|
+
*/
|
|
27
|
+
language?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default UserInfo;
|
|
@@ -132,3 +132,12 @@ export const transFileCloudidToName = (fileID) => {
|
|
|
132
132
|
const title = name.replace(uuidReg, '');
|
|
133
133
|
return title;
|
|
134
134
|
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 判断是否是url
|
|
138
|
+
*/
|
|
139
|
+
const reg =
|
|
140
|
+
// eslint-disable-next-line no-useless-escape
|
|
141
|
+
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
|
142
|
+
|
|
143
|
+
export const isUrl = (path) => reg.test(path);
|
package/src/web/utils/tcb.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isInIde } from './platform';
|
|
1
2
|
/**
|
|
2
3
|
* 云存储/云函数相关
|
|
3
4
|
*/
|
|
@@ -54,6 +55,31 @@ export async function callDataSource(param) {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
/**
|
|
59
|
+
* 云API:获取用户自定义导航内容
|
|
60
|
+
* param
|
|
61
|
+
* WeAppId: string,
|
|
62
|
+
* EnvId: string,
|
|
63
|
+
* PublishType?: string,
|
|
64
|
+
*/
|
|
65
|
+
export async function getAppCustomNav() {
|
|
66
|
+
try {
|
|
67
|
+
const PublishType = isInIde() ? 'preview' : '';
|
|
68
|
+
const WeAppId = window?.app?.id;
|
|
69
|
+
const res = await callWedaApi({
|
|
70
|
+
action: 'DescribeAppCustomNav',
|
|
71
|
+
serviceType: 'lowcode',
|
|
72
|
+
data: {
|
|
73
|
+
WeAppId,
|
|
74
|
+
PublishType,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
return res;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('错误', error);
|
|
80
|
+
return {};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
57
83
|
|
|
58
84
|
export function callWedaApi(...args) {
|
|
59
85
|
return window.app.cloud.callWedaApi(...args);
|
package/src/web/weda-ui.css
CHANGED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
const isNull = (val) => [undefined, null].includes(val);
|
|
2
|
-
const REL_DICT = {
|
|
3
|
-
equal: 'eq', // 等于
|
|
4
|
-
unequal: 'neq', // 不等于
|
|
5
|
-
include: 'search', // 包含
|
|
6
|
-
exclude: '_exclude', // 不包含
|
|
7
|
-
begin_with: '_begin_with', // 开头是
|
|
8
|
-
greater: 'gt', // 大于
|
|
9
|
-
greater_or_equal: 'gte', // 大于等于
|
|
10
|
-
less: 'lt', // 小于
|
|
11
|
-
less_or_equal: 'lte', // 小于等于
|
|
12
|
-
in: 'in', // 多选值
|
|
13
|
-
not_in: 'nin', // 不在多选值
|
|
14
|
-
};
|
|
15
|
-
const ORDERTYPE = ['asc', 'desc'];
|
|
16
|
-
const getWhereList = (where) => {
|
|
17
|
-
let result = [];
|
|
18
|
-
Array.isArray(where) &&
|
|
19
|
-
where.forEach((item1) => {
|
|
20
|
-
if (item1?.groupLogic !== 'or' && Array.isArray(item1?.logicData)) {
|
|
21
|
-
item1?.logicData.forEach((item2) => {
|
|
22
|
-
let [rel, val] = [REL_DICT[item2?.rel], item2?.value];
|
|
23
|
-
if ('_begin_with' === rel) {
|
|
24
|
-
rel = 'regex';
|
|
25
|
-
val = `^${val}`;
|
|
26
|
-
}
|
|
27
|
-
if ('_exclude' === rel) {
|
|
28
|
-
rel = 'regex';
|
|
29
|
-
val = `^((?!${val}).)*$`;
|
|
30
|
-
}
|
|
31
|
-
if (item2?.logic !== 'or' && item2?.key && rel && !isNull(val)) {
|
|
32
|
-
result.push({ key: item2.key, rel, val });
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
const DEFAULT_DATA = {
|
|
40
|
-
pageNo: 1,
|
|
41
|
-
loading: false,
|
|
42
|
-
total: 0,
|
|
43
|
-
records: [],
|
|
44
|
-
pageStr: '0/0',
|
|
45
|
-
isVisiableSign: false,
|
|
46
|
-
isFirstScreen: true,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
Component({
|
|
50
|
-
options: {
|
|
51
|
-
virtualHost: true,
|
|
52
|
-
},
|
|
53
|
-
properties: {
|
|
54
|
-
className: {
|
|
55
|
-
type: String,
|
|
56
|
-
value: '',
|
|
57
|
-
},
|
|
58
|
-
style: {
|
|
59
|
-
type: String,
|
|
60
|
-
value: '',
|
|
61
|
-
},
|
|
62
|
-
datasource: {
|
|
63
|
-
type: Object,
|
|
64
|
-
value: {},
|
|
65
|
-
},
|
|
66
|
-
orderBy: {
|
|
67
|
-
type: String,
|
|
68
|
-
},
|
|
69
|
-
orderType: {
|
|
70
|
-
type: String,
|
|
71
|
-
},
|
|
72
|
-
where: {
|
|
73
|
-
type: Array,
|
|
74
|
-
value: [],
|
|
75
|
-
},
|
|
76
|
-
pageSize: {
|
|
77
|
-
type: Number,
|
|
78
|
-
value: 5,
|
|
79
|
-
},
|
|
80
|
-
template: {
|
|
81
|
-
type: String,
|
|
82
|
-
value: 'simpleList',
|
|
83
|
-
},
|
|
84
|
-
pagination: {
|
|
85
|
-
type: String,
|
|
86
|
-
value: 'loadMoreButton',
|
|
87
|
-
},
|
|
88
|
-
beforeDataChange: {
|
|
89
|
-
type: Function,
|
|
90
|
-
value: (v) => v,
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
data: { ...DEFAULT_DATA },
|
|
94
|
-
methods: {
|
|
95
|
-
/**
|
|
96
|
-
* 列表容器拉取数据,放在 setData 的回调函数中执行
|
|
97
|
-
*/
|
|
98
|
-
_fetchData: async function () {
|
|
99
|
-
const { app } = getApp();
|
|
100
|
-
const callDataSource = app?.cloud?.callDataSource;
|
|
101
|
-
const { pageNo, loading } = this.data;
|
|
102
|
-
const { datasource, orderBy, orderType, where, pageSize } =
|
|
103
|
-
this.properties;
|
|
104
|
-
if (loading) return;
|
|
105
|
-
if (!callDataSource) {
|
|
106
|
-
console.warn(`当前环境缺少方法 app.cloud.callDataSource`);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
this.setData({ loading: true });
|
|
110
|
-
const { name: dataSourceName, extra } = datasource || {};
|
|
111
|
-
const methodName =
|
|
112
|
-
typeof extra?.methodName === 'string'
|
|
113
|
-
? extra?.methodName
|
|
114
|
-
: 'wedaGetRecords';
|
|
115
|
-
const tcbParams = {};
|
|
116
|
-
|
|
117
|
-
// tcb分页参数
|
|
118
|
-
if (!isNull(pageNo) && !isNull(pageSize)) {
|
|
119
|
-
tcbParams['pageNo'] = pageNo;
|
|
120
|
-
tcbParams['pageSize'] = pageSize;
|
|
121
|
-
}
|
|
122
|
-
// tcb排序参数
|
|
123
|
-
if (orderBy && ORDERTYPE.includes(orderType)) {
|
|
124
|
-
tcbParams['orderBy'] = orderBy;
|
|
125
|
-
tcbParams['orderType'] = orderType;
|
|
126
|
-
}
|
|
127
|
-
// tcb过滤参数
|
|
128
|
-
const whereEffected = [].concat(getWhereList(where));
|
|
129
|
-
whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
|
|
130
|
-
// tcb结果和事件
|
|
131
|
-
const data = await callDataSource({
|
|
132
|
-
dataSourceName,
|
|
133
|
-
methodName,
|
|
134
|
-
params: tcbParams,
|
|
135
|
-
});
|
|
136
|
-
let records = data?.records || [];
|
|
137
|
-
let total = data?.total || 0;
|
|
138
|
-
if (
|
|
139
|
-
['loadMoreButton', 'bottomLoad'].includes(this.properties.pagination)
|
|
140
|
-
) {
|
|
141
|
-
records = [...this.data.records, ...records]; // TODO 可能存在单次 setData 数据量过大引起小程序性能问题
|
|
142
|
-
}
|
|
143
|
-
this.setData(
|
|
144
|
-
{
|
|
145
|
-
total,
|
|
146
|
-
records,
|
|
147
|
-
loading: false,
|
|
148
|
-
pageStr: `${total > 0 ? pageNo : 0}/${
|
|
149
|
-
Math.ceil(total / pageSize) || 0
|
|
150
|
-
}`,
|
|
151
|
-
},
|
|
152
|
-
() => {
|
|
153
|
-
this._handleEvents(data);
|
|
154
|
-
setTimeout(() => this._firstScreenLoadMore(), 150);
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
/**
|
|
159
|
-
* 下一页
|
|
160
|
-
*/
|
|
161
|
-
handleNext: function () {
|
|
162
|
-
if (
|
|
163
|
-
this.data.loading ||
|
|
164
|
-
!(this.properties.pageSize * this.data.pageNo < this.data.total)
|
|
165
|
-
) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.setData({ pageNo: this.data.pageNo + 1 }, () => this._fetchData());
|
|
169
|
-
},
|
|
170
|
-
/**
|
|
171
|
-
* 上一页
|
|
172
|
-
*/
|
|
173
|
-
handlePre: function () {
|
|
174
|
-
if (this.data.loading || !(this.properties.pageNo > 1)) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
this.setData({ pageNo: this.data.pageNo - 1 }, () => this._fetchData());
|
|
178
|
-
},
|
|
179
|
-
/**
|
|
180
|
-
* 向外部传递事件
|
|
181
|
-
*/
|
|
182
|
-
_handleEvents: function (data) {
|
|
183
|
-
const records = this.data.records || [];
|
|
184
|
-
const total = this.data.total || records?.length || 0;
|
|
185
|
-
const beforeDataChange = this.properties.beforeDataChange || ((v) => v);
|
|
186
|
-
this.triggerEvent('onDataChange', {
|
|
187
|
-
data: beforeDataChange(records),
|
|
188
|
-
});
|
|
189
|
-
if (JSON.stringify(data) === '{}') {
|
|
190
|
-
this.triggerEvent('queryFail', {
|
|
191
|
-
datasource: this.properties.datasource,
|
|
192
|
-
data: null,
|
|
193
|
-
});
|
|
194
|
-
} else {
|
|
195
|
-
if (total === 0) {
|
|
196
|
-
this.triggerEvent('queryEmpty', {
|
|
197
|
-
datasource: this.properties.datasource,
|
|
198
|
-
data: beforeDataChange([]),
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
this.triggerEvent('querySuccess', {
|
|
202
|
-
datasource: this.properties.datasource,
|
|
203
|
-
data: beforeDataChange(records),
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
/**
|
|
208
|
-
* 首屏持续触底加载特殊处理
|
|
209
|
-
*/
|
|
210
|
-
_firstScreenLoadMore: function () {
|
|
211
|
-
if (this.properties.pagination === 'bottomLoad') {
|
|
212
|
-
if (this.data.isFirstScreen) {
|
|
213
|
-
this.setData({ isFirstScreen: false });
|
|
214
|
-
this.contentObserver?.disconnect();
|
|
215
|
-
this._observerContent();
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
/**
|
|
220
|
-
* 开始监听slot
|
|
221
|
-
*/
|
|
222
|
-
_observerContent: function () {
|
|
223
|
-
this.contentObserver = this.createIntersectionObserver();
|
|
224
|
-
this.contentObserver
|
|
225
|
-
.relativeToViewport()
|
|
226
|
-
.observe('#weda-list-view_content', (res) => {
|
|
227
|
-
this.setData({
|
|
228
|
-
isFirstScreen:
|
|
229
|
-
res?.boundingClientRect?.bottom <= res?.relativeRect?.bottom,
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
/**
|
|
234
|
-
* 开始监听sign
|
|
235
|
-
*/
|
|
236
|
-
_observerSign: function () {
|
|
237
|
-
this.signObserver = this.createIntersectionObserver();
|
|
238
|
-
this.signObserver
|
|
239
|
-
.relativeTo('.weda-list-view__containor', { bottom: 10 })
|
|
240
|
-
.observe('#weda-list-view_sign', (res) => {
|
|
241
|
-
this.setData({ isVisiableSign: res?.intersectionRatio > 0 });
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
observers: {
|
|
246
|
-
'datasource,orderBy,orderType,where,pageSize,pagination': function (
|
|
247
|
-
dDatasource,
|
|
248
|
-
dOrderBy,
|
|
249
|
-
dOrderType,
|
|
250
|
-
dWhere,
|
|
251
|
-
dPageSize,
|
|
252
|
-
dPagination
|
|
253
|
-
) {
|
|
254
|
-
if (
|
|
255
|
-
dDatasource !== this.properties.datasource ||
|
|
256
|
-
dOrderBy !== this.properties.orderBy ||
|
|
257
|
-
dOrderType !== this.properties.orderType ||
|
|
258
|
-
dWhere !== this.properties.where ||
|
|
259
|
-
dPageSize !== this.properties.pageSize ||
|
|
260
|
-
dPagination !== this.properties.pagination
|
|
261
|
-
) {
|
|
262
|
-
this.setData({ ...DEFAULT_DATA }, () => this._fetchData());
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
isVisiableSign: function (dIsVisiableSign) {
|
|
266
|
-
if (dIsVisiableSign && this.properties.pagination === 'bottomLoad') {
|
|
267
|
-
this.handleNext();
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
isFirstScreen: function (dIsFirstScreen) {
|
|
271
|
-
if (dIsFirstScreen && this.properties.pagination === 'bottomLoad') {
|
|
272
|
-
this.handleNext();
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
},
|
|
276
|
-
lifetimes: {
|
|
277
|
-
attached: function () {
|
|
278
|
-
this._fetchData();
|
|
279
|
-
this._observerSign();
|
|
280
|
-
},
|
|
281
|
-
detached: function () {
|
|
282
|
-
this.contentObserver?.disconnect();
|
|
283
|
-
this.signObserver?.disconnect();
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<scroll-view scroll-y scroll-with-animation lower-threshold="5" style="height:97vh;{{style}}"
|
|
2
|
-
class="weda-list-view__containor weda-ui {{className}}">
|
|
3
|
-
<!-- 列表插槽 -->
|
|
4
|
-
<view class="{{template === 'cardList' ? 'weda-list-view-card' : ''}}" id="weda-list-view_content">
|
|
5
|
-
<slot></slot>
|
|
6
|
-
</view>
|
|
7
|
-
|
|
8
|
-
<view class="weda-list-view__more">
|
|
9
|
-
<!-- 加载更多 -->
|
|
10
|
-
<block wx:if="{{pagination==='loadMoreButton' && pageSize * pageNo < total}}">
|
|
11
|
-
<view class="weda-list-view__more-text" bindtap="handleNext">加载更多</view>
|
|
12
|
-
</block>
|
|
13
|
-
<!-- 触底刷新 -->
|
|
14
|
-
<block wx:elif="{{pagination==='bottomLoad'}}">
|
|
15
|
-
<view class="weda-list-view__bottom-load" id="weda-list-view_sign">
|
|
16
|
-
<view class="weda-list-view__more-symbol" wx:if="{{loading}}">
|
|
17
|
-
<view class="weda-list-view__symbol-item"></view>
|
|
18
|
-
<view class="weda-list-view__symbol-item"></view>
|
|
19
|
-
<view class="weda-list-view__symbol-item"></view>
|
|
20
|
-
</view>
|
|
21
|
-
</view>
|
|
22
|
-
</block>
|
|
23
|
-
<!-- 分页器 -->
|
|
24
|
-
<block wx:elif="{{pagination==='pagination'}}">
|
|
25
|
-
<view class="weda-list-view__more-pagination">
|
|
26
|
-
<view class="weda-list-view__pagination-pre {{pageNo > 1 ? 'active': ''}}" bindtap="handlePre">
|
|
27
|
-
<image class="weda-list-view__pagination-icon" src='arrow-right-line.svg' />
|
|
28
|
-
上一页
|
|
29
|
-
</view>
|
|
30
|
-
<view class="weda-list-view__pagination-text">{{pageStr}}</view>
|
|
31
|
-
<view class="weda-list-view__pagination-next {{pageSize * pageNo < total ? 'active' : ''}}"
|
|
32
|
-
bindtap="handleNext">
|
|
33
|
-
<image class="weda-list-view__pagination-icon" src='arrow-right-line.svg' />
|
|
34
|
-
下一页
|
|
35
|
-
</view>
|
|
36
|
-
</view>
|
|
37
|
-
</block>
|
|
38
|
-
<block wx:else></block>
|
|
39
|
-
</view>
|
|
40
|
-
</scroll-view>
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/* weda_list_view */
|
|
2
|
-
|
|
3
|
-
.weda-list-view__containor {
|
|
4
|
-
background: #fff;
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 100%;
|
|
7
|
-
overflow-x: hidden;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* 卡片列表 */
|
|
11
|
-
.weda-list-view-card {
|
|
12
|
-
display: flex;
|
|
13
|
-
flex-wrap: wrap;
|
|
14
|
-
margin-right: 6rpx;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* 加载更多 */
|
|
18
|
-
.weda-list-view__containor .weda-list-view__more {
|
|
19
|
-
width: 100%;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.weda-list-view__containor .weda-list-view__more .weda-list-view__more-text {
|
|
23
|
-
padding-top: 20rpx;
|
|
24
|
-
padding-bottom: 28rpx;
|
|
25
|
-
font-size: 24rpx;
|
|
26
|
-
line-height: 44rpx;
|
|
27
|
-
color: rgba(0, 0, 0, 0.4);
|
|
28
|
-
text-align: center;
|
|
29
|
-
box-sizing: border-box;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* 加载更多 ... */
|
|
33
|
-
.weda-list-view__containor .weda-list-view__more {
|
|
34
|
-
background: #fff;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.weda-list-view__bottom-load {
|
|
38
|
-
padding-top: 1px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.weda-list-view__containor .weda-list-view__more .weda-list-view__more-symbol {
|
|
42
|
-
display: flex;
|
|
43
|
-
align-items: center;
|
|
44
|
-
justify-content: center;
|
|
45
|
-
padding-top: 40rpx;
|
|
46
|
-
padding-bottom: 36rpx;
|
|
47
|
-
box-sizing: border-box;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.weda-list-view__containor .weda-list-view__more .weda-list-view__symbol-item {
|
|
51
|
-
width: 16rpx;
|
|
52
|
-
height: 16rpx;
|
|
53
|
-
background: #c4c4c4;
|
|
54
|
-
margin-left: 12rpx;
|
|
55
|
-
border-radius: 50%;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.weda-list-view__containor
|
|
59
|
-
.weda-list-view__more
|
|
60
|
-
.weda-list-view__symbol-item:first-child {
|
|
61
|
-
width: 12rpx;
|
|
62
|
-
height: 12rpx;
|
|
63
|
-
margin-left: 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* 加载更多 分页 */
|
|
67
|
-
.weda-list-view__containor
|
|
68
|
-
.weda-list-view__more
|
|
69
|
-
.weda-list-view__more-pagination {
|
|
70
|
-
display: flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
justify-content: space-between;
|
|
73
|
-
position: relative;
|
|
74
|
-
padding: 20rpx 36rpx 24rpx 32rpx;
|
|
75
|
-
box-sizing: border-box;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.weda-list-view__containor
|
|
79
|
-
.weda-list-view__more
|
|
80
|
-
.weda-list-view__pagination-pre,
|
|
81
|
-
.weda-list-view__containor
|
|
82
|
-
.weda-list-view__more
|
|
83
|
-
.weda-list-view__pagination-next {
|
|
84
|
-
font-size: 24rpx;
|
|
85
|
-
line-height: 48rpx;
|
|
86
|
-
color: rgba(0, 0, 0, 0.4);
|
|
87
|
-
padding: 0 48rpx;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.weda-list-view__containor
|
|
91
|
-
.weda-list-view__more
|
|
92
|
-
.weda-list-view__pagination-pre.active,
|
|
93
|
-
.weda-list-view__containor
|
|
94
|
-
.weda-list-view__more
|
|
95
|
-
.weda-list-view__pagination-next.active {
|
|
96
|
-
color: rgba(0, 0, 0, 0.9);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.weda-list-view__containor
|
|
100
|
-
.weda-list-view__more
|
|
101
|
-
.weda-list-view__pagination-pre
|
|
102
|
-
.weda-list-view__pagination-icon,
|
|
103
|
-
.weda-list-view__containor
|
|
104
|
-
.weda-list-view__more
|
|
105
|
-
.weda-list-view__pagination-next
|
|
106
|
-
.weda-list-view__pagination-icon {
|
|
107
|
-
position: absolute;
|
|
108
|
-
width: 48rpx;
|
|
109
|
-
height: 48rpx;
|
|
110
|
-
top: 20rpx;
|
|
111
|
-
opacity: 0.2;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.weda-list-view__containor
|
|
115
|
-
.weda-list-view__more
|
|
116
|
-
.active.weda-list-view__pagination-pre
|
|
117
|
-
.weda-list-view__pagination-icon,
|
|
118
|
-
.weda-list-view__containor
|
|
119
|
-
.weda-list-view__more
|
|
120
|
-
.active.weda-list-view__pagination-next
|
|
121
|
-
.weda-list-view__pagination-icon {
|
|
122
|
-
opacity: 1;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.weda-list-view__containor
|
|
126
|
-
.weda-list-view__more
|
|
127
|
-
.weda-list-view__pagination-pre
|
|
128
|
-
.weda-list-view__pagination-icon {
|
|
129
|
-
left: 32rpx;
|
|
130
|
-
transform: rotate(180deg);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.weda-list-view__containor
|
|
134
|
-
.weda-list-view__more
|
|
135
|
-
.weda-list-view__pagination-next
|
|
136
|
-
.weda-list-view__pagination-icon {
|
|
137
|
-
right: 36rpx;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.weda-list-view__containor
|
|
141
|
-
.weda-list-view__more
|
|
142
|
-
.weda-list-view__pagination-text {
|
|
143
|
-
font-size: 24rpx;
|
|
144
|
-
line-height: 44rpx;
|
|
145
|
-
color: rgba(0, 0, 0, 0.4);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.split {
|
|
149
|
-
height: 40rpx;
|
|
150
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M4.5 10.5C3.675 10.5 3 11.175 3 12C3 12.825 3.675 13.5 4.5 13.5C5.325 13.5 6 12.825 6 12C6 11.175 5.325 10.5 4.5 10.5ZM19.5 10.5C18.675 10.5 18 11.175 18 12C18 12.825 18.675 13.5 19.5 13.5C20.325 13.5 21 12.825 21 12C21 11.175 20.325 10.5 19.5 10.5ZM12 10.5C11.175 10.5 10.5 11.175 10.5 12C10.5 12.825 11.175 13.5 12 13.5C12.825 13.5 13.5 12.825 13.5 12C13.5 11.175 12.825 10.5 12 10.5Z" fill="#09121F"/>
|
|
3
|
-
</svg>
|