@cloudbase/weda-ui 0.2.15 → 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 +41 -169
- package/package.json +28 -15
- package/src/configs/components/calendar.json +78 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +379 -0
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +154 -0
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +410 -0
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +20 -4
- package/src/configs/components/listView.json +277 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +362 -0
- 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 +6 -3
- 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 +34 -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/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +253 -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/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/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 +382 -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/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +84 -48
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +106 -27
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +203 -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 +285 -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 +155 -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/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/swiper/index.wxml +2 -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/wxOpenApi/phone/index.json +4 -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 +18 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/platform.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 +62 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- 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/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/chart/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +307 -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/checkbox/index.tsx +55 -23
- 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/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +389 -71
- 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 +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
- package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
- package/src/web/components/graphicCard/index.css +159 -0
- package/src/web/components/graphicCard/index.tsx +310 -0
- package/src/web/components/image/image.tsx +1 -2
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +24 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +143 -0
- package/src/web/components/listView/index.tsx +359 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- 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 +4 -2
- package/src/web/components/tabs/tabs.h5.tsx +50 -37
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +40 -0
- package/src/web/utils/tcb.js +49 -0
- package/src/web/utils/tmap.js +4 -0
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- 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
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import classNames from '../../../../../utils/classnames';
|
|
3
|
+
import weui from '../../../../../utils/weui';
|
|
4
|
+
import './index.css';
|
|
5
|
+
import { renderDecorator } from '../../../renderDecorator';
|
|
6
|
+
import MapView from '../../common/mapView';
|
|
7
|
+
import SelectModal from '../../common/selectModal';
|
|
8
|
+
import { propTypes, defaultProps } from '../../common/propsConfig';
|
|
9
|
+
import { callDataSource } from '../../../../../utils/tcb';
|
|
10
|
+
import { inH5IsMobile } from '../../../../../utils/platform';
|
|
11
|
+
|
|
12
|
+
const { useEffect, useState, useRef } = React;
|
|
13
|
+
|
|
14
|
+
export default function LocationH5(props) {
|
|
15
|
+
const {
|
|
16
|
+
// 系统属性
|
|
17
|
+
id,
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
events,
|
|
21
|
+
// 组件属性
|
|
22
|
+
value,
|
|
23
|
+
label,
|
|
24
|
+
labelVisible,
|
|
25
|
+
showLngLat,
|
|
26
|
+
showMap,
|
|
27
|
+
drag,
|
|
28
|
+
zoom,
|
|
29
|
+
disabled,
|
|
30
|
+
requiredFlag,
|
|
31
|
+
decorator,
|
|
32
|
+
customLocation,
|
|
33
|
+
locationType,
|
|
34
|
+
dataSource,
|
|
35
|
+
} = props;
|
|
36
|
+
const cls = classNames({
|
|
37
|
+
'weda-ui': true,
|
|
38
|
+
cloudbase_standard: true,
|
|
39
|
+
[className]: className,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const locationPlugRef = useRef();
|
|
43
|
+
|
|
44
|
+
const [isSelectMapVisible, setIsSelectMapVisible] = useState(false);
|
|
45
|
+
const [currentLocStatus, setCurrentLocStatus] = useState(false);
|
|
46
|
+
const [dataSourceStatus, setDataSourceStatus] = useState({
|
|
47
|
+
status: false,
|
|
48
|
+
message: '请检查连接器初始化中',
|
|
49
|
+
});
|
|
50
|
+
const [APIKEY, setAPIKEY] = useState('');
|
|
51
|
+
const [apiKeyStatus, setApiKeyStatus] = useState({
|
|
52
|
+
status: false,
|
|
53
|
+
message: '地图定位中',
|
|
54
|
+
});
|
|
55
|
+
const [location, setLocation] = useState({
|
|
56
|
+
poiname: '',
|
|
57
|
+
latlng: { lat: 39.98410411, lng: 116.307503 },
|
|
58
|
+
});
|
|
59
|
+
const currentLocations = useRef();
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (value || !currentLocations.current) return;
|
|
63
|
+
// 重置表单时
|
|
64
|
+
const {
|
|
65
|
+
poiname,
|
|
66
|
+
latlng: { lat, lng },
|
|
67
|
+
} = currentLocations.current;
|
|
68
|
+
let location = {
|
|
69
|
+
poiname,
|
|
70
|
+
latlng: { lat, lng },
|
|
71
|
+
};
|
|
72
|
+
if (locationType === 1) {
|
|
73
|
+
location.locationType = 1;
|
|
74
|
+
events.change({ value: null });
|
|
75
|
+
} else if (locationType === 2) {
|
|
76
|
+
let res = {
|
|
77
|
+
value: {
|
|
78
|
+
address: poiname,
|
|
79
|
+
geopoint: {
|
|
80
|
+
coordinates: [lng, lat],
|
|
81
|
+
type: 'Point',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
events.change && events.change(res);
|
|
86
|
+
}
|
|
87
|
+
setLocation(location);
|
|
88
|
+
}, [value, locationType]);
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
let loc = {
|
|
92
|
+
latlng: {
|
|
93
|
+
lat: 39.98410411,
|
|
94
|
+
lng: 116.307503,
|
|
95
|
+
},
|
|
96
|
+
poiname: '',
|
|
97
|
+
locationType,
|
|
98
|
+
};
|
|
99
|
+
switch (locationType) {
|
|
100
|
+
case 3:
|
|
101
|
+
if (checkCustomLocation(customLocation)) {
|
|
102
|
+
weui.alert('位置输入格式错误 请检查');
|
|
103
|
+
return;
|
|
104
|
+
} else {
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
loc = {
|
|
107
|
+
latlng: {
|
|
108
|
+
lat: customLocation.latitude,
|
|
109
|
+
lng: customLocation.longitude,
|
|
110
|
+
},
|
|
111
|
+
poiname: customLocation.poiname,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
setLocation(loc);
|
|
117
|
+
// 暂不支持自定位置,初始化表单值都是null
|
|
118
|
+
events.change({ value: null });
|
|
119
|
+
}, [locationType]);
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (locationType != 3) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (checkCustomLocation(customLocation)) {
|
|
126
|
+
weui.alert('位置输入格式错误 请检查');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
let { latitude, longitude, poiname } = customLocation;
|
|
130
|
+
let loc = {
|
|
131
|
+
latlng: {
|
|
132
|
+
lat: latitude,
|
|
133
|
+
lng: longitude,
|
|
134
|
+
},
|
|
135
|
+
poiname: poiname,
|
|
136
|
+
};
|
|
137
|
+
setLocation(loc);
|
|
138
|
+
}, [customLocation, locationType]);
|
|
139
|
+
|
|
140
|
+
// 获取定位信息
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!dataSourceStatus.status || !APIKEY || APIKEY == '这里是示例') return;
|
|
143
|
+
function loadScript() {
|
|
144
|
+
// 移除之前的
|
|
145
|
+
if (document.getElementById('form-location-plug')) {
|
|
146
|
+
document.body.removeChild(
|
|
147
|
+
document.getElementById('form-location-plug')
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const script = document.createElement('script');
|
|
151
|
+
script.type = 'text/javascript';
|
|
152
|
+
script.src = `https://apis.map.qq.com/tools/geolocation/min?key=${APIKEY}&referer=myapp`;
|
|
153
|
+
script.setAttribute('id', 'form-location-plug');
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
locationPlugRef.current = 'form-location-plug';
|
|
156
|
+
script.onload = () => {
|
|
157
|
+
let geolocation = new window.qq.maps.Geolocation();
|
|
158
|
+
let getLocationType = inH5IsMobile() ? 'getLocation' : 'getIpLocation';
|
|
159
|
+
geolocation[getLocationType](
|
|
160
|
+
(ipLocation) => {
|
|
161
|
+
const { city, lat, lng, addr } = ipLocation;
|
|
162
|
+
let loc = {
|
|
163
|
+
poiname: city + addr,
|
|
164
|
+
latlng: { lat, lng },
|
|
165
|
+
};
|
|
166
|
+
if (locationType === 1) {
|
|
167
|
+
loc.locationType = 1;
|
|
168
|
+
}
|
|
169
|
+
setLocation(loc);
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
currentLocations.current = loc;
|
|
172
|
+
if (locationType === 2) {
|
|
173
|
+
loc.locationType = 1;
|
|
174
|
+
events.change &&
|
|
175
|
+
events.change({
|
|
176
|
+
value: {
|
|
177
|
+
address: city + addr,
|
|
178
|
+
geopoint: {
|
|
179
|
+
coordinates: [lng, lat],
|
|
180
|
+
type: 'Point',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
setApiKeyStatus({
|
|
186
|
+
status: true,
|
|
187
|
+
message: '',
|
|
188
|
+
});
|
|
189
|
+
setCurrentLocStatus(true);
|
|
190
|
+
},
|
|
191
|
+
(error) => {
|
|
192
|
+
console.log('error loc', error);
|
|
193
|
+
currentLocations.current = null;
|
|
194
|
+
setApiKeyStatus({
|
|
195
|
+
status: false,
|
|
196
|
+
message:
|
|
197
|
+
error.code === 1
|
|
198
|
+
? '请打开定位权限'
|
|
199
|
+
: error.message || '定位失败',
|
|
200
|
+
});
|
|
201
|
+
setCurrentLocStatus(false);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
script.onerror = (error) => {
|
|
206
|
+
console.log('Geolocation script onerror', error);
|
|
207
|
+
setApiKeyStatus({
|
|
208
|
+
status: false,
|
|
209
|
+
message: '定位失败',
|
|
210
|
+
});
|
|
211
|
+
setLocation({
|
|
212
|
+
poiname: '',
|
|
213
|
+
latlng: { lat: 39.98410411, lng: 116.307503 },
|
|
214
|
+
});
|
|
215
|
+
weui.alert('定位失败');
|
|
216
|
+
};
|
|
217
|
+
document.body.appendChild(script);
|
|
218
|
+
}
|
|
219
|
+
loadScript();
|
|
220
|
+
}, [APIKEY, locationType, dataSourceStatus]);
|
|
221
|
+
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
// 调用连接器数据源方法
|
|
224
|
+
if (dataSource.name) {
|
|
225
|
+
callDataSource({
|
|
226
|
+
dataSourceName: dataSource.name,
|
|
227
|
+
methodName: 'getApiKey',
|
|
228
|
+
})
|
|
229
|
+
.then((res) => {
|
|
230
|
+
if (res.apiKey) {
|
|
231
|
+
setAPIKEY(res.apiKey);
|
|
232
|
+
setDataSourceStatus({
|
|
233
|
+
status: true,
|
|
234
|
+
message: '',
|
|
235
|
+
});
|
|
236
|
+
setApiKeyStatus({
|
|
237
|
+
status: true,
|
|
238
|
+
message: '',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
.catch((error) => {
|
|
243
|
+
console.log('datasources error', error);
|
|
244
|
+
setDataSourceStatus({
|
|
245
|
+
status: false,
|
|
246
|
+
message: error,
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
setDataSourceStatus({
|
|
251
|
+
status: false,
|
|
252
|
+
message: '"地图定位组件"需进行地图配置,请检查',
|
|
253
|
+
});
|
|
254
|
+
weui.alert('"地图定位组件"需进行地图配置,请检查');
|
|
255
|
+
}
|
|
256
|
+
}, [dataSource]);
|
|
257
|
+
|
|
258
|
+
const checkCustomLocation = (params) => {
|
|
259
|
+
let { latitude, longitude } = params;
|
|
260
|
+
let message = '';
|
|
261
|
+
if (Object.prototype.toString.call(params) !== '[object Object]') {
|
|
262
|
+
return (message = '位置输入格式错误 请检查');
|
|
263
|
+
} else if (!latitude || !Number(latitude)) {
|
|
264
|
+
return (message = '位置输入格式错误 请检查');
|
|
265
|
+
} else if (!longitude || !Number(longitude)) {
|
|
266
|
+
return (message = '位置输入格式错误 请检查');
|
|
267
|
+
} else if (!params) {
|
|
268
|
+
return (message = '位置输入格式错误 请检查');
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const handleChooseLocation = () => {
|
|
273
|
+
if (disabled) return;
|
|
274
|
+
if (!dataSourceStatus.status) return weui.alert(dataSourceStatus.message);
|
|
275
|
+
if (!apiKeyStatus.status) return weui.alert(apiKeyStatus.message);
|
|
276
|
+
if (!currentLocStatus) return weui.alert('获取当前位置信息中,请稍等');
|
|
277
|
+
setIsSelectMapVisible(true);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const onChangeLocation = (value) => {
|
|
281
|
+
const { poiname, latlng } = value;
|
|
282
|
+
let res = {
|
|
283
|
+
value: {
|
|
284
|
+
address: poiname,
|
|
285
|
+
geopoint: {
|
|
286
|
+
coordinates: [latlng.lng, latlng.lat],
|
|
287
|
+
type: 'Point',
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
events.change && events.change(res);
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const getIsShowMap = () => {
|
|
295
|
+
let status = showMap;
|
|
296
|
+
// @ts-ignore
|
|
297
|
+
if (locationType === 1 && location.locationType === 1) {
|
|
298
|
+
status = false;
|
|
299
|
+
} else if (locationType === 2 && !dataSourceStatus.status) {
|
|
300
|
+
status = false;
|
|
301
|
+
} else if (locationType === 2 && !apiKeyStatus.status) {
|
|
302
|
+
status = false;
|
|
303
|
+
} else if (!currentLocStatus) {
|
|
304
|
+
status = false;
|
|
305
|
+
}
|
|
306
|
+
return status;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const getIsShowAddr = () => {
|
|
310
|
+
let status = true;
|
|
311
|
+
// @ts-ignore
|
|
312
|
+
if (locationType === 1 && location.locationType === 1) {
|
|
313
|
+
status = false;
|
|
314
|
+
} else if (locationType === 2 && !dataSourceStatus.status) {
|
|
315
|
+
status = false;
|
|
316
|
+
} else if (locationType === 2 && !apiKeyStatus.status) {
|
|
317
|
+
status = false;
|
|
318
|
+
} else if (!currentLocStatus) {
|
|
319
|
+
status = false;
|
|
320
|
+
}
|
|
321
|
+
return status;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const LocationEl = (
|
|
325
|
+
<div
|
|
326
|
+
className="form-location weda-ui_form-location"
|
|
327
|
+
data-testid="form-location"
|
|
328
|
+
>
|
|
329
|
+
<div className="form-location-warp">
|
|
330
|
+
{labelVisible && (
|
|
331
|
+
<div className="form-location-label">
|
|
332
|
+
{requiredFlag && <span>*</span>}
|
|
333
|
+
{label}
|
|
334
|
+
</div>
|
|
335
|
+
)}
|
|
336
|
+
<div className="form-location-con">
|
|
337
|
+
<img
|
|
338
|
+
src="https://qcloudimg.tencent-cloud.cn/raw/6542e1ce1dd36a90085b2eb979801df9.png"
|
|
339
|
+
alt=""
|
|
340
|
+
/>
|
|
341
|
+
<span
|
|
342
|
+
className={classNames({ 'form-location-con_disabled': disabled })}
|
|
343
|
+
onClick={handleChooseLocation}
|
|
344
|
+
>
|
|
345
|
+
选择地理位置
|
|
346
|
+
</span>
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
{getIsShowAddr() && (
|
|
350
|
+
<div className="form-location-addr">
|
|
351
|
+
<img
|
|
352
|
+
src="https://qcloudimg.tencent-cloud.cn/raw/f9729e0b091f394110a6e12d3f4e7290.png"
|
|
353
|
+
alt=""
|
|
354
|
+
/>
|
|
355
|
+
<div>
|
|
356
|
+
{location.poiname && (
|
|
357
|
+
<div className="form-location-addr-title">{location.poiname}</div>
|
|
358
|
+
)}
|
|
359
|
+
{showLngLat && (
|
|
360
|
+
<div className="form-location-addr-lat">
|
|
361
|
+
{location.latlng
|
|
362
|
+
? `${location.latlng.lat}N,${location.latlng.lng}E`
|
|
363
|
+
: ''}
|
|
364
|
+
</div>
|
|
365
|
+
)}
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
)}
|
|
369
|
+
{getIsShowMap() && (
|
|
370
|
+
<div className="form-map-container" style={{ height: '200px' }}>
|
|
371
|
+
<MapView
|
|
372
|
+
APIKEY={APIKEY}
|
|
373
|
+
drag={drag}
|
|
374
|
+
zoom={zoom}
|
|
375
|
+
latlng={location.latlng}
|
|
376
|
+
/>
|
|
377
|
+
</div>
|
|
378
|
+
)}
|
|
379
|
+
<SelectModal
|
|
380
|
+
isSelectMapVisible={isSelectMapVisible}
|
|
381
|
+
setIsSelectMapVisible={setIsSelectMapVisible}
|
|
382
|
+
location={location}
|
|
383
|
+
setLocation={setLocation}
|
|
384
|
+
chooseLocation={onChangeLocation}
|
|
385
|
+
APIKEY={APIKEY}
|
|
386
|
+
/>
|
|
387
|
+
</div>
|
|
388
|
+
);
|
|
389
|
+
return renderDecorator(
|
|
390
|
+
LocationEl,
|
|
391
|
+
decorator
|
|
392
|
+
)({
|
|
393
|
+
id,
|
|
394
|
+
className: cls,
|
|
395
|
+
style,
|
|
396
|
+
multiCell: false,
|
|
397
|
+
requiredFlag,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
LocationH5.propTypes = propTypes;
|
|
402
|
+
|
|
403
|
+
LocationH5.defaultProps = defaultProps;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Button } from 'tea-component';
|
|
3
|
+
import * as PropTypes from 'prop-types';
|
|
4
|
+
import classNames from '../../../../../utils/classnames';
|
|
5
|
+
|
|
6
|
+
const Header = ({
|
|
7
|
+
onClick,
|
|
8
|
+
isEdit,
|
|
9
|
+
info,
|
|
10
|
+
disabled,
|
|
11
|
+
showLngLat,
|
|
12
|
+
locationType,
|
|
13
|
+
dataSourceStatus,
|
|
14
|
+
apiKeyStatus,
|
|
15
|
+
currentLocStatus,
|
|
16
|
+
}) => {
|
|
17
|
+
const { poiname, latlng } = info || {};
|
|
18
|
+
const buttonType = isEdit ? 'weak' : 'primary';
|
|
19
|
+
const buttonText = isEdit ? '重新定位' : '选择地理位置';
|
|
20
|
+
|
|
21
|
+
const getIsShowAddr = () => {
|
|
22
|
+
let status = true;
|
|
23
|
+
// 默认显示位置 无
|
|
24
|
+
if (locationType === 1 && info.locationType === 1) {
|
|
25
|
+
status = false;
|
|
26
|
+
} else if (locationType === 2 && !dataSourceStatus) {
|
|
27
|
+
status = false;
|
|
28
|
+
} else if (locationType === 2 && !apiKeyStatus.status) {
|
|
29
|
+
status = false;
|
|
30
|
+
} else if (!currentLocStatus) {
|
|
31
|
+
status = false;
|
|
32
|
+
}
|
|
33
|
+
return status;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
className={classNames({
|
|
39
|
+
'wedatea2td-justify-grid _weda-fn-map__local': true,
|
|
40
|
+
'weda-fn-map__local_loc': true,
|
|
41
|
+
'weda-fn-map__local_edit': isEdit,
|
|
42
|
+
})}
|
|
43
|
+
>
|
|
44
|
+
{isEdit ? (
|
|
45
|
+
<>
|
|
46
|
+
<div className="wedatea2td-justify-grid__col wedatea2td-justify-grid__col--right weda-fn-map__local_loc_btn">
|
|
47
|
+
<Button type={buttonType} onClick={onClick} disabled={disabled}>
|
|
48
|
+
{buttonText}
|
|
49
|
+
</Button>
|
|
50
|
+
</div>
|
|
51
|
+
</>
|
|
52
|
+
) : (
|
|
53
|
+
<div className="wedatea2td-justify-grid__col wedatea2td-justify-grid__col--left weda-fn-map__local_loc_btn_left">
|
|
54
|
+
<Button type={buttonType} onClick={onClick} disabled={disabled}>
|
|
55
|
+
{buttonText}
|
|
56
|
+
</Button>
|
|
57
|
+
</div>
|
|
58
|
+
)}
|
|
59
|
+
{getIsShowAddr() && (
|
|
60
|
+
<div
|
|
61
|
+
className={classNames(
|
|
62
|
+
'wedatea2td-justify-grid__col',
|
|
63
|
+
'wedatea2td-justify-grid__col--left',
|
|
64
|
+
'weda-fn-map__local_wrap'
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
<i className="wedatea2td-icon _weda-fn-icon-local weda-fn-map__local_wrap_icon"></i>
|
|
68
|
+
<div className="weda-fn-map__local_wrap_addr">
|
|
69
|
+
{poiname && (
|
|
70
|
+
<span
|
|
71
|
+
className={classNames(
|
|
72
|
+
'wedatea2td-fz-reset',
|
|
73
|
+
'form-location-map-pc-address'
|
|
74
|
+
)}
|
|
75
|
+
>
|
|
76
|
+
{poiname}
|
|
77
|
+
</span>
|
|
78
|
+
)}
|
|
79
|
+
|
|
80
|
+
{showLngLat ? (
|
|
81
|
+
<div
|
|
82
|
+
className={classNames({
|
|
83
|
+
'form-location-addr-lat': true,
|
|
84
|
+
'form-location-map-pc-latlng': true,
|
|
85
|
+
})}
|
|
86
|
+
>
|
|
87
|
+
{latlng.lat ? `${latlng.lat}N,${latlng.lng}E` : ''}
|
|
88
|
+
</div>
|
|
89
|
+
) : null}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
Header.propTypes = {
|
|
98
|
+
onClick: PropTypes.func,
|
|
99
|
+
isEdit: PropTypes.bool,
|
|
100
|
+
info: PropTypes.object,
|
|
101
|
+
disabled: PropTypes.bool,
|
|
102
|
+
showLngLat: PropTypes.bool,
|
|
103
|
+
currentLocStatus: PropTypes.bool,
|
|
104
|
+
dataSourceStatus: PropTypes.bool,
|
|
105
|
+
locationType: PropTypes.number,
|
|
106
|
+
apiKeyStatus: PropTypes.object,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default Header;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.form-location-map-pc {
|
|
2
|
+
width: 490px;
|
|
3
|
+
height: 300px;
|
|
4
|
+
margin-top: 8px;
|
|
5
|
+
}
|
|
6
|
+
.form-location-map-pc-address {
|
|
7
|
+
vertical-align: middle;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.weda-fn-map__local_loc {
|
|
11
|
+
display: block !important;
|
|
12
|
+
position: relative;
|
|
13
|
+
min-height: 32px;
|
|
14
|
+
width: 490px !important;
|
|
15
|
+
}
|
|
16
|
+
.weda-fn-map__local_edit {
|
|
17
|
+
display: flex !important;
|
|
18
|
+
}
|
|
19
|
+
.weda-fn-map__local_loc_btn {
|
|
20
|
+
position: absolute;
|
|
21
|
+
right: 0;
|
|
22
|
+
top: 0;
|
|
23
|
+
}
|
|
24
|
+
.weda-fn-map__local_loc_btn_left {
|
|
25
|
+
margin-bottom: 8px;
|
|
26
|
+
}
|
|
27
|
+
.weda-fn-map__local_wrap {
|
|
28
|
+
display: flex;
|
|
29
|
+
/* margin-top: 8px; */
|
|
30
|
+
}
|
|
31
|
+
.weda-fn-map__local_wrap_icon {
|
|
32
|
+
width: 24px;
|
|
33
|
+
height: 24px;
|
|
34
|
+
}
|
|
35
|
+
.form-location-map-pc-latlng,
|
|
36
|
+
.form-location-map-pc-address {
|
|
37
|
+
display: block;
|
|
38
|
+
height: 24px;
|
|
39
|
+
line-height: 24px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.wedatea2td-form > .wa-comp-weda_standard-FormLocation {
|
|
43
|
+
padding-left: 2.28571rem;
|
|
44
|
+
}
|