|
|
@ -2,12 +2,14 @@
|
|
|
|
<div class="payment">
|
|
|
|
<div class="payment">
|
|
|
|
<nav-bar title="购物车" />
|
|
|
|
<nav-bar title="购物车" />
|
|
|
|
<!-- closeable 模式,在右侧显示关闭按钮 -->
|
|
|
|
<!-- closeable 模式,在右侧显示关闭按钮 -->
|
|
|
|
<van-notice-bar mode="closeable">请在半小时内完成付款,否则系统自动取消订单</van-notice-bar>
|
|
|
|
<van-notice-bar
|
|
|
|
|
|
|
|
mode="closeable"
|
|
|
|
|
|
|
|
>请在半小时内完成付款,否则系统自动取消订单</van-notice-bar>
|
|
|
|
|
|
|
|
|
|
|
|
<van-cell-group class="payment_group">
|
|
|
|
<van-cell-group class="payment_group">
|
|
|
|
<van-cell title="订单编号" :value="order.orderSn" />
|
|
|
|
<van-cell title="订单编号" :value="orderSn" />
|
|
|
|
<van-cell title="实付金额">
|
|
|
|
<van-cell title="实付金额">
|
|
|
|
<span class="red">{{ order.actualPrice | yuan }}</span>
|
|
|
|
<span class="red">{{ actualPrice | yuan }}</span>
|
|
|
|
</van-cell>
|
|
|
|
</van-cell>
|
|
|
|
</van-cell-group>
|
|
|
|
</van-cell-group>
|
|
|
|
|
|
|
|
|
|
|
@ -17,13 +19,23 @@
|
|
|
|
<van-cell-group>
|
|
|
|
<van-cell-group>
|
|
|
|
<van-cell>
|
|
|
|
<van-cell>
|
|
|
|
<template slot="title">
|
|
|
|
<template slot="title">
|
|
|
|
<img src="../../../assets/images/ali_pay.png" alt="支付宝" width="82" height="29">
|
|
|
|
<img
|
|
|
|
|
|
|
|
src="../../../assets/images/ali_pay.png"
|
|
|
|
|
|
|
|
alt="支付宝"
|
|
|
|
|
|
|
|
width="82"
|
|
|
|
|
|
|
|
height="29"
|
|
|
|
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<van-radio name="ali" />
|
|
|
|
<van-radio name="ali" />
|
|
|
|
</van-cell>
|
|
|
|
</van-cell>
|
|
|
|
<van-cell>
|
|
|
|
<van-cell>
|
|
|
|
<template slot="title">
|
|
|
|
<template slot="title">
|
|
|
|
<img src="../../../assets/images/wx_pay.png" alt="微信支付" width="113" height="23">
|
|
|
|
<img
|
|
|
|
|
|
|
|
src="../../../assets/images/wx_pay.png"
|
|
|
|
|
|
|
|
alt="微信支付"
|
|
|
|
|
|
|
|
width="113"
|
|
|
|
|
|
|
|
height="23"
|
|
|
|
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<van-radio name="wx" />
|
|
|
|
<van-radio name="wx" />
|
|
|
|
</van-cell>
|
|
|
|
</van-cell>
|
|
|
@ -31,12 +43,21 @@
|
|
|
|
</van-radio-group>
|
|
|
|
</van-radio-group>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<van-button class="pay_submit" type="primary" bottom-action @click="pay">去支付</van-button>
|
|
|
|
<van-button
|
|
|
|
|
|
|
|
class="pay_submit"
|
|
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
|
|
bottom-action
|
|
|
|
|
|
|
|
@click="pay"
|
|
|
|
|
|
|
|
>去支付</van-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import { orderDetail, orderPrepay, orderH5pay, testPayNotify } from '@/api/order'
|
|
|
|
import {
|
|
|
|
|
|
|
|
orderPrepay,
|
|
|
|
|
|
|
|
orderH5pay,
|
|
|
|
|
|
|
|
testPayNotify
|
|
|
|
|
|
|
|
} from '@/api/order'
|
|
|
|
import _ from 'lodash'
|
|
|
|
import _ from 'lodash'
|
|
|
|
import { getLocalStorage, setLocalStorage } from '@/utils/localStorage'
|
|
|
|
import { getLocalStorage, setLocalStorage } from '@/utils/localStorage'
|
|
|
|
|
|
|
|
|
|
|
@ -46,32 +67,29 @@ export default {
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
payWay: 'wx',
|
|
|
|
payWay: 'wx',
|
|
|
|
order: {},
|
|
|
|
orderSn: undefined,
|
|
|
|
orderId: 0
|
|
|
|
actualPrice: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
created() {
|
|
|
|
if (_.has(this.$route.params, 'orderId')) {
|
|
|
|
if (_.has(this.$route.params, 'orderSn')) {
|
|
|
|
this.orderId = this.$route.params.orderId
|
|
|
|
this.orderSn = this.$route.params.orderSn
|
|
|
|
this.getOrder(this.orderId)
|
|
|
|
this.actualPrice = this.$route.params.actualPrice
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
methods: {
|
|
|
|
getOrder(orderId) {
|
|
|
|
|
|
|
|
orderDetail({ orderId }).then((res) => {
|
|
|
|
|
|
|
|
this.order = res.map.data
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
pay() {
|
|
|
|
pay() {
|
|
|
|
this.$dialog.alert({
|
|
|
|
this.$dialog
|
|
|
|
|
|
|
|
.alert({
|
|
|
|
message:
|
|
|
|
message:
|
|
|
|
'你选择了' + (this.payWay === 'wx' ? '微信支付' : '支付宝支付')
|
|
|
|
'你选择了' + (this.payWay === 'wx' ? '微信支付' : '支付宝支付')
|
|
|
|
}).then(() => {
|
|
|
|
})
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
if (this.payWay === 'wx') {
|
|
|
|
if (this.payWay === 'wx') {
|
|
|
|
const ua = navigator.userAgent.toLowerCase()
|
|
|
|
const ua = navigator.userAgent.toLowerCase()
|
|
|
|
const isWeixin = ua.indexOf('micromessenger') !== -1
|
|
|
|
const isWeixin = ua.indexOf('micromessenger') !== -1
|
|
|
|
if (isWeixin) {
|
|
|
|
if (isWeixin) {
|
|
|
|
orderPrepay({ orderId: this.orderId })
|
|
|
|
orderPrepay({ orderSn: this.orderSn })
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
const data = res.map.result
|
|
|
|
const data = res.map.result
|
|
|
|
const prepayData = JSON.stringify({
|
|
|
|
const prepayData = JSON.stringify({
|
|
|
@ -115,7 +133,7 @@ export default {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
orderH5pay({ orderId: this.orderId })
|
|
|
|
orderH5pay({ orderSn: this.orderSn })
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
const data = res.map.data
|
|
|
|
const data = res.map.data
|
|
|
|
window.location.replace(
|
|
|
|
window.location.replace(
|
|
|
@ -123,8 +141,8 @@ export default {
|
|
|
|
'&redirect_url=' +
|
|
|
|
'&redirect_url=' +
|
|
|
|
encodeURIComponent(
|
|
|
|
encodeURIComponent(
|
|
|
|
window.location.origin +
|
|
|
|
window.location.origin +
|
|
|
|
'/#/?orderId=' +
|
|
|
|
'/#/?orderSn=' +
|
|
|
|
this.orderId +
|
|
|
|
this.orderSn +
|
|
|
|
'&tip=yes'
|
|
|
|
'&tip=yes'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -142,7 +160,7 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// todo : alipay
|
|
|
|
// todo : alipay
|
|
|
|
testPayNotify(this.orderId)
|
|
|
|
testPayNotify(this.orderSn)
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
|
this.$router.replace({
|
|
|
|
this.$router.replace({
|
|
|
|
name: 'PayStatus',
|
|
|
|
name: 'PayStatus',
|
|
|
@ -198,7 +216,6 @@ export default {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
@ -209,11 +226,11 @@ $mb2vw: 2vw;
|
|
|
|
background: #f5f5f5;
|
|
|
|
background: #f5f5f5;
|
|
|
|
|
|
|
|
|
|
|
|
.van-notice-bar {
|
|
|
|
.van-notice-bar {
|
|
|
|
margin-bottom: $mb2vw
|
|
|
|
margin-bottom: $mb2vw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.payment_group {
|
|
|
|
.payment_group {
|
|
|
|
margin-bottom: $mb2vw
|
|
|
|
margin-bottom: $mb2vw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.pay_submit {
|
|
|
|
.pay_submit {
|
|
|
|