@fle-ui/plus-address-selection 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/es/index.d.ts +6 -3
- package/es/index.js +59 -34
- package/es/utils/httpClient.d.ts +13 -0
- package/es/utils/httpClient.js +76 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +2 -0
- package/lib/index.d.ts +6 -3
- package/lib/index.js +59 -34
- package/lib/utils/httpClient.d.ts +13 -0
- package/lib/utils/httpClient.js +82 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +13 -0
- package/package.json +2 -2
- package/es/utils/api.d.ts +0 -10
- package/es/utils/api.js +0 -24
- package/lib/utils/api.d.ts +0 -10
- package/lib/utils/api.js +0 -31
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# @fle-ui/plus-address-selection
|
|
2
|
-
|
|
3
|
-
> @fle-ui/plus-address-selection
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
Using npm:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
$ npm install --save @fle-ui/plus-address-selection
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
or using yarn:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
$ yarn add @fle-ui/plus-address-selection
|
|
17
|
-
```
|
|
1
|
+
# @fle-ui/plus-address-selection
|
|
2
|
+
|
|
3
|
+
> @fle-ui/plus-address-selection
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Using npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ npm install --save @fle-ui/plus-address-selection
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or using yarn:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ yarn add @fle-ui/plus-address-selection
|
|
17
|
+
```
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CascaderProps } from 'antd';
|
|
3
|
-
import { Env } from './utils/api';
|
|
4
3
|
export declare type CascaderValueType = string | Array<string | number>;
|
|
5
4
|
export interface CascaderOptionType {
|
|
6
5
|
value?: string | number;
|
|
@@ -30,7 +29,12 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
30
29
|
*/
|
|
31
30
|
valueDivision?: string;
|
|
32
31
|
/**
|
|
33
|
-
* @description
|
|
32
|
+
* @description 接口地址 全地址哦
|
|
33
|
+
* @default
|
|
34
|
+
*/
|
|
35
|
+
apiUrl?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description 地址层级 默认四级
|
|
34
38
|
* @default 4
|
|
35
39
|
*/
|
|
36
40
|
level?: number;
|
|
@@ -44,7 +48,6 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
44
48
|
* @default []
|
|
45
49
|
*/
|
|
46
50
|
options?: CascaderOptionType[];
|
|
47
|
-
env?: Env;
|
|
48
51
|
}
|
|
49
52
|
declare const AddressSelection: React.FC<SiteSelectProps>;
|
|
50
53
|
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 = ["
|
|
4
|
+
var _excluded = ["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."); }
|
|
@@ -25,23 +25,22 @@ 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 { httpClient } from './utils';
|
|
29
29
|
var defaultProps = {
|
|
30
30
|
level: 4,
|
|
31
31
|
valueDivision: '',
|
|
32
32
|
value: [],
|
|
33
|
-
onChange: function onChange() {}
|
|
33
|
+
onChange: function onChange() {},
|
|
34
|
+
apiUrl: ''
|
|
34
35
|
};
|
|
35
36
|
var AddressSelection = function AddressSelection(props) {
|
|
36
37
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
37
|
-
env = _defaultProps$props.env,
|
|
38
38
|
level = _defaultProps$props.level,
|
|
39
39
|
value = _defaultProps$props.value,
|
|
40
40
|
onChange = _defaultProps$props.onChange,
|
|
41
41
|
valueDivision = _defaultProps$props.valueDivision,
|
|
42
|
+
apiUrl = _defaultProps$props.apiUrl,
|
|
42
43
|
otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
43
|
-
var _apiCreate = apiCreate(env),
|
|
44
|
-
getAddress = _apiCreate.getAddress;
|
|
45
44
|
var _useState = useState([]),
|
|
46
45
|
_useState2 = _slicedToArray(_useState, 2),
|
|
47
46
|
addressList = _useState2[0],
|
|
@@ -66,7 +65,7 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
66
65
|
while (1) switch (_context.prev = _context.next) {
|
|
67
66
|
case 0:
|
|
68
67
|
_context.next = 2;
|
|
69
|
-
return
|
|
68
|
+
return getAddressAPI({
|
|
70
69
|
parentCode: 0
|
|
71
70
|
});
|
|
72
71
|
case 2:
|
|
@@ -119,31 +118,57 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
119
118
|
};
|
|
120
119
|
});
|
|
121
120
|
};
|
|
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
|
+
}();
|
|
122
147
|
var initAddress = /*#__PURE__*/function () {
|
|
123
|
-
var
|
|
148
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(defaultValue, parentCode) {
|
|
124
149
|
var provinceList, len, thisAddress, _loop, i;
|
|
125
|
-
return _regeneratorRuntime().wrap(function
|
|
126
|
-
while (1) switch (
|
|
150
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
151
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
127
152
|
case 0:
|
|
128
153
|
provinceList = _.cloneDeep(addressList);
|
|
129
154
|
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
130
155
|
if (!len) {
|
|
131
|
-
|
|
156
|
+
_context4.next = 11;
|
|
132
157
|
break;
|
|
133
158
|
}
|
|
134
159
|
thisAddress = provinceList;
|
|
135
160
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
136
161
|
var _thisAddress;
|
|
137
162
|
var levelData, thisIndex;
|
|
138
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
139
|
-
while (1) switch (
|
|
163
|
+
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
|
164
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
140
165
|
case 0:
|
|
141
|
-
|
|
142
|
-
return
|
|
166
|
+
_context3.next = 2;
|
|
167
|
+
return getAddressAPI({
|
|
143
168
|
parentCode: defaultValue[i]
|
|
144
169
|
});
|
|
145
170
|
case 2:
|
|
146
|
-
levelData =
|
|
171
|
+
levelData = _context3.sent;
|
|
147
172
|
thisIndex = -1;
|
|
148
173
|
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
149
174
|
if (item.value === defaultValue[i]) {
|
|
@@ -159,53 +184,53 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
159
184
|
}
|
|
160
185
|
case 7:
|
|
161
186
|
case "end":
|
|
162
|
-
return
|
|
187
|
+
return _context3.stop();
|
|
163
188
|
}
|
|
164
189
|
}, _loop);
|
|
165
190
|
});
|
|
166
191
|
i = 0;
|
|
167
192
|
case 6:
|
|
168
193
|
if (!(i < len - 1)) {
|
|
169
|
-
|
|
194
|
+
_context4.next = 11;
|
|
170
195
|
break;
|
|
171
196
|
}
|
|
172
|
-
return
|
|
197
|
+
return _context4.delegateYield(_loop(i), "t0", 8);
|
|
173
198
|
case 8:
|
|
174
199
|
i++;
|
|
175
|
-
|
|
200
|
+
_context4.next = 6;
|
|
176
201
|
break;
|
|
177
202
|
case 11:
|
|
178
203
|
setAddressList(provinceList);
|
|
179
204
|
case 12:
|
|
180
205
|
case "end":
|
|
181
|
-
return
|
|
206
|
+
return _context4.stop();
|
|
182
207
|
}
|
|
183
|
-
},
|
|
208
|
+
}, _callee3);
|
|
184
209
|
}));
|
|
185
210
|
return function initAddress(_x, _x2) {
|
|
186
|
-
return
|
|
211
|
+
return _ref2.apply(this, arguments);
|
|
187
212
|
};
|
|
188
213
|
}();
|
|
189
214
|
var loadData = /*#__PURE__*/function () {
|
|
190
|
-
var
|
|
215
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(selectedOptions) {
|
|
191
216
|
var targetOption, data;
|
|
192
|
-
return _regeneratorRuntime().wrap(function
|
|
193
|
-
while (1) switch (
|
|
217
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
218
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
194
219
|
case 0:
|
|
195
220
|
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
196
221
|
if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
|
|
197
|
-
|
|
222
|
+
_context5.next = 3;
|
|
198
223
|
break;
|
|
199
224
|
}
|
|
200
|
-
return
|
|
225
|
+
return _context5.abrupt("return");
|
|
201
226
|
case 3:
|
|
202
227
|
targetOption.loading = true;
|
|
203
|
-
|
|
204
|
-
return
|
|
228
|
+
_context5.next = 6;
|
|
229
|
+
return getAddressAPI({
|
|
205
230
|
parentCode: targetOption.value
|
|
206
231
|
});
|
|
207
232
|
case 6:
|
|
208
|
-
data =
|
|
233
|
+
data = _context5.sent;
|
|
209
234
|
targetOption.loading = false;
|
|
210
235
|
if (data.length) {
|
|
211
236
|
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
@@ -216,12 +241,12 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
216
241
|
setAddressList(_toConsumableArray(addressList));
|
|
217
242
|
case 11:
|
|
218
243
|
case "end":
|
|
219
|
-
return
|
|
244
|
+
return _context5.stop();
|
|
220
245
|
}
|
|
221
|
-
},
|
|
246
|
+
}, _callee4);
|
|
222
247
|
}));
|
|
223
248
|
return function loadData(_x3) {
|
|
224
|
-
return
|
|
249
|
+
return _ref3.apply(this, arguments);
|
|
225
250
|
};
|
|
226
251
|
}();
|
|
227
252
|
var handleChange = function handleChange(info, selectedOptions) {
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,76 @@
|
|
|
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/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CascaderProps } from 'antd';
|
|
3
|
-
import { Env } from './utils/api';
|
|
4
3
|
export declare type CascaderValueType = string | Array<string | number>;
|
|
5
4
|
export interface CascaderOptionType {
|
|
6
5
|
value?: string | number;
|
|
@@ -30,7 +29,12 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
30
29
|
*/
|
|
31
30
|
valueDivision?: string;
|
|
32
31
|
/**
|
|
33
|
-
* @description
|
|
32
|
+
* @description 接口地址 全地址哦
|
|
33
|
+
* @default
|
|
34
|
+
*/
|
|
35
|
+
apiUrl?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description 地址层级 默认四级
|
|
34
38
|
* @default 4
|
|
35
39
|
*/
|
|
36
40
|
level?: number;
|
|
@@ -44,7 +48,6 @@ export interface SiteSelectProps extends Omit<CascaderProps<any>, 'options' | 'v
|
|
|
44
48
|
* @default []
|
|
45
49
|
*/
|
|
46
50
|
options?: CascaderOptionType[];
|
|
47
|
-
env?: Env;
|
|
48
51
|
}
|
|
49
52
|
declare const AddressSelection: React.FC<SiteSelectProps>;
|
|
50
53
|
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 = ["
|
|
11
|
+
var _utils = require("./utils");
|
|
12
|
+
var _excluded = ["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; }
|
|
@@ -38,18 +38,17 @@ var defaultProps = {
|
|
|
38
38
|
level: 4,
|
|
39
39
|
valueDivision: '',
|
|
40
40
|
value: [],
|
|
41
|
-
onChange: function onChange() {}
|
|
41
|
+
onChange: function onChange() {},
|
|
42
|
+
apiUrl: ''
|
|
42
43
|
};
|
|
43
44
|
var AddressSelection = function AddressSelection(props) {
|
|
44
45
|
var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
|
|
45
|
-
env = _defaultProps$props.env,
|
|
46
46
|
level = _defaultProps$props.level,
|
|
47
47
|
value = _defaultProps$props.value,
|
|
48
48
|
onChange = _defaultProps$props.onChange,
|
|
49
49
|
valueDivision = _defaultProps$props.valueDivision,
|
|
50
|
+
apiUrl = _defaultProps$props.apiUrl,
|
|
50
51
|
otherProps = _objectWithoutProperties(_defaultProps$props, _excluded);
|
|
51
|
-
var _apiCreate = (0, _api.apiCreate)(env),
|
|
52
|
-
getAddress = _apiCreate.getAddress;
|
|
53
52
|
var _useState = (0, _react.useState)([]),
|
|
54
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
55
54
|
addressList = _useState2[0],
|
|
@@ -74,7 +73,7 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
74
73
|
while (1) switch (_context.prev = _context.next) {
|
|
75
74
|
case 0:
|
|
76
75
|
_context.next = 2;
|
|
77
|
-
return
|
|
76
|
+
return getAddressAPI({
|
|
78
77
|
parentCode: 0
|
|
79
78
|
});
|
|
80
79
|
case 2:
|
|
@@ -127,31 +126,57 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
127
126
|
};
|
|
128
127
|
});
|
|
129
128
|
};
|
|
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
|
+
}();
|
|
130
155
|
var initAddress = /*#__PURE__*/function () {
|
|
131
|
-
var
|
|
156
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(defaultValue, parentCode) {
|
|
132
157
|
var provinceList, len, thisAddress, _loop, i;
|
|
133
|
-
return _regeneratorRuntime().wrap(function
|
|
134
|
-
while (1) switch (
|
|
158
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
159
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
135
160
|
case 0:
|
|
136
161
|
provinceList = _lodash.default.cloneDeep(addressList);
|
|
137
162
|
len = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length;
|
|
138
163
|
if (!len) {
|
|
139
|
-
|
|
164
|
+
_context4.next = 11;
|
|
140
165
|
break;
|
|
141
166
|
}
|
|
142
167
|
thisAddress = provinceList;
|
|
143
168
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(i) {
|
|
144
169
|
var _thisAddress;
|
|
145
170
|
var levelData, thisIndex;
|
|
146
|
-
return _regeneratorRuntime().wrap(function _loop$(
|
|
147
|
-
while (1) switch (
|
|
171
|
+
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
|
172
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
148
173
|
case 0:
|
|
149
|
-
|
|
150
|
-
return
|
|
174
|
+
_context3.next = 2;
|
|
175
|
+
return getAddressAPI({
|
|
151
176
|
parentCode: defaultValue[i]
|
|
152
177
|
});
|
|
153
178
|
case 2:
|
|
154
|
-
levelData =
|
|
179
|
+
levelData = _context3.sent;
|
|
155
180
|
thisIndex = -1;
|
|
156
181
|
(_thisAddress = thisAddress) === null || _thisAddress === void 0 ? void 0 : _thisAddress.forEach(function (item, index) {
|
|
157
182
|
if (item.value === defaultValue[i]) {
|
|
@@ -167,53 +192,53 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
167
192
|
}
|
|
168
193
|
case 7:
|
|
169
194
|
case "end":
|
|
170
|
-
return
|
|
195
|
+
return _context3.stop();
|
|
171
196
|
}
|
|
172
197
|
}, _loop);
|
|
173
198
|
});
|
|
174
199
|
i = 0;
|
|
175
200
|
case 6:
|
|
176
201
|
if (!(i < len - 1)) {
|
|
177
|
-
|
|
202
|
+
_context4.next = 11;
|
|
178
203
|
break;
|
|
179
204
|
}
|
|
180
|
-
return
|
|
205
|
+
return _context4.delegateYield(_loop(i), "t0", 8);
|
|
181
206
|
case 8:
|
|
182
207
|
i++;
|
|
183
|
-
|
|
208
|
+
_context4.next = 6;
|
|
184
209
|
break;
|
|
185
210
|
case 11:
|
|
186
211
|
setAddressList(provinceList);
|
|
187
212
|
case 12:
|
|
188
213
|
case "end":
|
|
189
|
-
return
|
|
214
|
+
return _context4.stop();
|
|
190
215
|
}
|
|
191
|
-
},
|
|
216
|
+
}, _callee3);
|
|
192
217
|
}));
|
|
193
218
|
return function initAddress(_x, _x2) {
|
|
194
|
-
return
|
|
219
|
+
return _ref2.apply(this, arguments);
|
|
195
220
|
};
|
|
196
221
|
}();
|
|
197
222
|
var loadData = /*#__PURE__*/function () {
|
|
198
|
-
var
|
|
223
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(selectedOptions) {
|
|
199
224
|
var targetOption, data;
|
|
200
|
-
return _regeneratorRuntime().wrap(function
|
|
201
|
-
while (1) switch (
|
|
225
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
226
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
202
227
|
case 0:
|
|
203
228
|
targetOption = selectedOptions[selectedOptions.length - 1];
|
|
204
229
|
if (!(stateValue === null || stateValue === void 0 ? void 0 : stateValue.includes(targetOption.value))) {
|
|
205
|
-
|
|
230
|
+
_context5.next = 3;
|
|
206
231
|
break;
|
|
207
232
|
}
|
|
208
|
-
return
|
|
233
|
+
return _context5.abrupt("return");
|
|
209
234
|
case 3:
|
|
210
235
|
targetOption.loading = true;
|
|
211
|
-
|
|
212
|
-
return
|
|
236
|
+
_context5.next = 6;
|
|
237
|
+
return getAddressAPI({
|
|
213
238
|
parentCode: targetOption.value
|
|
214
239
|
});
|
|
215
240
|
case 6:
|
|
216
|
-
data =
|
|
241
|
+
data = _context5.sent;
|
|
217
242
|
targetOption.loading = false;
|
|
218
243
|
if (data.length) {
|
|
219
244
|
targetOption.children = formatArea(data, targetOption.level + 1 === level);
|
|
@@ -224,12 +249,12 @@ var AddressSelection = function AddressSelection(props) {
|
|
|
224
249
|
setAddressList(_toConsumableArray(addressList));
|
|
225
250
|
case 11:
|
|
226
251
|
case "end":
|
|
227
|
-
return
|
|
252
|
+
return _context5.stop();
|
|
228
253
|
}
|
|
229
|
-
},
|
|
254
|
+
}, _callee4);
|
|
230
255
|
}));
|
|
231
256
|
return function loadData(_x3) {
|
|
232
|
-
return
|
|
257
|
+
return _ref3.apply(this, arguments);
|
|
233
258
|
};
|
|
234
259
|
}();
|
|
235
260
|
var handleChange = function handleChange(info, selectedOptions) {
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,82 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 }; }
|
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.12",
|
|
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": "e56b10c76831c3d57c62576452c07ae1cee01a8a"
|
|
45
45
|
}
|
package/es/utils/api.d.ts
DELETED
package/es/utils/api.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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/utils/api.d.ts
DELETED
package/lib/utils/api.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
};
|