@scgczm/bridge 1.0.0

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,279 @@
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["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
+ exports.isScgcApp = exports.commonBridgeFun = exports.initAsyncCallbackPool = exports.setDevMode = void 0;
40
+ var distinctionPlatform = function () {
41
+ var ua = navigator.userAgent;
42
+ if (/(iPhone|iPad|iPod)/i.test(ua)) {
43
+ return "ios";
44
+ }
45
+ else if (/Android/i.test(ua)) {
46
+ return "android";
47
+ }
48
+ else if (/openharmony/i.test(ua)) {
49
+ return "harmony";
50
+ }
51
+ else {
52
+ return "unknow";
53
+ }
54
+ };
55
+ var asyncFunsArr = [
56
+ "getToken",
57
+ "getUserId",
58
+ "getAvatar",
59
+ "getNickName",
60
+ "getPhoneNumber",
61
+ "getPromise", //测试用
62
+ ];
63
+ var androidAsyncFunsArr = ["getPromise"];
64
+ var devMode = false;
65
+ var setDevMode = function () {
66
+ devMode = true;
67
+ };
68
+ exports.setDevMode = setDevMode;
69
+ var initAsyncCallbackPool = function () {
70
+ window.bridgeCallbacks = {};
71
+ };
72
+ exports.initAsyncCallbackPool = initAsyncCallbackPool;
73
+ var devFn = function (platform, fnName, data) {
74
+ //动态判断是否为devMode,避免初始化commonBridgeFun比调用setDevMode的早的情况下,devMode参数已固定(损失的性能可以接受)
75
+ if (devMode) {
76
+ var devInfo = {
77
+ platform: platform,
78
+ fnName: fnName,
79
+ data: data,
80
+ };
81
+ console.log(devInfo);
82
+ }
83
+ };
84
+ function makeRandomId(fnName) {
85
+ return "".concat(fnName || "anonymous", "_").concat(Date.now());
86
+ }
87
+ function registerCallback(fnName, cb) {
88
+ if (!cb) {
89
+ return null;
90
+ }
91
+ var callbackId = makeRandomId(fnName);
92
+ if (!window.hasOwnProperty("bridgeCallbacks")) {
93
+ window.bridgeCallbacks = {};
94
+ }
95
+ window.bridgeCallbacks[callbackId] = function (data) {
96
+ var result;
97
+ if (typeof data === "object") {
98
+ result = data;
99
+ }
100
+ else if (typeof data === "string") {
101
+ try {
102
+ result = JSON.parse(data);
103
+ }
104
+ catch (e) {
105
+ result = data;
106
+ }
107
+ }
108
+ cb(result);
109
+ };
110
+ return "bridgeCallbacks.".concat(callbackId);
111
+ }
112
+ function androidBridgeFn(fnName, data) {
113
+ var _this = this;
114
+ var _a, _b;
115
+ var androidParams = {
116
+ Method: fnName,
117
+ Data: data,
118
+ };
119
+ devFn("android", fnName, data);
120
+ if (fnName == "getSlideData") {
121
+ (_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));
122
+ }
123
+ else if (asyncFunsArr.includes(fnName)) {
124
+ var promiseRes = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
125
+ var res, result;
126
+ var _a, _b;
127
+ return __generator(this, function (_c) {
128
+ try {
129
+ //安卓使用了异步返回
130
+ if (androidAsyncFunsArr.includes(fnName)) {
131
+ (_a = window === null || window === void 0 ? void 0 : window.newBridge) === null || _a === void 0 ? void 0 : _a[fnName](JSON.stringify({
132
+ callback: registerCallback(fnName, resolve),
133
+ }));
134
+ }
135
+ else {
136
+ res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();
137
+ result = void 0;
138
+ if (typeof res === "object") {
139
+ result = res;
140
+ }
141
+ else if (typeof res === "string") {
142
+ try {
143
+ result = JSON.parse(res);
144
+ }
145
+ catch (e) {
146
+ result = { success: false, data: res };
147
+ }
148
+ }
149
+ if ((result === null || result === void 0 ? void 0 : result.success) == true) {
150
+ resolve(result);
151
+ }
152
+ else {
153
+ reject(result);
154
+ }
155
+ }
156
+ }
157
+ catch (error) {
158
+ reject(error);
159
+ }
160
+ return [2 /*return*/];
161
+ });
162
+ }); });
163
+ return promiseRes;
164
+ }
165
+ else {
166
+ (_b = window === null || window === void 0 ? void 0 : window.bridge) === null || _b === void 0 ? void 0 : _b.callRouter(JSON.stringify(androidParams), function () { });
167
+ }
168
+ }
169
+ function iosBridgeFn(fnName, data) {
170
+ var _this = this;
171
+ var _a, _b, _c;
172
+ devFn("ios", fnName, data);
173
+ if (asyncFunsArr.includes(fnName)) {
174
+ var promiseRes = new Promise(function (resolve, reject) {
175
+ var _a, _b, _c;
176
+ try {
177
+ var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {
178
+ return __generator(this, function (_a) {
179
+ try {
180
+ if ((res === null || res === void 0 ? void 0 : res.success) == "true") {
181
+ resolve({
182
+ success: true,
183
+ data: res === null || res === void 0 ? void 0 : res.data,
184
+ });
185
+ }
186
+ else {
187
+ reject({
188
+ success: false,
189
+ data: res === null || res === void 0 ? void 0 : res.data,
190
+ });
191
+ }
192
+ }
193
+ catch (error) {
194
+ reject({
195
+ success: false,
196
+ data: error,
197
+ });
198
+ }
199
+ return [2 /*return*/];
200
+ });
201
+ }); };
202
+ (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage({
203
+ data: {},
204
+ callback: registerCallback(fnName, _cb),
205
+ });
206
+ }
207
+ catch (error) {
208
+ reject({
209
+ success: false,
210
+ data: error,
211
+ });
212
+ }
213
+ });
214
+ return promiseRes;
215
+ }
216
+ else {
217
+ (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage(data);
218
+ }
219
+ }
220
+ function harmonyBridgeFn(fnName, data) {
221
+ var _a, _b;
222
+ devFn("harmony", fnName, data);
223
+ if (asyncFunsArr.includes(fnName)) {
224
+ var promiseRes = new Promise(function (resolve, reject) {
225
+ var _a;
226
+ try {
227
+ (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]({
228
+ data: data,
229
+ callback: registerCallback(fnName, resolve),
230
+ });
231
+ }
232
+ catch (error) {
233
+ reject(error);
234
+ }
235
+ });
236
+ return promiseRes;
237
+ }
238
+ else {
239
+ (_b = (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, data);
240
+ }
241
+ }
242
+ function defaultBridgeFn(fnName, data) {
243
+ console.log("请使用scgc app打开");
244
+ if (asyncFunsArr.includes(fnName)) {
245
+ var promiseRes = new Promise(function (resolve, reject) {
246
+ try {
247
+ resolve("请使用scgc app打开");
248
+ }
249
+ catch (error) {
250
+ reject(error);
251
+ }
252
+ });
253
+ return promiseRes;
254
+ }
255
+ }
256
+ var commonBridgeFun = function () {
257
+ var platform = distinctionPlatform();
258
+ if (platform == "android") {
259
+ return androidBridgeFn;
260
+ }
261
+ else if (platform == "ios") {
262
+ return iosBridgeFn;
263
+ }
264
+ else if (platform == "harmony") {
265
+ return harmonyBridgeFn;
266
+ }
267
+ else {
268
+ return defaultBridgeFn;
269
+ }
270
+ };
271
+ exports.commonBridgeFun = commonBridgeFun;
272
+ /**
273
+ * @description 是否为app环境
274
+ * @return {boolean} true 是 false 否
275
+ */
276
+ var isScgcApp = function () {
277
+ return navigator.userAgent.indexOf("SCGC_UA") > -1;
278
+ };
279
+ exports.isScgcApp = isScgcApp;
@@ -0,0 +1,210 @@
1
+ import { ICommonResult } from "./utils";
2
+ export interface IGetSlideDataData {
3
+ token: string;
4
+ sessionId: string;
5
+ sig: string;
6
+ scene: string;
7
+ }
8
+ /**
9
+ * @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)
10
+ * @param {IGetSlideDataData} data
11
+ */
12
+ export declare const scgcGetSlideData: (data: IGetSlideDataData) => void;
13
+ /**
14
+ * @description 调用app登录
15
+ */
16
+ export declare const scgcLogin: () => void;
17
+ /**
18
+ * @description 调用app扫码
19
+ */
20
+ export declare const scgcScan: () => void;
21
+ /**
22
+ * @description 关闭当前webview
23
+ */
24
+ export declare const scgcClose: () => void;
25
+ export interface IOpenexplorerData {
26
+ path: string;
27
+ }
28
+ /**
29
+ * @description 使用系统浏览器打开指定的url
30
+ * @param {IOpenexplorerData} data
31
+ * @param {string} data.path 需要打开的url
32
+ */
33
+ export declare const scgcOpenexplorer: (data: IOpenexplorerData) => void;
34
+ export interface IOpenwechatData {
35
+ appid: string;
36
+ path: string;
37
+ }
38
+ /**
39
+ * @description 打开微信小程序
40
+ * @param {IOpenwechatData} data
41
+ * @param {string} data.appid 小程序appid,格式为gh开头
42
+ * @param {string} data.path 小程序路径
43
+ */
44
+ export declare const scgcOpenwechat: (data: IOpenwechatData) => void;
45
+ export interface ISaveimageData {
46
+ data: string;
47
+ }
48
+ /**
49
+ * @description 保存图片
50
+ * @param {ISaveimageData} data
51
+ * @param {string} data.data base64数据
52
+ */
53
+ export declare const scgcSaveimage: (data: ISaveimageData) => void;
54
+ export interface IShareData {
55
+ shareUrl?: string;
56
+ shareImg?: string;
57
+ shareTitle?: string;
58
+ shareDesc?: string;
59
+ doShare?: boolean;
60
+ }
61
+ /**
62
+ * @description 配置app分享
63
+ * @param {IShareData} data
64
+ * @param {string} data.shareUrl 需要分享的地址
65
+ * @param {string} data.shareImg 分享的封面
66
+ * @param {string} data.shareTitle 分享的标题
67
+ * @param {string} data.shareDesc 分享的说明
68
+ * @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置
69
+ */
70
+ export declare const scgcShare: (data: IShareData) => void;
71
+ export interface ItoH5Data {
72
+ path: string;
73
+ }
74
+ /**
75
+ * @description 打开一个webview
76
+ * @param {ItoH5Data} data
77
+ * @param {string} data.path 需要打开的url
78
+ */
79
+ export declare const scgcToH5: (data: ItoH5Data) => void;
80
+ export interface IToDetailData {
81
+ path: string;
82
+ newsType?: number;
83
+ }
84
+ /**
85
+ * @description 打开app原生新闻页
86
+ * @param {IToDetailData} data
87
+ * @param {string} data.path 新闻json地址 --相对地址,没有域名前缀的形式
88
+ * @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链
89
+ */
90
+ export declare const scgcToDetail: (data: IToDetailData) => void;
91
+ export interface IToSpecialData {
92
+ id: string;
93
+ }
94
+ /**
95
+ * @description 打开app原生专题详情页
96
+ * @param {IToSpecialData} data
97
+ * @param {string} data.id 专题id
98
+ */
99
+ export declare const scgcToSpecial: (data: IToSpecialData) => void;
100
+ export interface IToLiveData {
101
+ id: string;
102
+ type: 1 | 2;
103
+ }
104
+ /**
105
+ * @description 打开app原生直播页
106
+ * @param {IToLiveData} data
107
+ * @param {string} data.id 直播id
108
+ * @param {string} data.type 直播样式 1 横版 2 竖版
109
+ */
110
+ export declare const scgcToLive: (data: IToLiveData) => void;
111
+ export interface IToTopicData {
112
+ name: string;
113
+ cover: string;
114
+ id: string;
115
+ }
116
+ /**
117
+ * @description 打开app话题页
118
+ * @param {IToTopicData} data
119
+ * @param {string} data.name 话题名称
120
+ * @param {string} data.cover 话题封面图(完整的图片地址)
121
+ * @param {string} data.id 话题id
122
+ */
123
+ export declare const scgcToTopic: (data: IToTopicData) => void;
124
+ export interface ISetVolumeData {
125
+ type: 0 | 1;
126
+ }
127
+ /**
128
+ * @description 设置app音量
129
+ * @param {ISetVolumeData} data
130
+ * @param {number} data.type 0 调小 1 调大
131
+ */
132
+ export declare const scgcSetVolume: (data: ISetVolumeData) => void;
133
+ export interface IToSubSpecialData {
134
+ title: string;
135
+ id: string;
136
+ }
137
+ /**
138
+ * @description 打开app原生专题新闻列表页
139
+ * @param {IToSubSpecialData} data
140
+ * @param {string} data.title 专题标题
141
+ * @param {string} data.id 专题id
142
+ */
143
+ export declare const scgcToSubSpecial: (data: IToSubSpecialData) => void;
144
+ export interface IMallDetailData {
145
+ json: string;
146
+ url: string;
147
+ ptype: "0";
148
+ isDark: 0 | 1;
149
+ }
150
+ /**
151
+ * @description 打开积分商城商品详情
152
+ * @param {IMallDetailData} data
153
+ * @param {string} data.json 商品详情json地址
154
+ * @param {string} data.url 商品详情网页地址
155
+ * @param {string} data.ptype todo 未知
156
+ * @param {number} data.isDark 0 普通模式 1 黑暗模式
157
+ */
158
+ export declare const scgcToMallDetail: (data: IMallDetailData) => void;
159
+ export interface IFocusWebData {
160
+ focus: boolean;
161
+ }
162
+ /**
163
+ * @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)
164
+ * @param {IMallDetailData} data
165
+ * @param {boolean} data.focus 是否禁止app滑动
166
+ *
167
+ */
168
+ export declare const scgcFocusWeb: (data: IFocusWebData) => void;
169
+ /**
170
+ * @description 跳转至积分商城
171
+ */
172
+ export declare const scgcToMall: () => void;
173
+ /**
174
+ * @description 跳转至快拍
175
+ */
176
+ export declare const scgcToKuaipai: () => void;
177
+ /**
178
+ * @description 跳转至app首页
179
+ */
180
+ export declare const scgcToAppHome: () => void;
181
+ export interface IChangeStateBarColorData {
182
+ type: 1 | 2;
183
+ }
184
+ /**
185
+ * @description 设置app顶部时间栏颜色
186
+ * @param {IChangeStateBarColorData} data
187
+ * @param {number} data.type 1 黑色 2 白色
188
+ *
189
+ */
190
+ export declare const scgcChangeStateBarColor: (data: IChangeStateBarColorData) => void;
191
+ /**
192
+ * @description 获取app 用户id
193
+ * @return {Promise((success:boolean,data:string))} 返回promise
194
+ *
195
+ */
196
+ export declare const scgcGetUserId: () => Promise<ICommonResult<string>>;
197
+ /**
198
+ * @description 获取app 用户头像
199
+ * @return {Promise((success:boolean,data:string))} 返回promise
200
+ *
201
+ */
202
+ export declare const scgcGetAvatar: () => Promise<ICommonResult<string>>;
203
+ /**
204
+ * @description 获取app 用户昵称
205
+ * @return {Promise((success:boolean,data:string))} 返回promise
206
+ *
207
+ */
208
+ export declare const scgcGetNickName: () => Promise<ICommonResult<string>>;
209
+ export declare const scgcGetPhoneNumber: () => Promise<ICommonResult<string>>;
210
+ export { setDevMode, isScgcApp } from "./utils";
@@ -0,0 +1,215 @@
1
+ /*#__PURE__*/
2
+ import { commonBridgeFun, initAsyncCallbackPool } from "./utils";
3
+ initAsyncCallbackPool();
4
+ var commonBridge = commonBridgeFun();
5
+ /**
6
+ * @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)
7
+ * @param {IGetSlideDataData} data
8
+ */
9
+ export var scgcGetSlideData = function (data) {
10
+ commonBridge("getSlideData", data);
11
+ };
12
+ /**
13
+ * @description 调用app登录
14
+ */
15
+ export var scgcLogin = function () {
16
+ commonBridge("login");
17
+ };
18
+ /**
19
+ * @description 调用app扫码
20
+ */
21
+ export var scgcScan = function () {
22
+ commonBridge("scan");
23
+ };
24
+ /**
25
+ * @description 关闭当前webview
26
+ */
27
+ export var scgcClose = function () {
28
+ commonBridge("close");
29
+ };
30
+ /**
31
+ * @description 使用系统浏览器打开指定的url
32
+ * @param {IOpenexplorerData} data
33
+ * @param {string} data.path 需要打开的url
34
+ */
35
+ export var scgcOpenexplorer = function (data) {
36
+ commonBridge("openexplorer", data);
37
+ };
38
+ /**
39
+ * @description 打开微信小程序
40
+ * @param {IOpenwechatData} data
41
+ * @param {string} data.appid 小程序appid,格式为gh开头
42
+ * @param {string} data.path 小程序路径
43
+ */
44
+ export var scgcOpenwechat = function (data) {
45
+ commonBridge("openwechat", data);
46
+ };
47
+ /**
48
+ * @description 保存图片
49
+ * @param {ISaveimageData} data
50
+ * @param {string} data.data base64数据
51
+ */
52
+ export var scgcSaveimage = function (data) {
53
+ commonBridge("saveimage", data);
54
+ };
55
+ /**
56
+ * @description 配置app分享
57
+ * @param {IShareData} data
58
+ * @param {string} data.shareUrl 需要分享的地址
59
+ * @param {string} data.shareImg 分享的封面
60
+ * @param {string} data.shareTitle 分享的标题
61
+ * @param {string} data.shareDesc 分享的说明
62
+ * @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置
63
+ */
64
+ export var scgcShare = function (data) {
65
+ commonBridge("share", data);
66
+ };
67
+ /**
68
+ * @description 打开一个webview
69
+ * @param {ItoH5Data} data
70
+ * @param {string} data.path 需要打开的url
71
+ */
72
+ export var scgcToH5 = function (data) {
73
+ commonBridge("toH5", data);
74
+ };
75
+ /**
76
+ * @description 打开app原生新闻页
77
+ * @param {IToDetailData} data
78
+ * @param {string} data.path 新闻json地址 --相对地址,没有域名前缀的形式
79
+ * @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链
80
+ */
81
+ export var scgcToDetail = function (data) {
82
+ commonBridge("toDetail", data);
83
+ };
84
+ /**
85
+ * @description 打开app原生专题详情页
86
+ * @param {IToSpecialData} data
87
+ * @param {string} data.id 专题id
88
+ */
89
+ export var scgcToSpecial = function (data) {
90
+ commonBridge("toSpecial", data);
91
+ };
92
+ /**
93
+ * @description 打开app原生直播页
94
+ * @param {IToLiveData} data
95
+ * @param {string} data.id 直播id
96
+ * @param {string} data.type 直播样式 1 横版 2 竖版
97
+ */
98
+ export var scgcToLive = function (data) {
99
+ commonBridge("toLive", data);
100
+ };
101
+ /**
102
+ * @description 打开app话题页
103
+ * @param {IToTopicData} data
104
+ * @param {string} data.name 话题名称
105
+ * @param {string} data.cover 话题封面图(完整的图片地址)
106
+ * @param {string} data.id 话题id
107
+ */
108
+ export var scgcToTopic = function (data) {
109
+ commonBridge("toTopic", data);
110
+ };
111
+ /**
112
+ * @description 设置app音量
113
+ * @param {ISetVolumeData} data
114
+ * @param {number} data.type 0 调小 1 调大
115
+ */
116
+ export var scgcSetVolume = function (data) {
117
+ commonBridge("setVolume", data);
118
+ };
119
+ /**
120
+ * @description 打开app原生专题新闻列表页
121
+ * @param {IToSubSpecialData} data
122
+ * @param {string} data.title 专题标题
123
+ * @param {string} data.id 专题id
124
+ */
125
+ export var scgcToSubSpecial = function (data) {
126
+ commonBridge("toSubSpecial", data);
127
+ };
128
+ /**
129
+ * @description 打开积分商城商品详情
130
+ * @param {IMallDetailData} data
131
+ * @param {string} data.json 商品详情json地址
132
+ * @param {string} data.url 商品详情网页地址
133
+ * @param {string} data.ptype todo 未知
134
+ * @param {number} data.isDark 0 普通模式 1 黑暗模式
135
+ */
136
+ export var scgcToMallDetail = function (data) {
137
+ commonBridge("detailJson", data);
138
+ };
139
+ /**
140
+ * @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)
141
+ * @param {IMallDetailData} data
142
+ * @param {boolean} data.focus 是否禁止app滑动
143
+ *
144
+ */
145
+ export var scgcFocusWeb = function (data) {
146
+ commonBridge("focusWeb", data);
147
+ };
148
+ /**
149
+ * @description 跳转至积分商城
150
+ */
151
+ export var scgcToMall = function () {
152
+ commonBridge("mall");
153
+ };
154
+ /**
155
+ * @description 跳转至快拍
156
+ */
157
+ export var scgcToKuaipai = function () {
158
+ commonBridge("release");
159
+ };
160
+ /**
161
+ * @description 跳转至app首页
162
+ */
163
+ export var scgcToAppHome = function () {
164
+ commonBridge("mainPage");
165
+ };
166
+ /**
167
+ * @description 设置app顶部时间栏颜色
168
+ * @param {IChangeStateBarColorData} data
169
+ * @param {number} data.type 1 黑色 2 白色
170
+ *
171
+ */
172
+ export var scgcChangeStateBarColor = function (data) {
173
+ commonBridge("changeStatebarColor", data);
174
+ };
175
+ /**
176
+ * @description 获取app 用户id
177
+ * @return {Promise((success:boolean,data:string))} 返回promise
178
+ *
179
+ */
180
+ export var scgcGetUserId = function () {
181
+ return commonBridge("getUserId");
182
+ };
183
+ /**
184
+ * @description 获取app 用户头像
185
+ * @return {Promise((success:boolean,data:string))} 返回promise
186
+ *
187
+ */
188
+ export var scgcGetAvatar = function () {
189
+ return commonBridge("getAvatar");
190
+ };
191
+ /**
192
+ * @description 获取app 用户昵称
193
+ * @return {Promise((success:boolean,data:string))} 返回promise
194
+ *
195
+ */
196
+ export var scgcGetNickName = function () {
197
+ return commonBridge("getNickName");
198
+ };
199
+ // /**
200
+ // * @description 获取app 用户手机号
201
+ // * @return {Promise((success:boolean,data:string))} 返回promise
202
+ // *
203
+ // */
204
+ export var scgcGetPhoneNumber = function () {
205
+ return commonBridge("getPhoneNumber");
206
+ };
207
+ // /**
208
+ // * @description 获取app token --暂不可用
209
+ // * @return {Promise((success:boolean,data:string))} 返回promise,暂时不会有进catch的情况
210
+ // *
211
+ // */
212
+ // export const scgcGetToken = () => {
213
+ // return commonBridge("getToken");
214
+ // };
215
+ export { setDevMode, isScgcApp } from "./utils";