@tplc/business 0.4.197 → 0.4.199
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/CHANGELOG.md +4 -0
- package/global.d.ts +1 -0
- package/hooks/usePay.ts +23 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.4.199](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.4.198...v0.4.199) (2025-09-27)
|
|
6
|
+
|
|
7
|
+
### [0.4.198](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.4.197...v0.4.198) (2025-09-27)
|
|
8
|
+
|
|
5
9
|
### [0.4.197](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.4.196...v0.4.197) (2025-09-27)
|
|
6
10
|
|
|
7
11
|
### [0.4.196](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.4.195...v0.4.196) (2025-09-27)
|
package/global.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ declare module 'vue' {
|
|
|
50
50
|
'lcb-waterfall': (typeof import('@tplc/business/components/lcb-waterfall/lcb-waterfall.vue'))['default']
|
|
51
51
|
'lcb-wrapper-item': (typeof import('@tplc/business/components/lcb-wrapper-item/lcb-wrapper-item.vue'))['default']
|
|
52
52
|
'lcb-wrapper-list': (typeof import('@tplc/business/components/lcb-wrapper-list/lcb-wrapper-list.vue'))['default']
|
|
53
|
+
'lcb-custom-content': (typeof import('@tplc/business/components/lcb-custom-content/lcb-custom-content.vue'))['default']
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|
package/hooks/usePay.ts
CHANGED
|
@@ -2,24 +2,39 @@ import { commitOrder, queryOrderPaymentStatus, type CommitPageDetailParams } fro
|
|
|
2
2
|
import { onPageHide } from '@dcloudio/uni-app'
|
|
3
3
|
import { IResData } from '../action'
|
|
4
4
|
import { ref } from 'vue'
|
|
5
|
-
import { useRequest } from 'vue-hooks-plus'
|
|
6
5
|
|
|
7
6
|
const usePay = (
|
|
8
7
|
fun?: (data: unknown) => Promise<IResData<any>>,
|
|
9
8
|
queryStatusFun?: (orderNo: string) => Promise<any>,
|
|
10
9
|
) => {
|
|
11
10
|
const successFun = ref()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
let pollingTimer: NodeJS.Timeout | null = null
|
|
12
|
+
|
|
13
|
+
const runAsync = async (orderNo: string) => {
|
|
14
|
+
try {
|
|
15
|
+
const result = await (queryStatusFun || queryOrderPaymentStatus)(orderNo)
|
|
16
|
+
if (result.status === 1) {
|
|
17
17
|
uni.hideLoading()
|
|
18
18
|
cancel()
|
|
19
19
|
successFun.value?.()
|
|
20
|
+
} else {
|
|
21
|
+
// 继续轮询
|
|
22
|
+
pollingTimer = setTimeout(() => {
|
|
23
|
+
runAsync(orderNo)
|
|
24
|
+
}, 1000)
|
|
20
25
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
26
|
+
} catch (error) {
|
|
27
|
+
// 出错时停止轮询
|
|
28
|
+
cancel()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const cancel = () => {
|
|
33
|
+
if (pollingTimer) {
|
|
34
|
+
clearTimeout(pollingTimer)
|
|
35
|
+
pollingTimer = null
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
const pay = async (
|
|
24
39
|
data: CommitPageDetailParams,
|
|
25
40
|
options?: {
|