@fle-ui/plus-address-selection 1.0.9 → 1.0.11
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 -6
- package/es/index.js +34 -60
- package/es/utils/api.d.ts +10 -0
- package/es/utils/api.js +24 -0
- package/lib/index.d.ts +3 -6
- package/lib/index.js +34 -60
- 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;
|
|
@@ -29,12 +30,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
29
30
|
*/
|
|
30
31
|
valueDivision?: string;
|
|
31
32
|
/**
|
|
32
|
-
* @description
|
|
33
|
-
* @default
|
|
34
|
-
*/
|
|
35
|
-
apiUrl?: string;
|
|
36
|
-
/**
|
|
37
|
-
* @description 地址层级 默认四级
|
|
33
|
+
* @description 地址层级 默认四级 --
|
|
38
34
|
* @default 4
|
|
39
35
|
*/
|
|
40
36
|
level?: number;
|
|
@@ -48,6 +44,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
48
44
|
* @default []
|
|
49
45
|
*/
|
|
50
46
|
options?: CascaderOptionType[];
|
|
47
|
+
env?: Env;
|
|
51
48
|
}
|
|
52
49
|
declare const AddressSelection: React.FC<SiteSelectProps>;
|
|
53
50
|
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"
|
|
4
|
+
var _excluded = ["env", "level", "value", "onChange", "valueDivision"];
|
|
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."); }
|
|
@@ -25,23 +25,23 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
25
25
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; 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
|
-
onChange: function onChange() {}
|
|
34
|
-
apiUrl: ''
|
|
33
|
+
onChange: function onChange() {}
|
|
35
34
|
};
|
|
36
|
-
// publish -
|
|
37
35
|
var AddressSelection = function AddressSelection(props) {
|
|
38
36
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
37
|
+
env = _defaultProps$props.env,
|
|
39
38
|
level = _defaultProps$props.level,
|
|
40
39
|
value = _defaultProps$props.value,
|
|
41
40
|
onChange = _defaultProps$props.onChange,
|
|
42
41
|
valueDivision = _defaultProps$props.valueDivision,
|
|
43
|
-
apiUrl = _defaultProps$props.apiUrl,
|
|
44
42
|
otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
43
|
+
var _apiCreate = apiCreate(env),
|
|
44
|
+
getAddress = _apiCreate.getAddress;
|
|
45
45
|
var _useState = useState([]),
|
|
46
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
47
47
|
addressList = _useState2[0],
|
|
@@ -66,7 +66,7 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
66
66
|
while (1) switch (_context.prev = _context.next) {
|
|
67
67
|
case 0:
|
|
68
68
|
_context.next = 2;
|
|
69
|
-
return
|
|
69
|
+
return getAddress({
|
|
70
70
|
parentCode: 0
|
|
71
71
|
});
|
|
72
72
|
case 2:
|
|
@@ -119,57 +119,31 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
119
119
|
};
|
|
120
120
|
});
|
|
121
121
|
};
|
|
122
|
-
var getAddressAPI = /*#__PURE__*/function () {
|
|
123
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
124
|
-
var params,
|
|
125
|
-
_yield$httpClient$pos,
|
|
126
|
-
data,
|
|
127
|
-
_args2 = arguments;
|
|
128
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
129
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
130
|
-
case 0:
|
|
131
|
-
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
132
|
-
_context2.next = 3;
|
|
133
|
-
return httpClient.post(apiUrl || '/basic/area/areas', params);
|
|
134
|
-
case 3:
|
|
135
|
-
_yield$httpClient$pos = _context2.sent;
|
|
136
|
-
data = _yield$httpClient$pos.data;
|
|
137
|
-
return _context2.abrupt("return", data);
|
|
138
|
-
case 6:
|
|
139
|
-
case "end":
|
|
140
|
-
return _context2.stop();
|
|
141
|
-
}
|
|
142
|
-
}, _callee2);
|
|
143
|
-
}));
|
|
144
|
-
return function getAddressAPI() {
|
|
145
|
-
return _ref.apply(this, arguments);
|
|
146
|
-
};
|
|
147
|
-
}();
|
|
148
122
|
var initAddress = /*#__PURE__*/function () {
|
|
149
|
-
var
|
|
123
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
|
|
150
124
|
var provinceList, len, thisAddress, _loop, i;
|
|
151
|
-
return _regeneratorRuntime().wrap(function
|
|
152
|
-
while (1) switch (
|
|
125
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
126
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
153
127
|
case 0:
|
|
154
128
|
provinceList = _.cloneDeep(addressList);
|
|
155
129
|
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
156
130
|
if (!len) {
|
|
157
|
-
|
|
131
|
+
_context3.next = 11;
|
|
158
132
|
break;
|
|
159
133
|
}
|
|
160
134
|
thisAddress = provinceList;
|
|
161
135
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
162
136
|
var _thisAddress;
|
|
163
137
|
var levelData, thisIndex;
|
|
164
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
165
|
-
while (1) switch (
|
|
138
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
139
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
166
140
|
case 0:
|
|
167
|
-
|
|
168
|
-
return
|
|
141
|
+
_context2.next = 2;
|
|
142
|
+
return getAddress({
|
|
169
143
|
parentCode: defaultValue[i]
|
|
170
144
|
});
|
|
171
145
|
case 2:
|
|
172
|
-
levelData =
|
|
146
|
+
levelData = _context2.sent;
|
|
173
147
|
thisIndex = -1;
|
|
174
148
|
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
175
149
|
if (item.value === defaultValue[i]) {
|
|
@@ -185,53 +159,53 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
185
159
|
}
|
|
186
160
|
case 7:
|
|
187
161
|
case "end":
|
|
188
|
-
return
|
|
162
|
+
return _context2.stop();
|
|
189
163
|
}
|
|
190
164
|
}, _loop);
|
|
191
165
|
});
|
|
192
166
|
i = 0;
|
|
193
167
|
case 6:
|
|
194
168
|
if (!(i < len - 1)) {
|
|
195
|
-
|
|
169
|
+
_context3.next = 11;
|
|
196
170
|
break;
|
|
197
171
|
}
|
|
198
|
-
return
|
|
172
|
+
return _context3.delegateYield(_loop(i), "t0", 8);
|
|
199
173
|
case 8:
|
|
200
174
|
i++;
|
|
201
|
-
|
|
175
|
+
_context3.next = 6;
|
|
202
176
|
break;
|
|
203
177
|
case 11:
|
|
204
178
|
setAddressList(provinceList);
|
|
205
179
|
case 12:
|
|
206
180
|
case "end":
|
|
207
|
-
return
|
|
181
|
+
return _context3.stop();
|
|
208
182
|
}
|
|
209
|
-
},
|
|
183
|
+
}, _callee2);
|
|
210
184
|
}));
|
|
211
185
|
return function initAddress(_x, _x2) {
|
|
212
|
-
return
|
|
186
|
+
return _ref.apply(this, arguments);
|
|
213
187
|
};
|
|
214
188
|
}();
|
|
215
189
|
var loadData = /*#__PURE__*/function () {
|
|
216
|
-
var
|
|
190
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
|
|
217
191
|
var targetOption, data;
|
|
218
|
-
return _regeneratorRuntime().wrap(function
|
|
219
|
-
while (1) switch (
|
|
192
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
193
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
220
194
|
case 0:
|
|
221
195
|
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
222
196
|
if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
|
|
223
|
-
|
|
197
|
+
_context4.next = 3;
|
|
224
198
|
break;
|
|
225
199
|
}
|
|
226
|
-
return
|
|
200
|
+
return _context4.abrupt("return");
|
|
227
201
|
case 3:
|
|
228
202
|
targetOption.loading = true;
|
|
229
|
-
|
|
230
|
-
return
|
|
203
|
+
_context4.next = 6;
|
|
204
|
+
return getAddress({
|
|
231
205
|
parentCode: targetOption.value
|
|
232
206
|
});
|
|
233
207
|
case 6:
|
|
234
|
-
data =
|
|
208
|
+
data = _context4.sent;
|
|
235
209
|
targetOption.loading = false;
|
|
236
210
|
if (data.length) {
|
|
237
211
|
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
@@ -242,12 +216,12 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
242
216
|
setAddressList(_toConsumableArray(addressList));
|
|
243
217
|
case 11:
|
|
244
218
|
case "end":
|
|
245
|
-
return
|
|
219
|
+
return _context4.stop();
|
|
246
220
|
}
|
|
247
|
-
},
|
|
221
|
+
}, _callee3);
|
|
248
222
|
}));
|
|
249
223
|
return function loadData(_x3) {
|
|
250
|
-
return
|
|
224
|
+
return _ref2.apply(this, arguments);
|
|
251
225
|
};
|
|
252
226
|
}();
|
|
253
227
|
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(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, "/basic/area/areas"), 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;
|
|
@@ -29,12 +30,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
29
30
|
*/
|
|
30
31
|
valueDivision?: string;
|
|
31
32
|
/**
|
|
32
|
-
* @description
|
|
33
|
-
* @default
|
|
34
|
-
*/
|
|
35
|
-
apiUrl?: string;
|
|
36
|
-
/**
|
|
37
|
-
* @description 地址层级 默认四级
|
|
33
|
+
* @description 地址层级 默认四级 --
|
|
38
34
|
* @default 4
|
|
39
35
|
*/
|
|
40
36
|
level?: number;
|
|
@@ -48,6 +44,7 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
48
44
|
* @default []
|
|
49
45
|
*/
|
|
50
46
|
options?: CascaderOptionType[];
|
|
47
|
+
env?: Env;
|
|
51
48
|
}
|
|
52
49
|
declare const AddressSelection: React.FC<SiteSelectProps>;
|
|
53
50
|
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"
|
|
11
|
+
var _api = require("./utils/api");
|
|
12
|
+
var _excluded = ["env", "level", "value", "onChange", "valueDivision"];
|
|
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; }
|
|
@@ -38,18 +38,18 @@ var defaultProps = {
|
|
|
38
38
|
level: 4,
|
|
39
39
|
valueDivision: '',
|
|
40
40
|
value: [],
|
|
41
|
-
onChange: function onChange() {}
|
|
42
|
-
apiUrl: ''
|
|
41
|
+
onChange: function onChange() {}
|
|
43
42
|
};
|
|
44
|
-
// publish -
|
|
45
43
|
var AddressSelection = function AddressSelection(props) {
|
|
46
44
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
45
|
+
env = _defaultProps$props.env,
|
|
47
46
|
level = _defaultProps$props.level,
|
|
48
47
|
value = _defaultProps$props.value,
|
|
49
48
|
onChange = _defaultProps$props.onChange,
|
|
50
49
|
valueDivision = _defaultProps$props.valueDivision,
|
|
51
|
-
apiUrl = _defaultProps$props.apiUrl,
|
|
52
50
|
otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
51
|
+
var _apiCreate = (0, _api.apiCreate)(env),
|
|
52
|
+
getAddress = _apiCreate.getAddress;
|
|
53
53
|
var _useState = (0, _react.useState)([]),
|
|
54
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
55
55
|
addressList = _useState2[0],
|
|
@@ -74,7 +74,7 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
74
74
|
while (1) switch (_context.prev = _context.next) {
|
|
75
75
|
case 0:
|
|
76
76
|
_context.next = 2;
|
|
77
|
-
return
|
|
77
|
+
return getAddress({
|
|
78
78
|
parentCode: 0
|
|
79
79
|
});
|
|
80
80
|
case 2:
|
|
@@ -127,57 +127,31 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
127
127
|
};
|
|
128
128
|
});
|
|
129
129
|
};
|
|
130
|
-
var getAddressAPI = /*#__PURE__*/function () {
|
|
131
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
132
|
-
var params,
|
|
133
|
-
_yield$httpClient$pos,
|
|
134
|
-
data,
|
|
135
|
-
_args2 = arguments;
|
|
136
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
137
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
138
|
-
case 0:
|
|
139
|
-
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
140
|
-
_context2.next = 3;
|
|
141
|
-
return _utils.httpClient.post(apiUrl || '/basic/area/areas', params);
|
|
142
|
-
case 3:
|
|
143
|
-
_yield$httpClient$pos = _context2.sent;
|
|
144
|
-
data = _yield$httpClient$pos.data;
|
|
145
|
-
return _context2.abrupt("return", data);
|
|
146
|
-
case 6:
|
|
147
|
-
case "end":
|
|
148
|
-
return _context2.stop();
|
|
149
|
-
}
|
|
150
|
-
}, _callee2);
|
|
151
|
-
}));
|
|
152
|
-
return function getAddressAPI() {
|
|
153
|
-
return _ref.apply(this, arguments);
|
|
154
|
-
};
|
|
155
|
-
}();
|
|
156
130
|
var initAddress = /*#__PURE__*/function () {
|
|
157
|
-
var
|
|
131
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultValue, parentCode) {
|
|
158
132
|
var provinceList, len, thisAddress, _loop, i;
|
|
159
|
-
return _regeneratorRuntime().wrap(function
|
|
160
|
-
while (1) switch (
|
|
133
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
134
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
161
135
|
case 0:
|
|
162
136
|
provinceList = _lodash.default.cloneDeep(addressList);
|
|
163
137
|
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
164
138
|
if (!len) {
|
|
165
|
-
|
|
139
|
+
_context3.next = 11;
|
|
166
140
|
break;
|
|
167
141
|
}
|
|
168
142
|
thisAddress = provinceList;
|
|
169
143
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
170
144
|
var _thisAddress;
|
|
171
145
|
var levelData, thisIndex;
|
|
172
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
173
|
-
while (1) switch (
|
|
146
|
+
return _regeneratorRuntime().wrap(function _loop$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
174
148
|
case 0:
|
|
175
|
-
|
|
176
|
-
return
|
|
149
|
+
_context2.next = 2;
|
|
150
|
+
return getAddress({
|
|
177
151
|
parentCode: defaultValue[i]
|
|
178
152
|
});
|
|
179
153
|
case 2:
|
|
180
|
-
levelData =
|
|
154
|
+
levelData = _context2.sent;
|
|
181
155
|
thisIndex = -1;
|
|
182
156
|
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
183
157
|
if (item.value === defaultValue[i]) {
|
|
@@ -193,53 +167,53 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
193
167
|
}
|
|
194
168
|
case 7:
|
|
195
169
|
case "end":
|
|
196
|
-
return
|
|
170
|
+
return _context2.stop();
|
|
197
171
|
}
|
|
198
172
|
}, _loop);
|
|
199
173
|
});
|
|
200
174
|
i = 0;
|
|
201
175
|
case 6:
|
|
202
176
|
if (!(i < len - 1)) {
|
|
203
|
-
|
|
177
|
+
_context3.next = 11;
|
|
204
178
|
break;
|
|
205
179
|
}
|
|
206
|
-
return
|
|
180
|
+
return _context3.delegateYield(_loop(i), "t0", 8);
|
|
207
181
|
case 8:
|
|
208
182
|
i++;
|
|
209
|
-
|
|
183
|
+
_context3.next = 6;
|
|
210
184
|
break;
|
|
211
185
|
case 11:
|
|
212
186
|
setAddressList(provinceList);
|
|
213
187
|
case 12:
|
|
214
188
|
case "end":
|
|
215
|
-
return
|
|
189
|
+
return _context3.stop();
|
|
216
190
|
}
|
|
217
|
-
},
|
|
191
|
+
}, _callee2);
|
|
218
192
|
}));
|
|
219
193
|
return function initAddress(_x, _x2) {
|
|
220
|
-
return
|
|
194
|
+
return _ref.apply(this, arguments);
|
|
221
195
|
};
|
|
222
196
|
}();
|
|
223
197
|
var loadData = /*#__PURE__*/function () {
|
|
224
|
-
var
|
|
198
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selectedOptions) {
|
|
225
199
|
var targetOption, data;
|
|
226
|
-
return _regeneratorRuntime().wrap(function
|
|
227
|
-
while (1) switch (
|
|
200
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
201
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
228
202
|
case 0:
|
|
229
203
|
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
230
204
|
if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
|
|
231
|
-
|
|
205
|
+
_context4.next = 3;
|
|
232
206
|
break;
|
|
233
207
|
}
|
|
234
|
-
return
|
|
208
|
+
return _context4.abrupt("return");
|
|
235
209
|
case 3:
|
|
236
210
|
targetOption.loading = true;
|
|
237
|
-
|
|
238
|
-
return
|
|
211
|
+
_context4.next = 6;
|
|
212
|
+
return getAddress({
|
|
239
213
|
parentCode: targetOption.value
|
|
240
214
|
});
|
|
241
215
|
case 6:
|
|
242
|
-
data =
|
|
216
|
+
data = _context4.sent;
|
|
243
217
|
targetOption.loading = false;
|
|
244
218
|
if (data.length) {
|
|
245
219
|
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
@@ -250,12 +224,12 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
250
224
|
setAddressList(_toConsumableArray(addressList));
|
|
251
225
|
case 11:
|
|
252
226
|
case "end":
|
|
253
|
-
return
|
|
227
|
+
return _context4.stop();
|
|
254
228
|
}
|
|
255
|
-
},
|
|
229
|
+
}, _callee3);
|
|
256
230
|
}));
|
|
257
231
|
return function loadData(_x3) {
|
|
258
|
-
return
|
|
232
|
+
return _ref2.apply(this, arguments);
|
|
259
233
|
};
|
|
260
234
|
}();
|
|
261
235
|
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(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, "/basic/area/areas"), 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.11",
|
|
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": "89623cde9674f6e35e70f4678f856578d60019f9"
|
|
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 }; }
|