feat(我的订单):对接支付宝支付

This commit is contained in:
wangsongsole 2022-09-29 16:35:37 +08:00
parent 972d2e544a
commit befa09d2f3
1 changed files with 29 additions and 9 deletions

View File

@ -31,9 +31,7 @@
</p>
</div>
<div class="middle">
<img :src="item.show_url" alt="" v-if="item.type===1">
<img :src="`http://lsxdemall.oss-cn-beijing.aliyuncs.com/commonproductlogo/${item.pay_type===1?'zfbreduce':'wxreduce'}.png`"
alt="" v-else>
<img :src="item.show_url" alt="">
<div class="right">
<div class="title_originalPrice">
<p class="title">{{item.product_name}}</p>
@ -58,6 +56,7 @@
<!-- 支付弹窗 -->
<pay-pop :show.sync="show" :active="active" @payFunction="payFunction" :money="activeOrder.pay_amount" />
<div></div>
</div>
<script>
@ -70,7 +69,7 @@
limit: 50,
page: 1,
orderList: [],
activeOrder: {}
activeOrder: {},
}
},
@ -116,15 +115,18 @@
window.location.replace('./couponCollection.html');
},
/* 立即支付 */
/* 立即支付按钮 */
immediatelyPay (item) {
this.activeOrder = item;
this.show = true
this.active = item.pay_type === 5 ? 1 : 2
},
/* 去支付 */
payFunction ({ payType, isSupport }) {
this.active = payType
/* payType 1:微信 2:支付宝 */
/* 后端 微信是5 */
this.active = payType === 2 ? 1 : 5
this.show = false
/* 判断浏览器 */
if (isSupport) {
@ -134,10 +136,28 @@
this.popShow = true
return
}
/* 请求支付 */
req.axiosPut(`/key/order/setPayType/${this.activeOrder.order_number}/${payType}`).then(({ data, code }) => {
/* 设置支付类型 */
if (this.active !== this.activeOrder.pay_type) { /* 支付类型是否变化 */
req.axiosPut(`/key/order/setPayType/${this.activeOrder.order_number}/${this.active}`).then(({ code }) => {
if (code === 200) {
console.log(data);
this.getOrderList()
this.payRealFunction()
}
})
} else {
this.payRealFunction()
}
},
/* 调用支付 */
payRealFunction () {
req.axiosGet(`/key/coupon/createPay/${this.activeOrder.order_number}`).then(({ code, data }) => {
if (code === 200) {
const div = document.createElement('div')//创建div
div.innerHTML = data//将返回的form 放入div
document.body.appendChild(div);
document.forms[0].submit();
}
})
},