count.vue
8.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<template>
<div class="zj-main">
<mt-header title="确认订单">
<span @click="gotoback" slot="left">
<mt-button icon="back"></mt-button>
</span>
</mt-header>
<div class="zj-count-mid">
<router-link :to="{name:'selectAddress',params: { id: $route.params.addressId}}" tag="div"
class="order-address" style="margin-top:0px">
<order-address-item :select-address="selectAddress">
<span slot="right" class="right"><i class="mint-cell-allow-right"></i></span>
</order-address-item>
</router-link>
<!--订单商品-->
<div class="order-Goods">
<div class="top">{{checkOrder.siteName}}</div>
<ul class="mid">
<li class="order-goods-li unactive-goods-li" v-for="item in checkOrder.products">
<order-goods-item :item="item" :unitname="checkOrder.siteUnitName"></order-goods-item>
</li>
</ul>
</div>
<!--订单价格-->
<div class="order-money">
<div class="typer">
<p class="order-cell-p" v-if="checkOrder.shippingFee>0">运费:<span class="purple">+¥{{checkOrder.shippingFee}}</span>
</p>
<p class="order-cell-p" v-else>运费:<span class="purple">免运费</span></p>
</div>
<div class="typer" @click="popupVisible = true">
<p class="order-cell-p" v-if="typeof checkOrder.coupon=='object'">优惠券:<span class="right">-¥{{checkOrder.coupon.money}}:{{checkOrder.coupon['cplName']}}<i
class="mint-cell-allow-right"></i></span></p>
<p class="order-cell-p" v-else>优惠券:<span class="right">请选择<i
class="mint-cell-allow-right"></i></span></p>
</div>
<div class="typer" v-if="typeof checkOrder.activity=='object'">
<p class="order-cell-p">
活动:<span>-¥{{checkOrder.activity.money}}:{{checkOrder.activity.actName}}</span></p>
</div>
</div>
<mt-popup v-model="popupVisible" position="bottom" style="width:100%;display:none">
<div style="max-height:60vh;overflow: auto">
<mt-cell :title="'-¥'+item.money+':'+item.cplName" v-for="item in matchCouponList"
@click.native="selectCoupon(item.cplId)"></mt-cell>
</div>
</mt-popup>
</div>
<div class="count-bottom">
<div class="right" style="margin-left:10px" @click="countpay">
<button>确认下单</button>
</div>
<div class="right">
<p class="bigfont">实付款:{{checkOrder.orderPoint
}}{{checkOrder.siteUnitName}}+¥{{checkOrder.orderMoney}}</p>
<p v-if="checkOrder.shippingFee>0">(含¥{{checkOrder.shippingFee}}运费)</p>
<p v-else>免运费</p>
</div>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import orderAddressItem from '../address/orderAddressItem.vue';
import orderGoodsItem from '../order/orderGoodsItem.vue';
import {MessageBox, Popup} from 'mint-ui';
import {
getmyAddressList,
getselectAddress,
postcheckOrder,
postconfirmOrder,
postmatchCouponList
} from '../../vuex/actions';
export default{
data(){
return {
item: 'http://img.pconline.com.cn/images/upload/upc/tx/wallpaper/1308/02/c0/24056523_1375430477597.jpg',
popupVisible: false,
actions: [],
addRessId: '', //收货地址id
cplID: '', //选中的优惠券id
products: [] //从url上获取的需要结算的商品
}
},
components: {
orderAddressItem,
orderGoodsItem
},
vuex: {
getters: {
myAddressCount: ({addressData}) => {
return addressData.myAddressCount;
},
selectAddress: ({addressData}) => {
return addressData.selectAddress;
},
checkOrder: ({orderData}) => {
return orderData.checkOrder;
},
confirmOrder: ({orderData}) => {
return orderData.confirmOrder;
},
matchCouponList: ({orderData}) => {
return orderData.matchCouponList;
},
},
actions: {
getmyAddressList,
getselectAddress,
postcheckOrder,
postconfirmOrder,
postmatchCouponList
}
},
methods: {
gotoback(){
this.$router.go(-1)
},
selectCoupon(id){
console.log(id);
this.popupVisible = false;
this.cplID = id;
let data = {
products: this.products,
cplID: this.cplID, // 优惠券id 结算时进入传0
from: this.$route.params.from, // 商品来源
addRessId: this.addRessId //收货地址ID ,结算时进入传0
};
this.postcheckOrder(data);
},
countpay(){
var self = this;
let data = {
products: this.products,
cplID: this.cplID, // 优惠券id 结算时进入传0
from: this.$route.params.from, // 商品来源
addRessId: this.addRessId //收货地址ID ,结算时进入传0
};
this.postconfirmOrder(data).then(function () {
self.$router.push({
name: 'pay',
params: {
orderId: self.confirmOrder.orderId,
}
})
});
}
},
beforeRouteEnter (to, from, next){
console.log("进入结算页了");
console.log(from);
next(vm => {
if (from.path.indexOf('pay') != -1) {
vm.$router.replace({
name: 'allOrderList'
});
}
vm.popupVisible = false;
vm.cplID = vm.$route.params.cplID;
vm.getmyAddressList(0, 10).then(function () {
if (vm.myAddressCount <= 0) {
vm.$router.push({name: 'addAddress', params: {Id: false, teype: 'add'}});
} else {
if (from.path.indexOf('selectAddress') != -1 && (from.params.id != vm.$route.params.addressId)) {//判断是否由选择地址页回退并且已改变地址
vm.addRessId = from.params.id
} else {
vm.addRessId = vm.$route.params.addressId
}
vm.getselectAddress(vm.addRessId);//获取指定收货地址
var goods = vm.$route.params.Goods;
var goodsArry = [];
goodsArry = goods.split(",");
goodsArry.forEach(function (el) {
var elArry = [];
elArry = el.split("-");
vm.products.push({spdId: elArry[0], productNum: elArry[1]});
});
var data = {
products: vm.products,
cplID: vm.cplID, // 优惠券id 结算时进入传0
from: vm.$route.params.from, // 商品来源
addRessId: vm.addRessId //收货地址ID ,结算时进入传0
}
vm.getselectAddress(vm.$route.params.addressId);
vm.postcheckOrder(data);
vm.postmatchCouponList(vm.products);
}
})
});
},
beforeRouteLeave (to, from, next){
next()
}
}
</script>