提交 456e7df4 authored 作者: pengxiaohui's avatar pengxiaohui

增加支付成功提示

上级 a27c6dca
......@@ -25,8 +25,8 @@
</div>
</template>
<script>
import { getOrderDetails, checkPayStatus } from '@/api/common'
import { getNonce } from '@/utils/utils'
import { getOrderDetails } from '@/api/common'
import { Toast } from 'vant'
const payTypeMap = {
0: '',
3: '微信支付',
......@@ -38,7 +38,8 @@ export default {
data() {
return {
details: {},
orderDetailId: ''
orderDetailId: '',
isPayBack: false
}
},
computed: {
......@@ -55,12 +56,12 @@ export default {
}
},
created() {
console.log(window.localStorage)
console.log('order_detail_id: ', window.localStorage.getItem('order_detail_id'))
if (this.$route.query.od_id) {
this.orderDetailId = this.$route.query.od_id
this.isPayBack = false
} else {
this.orderDetailId = window.localStorage.getItem('order_detail_id') || '6806478305244479488'
this.isPayBack = true
}
this.fetchOrderDetails()
},
......@@ -84,22 +85,14 @@ export default {
this.fetchOrderStatus()
}, 3000)
},
fetchOrderStatus() {
const params = {
timestamp: parseInt(Date.now() / 1000),
nonce: getNonce(12),
signature: 'UG7wBenexQhiuD2wpCwuxkU0jqcj006d',
order_id: this.payOrderId
}
checkPayStatus(params).then(res => {
if (res.code === '0' && res.msg === '成功') {}
})
},
fetchOrderDetails() {
getOrderDetails({ order_detail_id: this.orderDetailId }).then(res => {
if (res.code === 0 && Array.isArray(res.data)) {
const [first = {}] = res.data
this.details = first
if (this.isPayBack) {
if (this.details.order_status === 2) Toast.success('购买商品成功')
}
}
})
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论