syttunnel 0.1.5-5 → 0.1.5-8

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.
@@ -74,8 +74,9 @@ interface INavigatorFrameResponse {
74
74
  export declare class AppNavigator {
75
75
  /**
76
76
  * 关闭当前h5应用
77
+ * 对应app9.38版本升级为携带参数
77
78
  */
78
- closeH5App(): void;
79
+ closeH5App(params?: any): void;
79
80
  /**
80
81
  * 设置导航栏标题
81
82
  * @param params
@@ -12,6 +12,17 @@ export interface IGetUserInfoParams {
12
12
  needLogin?: boolean;
13
13
  domain?: string;
14
14
  }
15
+ export interface IGetUserBaseInfoParams {
16
+ needLogin?: boolean;
17
+ }
18
+ export interface IGetUserBaseInfoResponse {
19
+ nickName?: string;
20
+ birthday?: string;
21
+ sex?: string;
22
+ }
23
+ export interface IGetUserAvatarParams {
24
+ needLogin?: boolean;
25
+ }
15
26
  export declare class AppUser {
16
27
  /**
17
28
  * 调用OAuth2.0 授权接口
@@ -25,4 +36,16 @@ export declare class AppUser {
25
36
  * @returns
26
37
  */
27
38
  getUserInfo(params: IGetUserInfoParams): Promise<string>;
39
+ /**
40
+ * 获取用户基本信息
41
+ * @param params
42
+ * @returns
43
+ */
44
+ getUserBaseInfo(params: IGetUserBaseInfoParams): Promise<IGetUserBaseInfoResponse>;
45
+ /**
46
+ * 获取用户头像
47
+ * @param params
48
+ * @returns
49
+ */
50
+ getUserAvatar(params: IGetUserAvatarParams): Promise<string>;
28
51
  }
@@ -2,7 +2,7 @@
2
2
  * 基本的调用事件
3
3
  */
4
4
  import { IPostParams } from "./bridge";
5
- export declare type CommonEvents = "getUserInfo" | "sytFetch" | "authorize" | "backToBefore" | "setTitle" | "setStyle" | "getNavigationFrame" | "loadUrl" | "payByWeChat" | "payByAli" | "startScanCode" | "shareMessageToWXReq" | "currentLocation" | "appVersion" | "selectContacts" | "saveImageToLocal" | "getEnvironment" | "goBack" | "selectAddress" | "pasteString";
5
+ export declare type CommonEvents = "getUserInfo" | "getUserAvatar" | "getUserBaseInfo" | "sytFetch" | "authorize" | "backToBefore" | "setTitle" | "setStyle" | "getNavigationFrame" | "loadUrl" | "payByWeChat" | "payByAli" | "startScanCode" | "shareMessageToWXReq" | "currentLocation" | "appVersion" | "selectContacts" | "saveImageToLocal" | "getEnvironment" | "goBack" | "selectAddress" | "pasteString";
6
6
  export interface IPostBasicParams extends IPostParams {
7
7
  method: CommonEvents;
8
8
  }
@@ -1,26 +1,3 @@
1
1
  import { AppUser } from "../basic/appUser";
2
- export interface IGetUserBaseInfoParams {
3
- needLogin?: boolean;
4
- }
5
- export interface IGetUserBaseInfoResponse {
6
- nickName?: string;
7
- birthday?: string;
8
- sex?: string;
9
- }
10
- export interface IGetUserAvatarParams {
11
- needLogin?: boolean;
12
- }
13
2
  export declare class SFAppUser extends AppUser {
14
- /**
15
- * 获取用户基本信息
16
- * @param params
17
- * @returns
18
- */
19
- getUserBaseInfo(params: IGetUserBaseInfoParams): Promise<IGetUserBaseInfoResponse>;
20
- /**
21
- * 获取用户头像
22
- * @param params
23
- * @returns
24
- */
25
- getUserAvatar(params: IGetUserAvatarParams): Promise<string>;
26
3
  }
@@ -3,7 +3,7 @@ import { CommonEvents } from "../basic/eventsName";
3
3
  /**
4
4
  * 顺丰内部使用的事件
5
5
  */
6
- export declare type SFEvents = CommonEvents | "getUserAvatar" | "getUserBaseInfo" | "payBySVIP" | "payBySDK" | "wxAutoPaySignReq" | "payWaybillByPayId" | "digiCnyPayResult" | "startGetIMEICode" | "getReducerData" | "getDeviceId" | "syncCookie" | "getPushAuthStatus" | "setStateToPush" | "setStateToPushNoTimeLimit" | "getLocalWebSource" | "navigate" | "setCanBack" | "payByWXMiniProgram";
6
+ export declare type SFEvents = CommonEvents | "payBySVIP" | "payBySDK" | "wxAutoPaySignReq" | "payWaybillByPayId" | "digiCnyPayResult" | "startGetIMEICode" | "getReducerData" | "getDeviceId" | "syncCookie" | "getPushAuthStatus" | "setStateToPush" | "setStateToPushNoTimeLimit" | "getLocalWebSource" | "navigate" | "setCanBack" | "payByWXMiniProgram";
7
7
  export interface IPostSFParams extends IPostParams {
8
8
  method: SFEvents;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "syttunnel",
3
- "version": "0.1.5-5",
3
+ "version": "0.1.5-8",
4
4
  "description": "",
5
5
  "main": "syttunnel.js",
6
6
  "types": "index.d.ts",
package/syttunnel.js CHANGED
@@ -429,9 +429,16 @@ var Bridge = /** @class */ (function () {
429
429
  function Bridge() {
430
430
  var _this = this;
431
431
  this.onMessage = function (msg) {
432
- var message = typeof msg.data === "string"
433
- ? JSON.parse(msg.data || "")
434
- : msg.data || {};
432
+ var message = {};
433
+ if (msg.data && typeof msg.data === "string" && msg.data.length > 0) {
434
+ try {
435
+ message = JSON.parse(msg.data);
436
+ }
437
+ catch (error) { }
438
+ }
439
+ else if (msg.data) {
440
+ message = msg.data;
441
+ }
435
442
  var method = message.method;
436
443
  var value = message.value;
437
444
  var uniqueId = message.uniqueId;
@@ -769,11 +776,12 @@ var AppNavigator = /** @class */ (function () {
769
776
  }
770
777
  /**
771
778
  * 关闭当前h5应用
779
+ * 对应app9.38版本升级为携带参数
772
780
  */
773
- AppNavigator.prototype.closeH5App = function () {
781
+ AppNavigator.prototype.closeH5App = function (params) {
774
782
  var appFunc = {
775
783
  method: "backToBefore",
776
- params: {},
784
+ params: params,
777
785
  };
778
786
  bridge_1.default.postMessage(appFunc).then().catch();
779
787
  };
@@ -914,6 +922,36 @@ var AppUser = /** @class */ (function () {
914
922
  };
915
923
  return bridge_1.default.postMessage(appFunc);
916
924
  };
925
+ /**
926
+ * 获取用户基本信息
927
+ * @param params
928
+ * @returns
929
+ */
930
+ AppUser.prototype.getUserBaseInfo = function (params) {
931
+ var data = {
932
+ needLogin: params.needLogin || true,
933
+ };
934
+ var appFunc = {
935
+ method: "getUserBaseInfo",
936
+ params: data,
937
+ };
938
+ return bridge_1.default.postMessage(appFunc);
939
+ };
940
+ /**
941
+ * 获取用户头像
942
+ * @param params
943
+ * @returns
944
+ */
945
+ AppUser.prototype.getUserAvatar = function (params) {
946
+ var data = {
947
+ needLogin: params.needLogin || true,
948
+ };
949
+ var appFunc = {
950
+ method: "getUserAvatar",
951
+ params: data,
952
+ };
953
+ return bridge_1.default.postMessage(appFunc);
954
+ };
917
955
  return AppUser;
918
956
  }());
919
957
  exports.AppUser = AppUser;