@fle-ui/plus-address-selection 1.0.12 → 1.0.13
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/es/index.d.ts +3 -1
- package/es/index.js +36 -59
- package/es/utils/api.d.ts +10 -0
- package/es/utils/api.js +24 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +36 -59
- package/lib/utils/api.d.ts +10 -0
- package/lib/utils/api.js +31 -0
- package/package.json +2 -2
- package/es/utils/httpClient.d.ts +0 -13
- package/es/utils/httpClient.js +0 -76
- package/es/utils/index.d.ts +0 -2
- package/es/utils/index.js +0 -2
- package/lib/utils/httpClient.d.ts +0 -13
- package/lib/utils/httpClient.js +0 -82
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.js +0 -13
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CascaderProps } from 'antd';
|
|
3
|
+
import { Env } from './utils/api';
|
|
3
4
|
export declare type CascaderValueType = string | Array<string | number>;
|
|
4
5
|
export interface CascaderOptionType {
|
|
5
6
|
value?: string | number;
|
|
@@ -34,7 +35,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
34
35
|
*/
|
|
35
36
|
apiUrl?: string;
|
|
36
37
|
/**
|
|
37
|
-
* @description 地址层级 默认四级
|
|
38
|
+
* @description 地址层级 默认四级 --
|
|
38
39
|
* @default 4
|
|
39
40
|
*/
|
|
40
41
|
level?: number;
|
|
@@ -48,6 +49,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
48
49
|
* @default []
|
|
49
50
|
*/
|
|
50
51
|
options?: CascaderOptionType[];
|
|
52
|
+
env?: Env;
|
|
51
53
|
}
|
|
52
54
|
declare const AddressSelection: React.FC<SiteSelectProps>;
|
|
53
55
|
export default AddressSelection;
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
import "antd/es/cascader/style";
|
|
3
3
|
import _Cascader from "antd/es/cascader";
|
|
4
|
-
var _excluded = ["level", "value", "onChange", "valueDivision", "apiUrl"];
|
|
4
|
+
var _excluded = ["env", "level", "value", "onChange", "valueDivision", "apiUrl"];
|
|
5
5
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
6
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
7
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -22,25 +22,28 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
23
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
24
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
25
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var
|
|
25
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
26
26
|
import React, { useEffect, useState } from 'react';
|
|
27
27
|
import _ from 'lodash';
|
|
28
|
-
import {
|
|
28
|
+
import { apiCreate } from './utils/api';
|
|
29
29
|
var defaultProps = {
|
|
30
30
|
level: 4,
|
|
31
31
|
valueDivision: '',
|
|
32
32
|
value: [],
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
apiUrl: '/basic/area/areas',
|
|
34
|
+
onChange: function onChange() {}
|
|
35
35
|
};
|
|
36
36
|
var AddressSelection = function AddressSelection(props) {
|
|
37
37
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
38
|
+
env = _defaultProps$props.env,
|
|
38
39
|
level = _defaultProps$props.level,
|
|
39
40
|
value = _defaultProps$props.value,
|
|
40
41
|
onChange = _defaultProps$props.onChange,
|
|
41
42
|
valueDivision = _defaultProps$props.valueDivision,
|
|
42
43
|
apiUrl = _defaultProps$props.apiUrl,
|
|
43
44
|
otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
45
|
+
var _apiCreate = apiCreate(apiUrl, env),
|
|
46
|
+
getAddress = _apiCreate.getAddress;
|
|
44
47
|
var _useState = useState([]),
|
|
45
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
46
49
|
addressList = _useState2[0],
|
|
@@ -65,7 +68,7 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
65
68
|
while (1) switch (_context.prev = _context.next) {
|
|
66
69
|
case 0:
|
|
67
70
|
_context.next = 2;
|
|
68
|
-
return
|
|
71
|
+
return getAddress({
|
|
69
72
|
parentCode: 0
|
|
70
73
|
});
|
|
71
74
|
case 2:
|
|
@@ -118,57 +121,31 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
118
121
|
};
|
|
119
122
|
});
|
|
120
123
|
};
|
|
121
|
-
var getAddressAPI = /*#__PURE__*/function () {
|
|
122
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
123
|
-
var params,
|
|
124
|
-
_yield$httpClient$pos,
|
|
125
|
-
data,
|
|
126
|
-
_args2 = arguments;
|
|
127
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
128
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
129
|
-
case 0:
|
|
130
|
-
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
131
|
-
_context2.next = 3;
|
|
132
|
-
return httpClient.post(apiUrl || '/basic/area/areas', params);
|
|
133
|
-
case 3:
|
|
134
|
-
_yield$httpClient$pos = _context2.sent;
|
|
135
|
-
data = _yield$httpClient$pos.data;
|
|
136
|
-
return _context2.abrupt("return", data);
|
|
137
|
-
case 6:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context2.stop();
|
|
140
|
-
}
|
|
141
|
-
}, _callee2);
|
|
142
|
-
}));
|
|
143
|
-
return function getAddressAPI() {
|
|
144
|
-
return _ref.apply(this, arguments);
|
|
145
|
-
};
|
|
146
|
-
}();
|
|
147
124
|
var initAddress = /*#__PURE__*/function () {
|
|
148
|
-
var
|
|
125
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
|
|
149
126
|
var provinceList, len, thisAddress, _loop, i;
|
|
150
|
-
return _regeneratorRuntime().wrap(function
|
|
151
|
-
while (1) switch (
|
|
127
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
128
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
152
129
|
case 0:
|
|
153
130
|
provinceList = _.cloneDeep(addressList);
|
|
154
131
|
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
155
132
|
if (!len) {
|
|
156
|
-
|
|
133
|
+
_context3.next = 11;
|
|
157
134
|
break;
|
|
158
135
|
}
|
|
159
136
|
thisAddress = provinceList;
|
|
160
137
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
161
138
|
var _thisAddress;
|
|
162
139
|
var levelData, thisIndex;
|
|
163
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
164
|
-
while (1) switch (
|
|
140
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
141
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
165
142
|
case 0:
|
|
166
|
-
|
|
167
|
-
return
|
|
143
|
+
_context2.next = 2;
|
|
144
|
+
return getAddress({
|
|
168
145
|
parentCode: defaultValue[i]
|
|
169
146
|
});
|
|
170
147
|
case 2:
|
|
171
|
-
levelData =
|
|
148
|
+
levelData = _context2.sent;
|
|
172
149
|
thisIndex = -1;
|
|
173
150
|
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
174
151
|
if (item.value === defaultValue[i]) {
|
|
@@ -184,53 +161,53 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
184
161
|
}
|
|
185
162
|
case 7:
|
|
186
163
|
case "end":
|
|
187
|
-
return
|
|
164
|
+
return _context2.stop();
|
|
188
165
|
}
|
|
189
166
|
}, _loop);
|
|
190
167
|
});
|
|
191
168
|
i = 0;
|
|
192
169
|
case 6:
|
|
193
170
|
if (!(i < len - 1)) {
|
|
194
|
-
|
|
171
|
+
_context3.next = 11;
|
|
195
172
|
break;
|
|
196
173
|
}
|
|
197
|
-
return
|
|
174
|
+
return _context3.delegateYield(_loop(i), "t0", 8);
|
|
198
175
|
case 8:
|
|
199
176
|
i++;
|
|
200
|
-
|
|
177
|
+
_context3.next = 6;
|
|
201
178
|
break;
|
|
202
179
|
case 11:
|
|
203
180
|
setAddressList(provinceList);
|
|
204
181
|
case 12:
|
|
205
182
|
case "end":
|
|
206
|
-
return
|
|
183
|
+
return _context3.stop();
|
|
207
184
|
}
|
|
208
|
-
},
|
|
185
|
+
}, _callee2);
|
|
209
186
|
}));
|
|
210
187
|
return function initAddress(_x, _x2) {
|
|
211
|
-
return
|
|
188
|
+
return _ref.apply(this, arguments);
|
|
212
189
|
};
|
|
213
190
|
}();
|
|
214
191
|
var loadData = /*#__PURE__*/function () {
|
|
215
|
-
var
|
|
192
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
|
|
216
193
|
var targetOption, data;
|
|
217
|
-
return _regeneratorRuntime().wrap(function
|
|
218
|
-
while (1) switch (
|
|
194
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
195
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
219
196
|
case 0:
|
|
220
197
|
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
221
198
|
if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
|
|
222
|
-
|
|
199
|
+
_context4.next = 3;
|
|
223
200
|
break;
|
|
224
201
|
}
|
|
225
|
-
return
|
|
202
|
+
return _context4.abrupt("return");
|
|
226
203
|
case 3:
|
|
227
204
|
targetOption.loading = true;
|
|
228
|
-
|
|
229
|
-
return
|
|
205
|
+
_context4.next = 6;
|
|
206
|
+
return getAddress({
|
|
230
207
|
parentCode: targetOption.value
|
|
231
208
|
});
|
|
232
209
|
case 6:
|
|
233
|
-
data =
|
|
210
|
+
data = _context4.sent;
|
|
234
211
|
targetOption.loading = false;
|
|
235
212
|
if (data.length) {
|
|
236
213
|
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
@@ -241,12 +218,12 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
241
218
|
setAddressList(_toConsumableArray(addressList));
|
|
242
219
|
case 11:
|
|
243
220
|
case "end":
|
|
244
|
-
return
|
|
221
|
+
return _context4.stop();
|
|
245
222
|
}
|
|
246
|
-
},
|
|
223
|
+
}, _callee3);
|
|
247
224
|
}));
|
|
248
225
|
return function loadData(_x3) {
|
|
249
|
-
return
|
|
226
|
+
return _ref2.apply(this, arguments);
|
|
250
227
|
};
|
|
251
228
|
}();
|
|
252
229
|
var handleChange = function handleChange(info, selectedOptions) {
|
package/es/utils/api.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
var baseURLMap = {
|
|
3
|
+
dev: 'https://dev-gateway.fxqifu.net/pangu',
|
|
4
|
+
qa: 'https://qa-gateway.fxqifu.net/pangu',
|
|
5
|
+
prod: 'https://gateway.fxqifu.net/pangu'
|
|
6
|
+
};
|
|
7
|
+
export var apiCreate = function apiCreate(apiUrl, env) {
|
|
8
|
+
var envGet = env || localStorage.getItem('env') || 'prod';
|
|
9
|
+
var baseURL = baseURLMap[envGet];
|
|
10
|
+
return {
|
|
11
|
+
getAddress: function getAddress(data) {
|
|
12
|
+
return new Promise(function (resolve, reject) {
|
|
13
|
+
axios.post("".concat(baseURL).concat(apiUrl), data).then(function (res) {
|
|
14
|
+
var _res$data;
|
|
15
|
+
if (Array.isArray((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.data)) {
|
|
16
|
+
resolve(res.data.data);
|
|
17
|
+
} else {
|
|
18
|
+
resolve([]);
|
|
19
|
+
}
|
|
20
|
+
}).catch(reject);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CascaderProps } from 'antd';
|
|
3
|
+
import { Env } from './utils/api';
|
|
3
4
|
export declare type CascaderValueType = string | Array<string | number>;
|
|
4
5
|
export interface CascaderOptionType {
|
|
5
6
|
value?: string | number;
|
|
@@ -34,7 +35,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
34
35
|
*/
|
|
35
36
|
apiUrl?: string;
|
|
36
37
|
/**
|
|
37
|
-
* @description 地址层级 默认四级
|
|
38
|
+
* @description 地址层级 默认四级 --
|
|
38
39
|
* @default 4
|
|
39
40
|
*/
|
|
40
41
|
level?: number;
|
|
@@ -48,6 +49,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
48
49
|
* @default []
|
|
49
50
|
*/
|
|
50
51
|
options?: CascaderOptionType[];
|
|
52
|
+
env?: Env;
|
|
51
53
|
}
|
|
52
54
|
declare const AddressSelection: React.FC<SiteSelectProps>;
|
|
53
55
|
export default AddressSelection;
|
package/lib/index.js
CHANGED
|
@@ -8,8 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _antd = require("antd");
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
-
var
|
|
12
|
-
var _excluded = ["level", "value", "onChange", "valueDivision", "apiUrl"];
|
|
11
|
+
var _api = require("./utils/api");
|
|
12
|
+
var _excluded = ["env", "level", "value", "onChange", "valueDivision", "apiUrl"];
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -33,22 +33,25 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
33
33
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
34
34
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
35
35
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
36
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var
|
|
36
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
37
37
|
var defaultProps = {
|
|
38
38
|
level: 4,
|
|
39
39
|
valueDivision: '',
|
|
40
40
|
value: [],
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
apiUrl: '/basic/area/areas',
|
|
42
|
+
onChange: function onChange() {}
|
|
43
43
|
};
|
|
44
44
|
var AddressSelection = function AddressSelection(props) {
|
|
45
45
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
46
|
+
env = _defaultProps$props.env,
|
|
46
47
|
level = _defaultProps$props.level,
|
|
47
48
|
value = _defaultProps$props.value,
|
|
48
49
|
onChange = _defaultProps$props.onChange,
|
|
49
50
|
valueDivision = _defaultProps$props.valueDivision,
|
|
50
51
|
apiUrl = _defaultProps$props.apiUrl,
|
|
51
52
|
otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
53
|
+
var _apiCreate = (0, _api.apiCreate)(apiUrl, env),
|
|
54
|
+
getAddress = _apiCreate.getAddress;
|
|
52
55
|
var _useState = (0, _react.useState)([]),
|
|
53
56
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
57
|
addressList = _useState2[0],
|
|
@@ -73,7 +76,7 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
73
76
|
while (1) switch (_context.prev = _context.next) {
|
|
74
77
|
case 0:
|
|
75
78
|
_context.next = 2;
|
|
76
|
-
return
|
|
79
|
+
return getAddress({
|
|
77
80
|
parentCode: 0
|
|
78
81
|
});
|
|
79
82
|
case 2:
|
|
@@ -126,57 +129,31 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
126
129
|
};
|
|
127
130
|
});
|
|
128
131
|
};
|
|
129
|
-
var getAddressAPI = /*#__PURE__*/function () {
|
|
130
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
131
|
-
var params,
|
|
132
|
-
_yield$httpClient$pos,
|
|
133
|
-
data,
|
|
134
|
-
_args2 = arguments;
|
|
135
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
136
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
137
|
-
case 0:
|
|
138
|
-
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
139
|
-
_context2.next = 3;
|
|
140
|
-
return _utils.httpClient.post(apiUrl || '/basic/area/areas', params);
|
|
141
|
-
case 3:
|
|
142
|
-
_yield$httpClient$pos = _context2.sent;
|
|
143
|
-
data = _yield$httpClient$pos.data;
|
|
144
|
-
return _context2.abrupt("return", data);
|
|
145
|
-
case 6:
|
|
146
|
-
case "end":
|
|
147
|
-
return _context2.stop();
|
|
148
|
-
}
|
|
149
|
-
}, _callee2);
|
|
150
|
-
}));
|
|
151
|
-
return function getAddressAPI() {
|
|
152
|
-
return _ref.apply(this, arguments);
|
|
153
|
-
};
|
|
154
|
-
}();
|
|
155
132
|
var initAddress = /*#__PURE__*/function () {
|
|
156
|
-
var
|
|
133
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
|
|
157
134
|
var provinceList, len, thisAddress, _loop, i;
|
|
158
|
-
return _regeneratorRuntime().wrap(function
|
|
159
|
-
while (1) switch (
|
|
135
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
136
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
160
137
|
case 0:
|
|
161
138
|
provinceList = _lodash.default.cloneDeep(addressList);
|
|
162
139
|
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
163
140
|
if (!len) {
|
|
164
|
-
|
|
141
|
+
_context3.next = 11;
|
|
165
142
|
break;
|
|
166
143
|
}
|
|
167
144
|
thisAddress = provinceList;
|
|
168
145
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
169
146
|
var _thisAddress;
|
|
170
147
|
var levelData, thisIndex;
|
|
171
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
172
|
-
while (1) switch (
|
|
148
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
149
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
173
150
|
case 0:
|
|
174
|
-
|
|
175
|
-
return
|
|
151
|
+
_context2.next = 2;
|
|
152
|
+
return getAddress({
|
|
176
153
|
parentCode: defaultValue[i]
|
|
177
154
|
});
|
|
178
155
|
case 2:
|
|
179
|
-
levelData =
|
|
156
|
+
levelData = _context2.sent;
|
|
180
157
|
thisIndex = -1;
|
|
181
158
|
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
182
159
|
if (item.value === defaultValue[i]) {
|
|
@@ -192,53 +169,53 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
192
169
|
}
|
|
193
170
|
case 7:
|
|
194
171
|
case "end":
|
|
195
|
-
return
|
|
172
|
+
return _context2.stop();
|
|
196
173
|
}
|
|
197
174
|
}, _loop);
|
|
198
175
|
});
|
|
199
176
|
i = 0;
|
|
200
177
|
case 6:
|
|
201
178
|
if (!(i < len - 1)) {
|
|
202
|
-
|
|
179
|
+
_context3.next = 11;
|
|
203
180
|
break;
|
|
204
181
|
}
|
|
205
|
-
return
|
|
182
|
+
return _context3.delegateYield(_loop(i), "t0", 8);
|
|
206
183
|
case 8:
|
|
207
184
|
i++;
|
|
208
|
-
|
|
185
|
+
_context3.next = 6;
|
|
209
186
|
break;
|
|
210
187
|
case 11:
|
|
211
188
|
setAddressList(provinceList);
|
|
212
189
|
case 12:
|
|
213
190
|
case "end":
|
|
214
|
-
return
|
|
191
|
+
return _context3.stop();
|
|
215
192
|
}
|
|
216
|
-
},
|
|
193
|
+
}, _callee2);
|
|
217
194
|
}));
|
|
218
195
|
return function initAddress(_x, _x2) {
|
|
219
|
-
return
|
|
196
|
+
return _ref.apply(this, arguments);
|
|
220
197
|
};
|
|
221
198
|
}();
|
|
222
199
|
var loadData = /*#__PURE__*/function () {
|
|
223
|
-
var
|
|
200
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
|
|
224
201
|
var targetOption, data;
|
|
225
|
-
return _regeneratorRuntime().wrap(function
|
|
226
|
-
while (1) switch (
|
|
202
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
203
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
227
204
|
case 0:
|
|
228
205
|
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
229
206
|
if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
|
|
230
|
-
|
|
207
|
+
_context4.next = 3;
|
|
231
208
|
break;
|
|
232
209
|
}
|
|
233
|
-
return
|
|
210
|
+
return _context4.abrupt("return");
|
|
234
211
|
case 3:
|
|
235
212
|
targetOption.loading = true;
|
|
236
|
-
|
|
237
|
-
return
|
|
213
|
+
_context4.next = 6;
|
|
214
|
+
return getAddress({
|
|
238
215
|
parentCode: targetOption.value
|
|
239
216
|
});
|
|
240
217
|
case 6:
|
|
241
|
-
data =
|
|
218
|
+
data = _context4.sent;
|
|
242
219
|
targetOption.loading = false;
|
|
243
220
|
if (data.length) {
|
|
244
221
|
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
@@ -249,12 +226,12 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
249
226
|
setAddressList(_toConsumableArray(addressList));
|
|
250
227
|
case 11:
|
|
251
228
|
case "end":
|
|
252
|
-
return
|
|
229
|
+
return _context4.stop();
|
|
253
230
|
}
|
|
254
|
-
},
|
|
231
|
+
}, _callee3);
|
|
255
232
|
}));
|
|
256
233
|
return function loadData(_x3) {
|
|
257
|
-
return
|
|
234
|
+
return _ref2.apply(this, arguments);
|
|
258
235
|
};
|
|
259
236
|
}();
|
|
260
237
|
var handleChange = function handleChange(info, selectedOptions) {
|
package/lib/utils/api.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.apiCreate = void 0;
|
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
var baseURLMap = {
|
|
10
|
+
dev: 'https://dev-gateway.fxqifu.net/pangu',
|
|
11
|
+
qa: 'https://qa-gateway.fxqifu.net/pangu',
|
|
12
|
+
prod: 'https://gateway.fxqifu.net/pangu'
|
|
13
|
+
};
|
|
14
|
+
var apiCreate = exports.apiCreate = function apiCreate(apiUrl, env) {
|
|
15
|
+
var envGet = env || localStorage.getItem('env') || 'prod';
|
|
16
|
+
var baseURL = baseURLMap[envGet];
|
|
17
|
+
return {
|
|
18
|
+
getAddress: function getAddress(data) {
|
|
19
|
+
return new Promise(function (resolve, reject) {
|
|
20
|
+
_axios.default.post("".concat(baseURL).concat(apiUrl), data).then(function (res) {
|
|
21
|
+
var _res$data;
|
|
22
|
+
if (Array.isArray((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.data)) {
|
|
23
|
+
resolve(res.data.data);
|
|
24
|
+
} else {
|
|
25
|
+
resolve([]);
|
|
26
|
+
}
|
|
27
|
+
}).catch(reject);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fle-ui/plus-address-selection",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "@fle-ui/plus-address-selection",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/js-cookie": "^3.0.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "efedcaf9e8359b7bc34f9687d38c66c14c5516af"
|
|
45
45
|
}
|
package/es/utils/httpClient.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface Response {
|
|
2
|
-
status: number;
|
|
3
|
-
data: any;
|
|
4
|
-
statusText: string;
|
|
5
|
-
}
|
|
6
|
-
export interface AxiosRequestConfig {
|
|
7
|
-
baseURL?: string;
|
|
8
|
-
timeout: number;
|
|
9
|
-
headers?: any;
|
|
10
|
-
url?: string;
|
|
11
|
-
}
|
|
12
|
-
declare const httpClient: import("axios").AxiosInstance;
|
|
13
|
-
export default httpClient;
|
package/es/utils/httpClient.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import "antd/es/notification/style";
|
|
2
|
-
import _notification from "antd/es/notification";
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
import Cookies from 'js-cookie';
|
|
5
|
-
var axiosConfig = {
|
|
6
|
-
baseURL: 'https://gateway.fxqifu.net/pangu',
|
|
7
|
-
timeout: 60000
|
|
8
|
-
};
|
|
9
|
-
var httpClient = axios.create(axiosConfig);
|
|
10
|
-
// 登陆页面接口列表,不需要带token
|
|
11
|
-
var loginMap = [''];
|
|
12
|
-
httpClient.interceptors.request.use(function (config) {
|
|
13
|
-
config.headers['Content-Type'] = 'application/json;charset=UTF-8';
|
|
14
|
-
if (loginMap.find(function (item) {
|
|
15
|
-
return config.url.endsWith(item);
|
|
16
|
-
})) {
|
|
17
|
-
delete config.headers['authority_token'];
|
|
18
|
-
} else {
|
|
19
|
-
var tokenFrom = config['tokenFrom'];
|
|
20
|
-
var token = '';
|
|
21
|
-
switch (tokenFrom) {
|
|
22
|
-
case 'cookie':
|
|
23
|
-
token = Cookies.get('token');
|
|
24
|
-
break;
|
|
25
|
-
case 'localstorage':
|
|
26
|
-
token = localStorage.getItem('token');
|
|
27
|
-
break;
|
|
28
|
-
default:
|
|
29
|
-
token = Cookies.get('token') || localStorage.getItem('token');
|
|
30
|
-
}
|
|
31
|
-
config.headers['authority_token'] = token;
|
|
32
|
-
}
|
|
33
|
-
return config;
|
|
34
|
-
}, function (err) {
|
|
35
|
-
_notification.error({
|
|
36
|
-
message: '发送请求失败',
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
description: err
|
|
39
|
-
});
|
|
40
|
-
return false;
|
|
41
|
-
});
|
|
42
|
-
httpClient.interceptors.response.use(function (res) {
|
|
43
|
-
var status = res.status,
|
|
44
|
-
data = res.data,
|
|
45
|
-
statusText = res.statusText;
|
|
46
|
-
return new Promise(function (resolve, reject) {
|
|
47
|
-
if (status < 200 || status > 300) {
|
|
48
|
-
_notification.error({
|
|
49
|
-
message: "\u8BF7\u6C42\u9519\u8BEF: ".concat(status),
|
|
50
|
-
description: statusText
|
|
51
|
-
});
|
|
52
|
-
} else if (!data.success) {
|
|
53
|
-
if (data.code === '915003') {
|
|
54
|
-
return reject(data);
|
|
55
|
-
}
|
|
56
|
-
if (data.code === '100003') {
|
|
57
|
-
return reject(data);
|
|
58
|
-
}
|
|
59
|
-
_notification.error({
|
|
60
|
-
message: '提示',
|
|
61
|
-
description: data.message
|
|
62
|
-
});
|
|
63
|
-
return reject(data);
|
|
64
|
-
} else {
|
|
65
|
-
return resolve(data || true);
|
|
66
|
-
}
|
|
67
|
-
return reject();
|
|
68
|
-
});
|
|
69
|
-
}, function () {
|
|
70
|
-
_notification.error({
|
|
71
|
-
message: '提示',
|
|
72
|
-
description: '系统错误'
|
|
73
|
-
});
|
|
74
|
-
return false;
|
|
75
|
-
});
|
|
76
|
-
export default httpClient;
|
package/es/utils/index.d.ts
DELETED
package/es/utils/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface Response {
|
|
2
|
-
status: number;
|
|
3
|
-
data: any;
|
|
4
|
-
statusText: string;
|
|
5
|
-
}
|
|
6
|
-
export interface AxiosRequestConfig {
|
|
7
|
-
baseURL?: string;
|
|
8
|
-
timeout: number;
|
|
9
|
-
headers?: any;
|
|
10
|
-
url?: string;
|
|
11
|
-
}
|
|
12
|
-
declare const httpClient: import("axios").AxiosInstance;
|
|
13
|
-
export default httpClient;
|
package/lib/utils/httpClient.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
-
var _antd = require("antd");
|
|
9
|
-
var _jsCookie = _interopRequireDefault(require("js-cookie"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var axiosConfig = {
|
|
12
|
-
baseURL: 'https://gateway.fxqifu.net/pangu',
|
|
13
|
-
timeout: 60000
|
|
14
|
-
};
|
|
15
|
-
var httpClient = _axios.default.create(axiosConfig);
|
|
16
|
-
// 登陆页面接口列表,不需要带token
|
|
17
|
-
var loginMap = [''];
|
|
18
|
-
httpClient.interceptors.request.use(function (config) {
|
|
19
|
-
config.headers['Content-Type'] = 'application/json;charset=UTF-8';
|
|
20
|
-
if (loginMap.find(function (item) {
|
|
21
|
-
return config.url.endsWith(item);
|
|
22
|
-
})) {
|
|
23
|
-
delete config.headers['authority_token'];
|
|
24
|
-
} else {
|
|
25
|
-
var tokenFrom = config['tokenFrom'];
|
|
26
|
-
var token = '';
|
|
27
|
-
switch (tokenFrom) {
|
|
28
|
-
case 'cookie':
|
|
29
|
-
token = _jsCookie.default.get('token');
|
|
30
|
-
break;
|
|
31
|
-
case 'localstorage':
|
|
32
|
-
token = localStorage.getItem('token');
|
|
33
|
-
break;
|
|
34
|
-
default:
|
|
35
|
-
token = _jsCookie.default.get('token') || localStorage.getItem('token');
|
|
36
|
-
}
|
|
37
|
-
config.headers['authority_token'] = token;
|
|
38
|
-
}
|
|
39
|
-
return config;
|
|
40
|
-
}, function (err) {
|
|
41
|
-
_antd.notification.error({
|
|
42
|
-
message: '发送请求失败',
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
description: err
|
|
45
|
-
});
|
|
46
|
-
return false;
|
|
47
|
-
});
|
|
48
|
-
httpClient.interceptors.response.use(function (res) {
|
|
49
|
-
var status = res.status,
|
|
50
|
-
data = res.data,
|
|
51
|
-
statusText = res.statusText;
|
|
52
|
-
return new Promise(function (resolve, reject) {
|
|
53
|
-
if (status < 200 || status > 300) {
|
|
54
|
-
_antd.notification.error({
|
|
55
|
-
message: "\u8BF7\u6C42\u9519\u8BEF: ".concat(status),
|
|
56
|
-
description: statusText
|
|
57
|
-
});
|
|
58
|
-
} else if (!data.success) {
|
|
59
|
-
if (data.code === '915003') {
|
|
60
|
-
return reject(data);
|
|
61
|
-
}
|
|
62
|
-
if (data.code === '100003') {
|
|
63
|
-
return reject(data);
|
|
64
|
-
}
|
|
65
|
-
_antd.notification.error({
|
|
66
|
-
message: '提示',
|
|
67
|
-
description: data.message
|
|
68
|
-
});
|
|
69
|
-
return reject(data);
|
|
70
|
-
} else {
|
|
71
|
-
return resolve(data || true);
|
|
72
|
-
}
|
|
73
|
-
return reject();
|
|
74
|
-
});
|
|
75
|
-
}, function () {
|
|
76
|
-
_antd.notification.error({
|
|
77
|
-
message: '提示',
|
|
78
|
-
description: '系统错误'
|
|
79
|
-
});
|
|
80
|
-
return false;
|
|
81
|
-
});
|
|
82
|
-
var _default = exports.default = httpClient;
|
package/lib/utils/index.d.ts
DELETED
package/lib/utils/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "httpClient", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _httpClient.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _httpClient = _interopRequireDefault(require("./httpClient"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|