@kbapp/market-partner-sdk 0.0.4 → 0.0.5

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,32 +1,32 @@
1
- const u = class u {
1
+ const l = class l {
2
2
  constructor(r) {
3
3
  this.errorCode = r.errorCode, this.errorMsg = r.errorMsg;
4
4
  }
5
5
  };
6
- u.UNKNOWN = new u({
6
+ l.UNKNOWN = new l({
7
7
  errorCode: 1e3,
8
8
  errorMsg: "未知错误"
9
- }), u.UNSUPPORTED_VERSION = new u({
9
+ }), l.UNSUPPORTED_VERSION = new l({
10
10
  errorCode: 1001,
11
11
  errorMsg: "当前开吧版本不支持"
12
- }), u.TIMEOUT = new u({
12
+ }), l.TIMEOUT = new l({
13
13
  errorCode: 1002,
14
14
  errorMsg: "执行超时"
15
- }), u.UNSUPPORTED_BRIDGE_ENV = new u({
15
+ }), l.UNSUPPORTED_BRIDGE_ENV = new l({
16
16
  errorCode: 1003,
17
17
  errorMsg: "请在开吧app内执行"
18
18
  });
19
- let l = u;
19
+ let f = l;
20
20
  const T = () => {
21
- const e = (t, s, n) => {
21
+ const e = (t, o, n) => {
22
22
  var a = "";
23
- typeof s == "function" && (n = s, s = {});
24
- var c = { data: s === void 0 ? null : s };
23
+ typeof o == "function" && (n = o, o = {});
24
+ var u = { data: o === void 0 ? null : o };
25
25
  if (typeof n == "function") {
26
26
  var v = "dscb" + window.dscb++;
27
- window[v] = n, c._dscbstub = v;
27
+ window[v] = n, u._dscbstub = v;
28
28
  }
29
- 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)
29
+ if (u = JSON.stringify(u), window.flutter_inappwebview ? window.flutter_inappwebview.callHandler && (a = window.flutter_inappwebview.callHandler("" + t, u)) : (window._dswk || navigator.userAgent.indexOf("_dsbridge") != -1) && (a = prompt("_flutterDsbridge=" + t, u)), a instanceof Promise)
30
30
  return a;
31
31
  try {
32
32
  return JSON.parse(a || "{}").data;
@@ -34,8 +34,8 @@ const T = () => {
34
34
  console.error("callHandle异常,JSON.parse错误");
35
35
  }
36
36
  }, r = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, i = (() => {
37
- const t = [], s = setInterval(() => {
38
- r() && (clearInterval(s), t.forEach((n) => {
37
+ const t = [], o = setInterval(() => {
38
+ r() && (clearInterval(o), t.forEach((n) => {
39
39
  e.apply(window, n);
40
40
  }), t.length = 0);
41
41
  }, 500);
@@ -43,20 +43,20 @@ const T = () => {
43
43
  t.push(n);
44
44
  };
45
45
  })();
46
- var o = {
46
+ var s = {
47
47
  default: void 0,
48
48
  // for typescript
49
- callHandler: function(t, s, n) {
50
- return r() ? e(t, s, n) : i(t, s, n);
49
+ callHandler: function(t, o, n) {
50
+ return r() ? e(t, o, n) : i(t, o, n);
51
51
  },
52
- register: function(t, s, n) {
52
+ register: function(t, o, n) {
53
53
  var a = n ? window._dsaf : window._dsf;
54
54
  window._dsInit || (window._dsInit = !0, setTimeout(function() {
55
- o.callHandler("_dsb.dsinit");
56
- }, 0)), typeof s == "object" ? a._obs[t] = s : a[t] = s;
55
+ s.callHandler("_dsb.dsinit");
56
+ }, 0)), typeof o == "object" ? a._obs[t] = o : a[t] = o;
57
57
  },
58
- registerHandler: function(t, s) {
59
- this.register(t, s, !0);
58
+ registerHandler: function(t, o) {
59
+ this.register(t, o, !0);
60
60
  }
61
61
  };
62
62
  return (function() {
@@ -71,70 +71,70 @@ const T = () => {
71
71
  _obs: {}
72
72
  },
73
73
  dscb: 0,
74
- jsBridge: o,
74
+ jsBridge: s,
75
75
  _handleMessageFromNative: function(n) {
76
- var a = JSON.parse(n.data), c = {
76
+ var a = JSON.parse(n.data), u = {
77
77
  id: n.callbackId,
78
78
  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);
79
+ }, v = this._dsf[n.method], _ = this._dsaf[n.method], S = function(m, E) {
80
+ u.data = m.apply(E, a), s.callHandler("_dsb.returnValue", u);
81
+ }, N = function(m, E) {
82
+ a.push(function(b, I) {
83
+ u.data = b, u.complete = I !== !1, s.callHandler("_dsb.returnValue", u);
84
+ }), m.apply(E, a);
85
85
  };
86
86
  if (v)
87
- N(v, this._dsf);
88
- else if (y)
89
- m(y, this._dsaf);
87
+ S(v, this._dsf);
88
+ else if (_)
89
+ N(_, this._dsaf);
90
90
  else {
91
91
  var A = n.method.split(".");
92
92
  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);
93
+ var O = A.pop(), R = A.join("."), g = this._dsf._obs, y = g[R] || {}, w = y[O];
94
+ if (w && typeof w == "function") {
95
+ S(w, y);
96
96
  return;
97
97
  }
98
- if (g = this._dsaf._obs, h = g[P] || {}, p = h[O], p && typeof p == "function") {
99
- m(p, h);
98
+ if (g = this._dsaf._obs, y = g[R] || {}, w = y[O], w && typeof w == "function") {
99
+ N(w, y);
100
100
  return;
101
101
  }
102
102
  }
103
103
  }
104
104
  };
105
- for (var s in t)
106
- window[s] = t[s];
105
+ for (var o in t)
106
+ window[o] = t[o];
107
107
  }
108
- })(), o;
109
- }, R = ((e) => /(kb)/i.test(e) ? T() : {
108
+ })(), s;
109
+ }, P = ((e) => /(kb)/i.test(e) ? T() : {
110
110
  registerHandler(r, i) {
111
- throw l.UNSUPPORTED_BRIDGE_ENV;
111
+ throw f.UNSUPPORTED_BRIDGE_ENV;
112
112
  },
113
- callHandler(r, i, o) {
114
- throw l.UNSUPPORTED_BRIDGE_ENV;
113
+ callHandler(r, i, s) {
114
+ throw f.UNSUPPORTED_BRIDGE_ENV;
115
115
  }
116
116
  })(window?.navigator?.userAgent), k = (e) => new Promise((r, i) => {
117
117
  try {
118
- R.registerHandler(e.name, e.handler), e.success?.(), r();
119
- } catch (o) {
120
- e.fail?.(o), i(o);
118
+ P.registerHandler(e.name, e.handler), e.success?.(), r();
119
+ } catch (s) {
120
+ e.fail?.(s), i(s);
121
121
  } finally {
122
122
  e.complete?.();
123
123
  }
124
124
  });
125
- function f(e) {
125
+ function d(e) {
126
126
  const r = (i) => {
127
- let o;
127
+ let s;
128
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));
129
+ (!s || s === "success") && (s = "success", i.success?.(n));
130
+ }, o = (n) => {
131
+ (!s || s === "error") && (s = "error", i.fail?.(n));
132
132
  };
133
133
  i.timeout && setTimeout(() => {
134
- s(l.TIMEOUT);
134
+ o(f.TIMEOUT);
135
135
  }, i.timeout);
136
136
  try {
137
- R.callHandler(i.name, i.params, (n) => {
137
+ P.callHandler(i.name, i.params, (n) => {
138
138
  let a;
139
139
  try {
140
140
  a = typeof n == "string" ? JSON.parse(n.replace(/\n/g, "\\n").replace(/\r/g, "\\r")) : n;
@@ -144,10 +144,10 @@ function f(e) {
144
144
  t(a);
145
145
  });
146
146
  } catch (n) {
147
- s(n);
147
+ o(n);
148
148
  }
149
149
  };
150
- return new Promise((i, o) => {
150
+ return new Promise((i, s) => {
151
151
  r({
152
152
  name: e.name,
153
153
  params: e.params,
@@ -156,26 +156,26 @@ function f(e) {
156
156
  e.success?.(t), e.complete?.(), i(t);
157
157
  },
158
158
  fail: (t) => {
159
- e.fail?.(t), e.complete?.(), o(t);
159
+ e.fail?.(t), e.complete?.(), s(t);
160
160
  }
161
161
  });
162
162
  });
163
163
  }
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) => {
164
+ const q = /(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);
165
+ function c(e, r) {
166
+ return new Promise(async (i, s) => {
167
167
  try {
168
168
  const t = await r();
169
169
  e.success?.(t), i(t);
170
170
  } catch (t) {
171
- const s = t?.errorCode ? t : new l({ errorCode: l.UNKNOWN.errorCode, errorMsg: String(t) });
172
- e.fail?.(s), o(s);
171
+ const o = t?.errorCode ? t : new f({ errorCode: f.UNKNOWN.errorCode, errorMsg: String(t) });
172
+ e.fail?.(o), s(o);
173
173
  } finally {
174
174
  e.complete?.();
175
175
  }
176
176
  });
177
177
  }
178
- function b(e) {
178
+ function V(e) {
179
179
  let r;
180
180
  return function(...i) {
181
181
  return r || (r = e(...i), Promise.resolve(r).catch(() => {
@@ -183,7 +183,7 @@ function b(e) {
183
183
  }), r);
184
184
  };
185
185
  }
186
- const H = b(() => f({
186
+ const H = V(() => d({
187
187
  name: "OpenActRequest",
188
188
  params: {
189
189
  // 这个函数只能使用35, 而不能使用新提供的60001, 这是因为写这个sdk的时候, 60001 也没有提供!!!
@@ -192,21 +192,21 @@ const H = b(() => f({
192
192
  }
193
193
  }));
194
194
  function M(e) {
195
- return d(e, async () => (await H()).vcode >= e.minVersion);
195
+ return c(e, async () => (await H()).vcode >= e.minVersion);
196
196
  }
197
- function w(e, r) {
197
+ function p(e, r) {
198
198
  return (...i) => M({
199
199
  minVersion: e.minVersion
200
- }).then((o) => o ? r(...i) : Promise.reject(new l({
201
- errorCode: l.UNSUPPORTED_VERSION.errorCode,
200
+ }).then((s) => s ? r(...i) : Promise.reject(new f({
201
+ errorCode: f.UNSUPPORTED_VERSION.errorCode,
202
202
  errorMsg: `最低版本要求${e.minVersion}`
203
203
  })));
204
204
  }
205
- class C {
205
+ class D {
206
206
  }
207
- const q = b((e) => d(
207
+ const C = V((e) => c(
208
208
  e || {},
209
- w({ minVersion: 80801 }, () => f({
209
+ p({ minVersion: 80805 }, () => d({
210
210
  name: "OpenActRequest",
211
211
  params: {
212
212
  type: 60001,
@@ -219,14 +219,14 @@ function U(e) {
219
219
  return {};
220
220
  const r = {};
221
221
  return Object.keys(e).forEach((i) => {
222
- const o = e[i];
223
- o !== void 0 && (r[i] = o);
222
+ const s = e[i];
223
+ s !== void 0 && (r[i] = s);
224
224
  }), r;
225
225
  }
226
226
  function J(e) {
227
- return d(
227
+ return c(
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,
@@ -243,9 +243,9 @@ function J(e) {
243
243
  );
244
244
  }
245
245
  function B(e) {
246
- return d(
246
+ return c(
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 x = (e) => c(
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";
266
+ ), h = "SHARE_EVENT_NAME";
267
267
  class G {
268
268
  }
269
269
  function K(e) {
270
- return d(e, async () => k({
270
+ return c(e, async () => k({
271
271
  name: "CommonShare",
272
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 });
273
+ window.dispatchEvent(new Event(h)), "onShareApp" in e && e.onShareApp ? i({ type: 12, data: e.onShareApp() }) : i({ type: 12, data: e });
274
274
  }
275
275
  }));
276
276
  }
277
277
  function W(e) {
278
- return d(
278
+ return c(
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,
@@ -287,46 +287,66 @@ function W(e) {
287
287
  );
288
288
  }
289
289
  function $(e) {
290
- return window.addEventListener(_, e), () => {
291
- window.removeEventListener(_, e);
290
+ return window.addEventListener(h, e), () => {
291
+ window.removeEventListener(h, e);
292
292
  };
293
293
  }
294
294
  class j {
295
295
  }
296
296
  async function F(e) {
297
- return d(
297
+ return c(
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 c(
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 c(
316
+ e || {},
317
+ p({ minVersion: 80805 }, async () => (await d({
318
+ name: "OpenActRequest",
319
+ params: { type: 60201 }
320
+ })).data)
321
+ );
322
+ }
323
+ function Q(e) {
324
+ return c(
325
+ e || {},
326
+ p({ minVersion: 80805 }, async () => (await d({
327
+ name: "OpenActRequest",
328
+ params: { type: 60210 }
329
+ })).data)
330
+ );
331
+ }
314
332
  export {
315
- C as AppBaseInfo,
333
+ D as AppBaseInfo,
316
334
  G as AppShareModel,
317
335
  j as AuthResult,
318
- l as BridgeCode,
319
- D as IS_KB_APP_ENV,
336
+ f as BridgeCode,
337
+ q as IS_KB_APP_ENV,
320
338
  K as defineAppShareModel,
321
- q as getAppBaseInfo,
339
+ C as getAppBaseInfo,
322
340
  F as getAuthToken,
323
341
  L as getAuthTokenWithSilent,
324
- f as invokeNativeApi,
342
+ d as invokeNativeApi,
325
343
  M as isAppVersionSupport,
326
344
  $ as onAppSharePanelShow,
327
345
  W as openAppSharePanel,
328
346
  k as registerNativeApiHandler,
329
347
  J as reportDAEvent,
348
+ z as requestPayment,
349
+ Q as requestRefund,
330
350
  B as runAction,
331
351
  x as shareImage
332
352
  };
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,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.kbMarket={}))})(this,(function(s){"use strict";const p=class p{constructor(t){this.errorCode=t.errorCode,this.errorMsg=t.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 c=p;const k=()=>{const e=(n,o,r)=>{var u="";typeof o=="function"&&(r=o,o={});var l={data:o===void 0?null:o};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=[],o=setInterval(()=>{t()&&(clearInterval(o),n.forEach(r=>{e.apply(window,r)}),n.length=0)},500);return(...r)=>{n.push(r)}})();var a={default:void 0,callHandler:function(n,o,r){return t()?e(n,o,r):i(n,o,r)},register:function(n,o,r){var u=r?window._dsaf:window._dsf;window._dsInit||(window._dsInit=!0,setTimeout(function(){a.callHandler("_dsb.dsinit")},0)),typeof o=="object"?u._obs[n]=o:u[n]=o},registerHandler:function(n,o){this.register(n,o,!0)}};return(function(){if(!window._dsf){var n={_dsf:{_obs:{}},_dsaf:{_obs:{}},dscb:0,jsBridge:a,_handleMessageFromNative:function(r){var u=JSON.parse(r.data),l={id:r.callbackId,complete:!0},v=this._dsf[r.method],_=this._dsaf[r.method],b=function(m,E){l.data=m.apply(E,u),a.callHandler("_dsb.returnValue",l)},V=function(m,E){u.push(function(X,Y){l.data=X,l.complete=Y!==!1,a.callHandler("_dsb.returnValue",l)}),m.apply(E,u)};if(v)b(v,this._dsf);else if(_)V(_,this._dsaf);else{var g=r.method.split(".");if(g.length<2)return;var I=g.pop(),T=g.join("."),S=this._dsf._obs,A=S[T]||{},h=A[I];if(h&&typeof h=="function"){b(h,A);return}if(S=this._dsaf._obs,A=S[T]||{},h=A[I],h&&typeof h=="function"){V(h,A);return}}}};for(var o in n)window[o]=n[o]}})(),a},P=(e=>/(kb)/i.test(e)?k():{registerHandler(t,i){throw c.UNSUPPORTED_BRIDGE_ENV},callHandler(t,i,a){throw c.UNSUPPORTED_BRIDGE_ENV}})(window?.navigator?.userAgent),N=e=>new Promise((t,i)=>{try{P.registerHandler(e.name,e.handler),e.success?.(),t()}catch(a){e.fail?.(a),i(a)}finally{e.complete?.()}});function d(e){const t=i=>{let a;const n=r=>{(!a||a==="success")&&(a="success",i.success?.(r))},o=r=>{(!a||a==="error")&&(a="error",i.fail?.(r))};i.timeout&&setTimeout(()=>{o(c.TIMEOUT)},i.timeout);try{P.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){o(r)}};return new Promise((i,a)=>{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?.(),a(n)}})})}const M=/(kb_flutter|kb_dsbridge_flutter|kb_ios|kb_android|kb_dsbridge_android)/i.test(window.navigator.userAgent);function f(e,t){return new Promise(async(i,a)=>{try{const n=await t();e.success?.(n),i(n)}catch(n){const o=n?.errorCode?n:new c({errorCode:c.UNKNOWN.errorCode,errorMsg:String(n)});e.fail?.(o),a(o)}finally{e.complete?.()}})}function R(e){let t;return function(...i){return t||(t=e(...i),Promise.resolve(t).catch(()=>{t=void 0}),t)}}const H=R(()=>d({name:"OpenActRequest",params:{type:35,data:{}}}));function O(e){return f(e,async()=>(await H()).vcode>=e.minVersion)}function w(e,t){return(...i)=>O({minVersion:e.minVersion}).then(a=>a?t(...i):Promise.reject(new c({errorCode:c.UNSUPPORTED_VERSION.errorCode,errorMsg:`最低版本要求${e.minVersion}`})))}class q{}const U=R(e=>f(e||{},w({minVersion:80805},()=>d({name:"OpenActRequest",params:{type:60001,data:{}}}))));function D(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};const t={};return Object.keys(e).forEach(i=>{const a=e[i];a!==void 0&&(t[i]=a)}),t}function C(e){return f(e,w({minVersion:80805},async()=>d({name:"OpenActRequest",params:{type:60400,data:D({eventId:e.eventName,trackParams:e.eventParams,ExtEventType:e.eventType})}})))}function B(e){return f({...e},w({minVersion:80805},async()=>d({name:"OpenActRequest",params:{type:60300,data:e}})))}const J=e=>f(e,w({minVersion:80805},async()=>d({name:"OpenActRequest",params:{type:60500,data:e}}))),y="SHARE_EVENT_NAME";class j{}function K(e){return f(e,async()=>N({name:"CommonShare",handler(t,i){window.dispatchEvent(new Event(y)),"onShareApp"in e&&e.onShareApp?i({type:12,data:e.onShareApp()}):i({type:12,data:e})}}))}function W(e){return f(e,w({minVersion:80805},async()=>(window.dispatchEvent(new Event(y)),d({name:"OpenActRequest",params:{type:60500,data:e}}))))}function G(e){return window.addEventListener(y,e),()=>{window.removeEventListener(y,e)}}class ${}async function F(e){return f(e||{},w({minVersion:80805},async()=>(await d({name:"OpenActRequest",params:{type:60101}})).data||null))}function L(e){return f(e||{},w({minVersion:80805},async()=>(await d({name:"OpenActRequest",params:{type:60100}})).data||null))}async function z(e){return f(e||{},w({minVersion:80805},async()=>(await d({name:"OpenActRequest",params:{type:60201}})).data))}function Q(e){return f(e||{},w({minVersion:80805},async()=>(await d({name:"OpenActRequest",params:{type:60210}})).data))}s.AppBaseInfo=q,s.AppShareModel=j,s.AuthResult=$,s.BridgeCode=c,s.IS_KB_APP_ENV=M,s.defineAppShareModel=K,s.getAppBaseInfo=U,s.getAuthToken=F,s.getAuthTokenWithSilent=L,s.invokeNativeApi=d,s.isAppVersionSupport=O,s.onAppSharePanelShow=G,s.openAppSharePanel=W,s.registerNativeApiHandler=N,s.reportDAEvent=C,s.requestPayment=z,s.requestRefund=Q,s.runAction=B,s.shareImage=J,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
@@ -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 })
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.5",
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
  },