下单调整

master
hequan_waynaqua 4 years ago
parent f46d7b5a13
commit d71f7d78b3

@ -7,9 +7,14 @@
<div v-for="(item, idx) in goodsList" :key="idx" class="item"> <div v-for="(item, idx) in goodsList" :key="idx" class="item">
<image-pic width="80" height="80" fit="fill" :src="item.picUrl" /> <image-pic width="80" height="80" fit="fill" :src="item.picUrl" />
<div class="item__main"> <div class="item__main">
<p class="item__main__desc van-multi-ellipsis--l2">{{ item.goodsName }}</p> <p class="item__main__desc van-multi-ellipsis--l2">
{{ item.goodsName }}
</p>
<p class="item__main__attr"> <p class="item__main__attr">
<span v-for="(specification, index) in item.specifications" :key="index">{{ specification }}</span> <span
v-for="(specification, index) in item.specifications"
:key="index"
>{{ specification }}</span>
</p> </p>
</div> </div>
<div class="item__price"> <div class="item__price">
@ -82,8 +87,11 @@ export default {
const message = this.message const message = this.message
const userId = this.id const userId = this.id
submit({ cartIdArr, addressId, userId, message }).then((res) => { submit({ cartIdArr, addressId, userId, message }).then((res) => {
const { orderId } = res.map const { orderSn, actualPrice } = res.map
this.$router.push({ name: 'OrderPay', params: { orderId }}) this.$router.push({
name: 'OrderPay',
params: { orderSn, actualPrice }
})
}) })
} }
} }

@ -65,7 +65,7 @@
v-if="el.handleOption.pay" v-if="el.handleOption.pay"
size="small" size="small"
type="danger" type="danger"
@click.stop="toPay(el.id)" @click.stop="toPay(el.orderSn, el.actualPrice)"
>去支付</van-button> >去支付</van-button>
<van-button <van-button
v-if="el.handleOption.refund" v-if="el.handleOption.refund"
@ -205,8 +205,8 @@ export default {
.catch(() => {}) .catch(() => {})
}, },
commentOrder(id) {}, commentOrder(id) {},
toPay(id) { toPay(orderSn, actualPrice) {
this.$router.push({ name: 'OrderPay', params: { orderId: id }}) this.$router.push({ name: 'OrderPay', params: { orderSn, actualPrice }})
}, },
handleTabClick() { handleTabClick() {
this.page = 0 this.page = 0

@ -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 {

Loading…
Cancel
Save