@kbapp/market-partner-sdk 0.0.4 → 0.0.6

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/README.MD CHANGED
@@ -79,6 +79,8 @@ const onTapRunAction = async () => {
79
79
  | `isAppVersionSupport` | 检查当前 App 版本是否支持某个 API |
80
80
  | `getAuthToken` | 获取认证令牌 |
81
81
  | `getAuthTokenWithSilent` | 静默获取认证令牌 |
82
+ | `requestPayment` | 唤起支付 |
83
+ | `requestRefund` | 申请退款 |
82
84
 
83
85
  | 类/枚举 | 说明 |
84
86
  | --------------- | -------------------- |
@@ -241,7 +243,7 @@ console.log('是否能使用', canUse)
241
243
 
242
244
  > 获取认证令牌
243
245
 
244
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
246
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
245
247
 
246
248
  #### 请求参数
247
249
 
@@ -281,7 +283,7 @@ if (authResult.code === 0) {
281
283
 
282
284
  > 静默获取认证令牌,当用户未登录时不会唤起登录界面
283
285
 
284
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
286
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
285
287
 
286
288
  #### 请求参数
287
289
 
@@ -325,7 +327,7 @@ if (authResult.code === 0) {
325
327
 
326
328
  > 执行统一跳转页面标准
327
329
 
328
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
330
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
329
331
 
330
332
  #### 请求参数
331
333
 
@@ -359,7 +361,7 @@ runAction({
359
361
 
360
362
  > 定义 app 点击转发时候的分享卡片内容
361
363
 
362
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
364
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
363
365
 
364
366
  #### 请求参数 方式 1
365
367
 
@@ -438,7 +440,7 @@ await defineAppShareModel({
438
440
 
439
441
  > 主动唤起分享面板
440
442
 
441
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
443
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
442
444
 
443
445
  #### 请求参数
444
446
 
@@ -475,7 +477,7 @@ openAppSharePanel({
475
477
 
476
478
  > 监听分享面板打开时触发(主动和被动)
477
479
 
478
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
480
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
479
481
 
480
482
  #### 请求参数
481
483
 
@@ -506,7 +508,7 @@ const stopHandle = onAppSharePanelShow(() => {
506
508
 
507
509
  > 分享图片
508
510
 
509
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
511
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
510
512
 
511
513
  #### 请求参数
512
514
 
@@ -536,7 +538,7 @@ shareImage({
536
538
 
537
539
  > 获取开吧 App 基础信息
538
540
 
539
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
541
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
540
542
 
541
543
  #### 请求参数
542
544
 
@@ -576,7 +578,7 @@ getAppBaseInfo().then((deviceInfo: AppBaseInfo) => {
576
578
 
577
579
  > 上报数据埋点
578
580
 
579
- > @version 开吧 APP:80801 开始支持,低版本需开发者做兼容处理
581
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
580
582
 
581
583
  #### 请求参数
582
584
 
@@ -610,6 +612,104 @@ reportDAEvent({
610
612
  })
611
613
  ```
612
614
 
615
+ ### requestPayment
616
+
617
+ > 唤起支付
618
+
619
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
620
+
621
+ #### 请求参数
622
+
623
+ | 参数 | 类型 | 必填 | 说明 |
624
+ | ------------- | ----------------------------- | ---- | ------------------------------------------------------------ |
625
+ | `payFee` | `number` | 是 | 支付金额,单位分 |
626
+ | `orderCode` | `string` | 是 | 订单 code(商户订单 UK) |
627
+ | `payChannel` | `number` | 是 | 支付渠道 1: 支付宝 2: 微信(20260115 暂不支持微信支付) |
628
+ | `subjectName` | `string` | 是 | 订单展示名称 |
629
+ | `partnerKey` | `string` | 是 | 约定的商户标识 |
630
+ | `notifyUrl` | `string` | 否 | 支付完成回调地址 |
631
+ | `expireTime` | `number` | 否 | 订单过期时间,13 位毫秒数的绝对时间戳,不传默认当前时间 + 15 分钟 |
632
+ | `success` | `(result: Result) => void` | 否 | 成功回调 |
633
+ | `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
634
+
635
+ #### 返回值
636
+
637
+ ```js
638
+ Promise<{
639
+ /** 支付结果 0: 成功 1: 失败 */
640
+ result: 0 | 1
641
+ /** 支付结果描述 */
642
+ msg: string
643
+ /** 支付成功时返回支付订单号, 失败不返回 */
644
+ fundsCode: string
645
+ }>
646
+ ```
647
+
648
+ #### 示例代码
649
+
650
+ ```js
651
+ import { requestPayment } from '@kbapp/market-partner-sdk'
652
+
653
+ requestPayment({
654
+ payFee: 1,
655
+ orderCode: 'xxxx',
656
+ payChannel: 1,
657
+ partnerKey: 'xxxx',
658
+ subjectName: 'xxxx',
659
+ success(result) {
660
+ console.log(result)
661
+ },
662
+ fail(error) {
663
+ console.error(error)
664
+ },
665
+ })
666
+ ```
667
+
668
+ ### requestRefund
669
+
670
+ > 申请退款
671
+
672
+ > @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
673
+
674
+ #### 请求参数
675
+
676
+ | 参数 | 类型 | 必填 | 说明 |
677
+ | ----------- | ----------------------------- | ---- | ---------------------------- |
678
+ | `orderCode` | `string` | 是 | 订单 code(商户订单 UK) |
679
+ | `partnerKey`| `string` | 是 | 约定的商户标识 |
680
+ | `fundsCode` | `string` | 是 | 支付成功时返回支付订单号 |
681
+ | `success` | `(result: Result) => void` | 否 | 成功回调 |
682
+ | `fail` | `(error: BridgeCode) => void` | 否 | 失败回调 |
683
+
684
+ #### 返回值
685
+
686
+ ```js
687
+ Promise<{
688
+ /** 0: 成功 1: 失败 */
689
+ result: 0 | 1
690
+ /** 结果描述 */
691
+ msg: string
692
+ }>
693
+ ```
694
+
695
+ #### 示例代码
696
+
697
+ ```js
698
+ import { requestRefund } from '@kbapp/market-partner-sdk'
699
+
700
+ requestRefund({
701
+ orderCode: 'xxxx',
702
+ partnerKey: 'xxxx',
703
+ fundsCode: 'xxxx',
704
+ success(result) {
705
+ console.log(result)
706
+ },
707
+ fail(error) {
708
+ console.error(error)
709
+ },
710
+ })
711
+ ```
712
+
613
713
  ## 数据模型
614
714
 
615
715
  ### AuthResult
package/dist/index.d.ts CHANGED
@@ -7,4 +7,5 @@ export * from './lib/run-action';
7
7
  export * from './lib/share-image';
8
8
  export * from './lib/share-model';
9
9
  export * from './lib/auth-token';
10
+ export * from './lib/payment';
10
11
  export { isAppVersionSupport } from './lib/app-version-support';
package/dist/index.es.js CHANGED
@@ -1,30 +1,39 @@
1
- const u = class u {
2
- constructor(r) {
3
- this.errorCode = r.errorCode, this.errorMsg = r.errorMsg;
1
+ function R(e) {
2
+ if (Object.prototype.toString.call(e) !== "[object Object]")
3
+ return e;
4
+ const n = {};
5
+ return Object.keys(e).forEach((o) => {
6
+ const r = e[o];
7
+ r != null && (n[o] = Object.prototype.toString.call(r) === "[object Object]" ? R(r) : r);
8
+ }), n;
9
+ }
10
+ const l = class l {
11
+ constructor(n) {
12
+ this.errorCode = n.errorCode, this.errorMsg = n.errorMsg;
4
13
  }
5
14
  };
6
- u.UNKNOWN = new u({
15
+ l.UNKNOWN = new l({
7
16
  errorCode: 1e3,
8
17
  errorMsg: "未知错误"
9
- }), u.UNSUPPORTED_VERSION = new u({
18
+ }), l.UNSUPPORTED_VERSION = new l({
10
19
  errorCode: 1001,
11
20
  errorMsg: "当前开吧版本不支持"
12
- }), u.TIMEOUT = new u({
21
+ }), l.TIMEOUT = new l({
13
22
  errorCode: 1002,
14
23
  errorMsg: "执行超时"
15
- }), u.UNSUPPORTED_BRIDGE_ENV = new u({
24
+ }), l.UNSUPPORTED_BRIDGE_ENV = new l({
16
25
  errorCode: 1003,
17
26
  errorMsg: "请在开吧app内执行"
18
27
  });
19
- let l = u;
20
- const T = () => {
21
- const e = (t, s, n) => {
28
+ let f = l;
29
+ const k = () => {
30
+ const e = (t, s, i) => {
22
31
  var a = "";
23
- typeof s == "function" && (n = s, s = {});
32
+ typeof s == "function" && (i = s, s = {});
24
33
  var c = { data: s === void 0 ? null : s };
25
- if (typeof n == "function") {
34
+ if (typeof i == "function") {
26
35
  var v = "dscb" + window.dscb++;
27
- window[v] = n, c._dscbstub = v;
36
+ window[v] = i, c._dscbstub = v;
28
37
  }
29
38
  if (c = JSON.stringify(c), window.flutter_inappwebview ? window.flutter_inappwebview.callHandler && (a = window.flutter_inappwebview.callHandler("" + t, c)) : (window._dswk || navigator.userAgent.indexOf("_dsbridge") != -1) && (a = prompt("_flutterDsbridge=" + t, c)), a instanceof Promise)
30
39
  return a;
@@ -33,26 +42,26 @@ const T = () => {
33
42
  } catch {
34
43
  console.error("callHandle异常,JSON.parse错误");
35
44
  }
36
- }, r = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, i = (() => {
45
+ }, n = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, o = (() => {
37
46
  const t = [], s = setInterval(() => {
38
- r() && (clearInterval(s), t.forEach((n) => {
39
- e.apply(window, n);
47
+ n() && (clearInterval(s), t.forEach((i) => {
48
+ e.apply(window, i);
40
49
  }), t.length = 0);
41
50
  }, 500);
42
- return (...n) => {
43
- t.push(n);
51
+ return (...i) => {
52
+ t.push(i);
44
53
  };
45
54
  })();
46
- var o = {
55
+ var r = {
47
56
  default: void 0,
48
57
  // for typescript
49
- callHandler: function(t, s, n) {
50
- return r() ? e(t, s, n) : i(t, s, n);
58
+ callHandler: function(t, s, i) {
59
+ return n() ? e(t, s, i) : o(t, s, i);
51
60
  },
52
- register: function(t, s, n) {
53
- var a = n ? window._dsaf : window._dsf;
61
+ register: function(t, s, i) {
62
+ var a = i ? window._dsaf : window._dsf;
54
63
  window._dsInit || (window._dsInit = !0, setTimeout(function() {
55
- o.callHandler("_dsb.dsinit");
64
+ r.callHandler("_dsb.dsinit");
56
65
  }, 0)), typeof s == "object" ? a._obs[t] = s : a[t] = s;
57
66
  },
58
67
  registerHandler: function(t, s) {
@@ -71,32 +80,32 @@ const T = () => {
71
80
  _obs: {}
72
81
  },
73
82
  dscb: 0,
74
- jsBridge: o,
75
- _handleMessageFromNative: function(n) {
76
- var a = JSON.parse(n.data), c = {
77
- id: n.callbackId,
83
+ jsBridge: r,
84
+ _handleMessageFromNative: function(i) {
85
+ var a = JSON.parse(i.data), c = {
86
+ id: i.callbackId,
78
87
  complete: !0
79
- }, v = this._dsf[n.method], y = this._dsaf[n.method], N = function(E, S) {
80
- c.data = E.apply(S, a), o.callHandler("_dsb.returnValue", c);
81
- }, m = function(E, S) {
82
- a.push(function(V, I) {
83
- c.data = V, c.complete = I !== !1, o.callHandler("_dsb.returnValue", c);
84
- }), E.apply(S, a);
88
+ }, v = this._dsf[i.method], _ = this._dsaf[i.method], S = function(E, m) {
89
+ c.data = E.apply(m, a), r.callHandler("_dsb.returnValue", c);
90
+ }, O = function(E, m) {
91
+ a.push(function(I, T) {
92
+ c.data = I, c.complete = T !== !1, r.callHandler("_dsb.returnValue", c);
93
+ }), E.apply(m, a);
85
94
  };
86
95
  if (v)
87
- N(v, this._dsf);
88
- else if (y)
89
- m(y, this._dsaf);
96
+ S(v, this._dsf);
97
+ else if (_)
98
+ O(_, this._dsaf);
90
99
  else {
91
- var A = n.method.split(".");
100
+ var A = i.method.split(".");
92
101
  if (A.length < 2) return;
93
- var O = A.pop(), P = A.join("."), g = this._dsf._obs, h = g[P] || {}, p = h[O];
94
- if (p && typeof p == "function") {
95
- N(p, h);
102
+ var b = A.pop(), N = A.join("."), g = this._dsf._obs, y = g[N] || {}, w = y[b];
103
+ if (w && typeof w == "function") {
104
+ S(w, y);
96
105
  return;
97
106
  }
98
- if (g = this._dsaf._obs, h = g[P] || {}, p = h[O], p && typeof p == "function") {
99
- m(p, h);
107
+ if (g = this._dsaf._obs, y = g[N] || {}, w = y[b], w && typeof w == "function") {
108
+ O(w, y);
100
109
  return;
101
110
  }
102
111
  }
@@ -105,85 +114,85 @@ const T = () => {
105
114
  for (var s in t)
106
115
  window[s] = t[s];
107
116
  }
108
- })(), o;
109
- }, R = ((e) => /(kb)/i.test(e) ? T() : {
110
- registerHandler(r, i) {
111
- throw l.UNSUPPORTED_BRIDGE_ENV;
117
+ })(), r;
118
+ }, P = ((e) => /(kb)/i.test(e) ? k() : {
119
+ registerHandler(n, o) {
120
+ throw f.UNSUPPORTED_BRIDGE_ENV;
112
121
  },
113
- callHandler(r, i, o) {
114
- throw l.UNSUPPORTED_BRIDGE_ENV;
122
+ callHandler(n, o, r) {
123
+ throw f.UNSUPPORTED_BRIDGE_ENV;
115
124
  }
116
- })(window?.navigator?.userAgent), k = (e) => new Promise((r, i) => {
125
+ })(window?.navigator?.userAgent), H = (e) => new Promise((n, o) => {
117
126
  try {
118
- R.registerHandler(e.name, e.handler), e.success?.(), r();
119
- } catch (o) {
120
- e.fail?.(o), i(o);
127
+ P.registerHandler(e.name, e.handler), e.success?.(), n();
128
+ } catch (r) {
129
+ e.fail?.(r), o(r);
121
130
  } finally {
122
131
  e.complete?.();
123
132
  }
124
133
  });
125
- function f(e) {
126
- const r = (i) => {
127
- let o;
128
- const t = (n) => {
129
- (!o || o === "success") && (o = "success", i.success?.(n));
130
- }, s = (n) => {
131
- (!o || o === "error") && (o = "error", i.fail?.(n));
134
+ function d(e) {
135
+ const n = (o) => {
136
+ let r;
137
+ const t = (i) => {
138
+ (!r || r === "success") && (r = "success", o.success?.(i));
139
+ }, s = (i) => {
140
+ (!r || r === "error") && (r = "error", o.fail?.(i));
132
141
  };
133
- i.timeout && setTimeout(() => {
134
- s(l.TIMEOUT);
135
- }, i.timeout);
142
+ o.timeout && setTimeout(() => {
143
+ s(f.TIMEOUT);
144
+ }, o.timeout);
136
145
  try {
137
- R.callHandler(i.name, i.params, (n) => {
146
+ P.callHandler(o.name, o.params, (i) => {
138
147
  let a;
139
148
  try {
140
- a = typeof n == "string" ? JSON.parse(n.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : n;
149
+ a = typeof i == "string" ? JSON.parse(i.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : i;
141
150
  } catch {
142
151
  a = null;
143
152
  }
144
153
  t(a);
145
154
  });
146
- } catch (n) {
147
- s(n);
155
+ } catch (i) {
156
+ s(i);
148
157
  }
149
158
  };
150
- return new Promise((i, o) => {
151
- r({
159
+ return new Promise((o, r) => {
160
+ n({
152
161
  name: e.name,
153
- params: e.params,
162
+ params: R(e.params),
154
163
  timeout: e.timeout,
155
164
  success: (t) => {
156
- e.success?.(t), e.complete?.(), i(t);
165
+ e.success?.(t), e.complete?.(), o(t);
157
166
  },
158
167
  fail: (t) => {
159
- e.fail?.(t), e.complete?.(), o(t);
168
+ e.fail?.(t), e.complete?.(), r(t);
160
169
  }
161
170
  });
162
171
  });
163
172
  }
164
- const D = /(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);
165
- function d(e, r) {
166
- return new Promise(async (i, o) => {
173
+ const q = /(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);
174
+ function u(e, n) {
175
+ return new Promise(async (o, r) => {
167
176
  try {
168
- const t = await r();
169
- e.success?.(t), i(t);
177
+ const t = await n();
178
+ e.success?.(t), o(t);
170
179
  } catch (t) {
171
- const s = t?.errorCode ? t : new l({ errorCode: l.UNKNOWN.errorCode, errorMsg: String(t) });
172
- e.fail?.(s), o(s);
180
+ const s = t?.errorCode ? t : new f({ errorCode: f.UNKNOWN.errorCode, errorMsg: String(t) });
181
+ e.fail?.(s), r(s);
173
182
  } finally {
174
183
  e.complete?.();
175
184
  }
176
185
  });
177
186
  }
178
- function b(e) {
179
- let r;
180
- return function(...i) {
181
- return r || (r = e(...i), Promise.resolve(r).catch(() => {
182
- r = void 0;
183
- }), r);
187
+ function V(e) {
188
+ let n;
189
+ return function(...o) {
190
+ return n || (n = e(...o), Promise.resolve(n).catch(() => {
191
+ n = void 0;
192
+ }), n);
184
193
  };
185
194
  }
186
- const H = b(() => f({
195
+ const M = V(() => d({
187
196
  name: "OpenActRequest",
188
197
  params: {
189
198
  // 这个函数只能使用35, 而不能使用新提供的60001, 这是因为写这个sdk的时候, 60001 也没有提供!!!
@@ -191,22 +200,22 @@ const H = b(() => f({
191
200
  data: {}
192
201
  }
193
202
  }));
194
- function M(e) {
195
- return d(e, async () => (await H()).vcode >= e.minVersion);
203
+ function U(e) {
204
+ return u(e, async () => (await M()).vcode >= e.minVersion);
196
205
  }
197
- function w(e, r) {
198
- return (...i) => M({
206
+ function p(e, n) {
207
+ return (...o) => U({
199
208
  minVersion: e.minVersion
200
- }).then((o) => o ? r(...i) : Promise.reject(new l({
201
- errorCode: l.UNSUPPORTED_VERSION.errorCode,
209
+ }).then((r) => r ? n(...o) : Promise.reject(new f({
210
+ errorCode: f.UNSUPPORTED_VERSION.errorCode,
202
211
  errorMsg: `最低版本要求${e.minVersion}`
203
212
  })));
204
213
  }
205
- class C {
214
+ class D {
206
215
  }
207
- const q = b((e) => d(
216
+ const C = V((e) => u(
208
217
  e || {},
209
- w({ minVersion: 80801 }, () => f({
218
+ p({ minVersion: 80805 }, () => d({
210
219
  name: "OpenActRequest",
211
220
  params: {
212
221
  type: 60001,
@@ -214,38 +223,29 @@ const q = b((e) => d(
214
223
  }
215
224
  }))
216
225
  ));
217
- function U(e) {
218
- if (typeof e != "object" || e === null || Array.isArray(e))
219
- return {};
220
- const r = {};
221
- return Object.keys(e).forEach((i) => {
222
- const o = e[i];
223
- o !== void 0 && (r[i] = o);
224
- }), r;
225
- }
226
- function J(e) {
227
- return d(
226
+ function j(e) {
227
+ return u(
228
228
  e,
229
- w({ minVersion: 80801 }, async () => f({
229
+ p({ minVersion: 80805 }, async () => d({
230
230
  name: "OpenActRequest",
231
231
  params: {
232
232
  type: 60400,
233
- data: U({
233
+ data: {
234
234
  /** 事件名 */
235
235
  eventId: e.eventName,
236
236
  /** 上报值 */
237
237
  trackParams: e.eventParams,
238
238
  /** 开始结束类型传递 */
239
239
  ExtEventType: e.eventType
240
- })
240
+ }
241
241
  }
242
242
  }))
243
243
  );
244
244
  }
245
- function B(e) {
246
- return d(
245
+ function J(e) {
246
+ return u(
247
247
  { ...e },
248
- w({ minVersion: 80801 }, async () => f({
248
+ p({ minVersion: 80805 }, async () => d({
249
249
  name: "OpenActRequest",
250
250
  params: {
251
251
  type: 60300,
@@ -254,30 +254,30 @@ function B(e) {
254
254
  }))
255
255
  );
256
256
  }
257
- const x = (e) => d(
257
+ const B = (e) => u(
258
258
  e,
259
- w({ minVersion: 80801 }, async () => f({
259
+ p({ minVersion: 80805 }, async () => d({
260
260
  name: "OpenActRequest",
261
261
  params: {
262
262
  type: 60500,
263
263
  data: e
264
264
  }
265
265
  }))
266
- ), _ = "SHARE_EVENT_NAME";
267
- class G {
266
+ ), h = "SHARE_EVENT_NAME";
267
+ class x {
268
268
  }
269
- function K(e) {
270
- return d(e, async () => k({
269
+ function G(e) {
270
+ return u(e, async () => H({
271
271
  name: "CommonShare",
272
- handler(r, i) {
273
- window.dispatchEvent(new Event(_)), "onShareApp" in e && e.onShareApp ? i({ type: 12, data: e.onShareApp() }) : i({ type: 12, data: e });
272
+ handler(n, o) {
273
+ window.dispatchEvent(new Event(h)), "onShareApp" in e && e.onShareApp ? o({ type: 12, data: e.onShareApp() }) : o({ type: 12, data: e });
274
274
  }
275
275
  }));
276
276
  }
277
- function W(e) {
278
- return d(
277
+ function K(e) {
278
+ return u(
279
279
  e,
280
- w({ minVersion: 80801 }, async () => (window.dispatchEvent(new Event(_)), f({
280
+ p({ minVersion: 80805 }, async () => (window.dispatchEvent(new Event(h)), d({
281
281
  name: "OpenActRequest",
282
282
  params: {
283
283
  type: 60500,
@@ -286,47 +286,70 @@ function W(e) {
286
286
  })))
287
287
  );
288
288
  }
289
- function $(e) {
290
- return window.addEventListener(_, e), () => {
291
- window.removeEventListener(_, e);
289
+ function W(e) {
290
+ return window.addEventListener(h, e), () => {
291
+ window.removeEventListener(h, e);
292
292
  };
293
293
  }
294
- class j {
294
+ class $ {
295
295
  }
296
296
  async function F(e) {
297
- return d(
297
+ return u(
298
298
  e || {},
299
- w({ minVersion: 80801 }, async () => (await f({
299
+ p({ minVersion: 80805 }, async () => (await d({
300
300
  name: "OpenActRequest",
301
301
  params: { type: 60101 }
302
302
  })).data || null)
303
303
  );
304
304
  }
305
305
  function L(e) {
306
- return d(
306
+ return u(
307
307
  e || {},
308
- w({ minVersion: 80801 }, async () => (await f({
308
+ p({ minVersion: 80805 }, async () => (await d({
309
309
  name: "OpenActRequest",
310
310
  params: { type: 60100 }
311
311
  })).data || null)
312
312
  );
313
313
  }
314
+ async function z(e) {
315
+ return u(
316
+ e || {},
317
+ p({ minVersion: 80805 }, async () => (await d({
318
+ name: "OpenActRequest",
319
+ params: { type: 60201, data: e }
320
+ })).data)
321
+ );
322
+ }
323
+ function Q(e) {
324
+ return u(
325
+ e || {},
326
+ p({ minVersion: 80805 }, async () => (await d({
327
+ name: "OpenActRequest",
328
+ params: {
329
+ type: 60210,
330
+ data: e
331
+ }
332
+ })).data)
333
+ );
334
+ }
314
335
  export {
315
- C as AppBaseInfo,
316
- G as AppShareModel,
317
- j as AuthResult,
318
- l as BridgeCode,
319
- D as IS_KB_APP_ENV,
320
- K as defineAppShareModel,
321
- q as getAppBaseInfo,
336
+ D as AppBaseInfo,
337
+ x as AppShareModel,
338
+ $ as AuthResult,
339
+ f as BridgeCode,
340
+ q as IS_KB_APP_ENV,
341
+ G as defineAppShareModel,
342
+ C as getAppBaseInfo,
322
343
  F as getAuthToken,
323
344
  L as getAuthTokenWithSilent,
324
- f as invokeNativeApi,
325
- M as isAppVersionSupport,
326
- $ as onAppSharePanelShow,
327
- W as openAppSharePanel,
328
- k as registerNativeApiHandler,
329
- J as reportDAEvent,
330
- B as runAction,
331
- x as shareImage
345
+ d as invokeNativeApi,
346
+ U as isAppVersionSupport,
347
+ W as onAppSharePanelShow,
348
+ K as openAppSharePanel,
349
+ H as registerNativeApiHandler,
350
+ j as reportDAEvent,
351
+ z as requestPayment,
352
+ Q as requestRefund,
353
+ J as runAction,
354
+ B as shareImage
332
355
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a.kbMarket={}))})(this,(function(a){"use strict";const d=class d{constructor(t){this.errorCode=t.errorCode,this.errorMsg=t.errorMsg}};d.UNKNOWN=new d({errorCode:1e3,errorMsg:"未知错误"}),d.UNSUPPORTED_VERSION=new d({errorCode:1001,errorMsg:"当前开吧版本不支持"}),d.TIMEOUT=new d({errorCode:1002,errorMsg:"执行超时"}),d.UNSUPPORTED_BRIDGE_ENV=new d({errorCode:1003,errorMsg:"请在开吧app内执行"});let c=d;const k=()=>{const e=(n,s,r)=>{var u="";typeof s=="function"&&(r=s,s={});var l={data:s===void 0?null:s};if(typeof r=="function"){var v="dscb"+window.dscb++;window[v]=r,l._dscbstub=v}if(l=JSON.stringify(l),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+n,l)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+n,l)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch{console.error("callHandle异常,JSON.parse错误")}},t=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,i=(()=>{const n=[],s=setInterval(()=>{t()&&(clearInterval(s),n.forEach(r=>{e.apply(window,r)}),n.length=0)},500);return(...r)=>{n.push(r)}})();var o={default:void 0,callHandler:function(n,s,r){return t()?e(n,s,r):i(n,s,r)},register:function(n,s,r){var u=r?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){o.callHandler("_dsb.dsinit")},0)),typeof s=="object"?u._obs[n]=s:u[n]=s},registerHandler:function(n,s){this.register(n,s,!0)}};return(function(){if(!window._dsf){var n={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:o,_handleMessageFromNative:function(r){var u=JSON.parse(r.data),l={id:r.callbackId,complete:!0},v=this._dsf[r.method],y=this._dsaf[r.method],R=function(E,m){l.data=E.apply(m,u),o.callHandler("_dsb.returnValue",l)},I=function(E,m){u.push(function(z,Q){l.data=z,l.complete=Q!==!1,o.callHandler("_dsb.returnValue",l)}),E.apply(m,u)};if(v)R(v,this._dsf);else if(y)I(y,this._dsaf);else{var g=r.method.split(".");if(g.length<2)return;var V=g.pop(),T=g.join("."),S=this._dsf._obs,A=S[T]||{},h=A[V];if(h&&typeof h=="function"){R(h,A);return}if(S=this._dsaf._obs,A=S[T]||{},h=A[V],h&&typeof h=="function"){I(h,A);return}}}};for(var s in n)window[s]=n[s]}})(),o},N=(e=>/(kb)/i.test(e)?k():{registerHandler(t,i){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(t,i,o){throw c.UNSUPPORTED_BRIDGE_ENV}})(window?.navigator?.userAgent),P=e=>new Promise((t,i)=>{try{N.registerHandler(e.name,e.handler),e.success?.(),t()}catch(o){e.fail?.(o),i(o)}finally{e.complete?.()}});function f(e){const t=i=>{let o;const n=r=>{(!o||o==="success")&&(o="success",i.success?.(r))},s=r=>{(!o||o==="error")&&(o="error",i.fail?.(r))};i.timeout&&setTimeout(()=>{s(c.TIMEOUT)},i.timeout);try{N.callHandler(i.name,i.params,r=>{let u;try{u=typeof r=="string"?JSON.parse(r.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):r}catch{u=null}n(u)})}catch(r){s(r)}};return new Promise((i,o)=>{t({name:e.name,params:e.params,timeout:e.timeout,success:n=>{e.success?.(n),e.complete?.(),i(n)},fail:n=>{e.fail?.(n),e.complete?.(),o(n)}})})}const M=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);function p(e,t){return new Promise(async(i,o)=>{try{const n=await t();e.success?.(n),i(n)}catch(n){const s=n?.errorCode?n:new c({errorCode:c.UNKNOWN.errorCode,errorMsg:String(n)});e.fail?.(s),o(s)}finally{e.complete?.()}})}function b(e){let t;return function(...i){return t||(t=e(...i),Promise.resolve(t).catch(()=>{t=void 0}),t)}}const H=b(()=>f({name:"OpenActRequest",params:{type:35,data:{}}}));function O(e){return p(e,async()=>(await H()).vcode>=e.minVersion)}function w(e,t){return(...i)=>O({minVersion:e.minVersion}).then(o=>o?t(...i):Promise.reject(new c({errorCode:c.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}class U{}const D=b(e=>p(e||{},w({minVersion:80801},()=>f({name:"OpenActRequest",params:{type:60001,data:{}}}))));function C(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};const t={};return Object.keys(e).forEach(i=>{const o=e[i];o!==void 0&&(t[i]=o)}),t}function q(e){return p(e,w({minVersion:80801},async()=>f({name:"OpenActRequest",params:{type:60400,data:C({eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType})}})))}function B(e){return p({...e},w({minVersion:80801},async()=>f({name:"OpenActRequest",params:{type:60300,data:e}})))}const J=e=>p(e,w({minVersion:80801},async()=>f({name:"OpenActRequest",params:{type:60500,data:e}}))),_="SHARE_EVENT_NAME";class j{}function K(e){return p(e,async()=>P({name:"CommonShare",handler(t,i){window.dispatchEvent(new Event(_)),"onShareApp"in e&&e.onShareApp?i({type:12,data:e.onShareApp()}):i({type:12,data:e})}}))}function W(e){return p(e,w({minVersion:80801},async()=>(window.dispatchEvent(new Event(_)),f({name:"OpenActRequest",params:{type:60500,data:e}}))))}function G(e){return window.addEventListener(_,e),()=>{window.removeEventListener(_,e)}}class ${}async function F(e){return p(e||{},w({minVersion:80801},async()=>(await f({name:"OpenActRequest",params:{type:60101}})).data||null))}function L(e){return p(e||{},w({minVersion:80801},async()=>(await f({name:"OpenActRequest",params:{type:60100}})).data||null))}a.AppBaseInfo=U,a.AppShareModel=j,a.AuthResult=$,a.BridgeCode=c,a.IS_KB_APP_ENV=M,a.defineAppShareModel=K,a.getAppBaseInfo=D,a.getAuthToken=F,a.getAuthTokenWithSilent=L,a.invokeNativeApi=f,a.isAppVersionSupport=O,a.onAppSharePanelShow=G,a.openAppSharePanel=W,a.registerNativeApiHandler=P,a.reportDAEvent=q,a.runAction=B,a.shareImage=J,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(s,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(s=typeof globalThis<"u"?globalThis:s||self,v(s.kbMarket={}))})(this,(function(s){"use strict";function v(e){if(Object.prototype.toString.call(e)!=="[object Object]")return e;const n={};return Object.keys(e).forEach(o=>{const r=e[o];r!=null&&(n[o]=Object.prototype.toString.call(r)==="[object Object]"?v(r):r)}),n}const p=class p{constructor(n){this.errorCode=n.errorCode,this.errorMsg=n.errorMsg}};p.UNKNOWN=new p({errorCode:1e3,errorMsg:"未知错误"}),p.UNSUPPORTED_VERSION=new p({errorCode:1001,errorMsg:"当前开吧版本不支持"}),p.TIMEOUT=new p({errorCode:1002,errorMsg:"执行超时"}),p.UNSUPPORTED_BRIDGE_ENV=new p({errorCode:1003,errorMsg:"请在开吧app内执行"});let f=p;const M=()=>{const e=(t,a,i)=>{var u="";typeof a=="function"&&(i=a,a={});var c={data:a===void 0?null:a};if(typeof i=="function"){var A="dscb"+window.dscb++;window[A]=i,c._dscbstub=A}if(c=JSON.stringify(c),window.flutter_inappwebview?window.flutter_inappwebview.callHandler&&(u=window.flutter_inappwebview.callHandler(""+t,c)):(window._dswk||navigator.userAgent.indexOf("_dsbridge")!=-1)&&(u=prompt("_flutterDsbridge="+t,c)),u instanceof Promise)return u;try{return JSON.parse(u||"{}").data}catch{console.error("callHandle异常,JSON.parse错误")}},n=()=>window.navigator.userAgent.includes("Android")?window.flutter_inappwebview&&window.flutter_inappwebview._platformReady:!0,o=(()=>{const t=[],a=setInterval(()=>{n()&&(clearInterval(a),t.forEach(i=>{e.apply(window,i)}),t.length=0)},500);return(...i)=>{t.push(i)}})();var r={default:void 0,callHandler:function(t,a,i){return n()?e(t,a,i):o(t,a,i)},register:function(t,a,i){var u=i?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){r.callHandler("_dsb.dsinit")},0)),typeof a=="object"?u._obs[t]=a:u[t]=a},registerHandler:function(t,a){this.register(t,a,!0)}};return(function(){if(!window._dsf){var t={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:r,_handleMessageFromNative:function(i){var u=JSON.parse(i.data),c={id:i.callbackId,complete:!0},A=this._dsf[i.method],g=this._dsaf[i.method],V=function(E,b){c.data=E.apply(b,u),r.callHandler("_dsb.returnValue",c)},I=function(E,b){u.push(function(X,Y){c.data=X,c.complete=Y!==!1,r.callHandler("_dsb.returnValue",c)}),E.apply(b,u)};if(A)V(A,this._dsf);else if(g)I(g,this._dsaf);else{var S=i.method.split(".");if(S.length<2)return;var T=S.pop(),k=S.join("."),m=this._dsf._obs,y=m[k]||{},h=y[T];if(h&&typeof h=="function"){V(h,y);return}if(m=this._dsaf._obs,y=m[k]||{},h=y[T],h&&typeof h=="function"){I(h,y);return}}}};for(var a in t)window[a]=t[a]}})(),r},N=(e=>/(kb)/i.test(e)?M():{registerHandler(n,o){throw f.UNSUPPORTED_BRIDGE_ENV},callHandler(n,o,r){throw f.UNSUPPORTED_BRIDGE_ENV}})(window?.navigator?.userAgent),O=e=>new Promise((n,o)=>{try{N.registerHandler(e.name,e.handler),e.success?.(),n()}catch(r){e.fail?.(r),o(r)}finally{e.complete?.()}});function l(e){const n=o=>{let r;const t=i=>{(!r||r==="success")&&(r="success",o.success?.(i))},a=i=>{(!r||r==="error")&&(r="error",o.fail?.(i))};o.timeout&&setTimeout(()=>{a(f.TIMEOUT)},o.timeout);try{N.callHandler(o.name,o.params,i=>{let u;try{u=typeof i=="string"?JSON.parse(i.replace(/\n/g,"\\n").replace(/\r/g,"\\r")):i}catch{u=null}t(u)})}catch(i){a(i)}};return new Promise((o,r)=>{n({name:e.name,params:v(e.params),timeout:e.timeout,success:t=>{e.success?.(t),e.complete?.(),o(t)},fail:t=>{e.fail?.(t),e.complete?.(),r(t)}})})}const H=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);function d(e,n){return new Promise(async(o,r)=>{try{const t=await n();e.success?.(t),o(t)}catch(t){const a=t?.errorCode?t:new f({errorCode:f.UNKNOWN.errorCode,errorMsg:String(t)});e.fail?.(a),r(a)}finally{e.complete?.()}})}function P(e){let n;return function(...o){return n||(n=e(...o),Promise.resolve(n).catch(()=>{n=void 0}),n)}}const q=P(()=>l({name:"OpenActRequest",params:{type:35,data:{}}}));function R(e){return d(e,async()=>(await q()).vcode>=e.minVersion)}function w(e,n){return(...o)=>R({minVersion:e.minVersion}).then(r=>r?n(...o):Promise.reject(new f({errorCode:f.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}class U{}const D=P(e=>d(e||{},w({minVersion:80805},()=>l({name:"OpenActRequest",params:{type:60001,data:{}}}))));function C(e){return d(e,w({minVersion:80805},async()=>l({name:"OpenActRequest",params:{type:60400,data:{eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType}}})))}function j(e){return d({...e},w({minVersion:80805},async()=>l({name:"OpenActRequest",params:{type:60300,data:e}})))}const B=e=>d(e,w({minVersion:80805},async()=>l({name:"OpenActRequest",params:{type:60500,data:e}}))),_="SHARE_EVENT_NAME";class J{}function K(e){return d(e,async()=>O({name:"CommonShare",handler(n,o){window.dispatchEvent(new Event(_)),"onShareApp"in e&&e.onShareApp?o({type:12,data:e.onShareApp()}):o({type:12,data:e})}}))}function W(e){return d(e,w({minVersion:80805},async()=>(window.dispatchEvent(new Event(_)),l({name:"OpenActRequest",params:{type:60500,data:e}}))))}function G(e){return window.addEventListener(_,e),()=>{window.removeEventListener(_,e)}}class ${}async function F(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60101}})).data||null))}function L(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60100}})).data||null))}async function z(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60201,data:e}})).data))}function Q(e){return d(e||{},w({minVersion:80805},async()=>(await l({name:"OpenActRequest",params:{type:60210,data:e}})).data))}s.AppBaseInfo=U,s.AppShareModel=J,s.AuthResult=$,s.BridgeCode=f,s.IS_KB_APP_ENV=H,s.defineAppShareModel=K,s.getAppBaseInfo=D,s.getAuthToken=F,s.getAuthTokenWithSilent=L,s.invokeNativeApi=l,s.isAppVersionSupport=R,s.onAppSharePanelShow=G,s.openAppSharePanel=W,s.registerNativeApiHandler=O,s.reportDAEvent=C,s.requestPayment=z,s.requestRefund=Q,s.runAction=j,s.shareImage=B,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
@@ -14,7 +14,7 @@ export declare class AuthResult {
14
14
  * @description 获取开吧 登录授权凭证, 当app未登录, 则会唤起登录, 登录成功后返回token
15
15
  *
16
16
  * ⚠️ **重要异常提示**:在用户取消登录的某些场景下,该函数可能出现「无任何回调」的情况(`success` 和 `fail` 回调均不会触发),请开发者做好兜底处理。
17
- * @version 开吧APP:80801开始支持,低版本需开发者做兼容处理
17
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
18
18
  * @example
19
19
  * **示例代码**
20
20
  ```js
@@ -26,7 +26,7 @@ export declare class AppBaseInfo {
26
26
  /**
27
27
  *
28
28
  * @description 获取开吧APP基础信息
29
- * @version 开吧APP:80801开始支持,低版本需开发者做兼容处理
29
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
30
30
  * @example
31
31
  * **示例代码**
32
32
  ```js
@@ -0,0 +1,98 @@
1
+ import { CallbackOptions } from './callback-options';
2
+ /**
3
+ *
4
+ * @description 唤起支付
5
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
6
+ * @example
7
+ * **示例代码**
8
+ ```js
9
+ import { requestPayment } from '@kbapp/market-partner-sdk';
10
+
11
+ requestPayment({
12
+ payFee: 1,
13
+ orderCode: 'xxxx',
14
+ payChannel: 1,
15
+ partnerKey: 'xxxx',
16
+ subjectName: 'xxxx',
17
+ success(result) {
18
+ console.log(result)
19
+ },
20
+ fail(error) {
21
+ console.error(error)
22
+ },
23
+ })
24
+ ```
25
+ */
26
+ export declare function requestPayment(params: CallbackOptions<{
27
+ /** 支付结果 0: 成功 1: 失败 */
28
+ result: 0 | 1;
29
+ /** 支付结果描述 */
30
+ msg: string;
31
+ /** 支付成功时返回支付订单号, 失败不返回 */
32
+ fundsCode: string;
33
+ }> & {
34
+ /** 支付金额, 单位分 */
35
+ payFee: number;
36
+ /** 订单code(商户订单UK) */
37
+ orderCode: string;
38
+ /**
39
+ * 支付渠道 1: 支付宝 2: 微信
40
+ * 20260115 暂不支持微信支付
41
+ */
42
+ payChannel: number;
43
+ /** 订单展示名称 */
44
+ subjectName: string;
45
+ /** 约定的商户标识 */
46
+ partnerKey: string;
47
+ /** 支付完成回调地址 */
48
+ notifyUrl?: string;
49
+ /** 订单过期时间, 13位毫秒数的绝对时间戳, 不传默认当前时间+15分钟 */
50
+ expireTime?: number;
51
+ }): Promise<{
52
+ /** 支付结果 0: 成功 1: 失败 */
53
+ result: 0 | 1;
54
+ /** 支付结果描述 */
55
+ msg: string;
56
+ /** 支付成功时返回支付订单号, 失败不返回 */
57
+ fundsCode: string;
58
+ }>;
59
+ /**
60
+ *
61
+ * @description 申请退款
62
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
63
+ * @example
64
+ * **示例代码**
65
+ ```js
66
+ import { requestRefund } from '@kbapp/market-partner-sdk';
67
+
68
+ requestRefund({
69
+ orderCode: 'xxxx',
70
+ partnerKey: 'xxxx',
71
+ fundsCode: 'xxxx',
72
+ success(result) {
73
+ console.log(result)
74
+ },
75
+ fail(error) {
76
+ console.error(error)
77
+ },
78
+ })
79
+ ```
80
+ */
81
+ export declare function requestRefund(params: CallbackOptions<{
82
+ /** 0: 成功 1: 失败 */
83
+ result: 0 | 1;
84
+ /** 结果描述 */
85
+ msg: string;
86
+ }> & {
87
+ /** 订单code(商户订单UK) */
88
+ orderCode: string;
89
+ /** 约定的商户标识 */
90
+ partnerKey: string;
91
+ /** 支付成功时返回支付订单号 */
92
+ fundsCode: string;
93
+ }): Promise<{
94
+ /** 0: 成功 1: 失败 */
95
+ result: 0 | 1;
96
+ /** 结果描述 */
97
+ msg: string;
98
+ }>;
@@ -2,7 +2,7 @@ import { CallbackOptions } from './callback-options';
2
2
  /**
3
3
  *
4
4
  * @description 上报数据埋点到个推
5
- * @version 开吧APP:80801开始支持,低版本需开发者做兼容处理
5
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
6
6
  * @example
7
7
  * **示例代码**
8
8
  ```js
@@ -2,7 +2,7 @@ import { CallbackOptions } from './callback-options';
2
2
  /**
3
3
  *
4
4
  * @description 执行统一跳转页面标准
5
- * @version 开吧APP:80801开始支持,低版本需开发者做兼容处理
5
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
6
6
  * @example
7
7
  * **示例代码**
8
8
  ```js
@@ -2,7 +2,7 @@ import { CallbackOptions } from './callback-options';
2
2
  /**
3
3
  *
4
4
  * @description 分享图片
5
- * @version 开吧APP:80801开始支持,低版本需开发者做兼容处理
5
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
6
6
  * @example
7
7
  * **示例代码**
8
8
  ```js
@@ -131,7 +131,7 @@ export declare function defineAppShareModel(params: (AppShareModel & CallbackOpt
131
131
  /**
132
132
  *
133
133
  * @description 主动唤起 分享面板
134
- * @version 开吧APP:80801开始支持,低版本需开发者做兼容处理
134
+ * @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
135
135
  * @example
136
136
  * **示例代码**
137
137
  ```js
@@ -1,8 +1,6 @@
1
1
  /**
2
- * 过滤对象第一层中值为 undefined 的属性(不处理嵌套对象)
2
+ * 递归过滤对象中所有层级的 undefined 和 null 属性
3
3
  * @param obj 待过滤的对象(仅支持纯对象,不支持数组/非对象类型)
4
- * @returns 过滤后的新对象(自动剔除值为 undefined 的属性)
4
+ * @returns 过滤后的新对象(自动剔除所有层级的 undefined 和 null 值)
5
5
  */
6
- export declare function filterUndefinedProperties<T extends Record<string, any>>(obj: T): Pick<T, {
7
- [K in keyof T]: T[K] extends undefined ? never : K;
8
- }[keyof T]>;
6
+ export declare function filterUndefinedAndNullProperties<T extends Record<string, any>>(obj: T): T;
@@ -24,7 +24,7 @@
24
24
  </button>
25
25
  </template>
26
26
  <template v-else>
27
- <button type="button" class="btn btn-primary" @click="item.done">{{item.buttonText}}</button>
27
+ <button type="button" class="btn btn-primary" @click="() => {item.done()}">{{item.buttonText}}</button>
28
28
  </template>
29
29
  </div>
30
30
  </h5>
@@ -38,6 +38,36 @@
38
38
  <div class="card-text">{{item.desc}}</div>
39
39
  </template>
40
40
 
41
+ <template v-if="item.form && item.form.schema">
42
+ <div class="card mt-3">
43
+ <div class="card-header">执行参数</div>
44
+ <div class="card-body">
45
+ <div v-for="(key, index) in item.form.schema" :key="index">
46
+ <label :for="`exampleFormControlInput${index}`" class="form-label">{{ key.key }} {{ key.label }}</label>
47
+
48
+ <template v-if="key.type === 'number'">
49
+ <input
50
+ type="number"
51
+ class="form-control"
52
+ :id="`exampleFormControlInput${index}`"
53
+ :placeholder="key.label"
54
+ v-model="item.form.data[key.key]"
55
+ />
56
+ </template>
57
+ <template v-else>
58
+ <input
59
+ type="text"
60
+ class="form-control"
61
+ :id="`exampleFormControlInput${index}`"
62
+ :placeholder="key.label"
63
+ v-model="item.form.data[key.key]"
64
+ />
65
+ </template>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </template>
70
+
41
71
  <template v-if="item.done.status.data">
42
72
  <div class="alert alert-success mt-2" role="alert">{{item.done.status.data}}</div>
43
73
  </template>
@@ -51,7 +81,18 @@
51
81
  </body>
52
82
  <script type="module">
53
83
  import { createApp, ref, reactive } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
54
- import { getAuthToken, getAuthTokenWithSilent, runAction, defineAppShareModel, openAppSharePanel, reportDAEvent, getAppBaseInfo, shareImage } from 'https://unpkg.com/@kbapp/market-partner-sdk@latest/dist/index.es.js'
84
+ import {
85
+ getAuthToken,
86
+ getAuthTokenWithSilent,
87
+ runAction,
88
+ defineAppShareModel,
89
+ openAppSharePanel,
90
+ reportDAEvent,
91
+ getAppBaseInfo,
92
+ shareImage,
93
+ requestPayment,
94
+ requestRefund,
95
+ } from '../dist/index.es.js'
55
96
 
56
97
  /**
57
98
  * 装饰器,用于处理done函数的调用
@@ -77,7 +118,7 @@
77
118
  status.loading = true
78
119
 
79
120
  try {
80
- const data = await Promise.resolve(callback())
121
+ const data = await Promise.resolve(callback.call(this))
81
122
  status.data = data
82
123
  } catch (error) {
83
124
  status.error = error
@@ -200,6 +241,52 @@
200
241
  return '分享成功'
201
242
  }),
202
243
  },
244
+ {
245
+ title: 'requestPayment',
246
+ subtitle: '唤起支付',
247
+ buttonText: '执行',
248
+ desc: `执行结果 唤起支付`,
249
+ form: {
250
+ data: {
251
+ payFee: 1,
252
+ orderCode: '',
253
+ payChannel: 1,
254
+ partnerKey: '',
255
+ subjectName: '',
256
+ },
257
+ schema: [
258
+ { key: 'payFee', type: 'number' },
259
+ { key: 'orderCode', type: 'string' },
260
+ { key: 'payChannel', type: 'number' },
261
+ { key: 'partnerKey', type: 'string' },
262
+ { key: 'subjectName', type: 'string' },
263
+ ],
264
+ },
265
+ done: decorateDone(function () {
266
+ return requestPayment({ ...this.form.data, success() {} })
267
+ }),
268
+ },
269
+ {
270
+ title: 'requestRefund',
271
+ subtitle: '申请退款',
272
+ buttonText: '执行',
273
+ desc: `执行结果 申请退款`,
274
+ form: {
275
+ data: {
276
+ orderCode: '',
277
+ partnerKey: '',
278
+ fundsCode: '',
279
+ },
280
+ schema: [
281
+ { key: 'orderCode', type: 'string' },
282
+ { key: 'partnerKey', type: 'string' },
283
+ { key: 'fundsCode', type: 'string' },
284
+ ],
285
+ },
286
+ done: decorateDone(function () {
287
+ return requestRefund({ ...this.form.data })
288
+ }),
289
+ },
203
290
  ])
204
291
 
205
292
  createApp({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbapp/market-partner-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "开吧商城接入jssdk",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,7 +12,7 @@
12
12
  "browser": "./dist/index.umd.js",
13
13
  "author": "along",
14
14
  "scripts": {
15
- "dev": "npm run build && web-dev-server --root-dir ./ --port 3000 --open /examples/index.html --node-resolve --no-cache",
15
+ "dev": "npm run build && web-dev-server --root-dir ./ --port 3300 --open /examples/index.html --node-resolve --no-cache",
16
16
  "build": "rm -rf ./dist && vite build && npx tsc --emitDeclarationOnly",
17
17
  "publish": "npm run build && npm publish"
18
18
  },