|
|
@@ -21,6 +21,10 @@
|
|
|
<div class="text1">GAS费用</div>
|
|
|
<div class="text2">¥{{ gas }}</div>
|
|
|
</div>
|
|
|
+ <div class="info" @click="$router.push('/couponList')">
|
|
|
+ <div class="text1">优惠券</div>
|
|
|
+ <div class="text2">{{ couponInfo ? '已选择兑换券' : '选择兑换券' }}</div>
|
|
|
+ </div>
|
|
|
|
|
|
<van-field type="text" label="订单留言" placeholder="选填" v-model="message" />
|
|
|
|
|
|
@@ -56,6 +60,7 @@
|
|
|
const path = require('path');
|
|
|
import { add } from 'mathjs';
|
|
|
import product from '../mixins/product';
|
|
|
+import { mapState } from 'vuex';
|
|
|
let inWeixin = /micromessenger/i.test(navigator.userAgent);
|
|
|
export default {
|
|
|
name: 'Submit',
|
|
|
@@ -90,12 +95,24 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
money() {
|
|
|
- if (this.info.price) {
|
|
|
- return add(this.info.price, this.gas);
|
|
|
- } else {
|
|
|
- return 0;
|
|
|
+ let money = 0;
|
|
|
+ if (this.info.price && !this.couponInfo) {
|
|
|
+ money = add(this.info.price, money);
|
|
|
+ }
|
|
|
+ if (this.gas && (!this.couponInfo || this.couponInfo.needGas)) {
|
|
|
+ money = add(money, this.gas);
|
|
|
}
|
|
|
+
|
|
|
+ return money;
|
|
|
+ },
|
|
|
+ ...mapState(['couponInfo'])
|
|
|
+ },
|
|
|
+ beforeRouteLeave(to, from, next) {
|
|
|
+ console.log(to);
|
|
|
+ if (to.path !== '/couponList') {
|
|
|
+ this.$store.commit('setCouponInfo', null);
|
|
|
}
|
|
|
+ next();
|
|
|
},
|
|
|
mounted() {
|
|
|
this.$http.get('/sysConfig/get/gas_fee').then(res => {
|
|
|
@@ -110,7 +127,6 @@ export default {
|
|
|
this.info = res;
|
|
|
setTimeout(() => {
|
|
|
this.$toast.clear();
|
|
|
- this.bs.value.refresh();
|
|
|
}, 100);
|
|
|
|
|
|
// this.$http('/sysConfig/get/gas_fee')
|
|
|
@@ -146,8 +162,12 @@ export default {
|
|
|
methods: {
|
|
|
submit() {
|
|
|
this.$toast.loading('加载中');
|
|
|
+ let url = '/order/create?collectionId=' + this.$route.query.id + '&qty=1';
|
|
|
+ if (this.couponInfo) {
|
|
|
+ url += '&couponId=' + this.couponInfo.id;
|
|
|
+ }
|
|
|
this.$http
|
|
|
- .post('/order/create?collectionId=' + this.$route.query.id + '&qty=1')
|
|
|
+ .post(url)
|
|
|
.then(res => {
|
|
|
this.$toast.clear();
|
|
|
this.orderId = res.id;
|