@hzab/form-render-mobile 0.0.2 → 0.0.3
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/lib/index.js +1 -46492
- package/package.json +2 -4
- package/src/components/Select/index.tsx +4 -2
- package/src/components/Uploader/Image/index.less +43 -0
- package/src/components/Uploader/Image/index.tsx +32 -0
- package/src/components/Uploader/index.jsx +1 -2
- package/src/components/Uploader/uploader.jsx +2 -1
- package/src/components/index.ts +1 -2
- package/src/index.tsx +1 -1
- package/src/type.d.ts +2 -0
- package/lib/static/imgs/approachPointIcon_f2eb69df51.png +0 -0
- package/lib/static/imgs/layers-2x_8f2c4d1147.png +0 -0
- package/lib/static/imgs/layers_416d91365b.png +0 -0
- package/lib/static/imgs/marker-icon_2b3e1faf89.png +0 -0
- package/src/components/MapPicker/common/approachPointIcon.png +0 -0
- package/src/components/MapPicker/common/getCurrentPosition.js +0 -27
- package/src/components/MapPicker/common/gpsConvert.js +0 -236
- package/src/components/MapPicker/common/map-config.js +0 -7
- package/src/components/MapPicker/index.jsx +0 -82
- package/src/components/MapPicker/line-picker/car-route.json +0 -426
- package/src/components/MapPicker/line-picker/index.jsx +0 -188
- package/src/components/MapPicker/line-picker/index.less +0 -41
- package/src/components/MapPicker/line-picker/mockLonLat.js +0 -1
- package/src/components/MapPicker/location-picker/index.jsx +0 -104
- package/src/components/MapPicker/location-picker/index.less +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/form-render-mobile",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "formily-form-render-mobile",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"scripts": {
|
|
@@ -44,9 +44,7 @@
|
|
|
44
44
|
"@formily/core": "^2.2.29",
|
|
45
45
|
"@formily/react": "^2.2.29",
|
|
46
46
|
"antd-mobile": "^5.32.0",
|
|
47
|
-
"antd-mobile-icons": "^0.2.2"
|
|
48
|
-
"leaflet": "^1.9.4",
|
|
49
|
-
"react-leaflet": "^2.8.0"
|
|
47
|
+
"antd-mobile-icons": "^0.2.2"
|
|
50
48
|
},
|
|
51
49
|
"directories": {
|
|
52
50
|
"lib": "lib"
|
|
@@ -5,7 +5,7 @@ import { Picker } from "antd-mobile";
|
|
|
5
5
|
import "./index.less";
|
|
6
6
|
|
|
7
7
|
function Select(props) {
|
|
8
|
-
const { disabled, readOnly, placeholder = "请选择", field = {}, onChange } = props;
|
|
8
|
+
const { value, disabled, readOnly, placeholder = "请选择", field = {}, onChange } = props;
|
|
9
9
|
|
|
10
10
|
const { dataSource } = field;
|
|
11
11
|
|
|
@@ -33,13 +33,15 @@ function Select(props) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function onConfirm(value) {
|
|
36
|
-
|
|
36
|
+
// 去除数组?
|
|
37
|
+
onChange && onChange(value.length === 1 ? value[0] : value);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
return (
|
|
40
41
|
<div className="formily-select" onClick={onClick}>
|
|
41
42
|
<Picker
|
|
42
43
|
{...props}
|
|
44
|
+
value={Array.isArray(value) ? value : [value]}
|
|
43
45
|
style={{ pointerEvents: readOnly || disabled ? "none" : undefined }}
|
|
44
46
|
columns={_options}
|
|
45
47
|
visible={visible}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.uploader-image-previewer {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: center;
|
|
4
|
+
align-items: center;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
border: 1px solid #eee;
|
|
8
|
+
color: #fff;
|
|
9
|
+
background-color: #000;
|
|
10
|
+
border-radius: 4px;
|
|
11
|
+
|
|
12
|
+
.uploader-image-previewer-img {
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
max-height: 100%;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.uploader-image-previewer-mask {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
max-width: 100vw;
|
|
23
|
+
max-height: 100vh;
|
|
24
|
+
background-color: #000 !important;
|
|
25
|
+
.image-previewer-mask-img {
|
|
26
|
+
max-width: 100vw;
|
|
27
|
+
max-height: 100vh;
|
|
28
|
+
width: 100vw;
|
|
29
|
+
}
|
|
30
|
+
.image-previewer-mask-close-btn {
|
|
31
|
+
position: absolute;
|
|
32
|
+
right: 2vw;
|
|
33
|
+
top: 1vh;
|
|
34
|
+
width: 5vw;
|
|
35
|
+
height: 5vw;
|
|
36
|
+
line-height: 5vw;
|
|
37
|
+
font-size: 3vw;
|
|
38
|
+
text-align: center;
|
|
39
|
+
color: #fff;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
background-color: #333;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { Mask } from "antd-mobile";
|
|
3
|
+
|
|
4
|
+
import "./index.less";
|
|
5
|
+
|
|
6
|
+
function ImagePreviewer(props) {
|
|
7
|
+
const [maskVisible, setMaskVisible] = useState(false);
|
|
8
|
+
|
|
9
|
+
function onPreview() {
|
|
10
|
+
setMaskVisible(true);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={`uploader-image-previewer ${props.className || ""}`}>
|
|
15
|
+
<img className="uploader-image-previewer-img" src={props.src} alt={props.alt} onClick={onPreview} />
|
|
16
|
+
<Mask
|
|
17
|
+
className="uploader-image-previewer-mask"
|
|
18
|
+
visible={maskVisible}
|
|
19
|
+
getContainer={document.body}
|
|
20
|
+
destroyOnClose
|
|
21
|
+
onMaskClick={() => setMaskVisible(false)}
|
|
22
|
+
>
|
|
23
|
+
<img className="image-previewer-mask-img" src={props.src} alt={props.alt} />
|
|
24
|
+
<div className="image-previewer-mask-close-btn" onClick={() => setMaskVisible(false)}>
|
|
25
|
+
X
|
|
26
|
+
</div>
|
|
27
|
+
</Mask>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ImagePreviewer;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Form } from "antd-mobile";
|
|
2
1
|
import { connect, mapProps } from "@formily/react";
|
|
3
2
|
|
|
4
3
|
import Uploader from "./uploader";
|
|
5
4
|
|
|
6
5
|
function UploaderCom(props) {
|
|
7
|
-
const { field = {},
|
|
6
|
+
const { field = {}, onChange } = props;
|
|
8
7
|
const { name, mode } = field;
|
|
9
8
|
|
|
10
9
|
function onUploadChange(files) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useState, useRef, useEffect, useMemo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Button, Dialog, ActionSheet } from "antd-mobile";
|
|
3
3
|
import { CloseCircleFill } from "antd-mobile-icons";
|
|
4
4
|
|
|
5
5
|
import Video from "./video";
|
|
6
|
+
import Image from "./Image";
|
|
6
7
|
|
|
7
8
|
import { getImage, getVideo, getAudio } from "./common/cordova-camera";
|
|
8
9
|
import { getFileURL, checkImageUrl, checkVideoUrl, checkAudioUrl } from "./common/utils";
|
package/src/components/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ import Cascader from "./Cascader";
|
|
|
4
4
|
import NumberPicker from "./NumberPicker";
|
|
5
5
|
import DatePicker from "./DatePicker";
|
|
6
6
|
import Password from "./Password";
|
|
7
|
-
import MapPicker from "./MapPicker";
|
|
8
7
|
import Uploader from "./Uploader";
|
|
9
8
|
|
|
10
|
-
export { NumberPicker, Password, Select, Cascader, DatePicker, Text,
|
|
9
|
+
export { NumberPicker, Password, Select, Cascader, DatePicker, Text, Uploader };
|
package/src/index.tsx
CHANGED
package/src/type.d.ts
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
function getCurrentPosition(config) {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
// if (window._isMock) {
|
|
4
|
-
// // TODO: 去除 mock 数据
|
|
5
|
-
// resolve({
|
|
6
|
-
// coords: {
|
|
7
|
-
// longitude: 120.19832490988816,
|
|
8
|
-
// latitude: 30.229457352287543,
|
|
9
|
-
// },
|
|
10
|
-
// });
|
|
11
|
-
// return;
|
|
12
|
-
// }
|
|
13
|
-
navigator.geolocation.getCurrentPosition(
|
|
14
|
-
(position) => {
|
|
15
|
-
resolve(position);
|
|
16
|
-
},
|
|
17
|
-
reject,
|
|
18
|
-
{
|
|
19
|
-
enableHighAccuracy: true,
|
|
20
|
-
timeout: 5000,
|
|
21
|
-
...config,
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default getCurrentPosition;
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/* eslint-disable*/
|
|
2
|
-
/*
|
|
3
|
-
* BD-09:百度坐标系(百度地图)
|
|
4
|
-
* GCJ-02:火星坐标系(谷歌中国地图、高德地图)
|
|
5
|
-
* WGS84:地球坐标系(国际通用坐标系,谷歌地图)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const x_PI = (3.14159265358979324 * 3000.0) / 180.0;
|
|
9
|
-
const PI = 3.1415926535897932384626;
|
|
10
|
-
const a = 6378245.0;
|
|
11
|
-
const ee = 0.00669342162296594323;
|
|
12
|
-
|
|
13
|
-
// 百度坐标系转火星坐标系
|
|
14
|
-
function bd09togcj02(bd_lon, bd_lat) {
|
|
15
|
-
const x = bd_lon - 0.0065;
|
|
16
|
-
const y = bd_lat - 0.006;
|
|
17
|
-
const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI);
|
|
18
|
-
const theta = Math.Atan2(y, x) - 0.000003 * Math.cos(x * x_PI);
|
|
19
|
-
|
|
20
|
-
const gcj_lon = z * Math.cos(theta);
|
|
21
|
-
const gcj_lat = z * Math.sin(theta);
|
|
22
|
-
const gcj = [gcj_lon, gcj_lat]; // 火星坐标系值
|
|
23
|
-
|
|
24
|
-
// 火星坐标系转wgs84
|
|
25
|
-
const wgs = [gcj02towgs84(gcj[0], gcj[1])];
|
|
26
|
-
return wgs;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 火星坐标系转wgs84
|
|
30
|
-
export function gcj02towgs84(gcj_lon, gcj_lat) {
|
|
31
|
-
gcj_lon = Number(gcj_lon);
|
|
32
|
-
gcj_lat = Number(gcj_lat);
|
|
33
|
-
if (out_of_china(gcj_lon, gcj_lat)) {
|
|
34
|
-
// 不在国内,不进行纠偏
|
|
35
|
-
const back = [gcj_lat, gcj_lon];
|
|
36
|
-
return back;
|
|
37
|
-
} else {
|
|
38
|
-
let dlon = transformlon(gcj_lon - 105.0, gcj_lat - 35.0);
|
|
39
|
-
let dlat = transformlat(gcj_lon - 105.0, gcj_lat - 35.0);
|
|
40
|
-
const radlat = (gcj_lat / 180.0) * PI;
|
|
41
|
-
let magic = Math.sin(radlat);
|
|
42
|
-
magic = 1 - ee * magic * magic;
|
|
43
|
-
const sqrtmagic = Math.sqrt(magic);
|
|
44
|
-
dlon = (dlon * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI);
|
|
45
|
-
dlat = (dlat * 180.0) / (((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
|
|
46
|
-
const mglon = gcj_lon + dlon;
|
|
47
|
-
const mglat = gcj_lat + dlat;
|
|
48
|
-
const wgs_lon = gcj_lon * 2 - mglon;
|
|
49
|
-
const wgs_lat = gcj_lat * 2 - mglat;
|
|
50
|
-
const wgs = [wgs_lat, wgs_lon]; // wgs84坐标系值
|
|
51
|
-
return wgs;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 火星坐标系转百度坐标系
|
|
56
|
-
function gcj02tobd09(gcj_lon, gcj_lat) {
|
|
57
|
-
const z = Math.sqrt(gcj_lon * gcj_lon + gcj_lat * gcj_lat) + 0.00002 * Math.sin(gcj_lat * x_PI);
|
|
58
|
-
const theta = Math.atan2(gcj_lat, gcj_lon) + 0.000003 * Math.cos(gcj_lon * x_PI);
|
|
59
|
-
const bd_lon = z * Math.cos(theta) + 0.0065;
|
|
60
|
-
const bd_lat = z * Math.sin(theta) + 0.006;
|
|
61
|
-
const bd = [bd_lon, bd_lat];
|
|
62
|
-
return bd;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// wgs84转火星坐标系
|
|
66
|
-
export function wgs84togcj02(wgs_lon, wgs_lat, isWgs84 = false) {
|
|
67
|
-
wgs_lon = Number(wgs_lon);
|
|
68
|
-
wgs_lat = Number(wgs_lat);
|
|
69
|
-
if (out_of_china(wgs_lon, wgs_lat)) {
|
|
70
|
-
// 不在国内
|
|
71
|
-
const back = [wgs_lon, wgs_lat];
|
|
72
|
-
return back;
|
|
73
|
-
} else {
|
|
74
|
-
if (isWgs84) {
|
|
75
|
-
return [wgs_lat, wgs_lon];
|
|
76
|
-
} else {
|
|
77
|
-
let dwgs_lon = transformlon(wgs_lon - 105.0, wgs_lat - 35.0);
|
|
78
|
-
let dwgs_lat = transformlat(wgs_lon - 105.0, wgs_lat - 35.0);
|
|
79
|
-
const radwgs_lat = (wgs_lat / 180.0) * PI;
|
|
80
|
-
let magic = Math.sin(radwgs_lat);
|
|
81
|
-
magic = 1 - ee * magic * magic;
|
|
82
|
-
const sqrtmagic = Math.sqrt(magic);
|
|
83
|
-
dwgs_lon = (dwgs_lon * 180.0) / ((a / sqrtmagic) * Math.cos(radwgs_lat) * PI);
|
|
84
|
-
dwgs_lat = (dwgs_lat * 180.0) / (((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
|
|
85
|
-
const gcj_lon = wgs_lon + dwgs_lon;
|
|
86
|
-
const gcj_lat = wgs_lat + dwgs_lat;
|
|
87
|
-
const gcj = [gcj_lat, gcj_lon];
|
|
88
|
-
return gcj;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function transformlon(lon, lat) {
|
|
94
|
-
let ret = 300.0 + lon + 2.0 * lat + 0.1 * lon * lon + 0.1 * lon * lat + 0.1 * Math.sqrt(Math.abs(lon));
|
|
95
|
-
ret += ((20.0 * Math.sin(6.0 * lon * PI) + 20.0 * Math.sin(2.0 * lon * PI)) * 2.0) / 3.0;
|
|
96
|
-
ret += ((20.0 * Math.sin(lon * PI) + 40.0 * Math.sin((lon / 3.0) * PI)) * 2.0) / 3.0;
|
|
97
|
-
ret += ((150.0 * Math.sin((lon / 12.0) * PI) + 300.0 * Math.sin((lon / 30.0) * PI)) * 2.0) / 3.0;
|
|
98
|
-
return ret;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function transformlat(lon, lat) {
|
|
102
|
-
let ret = -100.0 + 2.0 * lon + 3.0 * lat + 0.2 * lat * lat + 0.1 * lon * lat + 0.2 * Math.sqrt(Math.abs(lon));
|
|
103
|
-
ret += ((20.0 * Math.sin(6.0 * lon * PI) + 20.0 * Math.sin(2.0 * lon * PI)) * 2.0) / 3.0;
|
|
104
|
-
ret += ((20.0 * Math.sin(lat * PI) + 40.0 * Math.sin((lat / 3.0) * PI)) * 2.0) / 3.0;
|
|
105
|
-
ret += ((160.0 * Math.sin((lat / 12.0) * PI) + 320 * Math.sin((lat * PI) / 30.0)) * 2.0) / 3.0;
|
|
106
|
-
return ret;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 判断是否在国内,不在国内则不做偏移
|
|
110
|
-
function out_of_china(lon, lat) {
|
|
111
|
-
return lon < 72.004 || lon > 137.8347 || lat < 0.8293 || lat > 55.8271 || false;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 1.加密解密方法使用:
|
|
115
|
-
|
|
116
|
-
// 1.加密
|
|
117
|
-
// var str = '124中文内容';
|
|
118
|
-
// var base = new Base64();
|
|
119
|
-
// var result = base.encode(str);
|
|
120
|
-
// document.write(result);
|
|
121
|
-
|
|
122
|
-
// 2.解密
|
|
123
|
-
// var result2 = base.decode(result);
|
|
124
|
-
// document.write(result2);
|
|
125
|
-
// 2.加密、解密算法封装:
|
|
126
|
-
|
|
127
|
-
function Base64() {
|
|
128
|
-
// private property
|
|
129
|
-
_keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
130
|
-
|
|
131
|
-
// public method for encoding
|
|
132
|
-
this.encode = function (input) {
|
|
133
|
-
let output = "";
|
|
134
|
-
let chr1;
|
|
135
|
-
let chr2;
|
|
136
|
-
let chr3;
|
|
137
|
-
let enc1;
|
|
138
|
-
let enc2;
|
|
139
|
-
let enc3;
|
|
140
|
-
let enc4;
|
|
141
|
-
let i = 0;
|
|
142
|
-
input = _utf8_encode(input);
|
|
143
|
-
while (i < input.length) {
|
|
144
|
-
chr1 = input.charCodeAt(i++);
|
|
145
|
-
chr2 = input.charCodeAt(i++);
|
|
146
|
-
chr3 = input.charCodeAt(i++);
|
|
147
|
-
enc1 = chr1 >> 2;
|
|
148
|
-
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
149
|
-
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
150
|
-
enc4 = chr3 & 63;
|
|
151
|
-
if (isNaN(chr2)) {
|
|
152
|
-
enc3 = enc4 = 64;
|
|
153
|
-
} else if (isNaN(chr3)) {
|
|
154
|
-
enc4 = 64;
|
|
155
|
-
}
|
|
156
|
-
output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
|
157
|
-
}
|
|
158
|
-
return output;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// public method for decoding
|
|
162
|
-
this.decode = function (input) {
|
|
163
|
-
let output = "";
|
|
164
|
-
let chr1;
|
|
165
|
-
let chr2;
|
|
166
|
-
let chr3;
|
|
167
|
-
let enc1;
|
|
168
|
-
let enc2;
|
|
169
|
-
let enc3;
|
|
170
|
-
let enc4;
|
|
171
|
-
let i = 0;
|
|
172
|
-
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
|
173
|
-
while (i < input.length) {
|
|
174
|
-
enc1 = _keyStr.indexOf(input.charAt(i++));
|
|
175
|
-
enc2 = _keyStr.indexOf(input.charAt(i++));
|
|
176
|
-
enc3 = _keyStr.indexOf(input.charAt(i++));
|
|
177
|
-
enc4 = _keyStr.indexOf(input.charAt(i++));
|
|
178
|
-
chr1 = (enc1 << 2) | (enc2 >> 4);
|
|
179
|
-
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
180
|
-
chr3 = ((enc3 & 3) << 6) | enc4;
|
|
181
|
-
output += String.fromCharCode(chr1);
|
|
182
|
-
if (enc3 != 64) {
|
|
183
|
-
output += String.fromCharCode(chr2);
|
|
184
|
-
}
|
|
185
|
-
if (enc4 != 64) {
|
|
186
|
-
output += String.fromCharCode(chr3);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
output = _utf8_decode(output);
|
|
190
|
-
return output;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// private method for UTF-8 encoding
|
|
194
|
-
_utf8_encode = function (string) {
|
|
195
|
-
string = string.replace(/\r\n/g, "\n");
|
|
196
|
-
let utftext = "";
|
|
197
|
-
for (let n = 0; n < string.length; n++) {
|
|
198
|
-
const c = string.charCodeAt(n);
|
|
199
|
-
if (c < 128) {
|
|
200
|
-
utftext += String.fromCharCode(c);
|
|
201
|
-
} else if (c > 127 && c < 2048) {
|
|
202
|
-
utftext += String.fromCharCode((c >> 6) | 192);
|
|
203
|
-
utftext += String.fromCharCode((c & 63) | 128);
|
|
204
|
-
} else {
|
|
205
|
-
utftext += String.fromCharCode((c >> 12) | 224);
|
|
206
|
-
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
207
|
-
utftext += String.fromCharCode((c & 63) | 128);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return utftext;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
// private method for UTF-8 decoding
|
|
214
|
-
_utf8_decode = function (utftext) {
|
|
215
|
-
let string = "";
|
|
216
|
-
let i = 0;
|
|
217
|
-
let c = (c1 = c2 = 0);
|
|
218
|
-
while (i < utftext.length) {
|
|
219
|
-
c = utftext.charCodeAt(i);
|
|
220
|
-
if (c < 128) {
|
|
221
|
-
string += String.fromCharCode(c);
|
|
222
|
-
i++;
|
|
223
|
-
} else if (c > 191 && c < 224) {
|
|
224
|
-
c2 = utftext.charCodeAt(i + 1);
|
|
225
|
-
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
|
226
|
-
i += 2;
|
|
227
|
-
} else {
|
|
228
|
-
c2 = utftext.charCodeAt(i + 1);
|
|
229
|
-
c3 = utftext.charCodeAt(i + 2);
|
|
230
|
-
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
|
231
|
-
i += 3;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return string;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { connect, mapProps } from "@formily/react";
|
|
3
|
-
import { Form, Button, Popup } from "antd-mobile";
|
|
4
|
-
|
|
5
|
-
import LocationPicker from "./location-picker";
|
|
6
|
-
import LinePicker from "./line-picker";
|
|
7
|
-
|
|
8
|
-
function LocationPickerCom(props) {
|
|
9
|
-
const { name, formInstance, onChange, data = {}, disabled, readOnly, fieldConf, mode } = props;
|
|
10
|
-
|
|
11
|
-
const [visible, setVisible] = useState(false);
|
|
12
|
-
const [_data, setData] = useState({});
|
|
13
|
-
|
|
14
|
-
function onLocationChange(res) {
|
|
15
|
-
formInstance?.setFieldValue(name, res);
|
|
16
|
-
|
|
17
|
-
setData(res);
|
|
18
|
-
onChange && onChange(res);
|
|
19
|
-
onCancel();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function onCancel() {
|
|
23
|
-
setVisible(false);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let _mode = mode;
|
|
27
|
-
if (fieldConf && fieldConf.mode && !_mode) {
|
|
28
|
-
_mode = fieldConf.mode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<>
|
|
33
|
-
{_mode === "line" ? (
|
|
34
|
-
// TODO: 展示逻辑优化
|
|
35
|
-
<div>
|
|
36
|
-
<div>
|
|
37
|
-
起点:{_data?.start?.lng || data?.start?.lng}, {_data?.start?.lat || data?.start?.lat}
|
|
38
|
-
</div>
|
|
39
|
-
<div>
|
|
40
|
-
终点:{_data?.end?.lng || data?.end?.lng}, {_data?.end?.lat || data?.end?.lat}
|
|
41
|
-
</div>
|
|
42
|
-
{/* <div>
|
|
43
|
-
起点:{_data.start && _data.start.lng},{" "}
|
|
44
|
-
{_data.start && _data.start.lat}
|
|
45
|
-
</div>
|
|
46
|
-
<div>
|
|
47
|
-
终点:{_data.end && _data.end.lng}, {_data.end && _data.end.lat}
|
|
48
|
-
</div> */}
|
|
49
|
-
</div>
|
|
50
|
-
) : (
|
|
51
|
-
<span>
|
|
52
|
-
经度:{_data.lng || data.lng}
|
|
53
|
-
纬度:{_data.lat || data.lat}
|
|
54
|
-
|
|
55
|
-
</span>
|
|
56
|
-
)}
|
|
57
|
-
{disabled || readOnly ? null : (
|
|
58
|
-
<Button
|
|
59
|
-
onClick={() => {
|
|
60
|
-
setVisible(true);
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
地图选点
|
|
64
|
-
</Button>
|
|
65
|
-
)}
|
|
66
|
-
<Popup visible={visible} onMaskClick={onCancel} bodyStyle={{ height: "80vh" }}>
|
|
67
|
-
{_mode === "line" ? (
|
|
68
|
-
<LinePicker data={props.data} onConfirm={onLocationChange} onCancel={onCancel} />
|
|
69
|
-
) : (
|
|
70
|
-
<LocationPicker data={props.data} onConfirm={onLocationChange} onCancel={onCancel} />
|
|
71
|
-
)}
|
|
72
|
-
</Popup>
|
|
73
|
-
</>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default connect(
|
|
78
|
-
LocationPickerCom,
|
|
79
|
-
mapProps((props, field) => {
|
|
80
|
-
return { ...props, form: field.form, field };
|
|
81
|
-
}),
|
|
82
|
-
);
|