crh-jssdk 1.0.31 → 1.0.33

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.
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var utils_1 = require("../utils");
40
+ // webview类型
41
+ var webviewType = (function () {
42
+ var ua = navigator.userAgent;
43
+ return {};
44
+ })();
45
+ var actionMap = {
46
+ /**
47
+ * iOS客户端方法加载函数(老乐赚老聚财)
48
+ * @param {string} url
49
+ */
50
+ loadIOSNative: function (url) {
51
+ var iFrame = "";
52
+ iFrame = document.createElement("iframe");
53
+ iFrame.setAttribute("src", url);
54
+ iFrame.setAttribute("style", "display:none;");
55
+ iFrame.setAttribute("height", "0px");
56
+ iFrame.setAttribute("width", "0px");
57
+ iFrame.setAttribute("frameborder", "0");
58
+ document.body.appendChild(iFrame);
59
+ iFrame.parentNode.removeChild(iFrame);
60
+ iFrame = null;
61
+ },
62
+ };
63
+ exports.default = {
64
+ actionMap: actionMap,
65
+ webviewType: function () {
66
+ return webviewType;
67
+ },
68
+ //是否在app内
69
+ isApp: function () {
70
+ var ua = navigator.userAgent;
71
+ var isAppFlags = [
72
+ "crhsdk",
73
+ ];
74
+ return isAppFlags.some(function (flag) { return ua.includes(flag); });
75
+ },
76
+ // 拦截Android物理返回键事件,并回调给前端 --- 仅安卓
77
+ interceptBack: function (callback) {
78
+ window.jtoJHandle.interceptBack("interceptBackCallBack");
79
+ window.interceptBackCallBack = function (e) {
80
+ callback && callback(e);
81
+ };
82
+ },
83
+ // 关闭页面 closeSJKH
84
+ closeSJKH: function () {
85
+ if (utils_1.ios) {
86
+ // iphone
87
+ window.location.href = "objc://callIOSQuit/";
88
+ }
89
+ else {
90
+ window.jtoJHandle.closeSJKH();
91
+ }
92
+ },
93
+ /**
94
+ * 通过pageId打开新的webview打开外部链接
95
+ */
96
+ goWebview: function (params) {
97
+ var sdk = params.sdk, h5 = params.h5, _a = params.h5url, h5url = _a === void 0 ? "" : _a, productCode = params.productCode;
98
+ var jsonObj = {
99
+ indexUrl: h5,
100
+ uploadPicUrl: "",
101
+ cookieDomain: "",
102
+ closeBusiness: "closeCallBack",
103
+ module: "",
104
+ identifier: "zt",
105
+ };
106
+ var jsonStr = JSON.stringify(jsonObj);
107
+ if (utils_1.ios) {
108
+ // iphone
109
+ actionMap.loadIOSNative("objc://openNewBusiness/$?".concat(jsonStr));
110
+ }
111
+ else {
112
+ window.jtoJHandle.openNewBusiness(jsonStr);
113
+ }
114
+ },
115
+ /**
116
+ * 通过打开新的webview打开外部链接
117
+ * @param {string} url 跳转地址
118
+ * @param {boolean} needTitle 打开新webview是否需要页头1需要0不需要
119
+ */
120
+ goWebview2: function (_a) {
121
+ var _b;
122
+ var _c = _a.url, url = _c === void 0 ? "" : _c, _d = _a.needTitle, needTitle = _d === void 0 ? false : _d, _e = _a.noNewWebView, noNewWebView = _e === void 0 ? false : _e;
123
+ var paramsObj = {
124
+ indexUrl: url,
125
+ };
126
+ paramsObj = JSON.stringify(paramsObj);
127
+ if (utils_1.ios) {
128
+ actionMap.loadIOSNative("objc://openNewBusiness/$?".concat(paramsObj));
129
+ }
130
+ else {
131
+ (_b = window.jtoJHandle) === null || _b === void 0 ? void 0 : _b.openNewBusiness(paramsObj);
132
+ }
133
+ },
134
+ /**
135
+ * @param {object} params
136
+ * @param {string} params.color 状态栏背景颜色,如#ff0000
137
+ * @param {string} params.wordColorStyle 状态栏文字颜色,0 白色,1 黑色
138
+ */
139
+ setStatusBar: function (params) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ return __generator(this, function (_a) {
142
+ if (utils_1.ios) {
143
+ actionMap.loadIOSNative("objc://setAppBackgroundColor/$?".concat(params.color));
144
+ }
145
+ else if (window.jtoJHandle) {
146
+ window.jtoJHandle.setAppBackgroundColor(params.color);
147
+ }
148
+ return [2 /*return*/];
149
+ });
150
+ });
151
+ },
152
+ };
@@ -85,64 +85,64 @@ var BUSINESS = /** @class */ (function () {
85
85
  function BUSINESS(sdkType) {
86
86
  this.isApp = false; //是否是app
87
87
  this.sdkType = sdkType; // 1 财人汇 2 财信 3 新意 4 联储 5 金圆
88
- this.bridge = utils_1.globalBridge; // 初始化Bridge实例
88
+ this.bridge = sdkType === 2 ? utils_1.cxBridge : utils_1.globalBridge; // 初始化Bridge实例
89
89
  }
90
90
  BUSINESS.prototype.initSdk = function () {
91
91
  return __awaiter(this, void 0, void 0, function () {
92
- var Obj, _a, _b, _c, _d, _e, _f, error_1, _g, _h, _j, _k, _l, _m, _o, _p;
93
- var _q, _r;
94
- return __generator(this, function (_s) {
95
- switch (_s.label) {
92
+ var Obj, _a, _b, _c, _d, _e, _f, error_1, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
93
+ var _u, _v;
94
+ return __generator(this, function (_w) {
95
+ switch (_w.label) {
96
96
  case 0:
97
97
  console.log("start initSdk");
98
98
  Obj = __assign(__assign(__assign({}, base_1.default), profession_1.default), user_1.default);
99
99
  if (!(+this.sdkType === 1)) return [3 /*break*/, 1];
100
100
  this.sdkObj = Obj;
101
- return [3 /*break*/, 19];
101
+ return [3 /*break*/, 23];
102
102
  case 1:
103
103
  if (!(+this.sdkType === 2)) return [3 /*break*/, 5];
104
104
  _a = this;
105
105
  _b = [__assign({}, Obj)];
106
106
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./base/crh-app-sdk-cxzq")); })];
107
107
  case 2:
108
- _c = [__assign.apply(void 0, _b.concat([(_s.sent()).default]))];
108
+ _c = [__assign.apply(void 0, _b.concat([(_w.sent()).default]))];
109
109
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./user/crh-app-sdk-cxzq")); })];
110
110
  case 3:
111
- _d = [__assign.apply(void 0, _c.concat([(_s.sent()).default]))];
111
+ _d = [__assign.apply(void 0, _c.concat([(_w.sent()).default]))];
112
112
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./profession/crh-app-sdk-cxzq")); })];
113
113
  case 4:
114
- _a.sdkObj = __assign.apply(void 0, _d.concat([(_s.sent()).default]));
114
+ _a.sdkObj = __assign.apply(void 0, _d.concat([(_w.sent()).default]));
115
115
  console.log(this.sdkObj, "sdkObj---jssdk");
116
116
  this.isApp = this.sdkObj.isApp();
117
117
  this.webviewType = this.sdkObj.webviewType();
118
- return [3 /*break*/, 19];
118
+ return [3 /*break*/, 23];
119
119
  case 5:
120
120
  if (!(+this.sdkType === 3)) return [3 /*break*/, 7];
121
121
  _e = this;
122
122
  _f = [{}];
123
123
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./user/crh-app-sdk-cy")); })];
124
124
  case 6:
125
- _e.sdkObj = __assign.apply(void 0, _f.concat([(_s.sent()).default]));
125
+ _e.sdkObj = __assign.apply(void 0, _f.concat([(_w.sent()).default]));
126
126
  console.log(this.sdkObj, "sdkObj---jssdk");
127
127
  this.isApp = this.sdkObj.isApp();
128
128
  this.webviewType = this.sdkObj.webviewType();
129
- return [3 /*break*/, 19];
129
+ return [3 /*break*/, 23];
130
130
  case 7:
131
131
  if (!(+this.sdkType === 4)) return [3 /*break*/, 15];
132
132
  console.log("初始化联储证券SDK...");
133
133
  if (!(typeof window !== "undefined" &&
134
134
  window.ClientTHS &&
135
135
  typeof window.ClientTHS.init === "function")) return [3 /*break*/, 11];
136
- _s.label = 8;
136
+ _w.label = 8;
137
137
  case 8:
138
- _s.trys.push([8, 10, , 11]);
139
- return [4 /*yield*/, ((_r = (_q = window.ClientTHS).init) === null || _r === void 0 ? void 0 : _r.call(_q))];
138
+ _w.trys.push([8, 10, , 11]);
139
+ return [4 /*yield*/, ((_v = (_u = window.ClientTHS).init) === null || _v === void 0 ? void 0 : _v.call(_u))];
140
140
  case 9:
141
- _s.sent();
141
+ _w.sent();
142
142
  console.log("ClientTHS初始化完成");
143
143
  return [3 /*break*/, 11];
144
144
  case 10:
145
- error_1 = _s.sent();
145
+ error_1 = _w.sent();
146
146
  console.error("ClientTHS初始化失败:", error_1);
147
147
  return [3 /*break*/, 11];
148
148
  case 11:
@@ -151,18 +151,18 @@ var BUSINESS = /** @class */ (function () {
151
151
  _h = [__assign({}, Obj)];
152
152
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./base/crh-app-sdk-lczq")); })];
153
153
  case 12:
154
- _j = [__assign.apply(void 0, _h.concat([(_s.sent()).default]))];
154
+ _j = [__assign.apply(void 0, _h.concat([(_w.sent()).default]))];
155
155
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./user/crh-app-sdk-lczq")); })];
156
156
  case 13:
157
- _k = [__assign.apply(void 0, _j.concat([(_s.sent()).default]))];
157
+ _k = [__assign.apply(void 0, _j.concat([(_w.sent()).default]))];
158
158
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./profession/crh-app-sdk-lczq")); })];
159
159
  case 14:
160
160
  // 联储证券使用Bridge版本
161
- _g.sdkObj = __assign.apply(void 0, _k.concat([(_s.sent()).default]));
161
+ _g.sdkObj = __assign.apply(void 0, _k.concat([(_w.sent()).default]));
162
162
  console.log("sdkObj---jssdk(Bridge版本)", this.sdkObj);
163
163
  this.isApp = this.sdkObj.isApp();
164
164
  this.webviewType = this.sdkObj.webviewType();
165
- return [3 /*break*/, 19];
165
+ return [3 /*break*/, 23];
166
166
  case 15:
167
167
  if (!(+this.sdkType === 5)) return [3 /*break*/, 19];
168
168
  console.log("初始化金圆统一SDK...");
@@ -171,19 +171,35 @@ var BUSINESS = /** @class */ (function () {
171
171
  _m = [__assign({}, Obj)];
172
172
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./base/crh-app-sdk-jy")); })];
173
173
  case 16:
174
- _o = [__assign.apply(void 0, _m.concat([(_s.sent()).default]))];
174
+ _o = [__assign.apply(void 0, _m.concat([(_w.sent()).default]))];
175
175
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./user/crh-app-sdk-jy")); })];
176
176
  case 17:
177
- _p = [__assign.apply(void 0, _o.concat([(_s.sent()).default]))];
177
+ _p = [__assign.apply(void 0, _o.concat([(_w.sent()).default]))];
178
178
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./profession/crh-app-sdk-jy")); })];
179
179
  case 18:
180
180
  // 金圆统一使用Bridge版本
181
- _l.sdkObj = __assign.apply(void 0, _p.concat([(_s.sent()).default]));
181
+ _l.sdkObj = __assign.apply(void 0, _p.concat([(_w.sent()).default]));
182
182
  console.log("sdkObj---jssdk(金圆统一)", this.sdkObj);
183
183
  this.isApp = this.sdkObj.isApp();
184
184
  this.webviewType = this.sdkObj.webviewType();
185
- _s.label = 19;
185
+ return [3 /*break*/, 23];
186
186
  case 19:
187
+ if (!(+this.sdkType === 6)) return [3 /*break*/, 23];
188
+ _q = this;
189
+ _r = [__assign({}, Obj)];
190
+ return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./base/crh-app-sdk-cctgsc")); })];
191
+ case 20:
192
+ _s = [__assign.apply(void 0, _r.concat([(_w.sent()).default]))];
193
+ return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./user/crh-app-sdk-cctgsc")); })];
194
+ case 21:
195
+ _t = [__assign.apply(void 0, _s.concat([(_w.sent()).default]))];
196
+ return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./profession/crh-app-sdk-cctgsc")); })];
197
+ case 22:
198
+ _q.sdkObj = __assign.apply(void 0, _t.concat([(_w.sent()).default]));
199
+ console.log("sdkObj---jssdk(诚通证券)", this.sdkObj);
200
+ this.isApp = this.sdkObj.isApp();
201
+ _w.label = 23;
202
+ case 23:
187
203
  // 设置Bridge实例到sdkObj中,供各模块使用
188
204
  if (this.sdkObj) {
189
205
  this.sdkObj.bridge = this.bridge;
@@ -0,0 +1,373 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ var utils_1 = require("../utils");
54
+ var crh_app_sdk_cxzq_1 = __importDefault(require("../base/crh-app-sdk-cxzq"));
55
+ var crh_app_sdk_cxzq_2 = __importDefault(require("../user/crh-app-sdk-cxzq"));
56
+ var actionMap = {
57
+ // 财信处理action地址方法
58
+ onJsOverrideUrlLoading: function (str) {
59
+ var _a, _b, _c;
60
+ if (utils_1.ios && ((_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.lzforward)) {
61
+ (_c = window.webkit.messageHandlers.lzforward) === null || _c === void 0 ? void 0 : _c.postMessage(str);
62
+ }
63
+ else if (window.MyWebView && window.MyWebView.onJsOverrideUrlLoading) {
64
+ window.MyWebView.onJsOverrideUrlLoading(str);
65
+ }
66
+ else if (window.HarmonyOS && window.HarmonyOS.onJsOverrideUrlLoading) {
67
+ console.log("HarmonyOS.onJsOverrideUrlLoading: ".concat(str));
68
+ window.HarmonyOS.onJsOverrideUrlLoading(str);
69
+ }
70
+ else {
71
+ window.location.href = str;
72
+ }
73
+ },
74
+ // 财信调用action路径
75
+ callAction: function (actionId, param, cbFunName) {
76
+ var url = "http://action:".concat(actionId, "/?target=2");
77
+ if (param) {
78
+ var paramStr = JSON.stringify(param);
79
+ url += "&param=".concat(encodeURIComponent(paramStr));
80
+ }
81
+ if (cbFunName) {
82
+ url += "&callback=".concat(cbFunName);
83
+ }
84
+ console.log("callAction:", url);
85
+ this.onJsOverrideUrlLoading(url);
86
+ },
87
+ // 财信聚财通过js bridge调用app接口
88
+ setupWebViewJavascriptBridge: function (callback) {
89
+ if (window.WebViewJavascriptBridge) {
90
+ callback(window.WebViewJavascriptBridge);
91
+ }
92
+ else {
93
+ document.addEventListener("WebViewJavascriptBridgeReady", function () {
94
+ callback(window.WebViewJavascriptBridge);
95
+ }, false);
96
+ if (!/android/gi.test(navigator.userAgent)) {
97
+ if (window.WebViewJavascriptBridge) {
98
+ callback(window.WebViewJavascriptBridge);
99
+ return;
100
+ }
101
+ if (window.WVJBCallbacks) {
102
+ window.WVJBCallbacks.push(callback);
103
+ return;
104
+ }
105
+ window.WVJBCallbacks = [callback];
106
+ var WVJBIframe_1 = document.createElement("iframe");
107
+ WVJBIframe_1.style.display = "none";
108
+ WVJBIframe_1.src = "wvjbscheme://__BRIDGE_LOADED__";
109
+ document.documentElement.appendChild(WVJBIframe_1);
110
+ setTimeout(function () {
111
+ document.documentElement.removeChild(WVJBIframe_1);
112
+ }, 0);
113
+ }
114
+ }
115
+ },
116
+ // 聚财Android调用app接口
117
+ callAndroidActionOfJvCai: function (param) {
118
+ var paramStr = JSON.stringify(param);
119
+ if (window.mobile) {
120
+ window.mobile.onActionEvent(paramStr);
121
+ }
122
+ },
123
+ // 财信调用聚财方法
124
+ callJuCaiAction: function (funName, data, callback) {
125
+ console.log("callJuCaiAction:", funName, data, callback);
126
+ if (utils_1.ios) {
127
+ this.setupWebViewJavascriptBridge(function (bridge) {
128
+ bridge.callHandler(funName, data, window[callback]);
129
+ });
130
+ }
131
+ else {
132
+ var param = {
133
+ funName: funName,
134
+ callbackFunName: callback,
135
+ };
136
+ if (data) {
137
+ param.data = data;
138
+ }
139
+ this.callAndroidActionOfJvCai(param);
140
+ }
141
+ },
142
+ /**
143
+ * iOS客户端方法加载函数(老乐赚老聚财)
144
+ * @param {string} url
145
+ */
146
+ loadIOSNative: function (url) {
147
+ var iFrame = "";
148
+ iFrame = document.createElement("iframe");
149
+ iFrame.setAttribute("src", url);
150
+ iFrame.setAttribute("style", "display:none;");
151
+ iFrame.setAttribute("height", "0px");
152
+ iFrame.setAttribute("width", "0px");
153
+ iFrame.setAttribute("frameborder", "0");
154
+ document.body.appendChild(iFrame);
155
+ iFrame.parentNode.removeChild(iFrame);
156
+ iFrame = null;
157
+ },
158
+ };
159
+ exports.default = {
160
+ // 获取客户端用户和设备信息
161
+ getDeviceInfo: function () {
162
+ var _this = this;
163
+ console.log("getDeviceInfo----");
164
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
165
+ var _a;
166
+ return __generator(this, function (_b) {
167
+ window.getDeviceInfoCB = function (jsonStr) {
168
+ console.log(jsonStr);
169
+ var obj = JSON.parse(jsonStr);
170
+ var appDeviceInfo = {};
171
+ if (obj.mac) { // 如果mac为空则取deviceId iphone取不到mac
172
+ appDeviceInfo.mac_address = obj.mac.replace(/:/g, '');
173
+ }
174
+ if (obj.deviceId && obj.deviceId !== null && obj.deviceId !== 'null') { // deviceId或为空则取mac的值 android逻辑
175
+ appDeviceInfo.device_id = obj.deviceId.replace(/AndroidId|IMEI|null/g, '');
176
+ }
177
+ appDeviceInfo.imsi = obj.imsi;
178
+ appDeviceInfo.ICCID = obj.ICCID;
179
+ appDeviceInfo.lanIP = obj.lanIP || obj.ipAddress;
180
+ appDeviceInfo.mobileNo = obj.mobileNo;
181
+ appDeviceInfo.appVersion = obj.appVersion;
182
+ resolve({
183
+ info: appDeviceInfo,
184
+ });
185
+ delete window.getDeviceInfoCB;
186
+ };
187
+ if (utils_1.ios) {
188
+ actionMap.loadIOSNative("objc://getDeviceInfo/?getDeviceInfoCB");
189
+ }
190
+ else {
191
+ (_a = window.jtoJHandle) === null || _a === void 0 ? void 0 : _a.getDeviceInfo("getDeviceInfoCB");
192
+ }
193
+ return [2 /*return*/];
194
+ });
195
+ }); });
196
+ },
197
+ // app各种方法:交易密码登录框、银证转账充值等。
198
+ // 参数格式:http://action:actionID/?target=tType&callback=funName&param=requestJSON
199
+ businessAlertView: function (url, callback) {
200
+ console.log("businessAlertView:", url, callback);
201
+ if (utils_1.ios) {
202
+ if (callback) {
203
+ url = "".concat(url, "$?").concat(callback);
204
+ }
205
+ actionMap.loadIOSNative("objc://businessAlertView/$?".concat(url));
206
+ }
207
+ else if (window.jtoJHandle) {
208
+ if (callback) {
209
+ window.jtoJHandle.businessAlertView(url, callback);
210
+ }
211
+ else {
212
+ window.jtoJHandle.businessAlertView(url);
213
+ }
214
+ }
215
+ else {
216
+ }
217
+ },
218
+ /**
219
+ * 设置原生状态栏颜色(乐赚客户端)
220
+ * @param {object} params
221
+ * @param {string} params.color 状态栏背景颜色,如#ff0000
222
+ * @param {string} params.wordColorStyle 状态栏文字颜色,0 白色,1 黑色
223
+ */
224
+ setStatusBar: function (params) {
225
+ return __awaiter(this, void 0, void 0, function () {
226
+ return __generator(this, function (_a) {
227
+ if (utils_1.ios) {
228
+ actionMap.loadIOSNative("objc://setAppBackgroundColor/$?".concat(params.color));
229
+ }
230
+ else if (window.jtoJHandle) {
231
+ window.jtoJHandle.setAppBackgroundColor(params.color);
232
+ }
233
+ return [2 /*return*/];
234
+ });
235
+ });
236
+ },
237
+ /**
238
+ * 产品收藏
239
+ * @param {object} params
240
+ * @param {string} params.versionList 支持自选的版本号
241
+ * @param {string} params.productNo 产品编号
242
+ * @param {string} params.productCode 产品代码
243
+ * @param {string} params.categoryId 产品类型
244
+ * @param {string} params.actionType 操作类型 1:收藏2:取消收藏3:查询是否收藏
245
+ * @param {string} params.callbackName 回调函数
246
+ */
247
+ setCollect: function (params) {
248
+ var _this = this;
249
+ var sdkParams = {
250
+ productNo: params.productNo,
251
+ productCode: params.productCode,
252
+ categoryId: params.categoryId,
253
+ actionType: params.actionType,
254
+ };
255
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
256
+ var res909, userInfo;
257
+ var _a;
258
+ return __generator(this, function (_b) {
259
+ switch (_b.label) {
260
+ case 0:
261
+ if (!(((_a = params === null || params === void 0 ? void 0 : params.versionList) === null || _a === void 0 ? void 0 : _a.indexOf(crh_app_sdk_cxzq_1.default.getVersion())) == -1 &&
262
+ crh_app_sdk_cxzq_1.default.webviewType().isNewLeZhuan)) return [3 /*break*/, 3];
263
+ window.callAfterFavor = function (actionId, data) {
264
+ console.log(data, params, "ret");
265
+ resolve(__assign({ error_no: "0", error_info: "" }, data));
266
+ };
267
+ return [4 /*yield*/, actionMap.callAction(909, {}, "getUserInfo")];
268
+ case 1:
269
+ res909 = _b.sent();
270
+ console.log("res909", res909);
271
+ return [4 /*yield*/, crh_app_sdk_cxzq_2.default.getUser()];
272
+ case 2:
273
+ userInfo = _b.sent();
274
+ console.log(userInfo, "===userInfo===");
275
+ if (userInfo.ret !== 0 && !userInfo.login_status) {
276
+ resolve({
277
+ error_no: "-1",
278
+ error_info: "调用失败",
279
+ });
280
+ }
281
+ else {
282
+ if (userInfo.isSnsLogin === 0) {
283
+ resolve({
284
+ error_no: "-2",
285
+ error_info: "社区未登录",
286
+ });
287
+ }
288
+ else {
289
+ actionMap.callAction(107, sdkParams, "callAfterFavor");
290
+ }
291
+ }
292
+ return [3 /*break*/, 4];
293
+ case 3:
294
+ resolve({
295
+ error_no: "-3",
296
+ error_info: "请在最新版财信证券APP中添加理财自选",
297
+ });
298
+ _b.label = 4;
299
+ case 4: return [2 /*return*/];
300
+ }
301
+ });
302
+ }); });
303
+ },
304
+ /**
305
+ * 查询产品收藏
306
+ * @param {object} params
307
+ * @param {string} params.versionList 支持自选的版本号
308
+ * @param {string} params.productNo 产品编号
309
+ * @param {string} params.productCode 产品代码
310
+ * @param {string} params.categoryId 产品类型
311
+ * @param {string} params.actionType 操作类型 1:收藏2:取消收藏3:查询是否收藏
312
+ * @param {string} params.callbackName 回调函数
313
+ */
314
+ queryCollect: function (params) {
315
+ var _this = this;
316
+ console.log('queryCollect', params);
317
+ var sdkParams = {
318
+ productNo: params.productNo,
319
+ productCode: params.productCode,
320
+ categoryId: params.categoryId,
321
+ actionType: params.actionType,
322
+ };
323
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
324
+ var _a;
325
+ return __generator(this, function (_b) {
326
+ if (((_a = params === null || params === void 0 ? void 0 : params.versionList) === null || _a === void 0 ? void 0 : _a.indexOf(crh_app_sdk_cxzq_1.default.getVersion())) == -1 &&
327
+ crh_app_sdk_cxzq_1.default.webviewType().isNewLeZhuan) {
328
+ window["callAfterSeachFavor".concat(params.productNo)] = function (actionId, data) {
329
+ resolve(__assign({ error_no: "0", error_info: "" }, data));
330
+ };
331
+ actionMap.callAction(107, sdkParams, "callAfterSeachFavor".concat(params.productNo));
332
+ }
333
+ else {
334
+ resolve({
335
+ error_no: "-3",
336
+ error_info: "请在最新版财信证券APP中添加理财自选",
337
+ });
338
+ }
339
+ return [2 /*return*/];
340
+ });
341
+ }); });
342
+ },
343
+ /**
344
+ * 银证转账
345
+ * @param {string} version 支持半屏转账的版本号
346
+ * @param {string} callbackName 回调函数
347
+ */
348
+ goBankTransfer: function () {
349
+ return __awaiter(this, arguments, void 0, function (version, callbackName) {
350
+ if (version === void 0) { version = "7.2.0"; }
351
+ return __generator(this, function (_a) {
352
+ if (crh_app_sdk_cxzq_1.default.webviewType().isNewLeZhuan) {
353
+ if (crh_app_sdk_cxzq_1.default.compareVersion(version, crh_app_sdk_cxzq_1.default.getVersion()) === 1) {
354
+ actionMap.callAction(218, { transType: "1" }, callbackName);
355
+ }
356
+ else {
357
+ actionMap.callAction(939, { transType: "1" }, callbackName);
358
+ }
359
+ }
360
+ else if (crh_app_sdk_cxzq_1.default.webviewType().isNewJuCai) {
361
+ actionMap.callJuCaiAction("gotoClientPage", {
362
+ pageId: "2621",
363
+ needLogin: "0",
364
+ });
365
+ }
366
+ else {
367
+ this.businessAlertView("http://action:218/?target=2", "");
368
+ }
369
+ return [2 /*return*/];
370
+ });
371
+ });
372
+ },
373
+ };