@10yun/cv-mobile-ui 0.5.37 → 0.5.38

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 CHANGED
@@ -4,4 +4,4 @@
4
4
 
5
5
  ## cv-mobile-ui
6
6
 
7
- 详见手册:[https://cvjs.cn/cv-mobile-ui/](https://cvjs.cn/cv-mobile-ui/)
7
+ 详见手册:[http://cvjs.cn/cv-mobile-ui/](http://cvjs.cn/cv-mobile-ui/)
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@10yun/cv-mobile-ui",
3
- "version": "0.5.37",
3
+ "version": "0.5.38",
4
4
  "description": "十云cvjs移动端ui,适用uniapp",
5
5
  "author": "10yun",
6
6
  "license": "Apache-2.0",
7
- "homepage": "https://cvjs.cn/cv-mobile-ui/",
7
+ "homepage": "http://cvjs.cn/cv-mobile-ui/",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org/"
10
10
  },
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- var clone = (function() {
2
+ var clone = (function () {
3
3
  'use strict';
4
4
 
5
5
  function _instanceof(obj, type) {
@@ -9,24 +9,24 @@ var clone = (function() {
9
9
  var nativeMap;
10
10
  try {
11
11
  nativeMap = Map;
12
- } catch(_) {
12
+ } catch (_) {
13
13
  // maybe a reference error because no `Map`. Give it a dummy value that no
14
14
  // value will ever be an instanceof.
15
- nativeMap = function() {};
15
+ nativeMap = function () {};
16
16
  }
17
17
 
18
18
  var nativeSet;
19
19
  try {
20
20
  nativeSet = Set;
21
- } catch(_) {
22
- nativeSet = function() {};
21
+ } catch (_) {
22
+ nativeSet = function () {};
23
23
  }
24
24
 
25
25
  var nativePromise;
26
26
  try {
27
27
  nativePromise = Promise;
28
- } catch(_) {
29
- nativePromise = function() {};
28
+ } catch (_) {
29
+ nativePromise = function () {};
30
30
  }
31
31
 
32
32
  /**
@@ -64,20 +64,16 @@ var clone = (function() {
64
64
 
65
65
  var useBuffer = typeof Buffer != 'undefined';
66
66
 
67
- if (typeof circular == 'undefined')
68
- circular = true;
67
+ if (typeof circular == 'undefined') circular = true;
69
68
 
70
- if (typeof depth == 'undefined')
71
- depth = Infinity;
69
+ if (typeof depth == 'undefined') depth = Infinity;
72
70
 
73
71
  // recurse this function so we don't reset allParents and allChildren
74
72
  function _clone(parent, depth) {
75
73
  // cloning null always returns null
76
- if (parent === null)
77
- return null;
74
+ if (parent === null) return null;
78
75
 
79
- if (depth === 0)
80
- return parent;
76
+ if (depth === 0) return parent;
81
77
 
82
78
  var child;
83
79
  var proto;
@@ -91,11 +87,14 @@ var clone = (function() {
91
87
  child = new nativeSet();
92
88
  } else if (_instanceof(parent, nativePromise)) {
93
89
  child = new nativePromise(function (resolve, reject) {
94
- parent.then(function(value) {
95
- resolve(_clone(value, depth - 1));
96
- }, function(err) {
97
- reject(_clone(err, depth - 1));
98
- });
90
+ parent.then(
91
+ function (value) {
92
+ resolve(_clone(value, depth - 1));
93
+ },
94
+ function (err) {
95
+ reject(_clone(err, depth - 1));
96
+ }
97
+ );
99
98
  });
100
99
  } else if (clone.__isArray(parent)) {
101
100
  child = [];
@@ -120,8 +119,7 @@ var clone = (function() {
120
119
  if (typeof prototype == 'undefined') {
121
120
  proto = Object.getPrototypeOf(parent);
122
121
  child = Object.create(proto);
123
- }
124
- else {
122
+ } else {
125
123
  child = Object.create(prototype);
126
124
  proto = prototype;
127
125
  }
@@ -138,14 +136,14 @@ var clone = (function() {
138
136
  }
139
137
 
140
138
  if (_instanceof(parent, nativeMap)) {
141
- parent.forEach(function(value, key) {
139
+ parent.forEach(function (value, key) {
142
140
  var keyChild = _clone(key, depth - 1);
143
141
  var valueChild = _clone(value, depth - 1);
144
142
  child.set(keyChild, valueChild);
145
143
  });
146
144
  }
147
145
  if (_instanceof(parent, nativeSet)) {
148
- parent.forEach(function(value) {
146
+ parent.forEach(function (value) {
149
147
  var entryChild = _clone(value, depth - 1);
150
148
  child.add(entryChild);
151
149
  });
@@ -164,17 +162,16 @@ var clone = (function() {
164
162
  continue;
165
163
  }
166
164
  child[i] = _clone(parent[i], depth - 1);
167
- } catch(e){
165
+ } catch (e) {
168
166
  if (e instanceof TypeError) {
169
167
  // when in strict mode, TypeError will be thrown if child[i] property only has a getter
170
168
  // we can't do anything about this, other than inform the user that this property cannot be set.
171
- continue
169
+ continue;
172
170
  } else if (e instanceof ReferenceError) {
173
171
  //this may happen in non strict mode
174
- continue
172
+ continue;
175
173
  }
176
174
  }
177
-
178
175
  }
179
176
 
180
177
  if (Object.getOwnPropertySymbols) {
@@ -219,15 +216,14 @@ var clone = (function() {
219
216
  * works.
220
217
  */
221
218
  clone.clonePrototype = function clonePrototype(parent) {
222
- if (parent === null)
223
- return null;
219
+ if (parent === null) return null;
224
220
 
225
221
  var c = function () {};
226
222
  c.prototype = parent;
227
223
  return new c();
228
224
  };
229
225
 
230
- // private utility functions
226
+ // private utility functions
231
227
 
232
228
  function __objToStr(o) {
233
229
  return Object.prototype.toString.call(o);
@@ -261,4 +257,4 @@ var clone = (function() {
261
257
  return clone;
262
258
  })();
263
259
 
264
- export default clone
260
+ export default clone;
@@ -72,6 +72,10 @@ export default {
72
72
  btnType: {
73
73
  type: [String],
74
74
  default: 'default'
75
+ },
76
+ onSendBefore: {
77
+ type: Function,
78
+ default: null
75
79
  }
76
80
  },
77
81
  watch: {
@@ -120,6 +124,11 @@ export default {
120
124
  },
121
125
  /******获取短信验证码************************************* */
122
126
  getSmsCode() {
127
+ if (this.onSendBefore && typeof this.onSendBefore == 'function') {
128
+ if (!this.onSendBefore()) {
129
+ return false;
130
+ }
131
+ }
123
132
  if (!this.localMobile) {
124
133
  this.showDiyMsg('手机号不正确');
125
134
  return;
@@ -1,7 +1,7 @@
1
- import buildURL from '../helpers/buildURL'
2
- import buildFullPath from '../core/buildFullPath'
3
- import settle from '../core/settle'
4
- import { isUndefined } from '../utils'
1
+ import buildURL from '../helpers/buildURL';
2
+ import buildFullPath from '../core/buildFullPath';
3
+ import settle from '../core/settle';
4
+ import { isUndefined } from '../utils';
5
5
 
6
6
  /**
7
7
  * 返回可选值存在的配置
@@ -10,88 +10,122 @@ import { isUndefined } from '../utils'
10
10
  * @return {{}} - 存在的配置项
11
11
  */
12
12
  const mergeKeys = (keys, config2) => {
13
- const config = {}
14
- keys.forEach((prop) => {
15
- if (!isUndefined(config2[prop])) {
16
- config[prop] = config2[prop]
17
- }
18
- })
19
- return config
20
- }
21
- export default (config) => new Promise((resolve, reject) => {
22
- const fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params)
23
- const _config = {
24
- url: fullPath,
25
- header: config.header,
26
- complete: (response) => {
27
- config.fullPath = fullPath
28
- response.config = config
29
- try {
30
- // 对可能字符串不是json 的情况容错
31
- if (typeof response.data === 'string') {
32
- response.data = JSON.parse(response.data)
33
- }
34
- // eslint-disable-next-line no-empty
35
- } catch (e) {
36
- }
37
- settle(resolve, reject, response)
38
- }
13
+ let config = {};
14
+ keys.forEach((prop) => {
15
+ if (!isUndefined(config2[prop])) {
16
+ config[prop] = config2[prop];
39
17
  }
40
- let requestTask
18
+ });
19
+ return config;
20
+ };
21
+ export default (config) => {
22
+ return new Promise((resolve, reject) => {
23
+ let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params, config.paramsSerializer);
24
+ const _config = {
25
+ url: fullPath,
26
+ header: config.header,
27
+ complete: (response) => {
28
+ config.fullPath = fullPath;
29
+ response.config = config;
30
+ response.rawData = response.data;
31
+ try {
32
+ let jsonParseHandle = false;
33
+ const forcedJSONParsingType = typeof config.forcedJSONParsing;
34
+ if (forcedJSONParsingType === 'boolean') {
35
+ jsonParseHandle = config.forcedJSONParsing;
36
+ } else if (forcedJSONParsingType === 'object') {
37
+ const includesMethod = config.forcedJSONParsing.include || [];
38
+ jsonParseHandle = includesMethod.includes(config.method);
39
+ }
40
+
41
+ // 对可能字符串不是json 的情况容错
42
+ if (jsonParseHandle && typeof response.data === 'string') {
43
+ response.data = JSON.parse(response.data);
44
+ }
45
+ // eslint-disable-next-line no-empty
46
+ } catch (e) {}
47
+ settle(resolve, reject, response);
48
+ }
49
+ };
50
+ let requestTask;
41
51
  if (config.method === 'UPLOAD') {
42
- delete _config.header['content-type']
43
- delete _config.header['Content-Type']
44
- const otherConfig = {
52
+ delete _config.header['content-type'];
53
+ delete _config.header['Content-Type'];
54
+ let otherConfig = {
45
55
  // #ifdef MP-ALIPAY
46
- fileType: config.fileType,
47
- // #endif
48
- filePath: config.filePath,
49
- name: config.name
50
- }
51
- const optionalKeys = [
56
+ fileType: config.fileType,
57
+ // #endif
58
+ filePath: config.filePath,
59
+ name: config.name
60
+ };
61
+ const optionalKeys = [
52
62
  // #ifdef APP-PLUS || H5
53
- 'files',
54
- // #endif
55
- // #ifdef H5
56
- 'file',
57
- // #endif
58
- // #ifdef H5 || APP-PLUS
59
- 'timeout',
60
- // #endif
61
- 'formData'
62
- ]
63
- requestTask = uni.uploadFile({ ..._config, ...otherConfig, ...mergeKeys(optionalKeys, config) })
63
+ 'files',
64
+ // #endif
65
+ // #ifdef H5
66
+ 'file',
67
+ // #endif
68
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
69
+ 'timeout',
70
+ // #endif
71
+ 'formData'
72
+ ];
73
+ requestTask = uni.uploadFile({ ..._config, ...otherConfig, ...mergeKeys(optionalKeys, config) });
64
74
  } else if (config.method === 'DOWNLOAD') {
65
- // #ifdef H5 || APP-PLUS
66
- if (!isUndefined(config.timeout)) {
67
- _config.timeout = config.timeout
68
- }
75
+ const optionalKeys = [
76
+ // #ifdef H5 || APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU
77
+ 'timeout',
78
+ // #endif
79
+ // #ifdef MP
80
+ 'filePath'
69
81
  // #endif
70
- requestTask = uni.downloadFile(_config)
82
+ ];
83
+ requestTask = uni.downloadFile({ ..._config, ...mergeKeys(optionalKeys, config) });
71
84
  } else {
72
- const optionalKeys = [
73
- 'data',
74
- 'method',
75
- // #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
76
- 'timeout',
77
- // #endif
78
- 'dataType',
79
- // #ifndef MP-ALIPAY
80
- 'responseType',
81
- // #endif
82
- // #ifdef APP-PLUS
83
- 'sslVerify',
84
- // #endif
85
- // #ifdef H5
86
- 'withCredentials',
87
- // #endif
88
- // #ifdef APP-PLUS
89
- 'firstIpv4'
90
- // #endif
91
- ]
92
- requestTask = uni.request({ ..._config, ...mergeKeys(optionalKeys, config) })
85
+ const optionalKeys = [
86
+ 'data',
87
+ 'method',
88
+ // #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
89
+ 'timeout',
90
+ // #endif
91
+ 'dataType',
92
+ // #ifndef MP-ALIPAY
93
+ 'responseType',
94
+ // #endif
95
+ // #ifdef APP-PLUS
96
+ 'sslVerify',
97
+ // #endif
98
+ // #ifdef H5
99
+ 'withCredentials',
100
+ // #endif
101
+ // #ifdef APP-PLUS
102
+ 'firstIpv4',
103
+ // #endif
104
+ // #ifdef MP-WEIXIN
105
+ 'enableHttp2',
106
+ 'enableQuic',
107
+ // #endif
108
+ // #ifdef MP-TOUTIAO || MP-WEIXIN
109
+ 'enableCache',
110
+ // #endif
111
+ // #ifdef MP-WEIXIN
112
+ 'enableHttpDNS',
113
+ 'httpDNSServiceId',
114
+ 'enableChunked',
115
+ 'forceCellularNetwork',
116
+ // #endif
117
+ // #ifdef MP-ALIPAY
118
+ 'enableCookie',
119
+ // #endif
120
+ // #ifdef MP-BAIDU
121
+ 'cloudCache',
122
+ 'defer'
123
+ // #endif
124
+ ];
125
+ requestTask = uni.request({ ..._config, ...mergeKeys(optionalKeys, config) });
93
126
  }
94
127
  if (config.getTask) {
95
- config.getTask(requestTask, config)
128
+ config.getTask(requestTask, config);
96
129
  }
97
- })
130
+ });
131
+ };
@@ -1,7 +1,7 @@
1
- 'use strict'
1
+ 'use strict';
2
2
 
3
3
  function InterceptorManager() {
4
- this.handlers = []
4
+ this.handlers = [];
5
5
  }
6
6
 
7
7
  /**
@@ -13,12 +13,12 @@ function InterceptorManager() {
13
13
  * @return {Number} An ID used to remove interceptor later
14
14
  */
15
15
  InterceptorManager.prototype.use = function use(fulfilled, rejected) {
16
- this.handlers.push({
17
- fulfilled,
18
- rejected
19
- })
20
- return this.handlers.length - 1
21
- }
16
+ this.handlers.push({
17
+ fulfilled: fulfilled,
18
+ rejected: rejected
19
+ });
20
+ return this.handlers.length - 1;
21
+ };
22
22
 
23
23
  /**
24
24
  * Remove an interceptor from the stack
@@ -26,10 +26,10 @@ InterceptorManager.prototype.use = function use(fulfilled, rejected) {
26
26
  * @param {Number} id The ID that was returned by `use`
27
27
  */
28
28
  InterceptorManager.prototype.eject = function eject(id) {
29
- if (this.handlers[id]) {
30
- this.handlers[id] = null
31
- }
32
- }
29
+ if (this.handlers[id]) {
30
+ this.handlers[id] = null;
31
+ }
32
+ };
33
33
 
34
34
  /**
35
35
  * Iterate over all the registered interceptors
@@ -40,11 +40,11 @@ InterceptorManager.prototype.eject = function eject(id) {
40
40
  * @param {Function} fn The function to call for each interceptor
41
41
  */
42
42
  InterceptorManager.prototype.forEach = function forEach(fn) {
43
- this.handlers.forEach((h) => {
44
- if (h !== null) {
45
- fn(h)
46
- }
47
- })
48
- }
43
+ this.handlers.forEach((h) => {
44
+ if (h !== null) {
45
+ fn(h);
46
+ }
47
+ });
48
+ };
49
49
 
50
- export default InterceptorManager
50
+ export default InterceptorManager;