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

增加支付成功提示

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