@tmsfe/tms-core 0.0.73 → 0.0.74

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.73",
3
+ "version": "0.0.74",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,9 +8,10 @@
8
8
  import syncApi from './syncfnmanager';
9
9
  import AutoReport from './report/proxy/index';
10
10
  import md5 from './md5';
11
- import { rpxToPx } from './rpx';
12
11
  import { serialize } from './objUtils';
13
12
  import { calCoordinateDistance, formatDistance } from './distanceUtils';
13
+ import { getNavBarConfigData } from './navbarUtils';
14
+ import * as rpxUtil from './rpx';
14
15
  import * as stringUtils from './stringUtils';
15
16
  import * as timeUtils from './timeUtils';
16
17
  import * as ipxHelper from './ipxHelper';
@@ -210,15 +211,16 @@ const api = {
210
211
  md5,
211
212
  getCarManager,
212
213
  getLocationManager,
213
- rpxToPx,
214
214
  serialize,
215
215
  calCoordinateDistance,
216
216
  formatDistance,
217
+ getNavBarConfigData,
217
218
  createRequest,
218
219
  getEnvInfo,
219
220
  isAppPageExist,
220
221
  getHomePage,
221
222
  storage,
223
+ ...rpxUtil,
222
224
  ...asyncFuncs,
223
225
  ...objFuncs,
224
226
  ...syncApi,
package/src/index.js CHANGED
@@ -11,7 +11,8 @@ import { callCloudFunc } from './cloudService';
11
11
  import EventDispatcher from './eventDispatcher';
12
12
  import { serialize } from './objUtils';
13
13
  import { calCoordinateDistance, formatDistance } from './distanceUtils';
14
- import { rpxToPx } from './rpx';
14
+ import { rpxToPx, pxToRpx } from './rpx';
15
+ import { getNavBarConfigData } from './navbarUtils';
15
16
  import {
16
17
  formatPlate,
17
18
  subStr,
@@ -192,6 +193,9 @@ const api = {
192
193
 
193
194
  /** rpx转px */
194
195
  rpxToPx,
196
+ pxToRpx,
197
+
198
+ getNavBarConfigData,
195
199
 
196
200
  storage,
197
201
 
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 获取导航栏相关信息
3
+ * @returns {Object} data 导航栏布局信息
4
+ * @returns {Number} data.enable 是否支持自定义导航栏
5
+ * @returns {Number} data.statusBarHeight 状态栏高度,单位px
6
+ * @returns {Number} data.navBarHeight 导航栏高度(不含状态栏),单位px
7
+ * @returns {Number} data.menuTop 菜单按钮上边距,单位px
8
+ * @returns {Number} data.menuRight 菜单按钮右边缘距离屏幕左边缘的距离,单位px
9
+ * @returns {Number} data.menuWidth 菜单按钮宽度,单位px
10
+ * @returns {Number} data.menuHeight 菜单按钮高度,单位px
11
+ */
12
+ const getNavBarConfigData = () => {
13
+ const { statusBarHeight } = wx.getSystemInfoSync();
14
+ const { right, width, height = 0, top } = wx.getMenuButtonBoundingClientRect(); // 插件下基础库2.15.0起支持
15
+ return {
16
+ enable: true,
17
+ statusBarHeight, // 顶部状态栏高度
18
+ navBarHeight: height + ((top - statusBarHeight) * 2), // 小程序导航栏高度
19
+ menuTop: top, // 菜单按钮上边距
20
+ menuRight: right, // 菜单按钮右边距离屏幕左边缘的距离
21
+ menuWidth: width, // 菜单按钮宽度
22
+ menuHeight: height, // 菜单按钮高度
23
+ };
24
+ };
25
+
26
+ export {
27
+ getNavBarConfigData,
28
+ };
@@ -48,7 +48,7 @@
48
48
  #### 页面自动上报事件
49
49
  ##### 一、必须上报的生命周期事件:
50
50
  1. onLoad: 页面加载
51
- 2. onShow: 页面显示
51
+ 2. onShow: 页面显示(曝光)
52
52
  3. onReady: 页面初次渲染完成
53
53
  4. onHide: 页面隐藏
54
54
  5. onUnload: 页面卸载
@@ -56,7 +56,7 @@
56
56
  ##### 二、可能会上报的生命周期事件(取决于页面是否实现该函数):
57
57
  1. onPullDownRefresh: 用户下拉动作
58
58
  2. onReachBottom: 页面上拉触底
59
- 3. onShareAppMessage: 用户点击右上角转发
59
+ 3. onShareAppMessage: 用户点击右上角转发(分享)
60
60
  4. onShareTimeline: 用户点击右上角转发到朋友圈
61
61
  5. onAddToFavorites: 用户点击右上角收藏
62
62
  6. onReportPageTouch: 用户触摸页面 - 如果页面wxml有view节点则会注入该事件
@@ -68,7 +68,7 @@ function executeFunc(context: any, func: Function, args: any[], callback: Functi
68
68
  let value: any;
69
69
  try {
70
70
  value = func.apply(context, args);
71
- } catch(e) {
71
+ } catch (e) {
72
72
  callback();
73
73
  throw e;
74
74
  }
package/src/rpx.js CHANGED
@@ -12,6 +12,19 @@ const rpxToPx = (rpx) => {
12
12
  return rpx * ratio;
13
13
  };
14
14
 
15
+ /**
16
+ * @description px to rpx
17
+ * @returns {Number} 转换后的rpx数值
18
+ * @param px
19
+ */
20
+ const pxToRpx = (px) => {
21
+ const sys = syncApi.getSystemInfoSync();
22
+ const ww = sys.windowWidth;
23
+ const ratio = 750 / ww;
24
+ return px * ratio;
25
+ };
26
+
15
27
  export {
16
28
  rpxToPx,
29
+ pxToRpx,
17
30
  };