feat(pay/success): 支付成功逻辑处理

This commit is contained in:
woody 2025-07-03 16:44:18 +08:00
parent 2ed0e7b409
commit cb8e6eeb13
4 changed files with 87 additions and 24 deletions

11
App.vue
View File

@ -1,4 +1,3 @@
<script>
import { setToken } from '@/config/auth.js'
export default {
@ -31,13 +30,13 @@ export default {
</script>
<style lang="scss">
body{
background-color: #f2f2f2;
}
body {
background-color: #f2f2f2;
}
/*每个页面公共css */
@import '@/uni_modules/uview-ui/index.scss';
::v-deep .uni-picker-container{
z-index: 100000!important;
::v-deep .uni-picker-container {
z-index: 100000 !important;
}
</style>

50
package-lock.json generated
View File

@ -17,6 +17,7 @@
"js-cookie": "^3.0.5",
"qrcodejs2": "0.0.2",
"swiper": "^3.4.2",
"vconsole": "^3.15.1",
"vue-clipboard2": "^0.3.3",
"vue-i18n": "^9.2.2",
"vue-tree-color": "^2.3.2",
@ -62,6 +63,15 @@
"node": ">=6.0.0"
}
},
"node_modules/@babel/runtime": {
"version": "7.27.6",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz",
"integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/types": {
"version": "7.27.0",
"resolved": "https://mirrors.cloud.tencent.com/npm/@babel/types/-/types-7.27.0.tgz",
@ -1819,6 +1829,29 @@
"node": ">=0.10.0"
}
},
"node_modules/copy-text-to-clipboard": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.0.tgz",
"integrity": "sha512-RnJFp1XR/LOBDckxTib5Qjr/PMfkatD0MUCQgdpqS8MdKiNUzBjAQBEN6oUy+jW7LI93BBG3DtMB2KOOKpGs2Q==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/core-js": {
"version": "3.43.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.43.0.tgz",
"integrity": "sha512-N6wEbTTZSYOY2rYAn85CuvWWkCK6QweMn7/4Nr3w+gDBeBhk/x4EJeY6FPo4QzDoJZxVTv8U7CMvgWk6pOHHqA==",
"hasInstallScript": true,
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/core-util-is": {
"version": "1.0.3",
"resolved": "https://mirrors.cloud.tencent.com/npm/core-util-is/-/core-util-is-1.0.3.tgz",
@ -4349,6 +4382,11 @@
"dev": true,
"peer": true
},
"node_modules/mutation-observer": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/mutation-observer/-/mutation-observer-1.0.3.tgz",
"integrity": "sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA=="
},
"node_modules/nan": {
"version": "2.22.2",
"resolved": "https://mirrors.cloud.tencent.com/npm/nan/-/nan-2.22.2.tgz",
@ -6455,6 +6493,18 @@
"base64-arraybuffer": "^1.0.2"
}
},
"node_modules/vconsole": {
"version": "3.15.1",
"resolved": "https://registry.npmjs.org/vconsole/-/vconsole-3.15.1.tgz",
"integrity": "sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.17.2",
"copy-text-to-clipboard": "^3.0.1",
"core-js": "^3.11.0",
"mutation-observer": "^1.0.3"
}
},
"node_modules/vm-browserify": {
"version": "1.1.2",
"resolved": "https://mirrors.cloud.tencent.com/npm/vm-browserify/-/vm-browserify-1.1.2.tgz",

View File

@ -12,6 +12,7 @@
"js-cookie": "^3.0.5",
"qrcodejs2": "0.0.2",
"swiper": "^3.4.2",
"vconsole": "^3.15.1",
"vue-clipboard2": "^0.3.3",
"vue-i18n": "^9.2.2",
"vue-tree-color": "^2.3.2",

View File

@ -45,7 +45,8 @@ import { mapGetters } from 'vuex'
import { payStatus, registerInfo } from '@/config/pay.js'
import successDialog from '@/components/successDialog.vue'
let setTimeoutFlag = null
let paySetTimeoutFlag = null
let getRegisterInfoTimeoutFlag = null
export default {
name: 'PaySuccess',
components: {
@ -76,38 +77,50 @@ export default {
this.specialArea = extParam.specialArea
this.isRecharge = extParam.source
this.orderCode = extParam.orderCode || ''
this.orderCode && this.pollingPayStatus(this.orderCode)
if (this.orderCode) {
setTimeout(() => {
this.pollingPayStatus(this.orderCode)
}, 500)
}
//
uni.setNavigationBarTitle({
title: '支付成功',
})
},
onUnload() {
clearTimeout(setTimeoutFlag)
clearTimeout(paySetTimeoutFlag)
clearTimeout(getRegisterInfoTimeoutFlag)
},
methods: {
getRegisterInfo() {
registerInfo(this.orderCode).then(res => {
if (res.data) {
uni.hideLoading()
this.$refs.successDialog.showSuccess(res.data)
} else {
getRegisterInfoTimeoutFlag = setTimeout(() => {
this.getRegisterInfo()
}, 3000)
}
})
},
pollingPayStatus(orderCode) {
payStatus({ businessCode: orderCode }).then(res => {
if (res.data == 1) {
//
clearTimeout(setTimeoutFlag)
clearTimeout(paySetTimeoutFlag)
if ([1, 7, 24].includes(Number(this.specialArea))) {
uni.showLoading({
title: '注册信息加载中...',
mask: false,
})
setTimeout(() => {
registerInfo(orderCode).then(res => {
this.$refs.successDialog.showSuccess(res.data)
})
}, 300)
this.getRegisterInfo()
}, 2000)
}
} else {
payStatus({ businessCode: orderCode }).then(res => {
if (res.data == 0) {
setTimeoutFlag = setTimeout(() => {
this.pollingPayStatus(orderCode)
}, 1000)
} else {
clearTimeout(setTimeoutFlag)
}
})
paySetTimeoutFlag = setTimeout(() => {
this.pollingPayStatus(orderCode)
}, 1000)
}
})
},