@tmsfe/tms-core 0.0.78 → 0.0.79
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/package.json +1 -1
- package/src/index-proxy.js +2 -0
- package/src/index.js +2 -0
- package/src/tmsuiUtils.js +68 -0
package/package.json
CHANGED
package/src/index-proxy.js
CHANGED
|
@@ -11,6 +11,7 @@ import md5 from './md5';
|
|
|
11
11
|
import { serialize } from './objUtils';
|
|
12
12
|
import { calCoordinateDistance, formatDistance } from './distanceUtils';
|
|
13
13
|
import { getNavBarConfigData } from './navbarUtils';
|
|
14
|
+
import * as uiUtil from './tmsuiUtils';
|
|
14
15
|
import * as rpxUtil from './rpx';
|
|
15
16
|
import * as stringUtils from './stringUtils';
|
|
16
17
|
import * as timeUtils from './timeUtils';
|
|
@@ -221,6 +222,7 @@ const api = {
|
|
|
221
222
|
getHomePage,
|
|
222
223
|
storage,
|
|
223
224
|
...rpxUtil,
|
|
225
|
+
...uiUtil,
|
|
224
226
|
...asyncFuncs,
|
|
225
227
|
...objFuncs,
|
|
226
228
|
...syncApi,
|
package/src/index.js
CHANGED
|
@@ -45,6 +45,7 @@ import getLocInstance from './location/index';
|
|
|
45
45
|
import LocationBase from './location/base';
|
|
46
46
|
import { getMpOpenId, getOuterOpenId, getEncryptUserInfo } from './mpInfo';
|
|
47
47
|
import * as storage from './storage';
|
|
48
|
+
import * as uiUtil from './tmsuiUtils';
|
|
48
49
|
import { throttle, debounce } from './funcUtils';
|
|
49
50
|
|
|
50
51
|
/**
|
|
@@ -200,6 +201,7 @@ const api = {
|
|
|
200
201
|
storage,
|
|
201
202
|
|
|
202
203
|
...syncApi,
|
|
204
|
+
...uiUtil,
|
|
203
205
|
throttle,
|
|
204
206
|
debounce,
|
|
205
207
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 从当前页面中选定组件
|
|
4
|
+
* @param {String} selector 元素选择器
|
|
5
|
+
* @returns {Element} 组件
|
|
6
|
+
*/
|
|
7
|
+
const selectCompFromCurPage = (selector) => {
|
|
8
|
+
const pages = getCurrentPages();
|
|
9
|
+
if (pages.length === 0) {
|
|
10
|
+
throw new Error('Empty page container found');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const context = pages[pages.length - 1];
|
|
14
|
+
const comp = context.selectComponent(selector);
|
|
15
|
+
if (!comp) {
|
|
16
|
+
throw new Error(`No component found with selector <${selector}>`);
|
|
17
|
+
}
|
|
18
|
+
return comp;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/* eslint-disable */
|
|
22
|
+
const showDrawer = (options = {}, selectComp = selectCompFromCurPage) => {
|
|
23
|
+
const { selector = '#drawer' } = options;
|
|
24
|
+
const comp = selectComp(selector);
|
|
25
|
+
comp?.show(options);
|
|
26
|
+
};
|
|
27
|
+
const hideDrawer = (options = {}, selectComp = selectCompFromCurPage) => {
|
|
28
|
+
const { selector = '#drawer' } = options;
|
|
29
|
+
const comp = selectComp(selector);
|
|
30
|
+
comp?.hide(options);
|
|
31
|
+
};
|
|
32
|
+
/* eslint-disable */
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 显示或隐藏Modal
|
|
36
|
+
* @param {Boolean} display 展示/隐藏
|
|
37
|
+
* @param {Object} options Modal参数
|
|
38
|
+
* @param {Function} selectComp 选择组件的方法
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
const toggleModal = (display = true, options = {}, selectComp) => {
|
|
42
|
+
const { selector = '#modal' } = options;
|
|
43
|
+
try {
|
|
44
|
+
const comp = selectComp(selector);
|
|
45
|
+
if (display) {
|
|
46
|
+
comp.show(options);
|
|
47
|
+
} else {
|
|
48
|
+
comp.hide(options);
|
|
49
|
+
}
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (typeof options.fail === 'function') {
|
|
52
|
+
options.fail({ errMsg: e.toString() });
|
|
53
|
+
} else {
|
|
54
|
+
throw e;
|
|
55
|
+
}
|
|
56
|
+
if (typeof options.complete === 'function') {
|
|
57
|
+
options.complete({ success: false, errMsg: e.toString() });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const showModal = (options, selectComp = selectCompFromCurPage) => toggleModal(true, options, selectComp);
|
|
63
|
+
const hideModal = (options, selectComp = selectCompFromCurPage) => toggleModal(false,options, selectComp);
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
showDrawer, hideDrawer,
|
|
67
|
+
showModal, hideModal,
|
|
68
|
+
};
|