@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 +109 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +169 -146
- package/dist/index.umd.js +1 -1
- package/dist/lib/auth-token.d.ts +1 -1
- package/dist/lib/get-app-base-info.d.ts +1 -1
- package/dist/lib/payment.d.ts +98 -0
- package/dist/lib/report-da-event.d.ts +1 -1
- package/dist/lib/run-action.d.ts +1 -1
- package/dist/lib/share-image.d.ts +1 -1
- package/dist/lib/share-model.d.ts +1 -1
- package/dist/util/filter-undefined-properties.d.ts +3 -5
- package/examples/index.html +90 -3
- package/package.json +2 -2
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
443
|
+
> @version 开吧 APP:80805 开始支持,低版本需开发者做兼容处理
|
|
442
444
|
|
|
443
445
|
#### 请求参数
|
|
444
446
|
|
|
@@ -475,7 +477,7 @@ openAppSharePanel({
|
|
|
475
477
|
|
|
476
478
|
> 监听分享面板打开时触发(主动和被动)
|
|
477
479
|
|
|
478
|
-
> @version 开吧 APP:
|
|
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:
|
|
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:
|
|
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:
|
|
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
package/dist/index.es.js
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
15
|
+
l.UNKNOWN = new l({
|
|
7
16
|
errorCode: 1e3,
|
|
8
17
|
errorMsg: "未知错误"
|
|
9
|
-
}),
|
|
18
|
+
}), l.UNSUPPORTED_VERSION = new l({
|
|
10
19
|
errorCode: 1001,
|
|
11
20
|
errorMsg: "当前开吧版本不支持"
|
|
12
|
-
}),
|
|
21
|
+
}), l.TIMEOUT = new l({
|
|
13
22
|
errorCode: 1002,
|
|
14
23
|
errorMsg: "执行超时"
|
|
15
|
-
}),
|
|
24
|
+
}), l.UNSUPPORTED_BRIDGE_ENV = new l({
|
|
16
25
|
errorCode: 1003,
|
|
17
26
|
errorMsg: "请在开吧app内执行"
|
|
18
27
|
});
|
|
19
|
-
let
|
|
20
|
-
const
|
|
21
|
-
const e = (t, s,
|
|
28
|
+
let f = l;
|
|
29
|
+
const k = () => {
|
|
30
|
+
const e = (t, s, i) => {
|
|
22
31
|
var a = "";
|
|
23
|
-
typeof s == "function" && (
|
|
32
|
+
typeof s == "function" && (i = s, s = {});
|
|
24
33
|
var c = { data: s === void 0 ? null : s };
|
|
25
|
-
if (typeof
|
|
34
|
+
if (typeof i == "function") {
|
|
26
35
|
var v = "dscb" + window.dscb++;
|
|
27
|
-
window[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
|
-
},
|
|
45
|
+
}, n = () => window.navigator.userAgent.includes("Android") ? window.flutter_inappwebview && window.flutter_inappwebview._platformReady : !0, o = (() => {
|
|
37
46
|
const t = [], s = setInterval(() => {
|
|
38
|
-
|
|
39
|
-
e.apply(window,
|
|
47
|
+
n() && (clearInterval(s), t.forEach((i) => {
|
|
48
|
+
e.apply(window, i);
|
|
40
49
|
}), t.length = 0);
|
|
41
50
|
}, 500);
|
|
42
|
-
return (...
|
|
43
|
-
t.push(
|
|
51
|
+
return (...i) => {
|
|
52
|
+
t.push(i);
|
|
44
53
|
};
|
|
45
54
|
})();
|
|
46
|
-
var
|
|
55
|
+
var r = {
|
|
47
56
|
default: void 0,
|
|
48
57
|
// for typescript
|
|
49
|
-
callHandler: function(t, s,
|
|
50
|
-
return
|
|
58
|
+
callHandler: function(t, s, i) {
|
|
59
|
+
return n() ? e(t, s, i) : o(t, s, i);
|
|
51
60
|
},
|
|
52
|
-
register: function(t, s,
|
|
53
|
-
var a =
|
|
61
|
+
register: function(t, s, i) {
|
|
62
|
+
var a = i ? window._dsaf : window._dsf;
|
|
54
63
|
window._dsInit || (window._dsInit = !0, setTimeout(function() {
|
|
55
|
-
|
|
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:
|
|
75
|
-
_handleMessageFromNative: function(
|
|
76
|
-
var a = JSON.parse(
|
|
77
|
-
id:
|
|
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[
|
|
80
|
-
c.data = E.apply(
|
|
81
|
-
},
|
|
82
|
-
a.push(function(
|
|
83
|
-
c.data =
|
|
84
|
-
}), E.apply(
|
|
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
|
-
|
|
88
|
-
else if (
|
|
89
|
-
|
|
96
|
+
S(v, this._dsf);
|
|
97
|
+
else if (_)
|
|
98
|
+
O(_, this._dsaf);
|
|
90
99
|
else {
|
|
91
|
-
var A =
|
|
100
|
+
var A = i.method.split(".");
|
|
92
101
|
if (A.length < 2) return;
|
|
93
|
-
var
|
|
94
|
-
if (
|
|
95
|
-
|
|
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,
|
|
99
|
-
|
|
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
|
-
})(),
|
|
109
|
-
},
|
|
110
|
-
registerHandler(
|
|
111
|
-
throw
|
|
117
|
+
})(), r;
|
|
118
|
+
}, P = ((e) => /(kb)/i.test(e) ? k() : {
|
|
119
|
+
registerHandler(n, o) {
|
|
120
|
+
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
112
121
|
},
|
|
113
|
-
callHandler(
|
|
114
|
-
throw
|
|
122
|
+
callHandler(n, o, r) {
|
|
123
|
+
throw f.UNSUPPORTED_BRIDGE_ENV;
|
|
115
124
|
}
|
|
116
|
-
})(window?.navigator?.userAgent),
|
|
125
|
+
})(window?.navigator?.userAgent), H = (e) => new Promise((n, o) => {
|
|
117
126
|
try {
|
|
118
|
-
|
|
119
|
-
} catch (
|
|
120
|
-
e.fail?.(
|
|
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
|
|
126
|
-
const
|
|
127
|
-
let
|
|
128
|
-
const t = (
|
|
129
|
-
(!
|
|
130
|
-
}, s = (
|
|
131
|
-
(!
|
|
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
|
-
|
|
134
|
-
s(
|
|
135
|
-
},
|
|
142
|
+
o.timeout && setTimeout(() => {
|
|
143
|
+
s(f.TIMEOUT);
|
|
144
|
+
}, o.timeout);
|
|
136
145
|
try {
|
|
137
|
-
|
|
146
|
+
P.callHandler(o.name, o.params, (i) => {
|
|
138
147
|
let a;
|
|
139
148
|
try {
|
|
140
|
-
a = typeof
|
|
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 (
|
|
147
|
-
s(
|
|
155
|
+
} catch (i) {
|
|
156
|
+
s(i);
|
|
148
157
|
}
|
|
149
158
|
};
|
|
150
|
-
return new Promise((
|
|
151
|
-
|
|
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?.(),
|
|
165
|
+
e.success?.(t), e.complete?.(), o(t);
|
|
157
166
|
},
|
|
158
167
|
fail: (t) => {
|
|
159
|
-
e.fail?.(t), e.complete?.(),
|
|
168
|
+
e.fail?.(t), e.complete?.(), r(t);
|
|
160
169
|
}
|
|
161
170
|
});
|
|
162
171
|
});
|
|
163
172
|
}
|
|
164
|
-
const
|
|
165
|
-
function
|
|
166
|
-
return new Promise(async (
|
|
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
|
|
169
|
-
e.success?.(t),
|
|
177
|
+
const t = await n();
|
|
178
|
+
e.success?.(t), o(t);
|
|
170
179
|
} catch (t) {
|
|
171
|
-
const s = t?.errorCode ? t : new
|
|
172
|
-
e.fail?.(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
|
|
179
|
-
let
|
|
180
|
-
return function(...
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
}),
|
|
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
|
|
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
|
|
195
|
-
return
|
|
203
|
+
function U(e) {
|
|
204
|
+
return u(e, async () => (await M()).vcode >= e.minVersion);
|
|
196
205
|
}
|
|
197
|
-
function
|
|
198
|
-
return (...
|
|
206
|
+
function p(e, n) {
|
|
207
|
+
return (...o) => U({
|
|
199
208
|
minVersion: e.minVersion
|
|
200
|
-
}).then((
|
|
201
|
-
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
|
|
214
|
+
class D {
|
|
206
215
|
}
|
|
207
|
-
const
|
|
216
|
+
const C = V((e) => u(
|
|
208
217
|
e || {},
|
|
209
|
-
|
|
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
|
|
218
|
-
|
|
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
|
-
|
|
229
|
+
p({ minVersion: 80805 }, async () => d({
|
|
230
230
|
name: "OpenActRequest",
|
|
231
231
|
params: {
|
|
232
232
|
type: 60400,
|
|
233
|
-
data:
|
|
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
|
|
246
|
-
return
|
|
245
|
+
function J(e) {
|
|
246
|
+
return u(
|
|
247
247
|
{ ...e },
|
|
248
|
-
|
|
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
|
|
257
|
+
const B = (e) => u(
|
|
258
258
|
e,
|
|
259
|
-
|
|
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
|
-
),
|
|
267
|
-
class
|
|
266
|
+
), h = "SHARE_EVENT_NAME";
|
|
267
|
+
class x {
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
269
|
+
function G(e) {
|
|
270
|
+
return u(e, async () => H({
|
|
271
271
|
name: "CommonShare",
|
|
272
|
-
handler(
|
|
273
|
-
window.dispatchEvent(new Event(
|
|
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
|
|
278
|
-
return
|
|
277
|
+
function K(e) {
|
|
278
|
+
return u(
|
|
279
279
|
e,
|
|
280
|
-
|
|
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
|
|
290
|
-
return window.addEventListener(
|
|
291
|
-
window.removeEventListener(
|
|
289
|
+
function W(e) {
|
|
290
|
+
return window.addEventListener(h, e), () => {
|
|
291
|
+
window.removeEventListener(h, e);
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
|
-
class
|
|
294
|
+
class $ {
|
|
295
295
|
}
|
|
296
296
|
async function F(e) {
|
|
297
|
-
return
|
|
297
|
+
return u(
|
|
298
298
|
e || {},
|
|
299
|
-
|
|
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
|
|
306
|
+
return u(
|
|
307
307
|
e || {},
|
|
308
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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(
|
|
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"})}));
|
package/dist/lib/auth-token.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class AuthResult {
|
|
|
14
14
|
* @description 获取开吧 登录授权凭证, 当app未登录, 则会唤起登录, 登录成功后返回token
|
|
15
15
|
*
|
|
16
16
|
* ⚠️ **重要异常提示**:在用户取消登录的某些场景下,该函数可能出现「无任何回调」的情况(`success` 和 `fail` 回调均不会触发),请开发者做好兜底处理。
|
|
17
|
-
* @version 开吧APP:
|
|
17
|
+
* @version 开吧APP:80805开始支持,低版本需开发者做兼容处理
|
|
18
18
|
* @example
|
|
19
19
|
* **示例代码**
|
|
20
20
|
```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
|
+
}>;
|
package/dist/lib/run-action.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 递归过滤对象中所有层级的 undefined 和 null 属性
|
|
3
3
|
* @param obj 待过滤的对象(仅支持纯对象,不支持数组/非对象类型)
|
|
4
|
-
* @returns
|
|
4
|
+
* @returns 过滤后的新对象(自动剔除所有层级的 undefined 和 null 值)
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
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;
|
package/examples/index.html
CHANGED
|
@@ -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 {
|
|
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.
|
|
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
|
|
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
|
},
|