下单调整

master
hequan_waynaqua 4 years ago
parent f46d7b5a13
commit d71f7d78b3

@ -4,12 +4,17 @@
<van-icon name="shop-o" /> <van-icon name="shop-o" />
<span class="title__name">熊猫商城自营</span> <span class="title__name">熊猫商城自营</span>
</h3> </h3>
<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">
@ -33,7 +38,7 @@
</van-cell-group> </van-cell-group>
<van-submit-bar <van-submit-bar
:price="amount * 100 " :price="amount * 100"
label="总计:" label="总计:"
button-text="提交订单" button-text="提交订单"
:disabled="false" :disabled="false"
@ -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,92 +67,110 @@ 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
message: .alert({
'你选择了' + (this.payWay === 'wx' ? '微信支付' : '支付宝支付') message:
}).then(() => { '你选择了' + (this.payWay === 'wx' ? '微信支付' : '支付宝支付')
if (this.payWay === 'wx') { })
const ua = navigator.userAgent.toLowerCase() .then(() => {
const isWeixin = ua.indexOf('micromessenger') !== -1 if (this.payWay === 'wx') {
if (isWeixin) { const ua = navigator.userAgent.toLowerCase()
orderPrepay({ orderId: this.orderId }) const isWeixin = ua.indexOf('micromessenger') !== -1
.then((res) => { if (isWeixin) {
const data = res.map.result orderPrepay({ orderSn: this.orderSn })
const prepayData = JSON.stringify({ .then((res) => {
appId: data.appId, const data = res.map.result
timeStamp: data.timeStamp, const prepayData = JSON.stringify({
nonceStr: data.nonceStr, appId: data.appId,
package: data.packageValue, timeStamp: data.timeStamp,
signType: 'MD5', nonceStr: data.nonceStr,
paySign: data.paySign package: data.packageValue,
}) signType: 'MD5',
setLocalStorage({ prepay_data: prepayData }) paySign: data.paySign
})
setLocalStorage({ prepay_data: prepayData })
if (typeof WeixinJSBridge === 'undefined') { if (typeof WeixinJSBridge === 'undefined') {
if (document.addEventListener) { if (document.addEventListener) {
document.addEventListener( document.addEventListener(
'WeixinJSBridgeReady', 'WeixinJSBridgeReady',
this.onBridgeReady, this.onBridgeReady,
false false
) )
} else if (document.attachEvent) { } else if (document.attachEvent) {
document.attachEvent( document.attachEvent(
'WeixinJSBridgeReady', 'WeixinJSBridgeReady',
this.onBridgeReady this.onBridgeReady
) )
document.attachEvent( document.attachEvent(
'onWeixinJSBridgeReady', 'onWeixinJSBridgeReady',
this.onBridgeReady this.onBridgeReady
) )
}
} else {
this.onBridgeReady()
} }
} else { })
this.onBridgeReady() .catch((err) => {
} this.$dialog.alert({ message: err.map.msg })
}) this.$router.replace({
.catch((err) => { name: 'paymentStatus',
this.$dialog.alert({ message: err.map.msg }) params: {
status: 'failed'
}
})
})
} else {
orderH5pay({ orderSn: this.orderSn })
.then((res) => {
const data = res.map.data
window.location.replace(
data.mwebUrl +
'&redirect_url=' +
encodeURIComponent(
window.location.origin +
'/#/?orderSn=' +
this.orderSn +
'&tip=yes'
)
)
})
.catch((err) => {
console.log(err)
// this.$dialog.alert({ message: '' })
this.$router.replace({
name: 'PayStatus',
params: {
status: 'failed'
}
})
})
}
} else {
// todo : alipay
testPayNotify(this.orderSn)
.then((res) => {
this.$router.replace({ this.$router.replace({
name: 'paymentStatus', name: 'PayStatus',
params: { params: {
status: 'failed' status: 'success'
} }
}) })
}) })
} else {
orderH5pay({ orderId: this.orderId })
.then((res) => {
const data = res.map.data
window.location.replace(
data.mwebUrl +
'&redirect_url=' +
encodeURIComponent(
window.location.origin +
'/#/?orderId=' +
this.orderId +
'&tip=yes'
)
)
})
.catch((err) => { .catch((err) => {
console.log(err) console.log(err)
// this.$dialog.alert({ message: '' })
this.$router.replace({ this.$router.replace({
name: 'PayStatus', name: 'PayStatus',
params: { params: {
@ -140,28 +179,7 @@ export default {
}) })
}) })
} }
} else { })
// todo : alipay
testPayNotify(this.orderId)
.then((res) => {
this.$router.replace({
name: 'PayStatus',
params: {
status: 'success'
}
})
})
.catch((err) => {
console.log(err)
this.$router.replace({
name: 'PayStatus',
params: {
status: 'failed'
}
})
})
}
})
}, },
onBridgeReady() { onBridgeReady() {
const that = this const that = this
@ -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