|
@@ -7,6 +7,9 @@
|
|
|
<div>
|
|
|
订单编号:{{payInfo.id}}
|
|
|
</div>
|
|
|
+
|
|
|
+ <div class="j-button-confirm mock-test-pay" @click="doTestPay">测试-模拟支付</div>
|
|
|
+
|
|
|
</div>
|
|
|
<div class="j-footer">
|
|
|
<div class="j-button-group">
|
|
@@ -21,7 +24,9 @@
|
|
|
|
|
|
<script>
|
|
|
import Taro from "@tarojs/taro";
|
|
|
-import { ajaxGetPayConfig } from "@/api/modules/common";
|
|
|
+import { showLoading, showToast } from '@/utils'
|
|
|
+import { ajaxGetPayConfig, ajaxTestPay, ajaxGetOrderStatus } from "@/api/modules/common";
|
|
|
+import {mapActions} from "vuex";
|
|
|
|
|
|
export default {
|
|
|
data () {
|
|
@@ -39,7 +44,9 @@ export default {
|
|
|
this.getOrderInfo(this.payInfo.id)
|
|
|
},
|
|
|
methods: {
|
|
|
- doBack () {
|
|
|
+ ...mapActions('tabbar', ['doSwitchTab']),
|
|
|
+ doBack (type = false) {
|
|
|
+ const _this = this
|
|
|
Taro.navigateBackMiniProgram({
|
|
|
extraData: {
|
|
|
foo: 'bar'
|
|
@@ -49,7 +56,13 @@ export default {
|
|
|
},
|
|
|
fail: function (err) {
|
|
|
console.log(err)
|
|
|
- Taro.navigateBack()
|
|
|
+ if (type === true && _this.payInfo?.back > 0) {
|
|
|
+ Taro.navigateBack({
|
|
|
+ delta: Number(_this.payInfo.back)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ Taro.navigateBack()
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -84,6 +97,38 @@ export default {
|
|
|
this.canPayTip = '请重新下单'
|
|
|
})
|
|
|
},
|
|
|
+ doTestPay () {
|
|
|
+ ajaxTestPay({
|
|
|
+ ordercode: this.payInfo.id
|
|
|
+ }).then(res => {
|
|
|
+ console.log('res', res)
|
|
|
+ this.checkStatus()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ checkStatus () {
|
|
|
+ const loading = showLoading('检查订单状态')
|
|
|
+ ajaxGetOrderStatus({
|
|
|
+ orderCode: this.payInfo.id
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ loading.clear()
|
|
|
+ if (res?.data === true) {
|
|
|
+ Taro.showToast({
|
|
|
+ title: '支付成功',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ this.doBack(true)
|
|
|
+ }, 1500)
|
|
|
+ } else {
|
|
|
+ showToast('支付未完成')
|
|
|
+ }
|
|
|
+ }).catch(e => {
|
|
|
+ console.log(e)
|
|
|
+ loading.clear()
|
|
|
+ showToast('支付未完成')
|
|
|
+ })
|
|
|
+ },
|
|
|
doPay () {
|
|
|
try {
|
|
|
const payment = Object.assign({
|
|
@@ -96,15 +141,9 @@ export default {
|
|
|
}, this.payParams)
|
|
|
Taro.requestPayment({
|
|
|
...payment,
|
|
|
- success: function (res) {
|
|
|
+ success: (res) => {
|
|
|
console.log('ok', JSON.stringify(res))
|
|
|
- Taro.showToast({
|
|
|
- title: '支付成功',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- this.doBack()
|
|
|
- }, 1500)
|
|
|
+ this.checkStatus()
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(JSON.stringify(res))
|
|
@@ -184,6 +223,12 @@ export default {
|
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
|
}
|
|
|
+ .mock-test-pay {
|
|
|
+ width: 200px;
|
|
|
+ max-height: 50px;
|
|
|
+ margin: 40px;
|
|
|
+ margin-left: 80px;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
</style>
|