@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.
Files changed (250) hide show
  1. package/README.md +41 -169
  2. package/package.json +28 -15
  3. package/src/configs/components/calendar.json +78 -0
  4. package/src/configs/components/carousel.json +273 -0
  5. package/src/configs/components/chart/bar.json +724 -0
  6. package/src/configs/components/chart/line.json +679 -0
  7. package/src/configs/components/chart/pie.json +497 -0
  8. package/src/configs/components/chart/statisticsCard.json +379 -0
  9. package/src/configs/components/container.json +7 -2
  10. package/src/configs/components/dataView.json +154 -0
  11. package/src/configs/components/form/checkbox.json +97 -5
  12. package/src/configs/components/form/location.json +152 -0
  13. package/src/configs/components/form/radio.json +96 -4
  14. package/src/configs/components/form/select.json +245 -11
  15. package/src/configs/components/form/uploaderFile.json +2 -1
  16. package/src/configs/components/graphicCard.json +410 -0
  17. package/src/configs/components/image.json +7 -2
  18. package/src/configs/components/link.json +20 -4
  19. package/src/configs/components/listView.json +277 -0
  20. package/src/configs/components/modal.json +37 -5
  21. package/src/configs/components/navLayout.json +362 -0
  22. package/src/configs/components/navigationBar.json +59 -0
  23. package/src/configs/components/richtextview.json +4 -1
  24. package/src/configs/components/scrollVeiw.json +74 -22
  25. package/src/configs/components/swiper.json +6 -3
  26. package/src/configs/components/tabs.json +51 -8
  27. package/src/configs/components/text.json +33 -25
  28. package/src/configs/components/wxOpenApi/phone.json +141 -0
  29. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  30. package/src/configs/components/wxOpenApi/share.json +167 -0
  31. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  32. package/src/configs/index.js +34 -0
  33. package/src/mp/components/button/index.js +12 -13
  34. package/src/mp/components/button/index.wxml +1 -1
  35. package/src/mp/components/calendar/arrowright--line.svg +11 -0
  36. package/src/mp/components/calendar/index.js +238 -0
  37. package/src/mp/components/calendar/index.json +4 -0
  38. package/src/mp/components/calendar/index.wxml +37 -0
  39. package/src/mp/components/calendar/index.wxss +178 -0
  40. package/src/mp/components/carousel/index.js +88 -0
  41. package/src/mp/components/carousel/index.json +7 -0
  42. package/src/mp/components/carousel/index.wxml +6 -0
  43. package/src/mp/components/chart/bar/index.js +258 -0
  44. package/src/mp/components/chart/bar/index.json +6 -0
  45. package/src/mp/components/chart/bar/index.wxml +3 -0
  46. package/src/mp/components/chart/bar/index.wxss +9 -0
  47. package/src/mp/components/chart/common/config/bar.js +50 -0
  48. package/src/mp/components/chart/common/config/global.js +16 -0
  49. package/src/mp/components/chart/common/config/line.js +48 -0
  50. package/src/mp/components/chart/common/config/pie.js +36 -0
  51. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  52. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  53. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  54. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  55. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  56. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  57. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  58. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  59. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  60. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  61. package/src/mp/components/chart/line/index.js +247 -0
  62. package/src/mp/components/chart/line/index.json +6 -0
  63. package/src/mp/components/chart/line/index.wxml +3 -0
  64. package/src/mp/components/chart/line/index.wxss +9 -0
  65. package/src/mp/components/chart/pie/index.js +182 -0
  66. package/src/mp/components/chart/pie/index.json +6 -0
  67. package/src/mp/components/chart/pie/index.wxml +4 -0
  68. package/src/mp/components/chart/pie/index.wxss +9 -0
  69. package/src/mp/components/chart/statisticsCard/index.js +253 -0
  70. package/src/mp/components/chart/statisticsCard/index.json +4 -0
  71. package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
  72. package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
  73. package/src/mp/components/dataView/index.js +34 -0
  74. package/src/mp/components/dataView/index.json +7 -0
  75. package/src/mp/components/dataView/index.wxml +15 -0
  76. package/src/mp/components/dataView/index.wxss +0 -0
  77. package/src/mp/components/form/checkbox/index.js +41 -2
  78. package/src/mp/components/form/checkbox/index.wxml +1 -1
  79. package/src/mp/components/form/input/index.js +1 -1
  80. package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
  81. package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
  82. package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
  83. package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
  84. package/src/mp/components/form/location/index.js +382 -0
  85. package/src/mp/components/form/location/index.json +6 -0
  86. package/src/mp/components/form/location/index.wxml +25 -0
  87. package/src/mp/components/form/location/index.wxss +91 -0
  88. package/src/mp/components/form/radio/index.js +38 -0
  89. package/src/mp/components/form/select/index.js +360 -40
  90. package/src/mp/components/form/select/index.wxml +21 -6
  91. package/src/mp/components/form/select/region/index.js +98 -0
  92. package/src/mp/components/form/textarea/index.wxml +6 -5
  93. package/src/mp/components/form/uploader/index.js +84 -48
  94. package/src/mp/components/form/uploader/index.wxml +15 -3
  95. package/src/mp/components/form/uploaderFile/index.js +106 -27
  96. package/src/mp/components/graphicCard/chevron-right.svg +3 -0
  97. package/src/mp/components/graphicCard/index.js +203 -0
  98. package/src/mp/components/graphicCard/index.json +4 -0
  99. package/src/mp/components/graphicCard/index.wxml +29 -0
  100. package/src/mp/components/graphicCard/index.wxss +157 -0
  101. package/src/mp/components/image/index.js +0 -1
  102. package/src/mp/components/listView/arrow-right-line.svg +3 -0
  103. package/src/mp/components/listView/index.js +285 -0
  104. package/src/mp/components/listView/index.json +4 -0
  105. package/src/mp/components/listView/index.wxml +40 -0
  106. package/src/mp/components/listView/index.wxss +155 -0
  107. package/src/mp/components/listView/more-line.svg +3 -0
  108. package/src/mp/components/navLayout/index.js +123 -0
  109. package/src/mp/components/navLayout/index.json +7 -0
  110. package/src/mp/components/navLayout/index.wxml +25 -0
  111. package/src/mp/components/navLayout/index.wxss +1193 -0
  112. package/src/mp/components/navigationBar/index.js +193 -0
  113. package/src/mp/components/navigationBar/index.json +6 -0
  114. package/src/mp/components/navigationBar/index.wxml +88 -0
  115. package/src/mp/components/navigationBar/index.wxss +1257 -0
  116. package/src/mp/components/swiper/index.wxml +2 -0
  117. package/src/mp/components/tabs/index.js +7 -2
  118. package/src/mp/components/tabs/index.wxml +2 -1
  119. package/src/mp/components/text/index.js +0 -25
  120. package/src/mp/components/text/index.wxml +3 -3
  121. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  122. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  123. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  124. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  125. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  126. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  127. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  128. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  129. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  130. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  131. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  132. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  133. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  134. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  135. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  136. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  137. package/src/mp/index.json +18 -2
  138. package/src/mp/style/weda-ui.wxss +2 -0
  139. package/src/mp/utils/debounce.js +133 -0
  140. package/src/mp/utils/destr.js +48 -0
  141. package/src/mp/utils/dr_square_point.js +25 -0
  142. package/src/mp/utils/platform.js +25 -0
  143. package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
  144. package/src/mp/utils/spark-md5.js +776 -0
  145. package/src/mp/utils/tcb.js +62 -0
  146. package/src/setupTests.js +2 -1
  147. package/src/web/components/button/index.css +8 -1
  148. package/src/web/components/button/index.tsx +3 -2
  149. package/src/web/components/calendar/index.css +382 -0
  150. package/src/web/components/calendar/index.jsx +312 -0
  151. package/src/web/components/calendar/util.js +90 -0
  152. package/src/web/components/carousel/index.css +119 -0
  153. package/src/web/components/carousel/index.tsx +417 -0
  154. package/src/web/components/chart/bar/index.tsx +140 -0
  155. package/src/web/components/chart/common/config/bar.js +49 -0
  156. package/src/web/components/chart/common/config/global.js +16 -0
  157. package/src/web/components/chart/common/config/line.js +50 -0
  158. package/src/web/components/chart/common/config/pie.js +37 -0
  159. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  160. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  161. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  162. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  163. package/src/web/components/chart/common/core/type.ts +34 -0
  164. package/src/web/components/chart/common/echart.css +106 -0
  165. package/src/web/components/chart/common/echarts.ts +33 -0
  166. package/src/web/components/chart/common/useChart.tsx +69 -0
  167. package/src/web/components/chart/line/index.tsx +136 -0
  168. package/src/web/components/chart/pie/index.tsx +99 -0
  169. package/src/web/components/chart/statisticsCard/index.css +62 -0
  170. package/src/web/components/chart/statisticsCard/index.tsx +307 -0
  171. package/src/web/components/chart/statisticsCard/interface.ts +14 -0
  172. package/src/web/components/dataView/index.tsx +20 -0
  173. package/src/web/components/dataView/interface.ts +6 -0
  174. package/src/web/components/form/checkbox/index.tsx +55 -23
  175. package/src/web/components/form/location/common/mapChoose.css +178 -0
  176. package/src/web/components/form/location/common/mapChoose.jsx +343 -0
  177. package/src/web/components/form/location/common/mapView.jsx +190 -0
  178. package/src/web/components/form/location/common/propsConfig.js +54 -0
  179. package/src/web/components/form/location/common/selectModal.css +44 -0
  180. package/src/web/components/form/location/common/selectModal.jsx +82 -0
  181. package/src/web/components/form/location/common/useLocationInfo.js +100 -0
  182. package/src/web/components/form/location/components/LocationH5/index.css +243 -0
  183. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
  184. package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
  185. package/src/web/components/form/location/components/LocationPC/index.css +44 -0
  186. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
  187. package/src/web/components/form/location/constants.js +4 -0
  188. package/src/web/components/form/location/index.css +0 -0
  189. package/src/web/components/form/location/index.jsx +25 -0
  190. package/src/web/components/form/radio/index.tsx +84 -53
  191. package/src/web/components/form/select/h5.tsx +389 -71
  192. package/src/web/components/form/select/index.css +10 -0
  193. package/src/web/components/form/select/index.tsx +404 -144
  194. package/src/web/components/form/select/region/index.ts +122 -31
  195. package/src/web/components/form/select/time.jsx +90 -0
  196. package/src/web/components/form/select/year.tsx +170 -0
  197. package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
  198. package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
  199. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
  200. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
  201. package/src/web/components/graphicCard/index.css +159 -0
  202. package/src/web/components/graphicCard/index.tsx +310 -0
  203. package/src/web/components/image/image.tsx +1 -2
  204. package/src/web/components/image/index.tsx +1 -1
  205. package/src/web/components/index.js +24 -2
  206. package/src/web/components/link/index.tsx +6 -3
  207. package/src/web/components/listView/arrow-right-line.svg +3 -0
  208. package/src/web/components/listView/index.css +143 -0
  209. package/src/web/components/listView/index.tsx +359 -0
  210. package/src/web/components/listView/interface.ts +98 -0
  211. package/src/web/components/modal/index.tsx +3 -1
  212. package/src/web/components/navLayout/index.css +332 -0
  213. package/src/web/components/navLayout/index.tsx +247 -0
  214. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  215. package/src/web/components/navigationBar/common.tsx +198 -0
  216. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  217. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  218. package/src/web/components/navigationBar/index.css +762 -0
  219. package/src/web/components/navigationBar/index.tsx +231 -0
  220. package/src/web/components/navigationBar/type.d.ts +111 -0
  221. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  222. package/src/web/components/phone/index.css +0 -0
  223. package/src/web/components/phone/index.tsx +22 -0
  224. package/src/web/components/phoneCode/index.css +0 -0
  225. package/src/web/components/phoneCode/index.tsx +22 -0
  226. package/src/web/components/richTextView/index.tsx +3 -5
  227. package/src/web/components/share/index.css +0 -0
  228. package/src/web/components/share/index.tsx +38 -0
  229. package/src/web/components/tabs/index.tsx +4 -2
  230. package/src/web/components/tabs/tabs.h5.tsx +50 -37
  231. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  232. package/src/web/components/text/index.tsx +6 -14
  233. package/src/web/components/uploaderFileView/index.css +9 -9
  234. package/src/web/components/uploaderFileView/index.jsx +32 -23
  235. package/src/web/components/userInfo/index.css +0 -0
  236. package/src/web/components/userInfo/index.tsx +30 -0
  237. package/src/web/types.d.ts +15 -14
  238. package/src/web/utils/debounce.js +98 -0
  239. package/src/web/utils/platform.js +40 -0
  240. package/src/web/utils/tcb.js +49 -0
  241. package/src/web/utils/tmap.js +4 -0
  242. package/src/web/weda-ui.css +2 -0
  243. package/CHANGELOG.md +0 -240
  244. package/src/.DS_Store +0 -0
  245. package/src/configs/.DS_Store +0 -0
  246. package/src/mp/.gitignore +0 -10
  247. package/src/web/.DS_Store +0 -0
  248. package/src/web/components/form/select/region/cities.ts +0 -2410
  249. package/src/web/components/form/select/region/provinces.ts +0 -240
  250. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,190 @@
1
+ import * as React from 'react';
2
+ import * as PropTypes from 'prop-types';
3
+ import { tmapApiUrl } from '../constants';
4
+ import { getTMap } from '../../../../utils/tmap';
5
+
6
+ const { useEffect, useRef, useState } = React;
7
+
8
+ export default function MapView({
9
+ APIKEY = '',
10
+ drag = true,
11
+ zoom = true,
12
+ latlng = {
13
+ lat: null,
14
+ lng: null,
15
+ },
16
+ }) {
17
+ const mapRef = useRef();
18
+ const markerRef = useRef();
19
+ const mapDom = useRef();
20
+ const mapDomName = useRef(new Date().getTime());
21
+ const [mapStatus, setMapStatus] = useState(false);
22
+ const { lat, lng } = latlng;
23
+
24
+ const initMap = () => {
25
+ if (mapRef.current || !mapDom.current) return;
26
+ try {
27
+ const TMap = getTMap();
28
+ //定义地图中心点坐标
29
+ const center = new TMap.LatLng(lat, lng);
30
+ //定义map变量,调用 TMap.Map() 构造函数创建地图
31
+ mapRef.current = new TMap.Map(mapDom.current, {
32
+ center, //设置地图中心点坐标
33
+ zoom: 16, //设置地图缩放级别
34
+ minZoom: 3,
35
+ maxZoom: 20,
36
+ });
37
+ // @ts-ignore
38
+ mapRef.current.setDraggable(drag);
39
+ removeOrAddZoom(mapRef.current, TMap);
40
+ initMarker();
41
+ setMapStatus(true);
42
+ } catch (error) {
43
+ console.log('initMap error', error);
44
+ }
45
+ };
46
+
47
+ const initMarker = () => {
48
+ try {
49
+ const TMap = getTMap();
50
+ const canLoad = TMap && lat && lng && mapRef.current;
51
+ if (canLoad) {
52
+ const position = new TMap.LatLng(lat, lng);
53
+ markerRef.current = new TMap.MultiMarker({
54
+ map: mapRef.current,
55
+ styles: {
56
+ pointer: new TMap.MarkerStyle({
57
+ width: 26,
58
+ height: 35,
59
+ }),
60
+ },
61
+ geometries: [
62
+ {
63
+ id: `pointer-${mapDomName.current}`,
64
+ styleId: 'pointer',
65
+ position,
66
+ },
67
+ ],
68
+ });
69
+ }
70
+ } catch (err) {
71
+ console.log('initMarker err', err);
72
+ }
73
+ };
74
+
75
+ useEffect(() => {
76
+ if (!APIKEY || APIKEY == '这里是示例') return;
77
+ function loadScript() {
78
+ // 移除之前的
79
+ if (document.getElementById('tmap-script')) {
80
+ document.body.removeChild(document.getElementById('tmap-script'));
81
+ }
82
+ const script = document.createElement('script');
83
+ script.type = 'text/javascript';
84
+ script.src = `${tmapApiUrl}?v=2.exp&key=${APIKEY}&callback=init&libraries=service`;
85
+ script.setAttribute('id', 'tmap-script');
86
+ script.onload = () => {
87
+ initMap();
88
+ };
89
+ script.onerror = (err) => {
90
+ console.log('loadScript err', err);
91
+ };
92
+ document.body.appendChild(script);
93
+ }
94
+ setTimeout(() => {
95
+ loadScript();
96
+ }, 1000);
97
+ return () => {
98
+ // @ts-ignore
99
+ mapRef.current && mapRef.current.destroy();
100
+ mapRef.current = null;
101
+ setMapStatus(false);
102
+ };
103
+ }, [APIKEY]);
104
+
105
+ useEffect(() => {
106
+ // @ts-ignore
107
+ mapRef.current && mapRef.current.setDraggable(drag);
108
+ }, [drag, mapRef.current]);
109
+
110
+ useEffect(() => {
111
+ mapRef.current && getTMap() && removeOrAddZoom(mapRef.current, getTMap());
112
+ }, [zoom, mapRef.current]);
113
+
114
+ useEffect(() => {
115
+ const TMap = getTMap();
116
+ const canLoad = TMap && lat && lng && mapRef.current && mapStatus;
117
+ if (canLoad) {
118
+ try {
119
+ const newLatLng = new TMap.LatLng(lat, lng);
120
+ // @ts-ignore
121
+ mapRef.current.setCenter(newLatLng);
122
+ // @ts-ignore
123
+ mapRef.current.panTo(newLatLng);
124
+ // @ts-ignore
125
+ markerRef.current.updateGeometries([
126
+ {
127
+ styleId: 'pointer',
128
+ id: `pointer-${mapDomName.current}`,
129
+ position: newLatLng,
130
+ },
131
+ ]);
132
+ } catch (error) {
133
+ console.log('updateGeometries error view', error);
134
+ }
135
+ }
136
+ }, [lat, lng, mapStatus]);
137
+
138
+ // 缩放事件
139
+ const removeOrAddZoom = (map, TMap) => {
140
+ try {
141
+ let level = map.getZoom();
142
+ map.setScrollable(zoom);
143
+ map.setDoubleClickZoom(zoom);
144
+ // 缩放控件
145
+ if (zoom) {
146
+ addControl(map, TMap);
147
+ map.setMaxZoom(20);
148
+ map.setMinZoom(3);
149
+ } else {
150
+ removeControl(map, TMap);
151
+ map.setMaxZoom(level);
152
+ map.setMinZoom(level);
153
+ }
154
+ } catch (error) {
155
+ console.log('removeOrAddZoom error', error);
156
+ }
157
+ };
158
+
159
+ // 移除缩放控件
160
+ const removeControl = (map, TMap) => {
161
+ if (!map.getControl(TMap.constants.DEFAULT_CONTROL_ID.ZOOM)) {
162
+ return;
163
+ }
164
+ map.removeControl(TMap.constants.DEFAULT_CONTROL_ID.ZOOM);
165
+ };
166
+
167
+ // 缩放控件添加到地图上
168
+ const addControl = (map, TMap) => {
169
+ let control = map.getControl(TMap.constants.DEFAULT_CONTROL_ID.ZOOM);
170
+ if (!control) {
171
+ map.addControl(control);
172
+ control.setPosition(TMap.constants.CONTROL_POSITION.BOTTOM_RIGHT);
173
+ }
174
+ };
175
+
176
+ return (
177
+ <div
178
+ ref={mapDom}
179
+ id={`form-location-map-${mapDomName.current}`}
180
+ style={{ height: '100%', width: '100%' }}
181
+ ></div>
182
+ );
183
+ }
184
+
185
+ MapView.propTypes = {
186
+ APIKEY: PropTypes.string,
187
+ drag: PropTypes.bool,
188
+ zoom: PropTypes.bool,
189
+ latlng: PropTypes.object,
190
+ };
@@ -0,0 +1,54 @@
1
+ import * as PropTypes from 'prop-types';
2
+
3
+ export const propTypes = {
4
+ // 系统属性
5
+ id: PropTypes.string,
6
+ className: PropTypes.string,
7
+ style: PropTypes.string,
8
+ events: PropTypes.object,
9
+ // 组件属性
10
+ label: PropTypes.string,
11
+ labelVisible: PropTypes.bool,
12
+ APIKEY: PropTypes.string,
13
+ showLngLat: PropTypes.bool,
14
+ showMap: PropTypes.bool,
15
+ defauleShowLocation: PropTypes.bool,
16
+ drag: PropTypes.bool,
17
+ zoom: PropTypes.bool,
18
+ disabled: PropTypes.bool,
19
+ requiredFlag: PropTypes.bool,
20
+ decorator: PropTypes.oneOfType([PropTypes.array, PropTypes.node]),
21
+ value: PropTypes.object,
22
+ locationType: PropTypes.number,
23
+ customLocation: PropTypes.object,
24
+ dataSource: PropTypes.object,
25
+ };
26
+
27
+ export const defaultProps = {
28
+ // 系统属性
29
+ events: {},
30
+ // 组件属性
31
+ label: '地图定位',
32
+ labelVisible: true,
33
+ APIKEY: '',
34
+ showLngLat: false,
35
+ showMap: false,
36
+ defauleShowLocation: false,
37
+ drag: true,
38
+ zoom: true,
39
+ disabled: false,
40
+ requiredFlag: false,
41
+ locationType: 1,
42
+ customLocation: {},
43
+ // 模型应用属性
44
+ value: {
45
+ address: '',
46
+ geopoint: {
47
+ coordinates: [39.984104, 116.307503],
48
+ type: 'Point',
49
+ },
50
+ },
51
+ readOnly: false,
52
+ isModalApp: false,
53
+ dataSource: {},
54
+ };
@@ -0,0 +1,44 @@
1
+ .form-select-map .tea-dialog__inner {
2
+ width: 100vw !important;
3
+ height: 100vh !important;
4
+ min-width: auto !important;
5
+ padding: 0;
6
+ }
7
+ .form-select-map .wedatea2td-dialog__inner {
8
+ box-shadow: none;
9
+ border: 0;
10
+ min-width: 100vw !important;
11
+ width: 100vw !important;
12
+ height: 100vh !important;
13
+ overflow-x: scroll;
14
+ }
15
+ .form-select-map .wedatea2td-dialog__inner .wedatea2td-dialog__header {
16
+ margin-bottom: 0;
17
+ }
18
+ .form-select-map .tea-dialog__header {
19
+ height: 30px;
20
+ margin-bottom: 0;
21
+ margin-left: 15px;
22
+ margin-right: 15px;
23
+ }
24
+ .form-select-map .tea-dialog__header .tea-dialog__headertitle {
25
+ line-height: 30px;
26
+ margin-bottom: 0;
27
+ }
28
+ .form-select-map .tea-dialog__body {
29
+ height: calc(100vh - 90px);
30
+ }
31
+ .form-select-map .tea-dialog__footer {
32
+ height: 30px;
33
+ margin-top: 10px;
34
+ }
35
+ .weda-ui_form-select {
36
+ background-color: #fff;
37
+ }
38
+ /* 大屏版样式 */
39
+ .form-select-map-pc .wedatea2td-dialog__inner {
40
+ height: 800px !important;
41
+ }
42
+ .form-select-map-pc .wedatea2td-dialog__body {
43
+ height: calc(100% - 100px);
44
+ }
@@ -0,0 +1,82 @@
1
+ import * as React from 'react';
2
+ import { Modal, Button } from 'tea-component';
3
+ import * as PropTypes from 'prop-types';
4
+ import { usePlatform } from '../../../../utils/platform';
5
+ import classNames from '../../../../utils/classnames';
6
+ import MapChoose from './mapChoose';
7
+ import './selectModal.css';
8
+
9
+ const { useRef } = React;
10
+
11
+ export default function SelectModal({
12
+ location = { latlng: { lat: null, lng: null } },
13
+ setLocation,
14
+ isSelectMapVisible = false,
15
+ setIsSelectMapVisible,
16
+ chooseLocation,
17
+ APIKEY = '',
18
+ }) {
19
+ const latlng = location.latlng || { lat: null, lng: null };
20
+ const positionRef = useRef({});
21
+ const platform = usePlatform();
22
+ const isPC = platform === 'pc';
23
+
24
+ const close = () => setIsSelectMapVisible(false);
25
+ const confirm = () => {
26
+ // @ts-ignore
27
+ if (positionRef.current.latlng) {
28
+ setLocation(positionRef.current);
29
+ chooseLocation(positionRef.current);
30
+ }
31
+ close();
32
+ };
33
+
34
+ const getPosition = (value) => {
35
+ const { title, location } = value;
36
+ let loc = {
37
+ poiname: title,
38
+ latlng: { lat: location.lat, lng: location.lng },
39
+ };
40
+ positionRef.current = loc;
41
+ };
42
+
43
+ return (
44
+ <Modal
45
+ visible={isSelectMapVisible}
46
+ caption="选择地理位置"
47
+ onClose={close}
48
+ className={classNames({
49
+ 'weda-ui_form-select': true,
50
+ 'form-select-map': !isPC,
51
+ 'form-select-map-pc': isPC,
52
+ })}
53
+ {...(isPC ? { size: 1200 } : {})}
54
+ >
55
+ <Modal.Body>
56
+ <MapChoose
57
+ latlng={latlng}
58
+ changeLocation={getPosition}
59
+ isPC={isPC}
60
+ APIKEY={APIKEY}
61
+ />
62
+ </Modal.Body>
63
+ <Modal.Footer>
64
+ <Button type="primary" onClick={confirm}>
65
+ 确定
66
+ </Button>
67
+ <Button type="weak" onClick={close}>
68
+ 取消
69
+ </Button>
70
+ </Modal.Footer>
71
+ </Modal>
72
+ );
73
+ }
74
+
75
+ SelectModal.propTypes = {
76
+ location: PropTypes.object,
77
+ isSelectMapVisible: PropTypes.bool,
78
+ APIKEY: PropTypes.string,
79
+ setLocation: PropTypes.func,
80
+ setIsSelectMapVisible: PropTypes.func,
81
+ chooseLocation: PropTypes.func,
82
+ };
@@ -0,0 +1,100 @@
1
+ import * as React from 'react';
2
+ const { useEffect, useState, useRef } = React;
3
+
4
+ export default function useLocationInfo({
5
+ apiKey: APIKEY,
6
+ locationType,
7
+ eventsChange,
8
+ dataSourceStatus,
9
+ }) {
10
+ const [location, setLocation] = useState({
11
+ poiname: '',
12
+ latlng: { lat: 39.98410411, lng: 116.307503 },
13
+ });
14
+ const [apiKeyStatus, setApiKeyStatus] = useState({
15
+ status: false,
16
+ message: '"地图定位组件"需进行地图配置,请检查',
17
+ });
18
+ const [currentLocStatus, setCurrentLocStatus] = useState(false);
19
+ const locationPlugRef = useRef();
20
+ const currentLocations = useRef();
21
+ useEffect(() => {
22
+ if (!dataSourceStatus || !APIKEY || APIKEY == '这里是示例') return;
23
+ function loadScript() {
24
+ // 移除之前的
25
+ if (document.getElementById('form-location-plug')) {
26
+ document.body.removeChild(
27
+ document.getElementById('form-location-plug')
28
+ );
29
+ }
30
+ const script = document.createElement('script');
31
+ script.type = 'text/javascript';
32
+ script.src = `https://apis.map.qq.com/tools/geolocation/min?key=${APIKEY}&referer=myapp`;
33
+ script.setAttribute('id', 'form-location-plug');
34
+ // @ts-ignore
35
+ locationPlugRef.current = 'form-location-plug';
36
+ script.onload = () => {
37
+ // @ts-ignore
38
+ let geolocation = new window.qq.maps.Geolocation();
39
+ geolocation.getIpLocation(
40
+ ({ city, lat, lng, addr }) => {
41
+ let locations = {
42
+ poiname: city + addr,
43
+ latlng: { lat, lng },
44
+ locationType,
45
+ };
46
+ setLocation(locations);
47
+ eventsChange &&
48
+ eventsChange(
49
+ {
50
+ poiname: city + addr,
51
+ latitude: lat,
52
+ longitude: lng,
53
+ },
54
+ locationType === 1
55
+ );
56
+ // @ts-ignore
57
+ currentLocations.current = locations;
58
+ setApiKeyStatus({ status: true, message: '' });
59
+ setCurrentLocStatus(true);
60
+ },
61
+ (error) => {
62
+ console.log('error loc', error);
63
+ currentLocations.current = null;
64
+ setApiKeyStatus({
65
+ status: false,
66
+ message:
67
+ error.code === 1
68
+ ? '请打开定位权限'
69
+ : error.message || '定位失败',
70
+ });
71
+ setCurrentLocStatus(false);
72
+ }
73
+ );
74
+ };
75
+ script.onerror = (error) => {
76
+ console.log('Geolocation script onerror', error);
77
+ setApiKeyStatus({
78
+ status: false,
79
+ message: '定位失败',
80
+ });
81
+ setLocation({
82
+ poiname: '',
83
+ latlng: { lat: 39.98410411, lng: 116.307503 },
84
+ // @ts-ignore
85
+ locationType,
86
+ });
87
+ };
88
+ document.body.appendChild(script);
89
+ }
90
+ loadScript();
91
+ }, [APIKEY, locationType]);
92
+ return {
93
+ location,
94
+ setLocation,
95
+ apiKeyStatus,
96
+ setApiKeyStatus,
97
+ currentLocStatus,
98
+ currentLocations,
99
+ };
100
+ }
@@ -0,0 +1,243 @@
1
+ .weda-ui_form-location {
2
+ padding: 1.14286rem 0;
3
+ }
4
+
5
+ .form-location-warp {
6
+ display: flex;
7
+ white-space: nowrap;
8
+ }
9
+
10
+ .form-location-label {
11
+ display: flex;
12
+ align-items: center;
13
+ padding: 0 1.14286rem;
14
+ }
15
+ .form-location-label > span {
16
+ margin-right: 0.28571rem;
17
+ font-family: SimSun;
18
+ font-size: 0.85714rem;
19
+ color: #f60;
20
+ }
21
+
22
+ .form-location-con {
23
+ padding-left: 1.14286rem;
24
+ display: flex;
25
+ align-items: center;
26
+ }
27
+ .form-location-con > img {
28
+ width: 18px;
29
+ height: 18px;
30
+ }
31
+ .form-location-con > span {
32
+ color: #006eff;
33
+ margin-left: 8px;
34
+ cursor: pointer;
35
+ }
36
+
37
+ .form-location-con_disabled {
38
+ cursor: not-allowed !important;
39
+ }
40
+
41
+ .form-location-addr {
42
+ display: flex;
43
+ align-items: flex-start;
44
+ margin-top: 12px;
45
+ padding-left: 1.14286rem;
46
+ padding-right: 1.14286rem;
47
+ }
48
+
49
+ .form-location-addr-title {
50
+ font-size: 16px;
51
+ }
52
+ .form-location-addr-lat {
53
+ font-size: 12px;
54
+ color: rgba(0, 0, 0, 0.4);
55
+ line-height: 20px;
56
+ }
57
+
58
+ .form-location-addr > img {
59
+ width: 19px;
60
+ height: 19px;
61
+ }
62
+ .form-location-addr > div {
63
+ margin-left: 12px;
64
+ }
65
+ .form-map-container {
66
+ margin-top: 12px;
67
+ padding-left: 1.14286rem;
68
+ padding-right: 1.14286rem;
69
+ }
70
+
71
+ .form-select-map .tea-dialog__inner {
72
+ width: 100vw !important;
73
+ height: 100vh !important;
74
+ min-width: auto !important;
75
+ padding: 0;
76
+ }
77
+ .form-select-map .tea-dialog__header {
78
+ height: 30px;
79
+ margin-bottom: 0;
80
+ margin-left: 15px;
81
+ margin-right: 15px;
82
+ }
83
+ .form-select-map .tea-dialog__header .tea-dialog__headertitle {
84
+ line-height: 30px;
85
+ margin-bottom: 0;
86
+ }
87
+ .form-select-map .tea-dialog__body {
88
+ height: calc(100vh - 90px);
89
+ }
90
+ .form-select-map .tea-dialog__footer {
91
+ height: 30px;
92
+ margin-top: 10px;
93
+ }
94
+
95
+ /* mapChoose组件 */
96
+ .weda-ui_map-choose {
97
+ width: 100%;
98
+ height: 100%;
99
+ }
100
+ .map-choose-header {
101
+ width: 100%;
102
+ padding: 8px 15px;
103
+ position: relative;
104
+ border-bottom: 1px solid #d3d3d3;
105
+ }
106
+ .map-choose-header_focus {
107
+ padding-right: 60px;
108
+ }
109
+ .map-choose-header_focus .map-choose-header_search_cancel {
110
+ display: block;
111
+ }
112
+ .map-choose-header_focus .map-choose-header_search_place {
113
+ left: 10px;
114
+ transform: translate(0, 0);
115
+ }
116
+ .map-choose-header_search {
117
+ height: 30px;
118
+ background-color: #ebebeb;
119
+ padding-left: 10px;
120
+ padding-right: 10px;
121
+ color: #b4b4b4;
122
+ font-size: 15px;
123
+ line-height: 31px;
124
+ border-radius: 5px;
125
+ overflow: hidden;
126
+ white-space: nowrap;
127
+ text-overflow: ellipsis;
128
+ position: relative;
129
+ }
130
+ .map-choose-header_search_place {
131
+ position: absolute;
132
+ top: 0;
133
+ left: 50%;
134
+ display: flex;
135
+ align-items: center;
136
+ transform: translate(-50%, 0);
137
+ }
138
+ .map-choose-header_search_cancel {
139
+ position: absolute;
140
+ top: 0;
141
+ right: 0;
142
+ width: 55px;
143
+ height: 46px;
144
+ line-height: 46px;
145
+ text-align: center;
146
+ font-size: 16px;
147
+ color: #0079ff;
148
+ background-color: #fff;
149
+ cursor: pointer;
150
+ display: none;
151
+ }
152
+ .map-choose-header_search img {
153
+ width: 16px;
154
+ height: 16px;
155
+ margin-right: 4px;
156
+ }
157
+ .map-choose-header_search input {
158
+ display: block;
159
+ width: 100%;
160
+ padding-top: 6px;
161
+ padding-bottom: 6px;
162
+ border: 0;
163
+ font-size: 14px;
164
+ line-height: 18px;
165
+ background: 0 0;
166
+ position: relative;
167
+ z-index: 1;
168
+ }
169
+
170
+ .map-choose-con {
171
+ width: 100%;
172
+ height: calc(100% - 50px);
173
+ position: relative;
174
+ }
175
+ .map-choose-warp,
176
+ .map-choose-explore {
177
+ width: 100%;
178
+ height: 100%;
179
+ }
180
+ .map-choose-explore {
181
+ display: none;
182
+ }
183
+ .map-choose-explore_show {
184
+ display: block;
185
+ position: absolute;
186
+ z-index: 1000;
187
+ top: 0;
188
+ left: 0;
189
+ background-color: #fff;
190
+ overflow: hidden;
191
+ }
192
+
193
+ .map-choose-warp_sugges {
194
+ height: 55%;
195
+ width: 100%;
196
+ }
197
+ .map-choose-warp_sugges ul,
198
+ .map-choose-explore_show ul {
199
+ width: 100%;
200
+ height: 100%;
201
+ padding: 0 15px;
202
+ overflow: scroll;
203
+ }
204
+ .map-choose-warp_sugges li,
205
+ .map-choose-explore_show li {
206
+ width: 100%;
207
+ height: 59px;
208
+ padding-top: 6px;
209
+ position: relative;
210
+ border-bottom: 1px solid #d3d3d3;
211
+ cursor: pointer;
212
+ position: relative;
213
+ }
214
+ .map-choose-warp_sugges li span {
215
+ display: none;
216
+ }
217
+ .map-choose-warp_sugges_choosed span {
218
+ position: absolute;
219
+ right: 20px;
220
+ top: 50%;
221
+ transform: translate(0, -50%);
222
+ width: 16px;
223
+ height: 16px;
224
+ display: block !important;
225
+ background-image: url('https://qcloudimg.tencent-cloud.cn/raw/354c15c0cb845120ac3e9c474e6737b3.png');
226
+ background-size: 100% 100%;
227
+ background-repeat: no-repeat;
228
+ }
229
+ .map-choose-warp_sugges li div,
230
+ .map-choose-explore_show li div {
231
+ text-overflow: ellipsis;
232
+ white-space: nowrap;
233
+ overflow: hidden;
234
+ width: 98%;
235
+ }
236
+ .map-choose-warp_sugges_title,
237
+ .map-choose-explore_title {
238
+ font-size: 14px;
239
+ line-height: 27px;
240
+ color: #333;
241
+ font-weight: 400;
242
+ display: block;
243
+ }