order-list.vue
5.39 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<template>
<layout-app>
<status-nav />
<div class="content-wrapper">
<scroll
@pulling-up="fetchMore"
:options="options"
:data="orderList"
class="order-list-scroll-wrap"
v-show="!isShowEmpty"
>
<ul class="list-wrapper">
<li v-for="order in orderList" :key="order.orderCode">
<order-info :order="order" />
<order-list-item :order="order" />
<!-- 订单操作 -->
<!-- <order-item-footer :order="order" /> -->
<div class="footer-wrapper">
<count-down :leftTime="order.leftTime" />
<order-actions
class="actions"
:order="order"
@on-action="action => onAction({ action, order })"
/>
</div>
</li>
</ul>
</scroll>
<empty-list
class="empty-wrapper"
tip="这里什么都没有..."
v-show="isShowEmpty"
/>
</div>
</layout-app>
</template>
<script>
import { Scroll } from "cube-ui";
import { createNamespacedHelpers } from "vuex";
import {
orderActionsMap,
ownType
} from "../../../../constants/order-constants";
import OrderListItem from "./components/order-item";
import StatusNav from "./components/status-nav";
import OrderInfo from "./components/order-info.vue";
import OrderItemFooter from "./components/order-footer";
import EmptyList from "../../../components//ufo-no-item";
import OrderActions from "../components/order-actions";
import CountDown from "../components/count-down";
import CancelConfirmInfo from "../components/order-list/cancel-confirm-info";
const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
"order/orderList"
);
export default {
components: {
Scroll,
OrderListItem,
StatusNav,
OrderInfo,
EmptyList,
OrderItemFooter,
OrderActions,
CountDown
},
computed: {
...mapState(["orderList", "pullUpLoad", "isShowEmpty"]),
options: function() {
return {
pullUpLoad: this.pullUpLoad
};
}
},
// 获取订单数据
asyncData({ store, router }) {
// const { owner, status } = router.params;
// store.dispatch("order/orderList/fetchOrderList", { owner, status });
},
activated() {
this.resetData();
this.fetchData();
},
methods: {
...mapActions([
"fetchOrderList",
"cancelTradeConfirmInfo",
"cancelTrade",
"deleteOrder"
]),
...mapMutations(["setOrderStatus", "filterOrderList", "resetData"]),
fetchMore() {
this.fetchOrderList(this.$route.params);
},
fetchData() {
const { params } = this.$route;
const { status } = params;
if (status) {
this.setOrderStatus(status);
}
this.fetchOrderList(params);
},
async onAction({ action, order }) {
console.log("----------action---------", action);
const { owner = ownType.SELL } = this.$route.params;
const {
orderCode,
earnestMoney = 0,
realPrice = "",
priceInfo = {}
} = order;
const { productId, storageId, skup } = order.goodsInfo;
switch (action.name) {
// 删除订单
case orderActionsMap.DEL_ORDER.name:
this.$createDialog({
type: "confirm",
content: "确认删除订单?",
onConfirm: async () => {
const isOk = await this.deleteOrder({
orderCode,
owner
});
if (isOk) {
this.filterOrderList(orderCode);
}
const txt = isOk ? "删除成功" : "删除失败";
this.$createToast({ txt, type: "txt" }).show();
}
}).show();
break;
case orderActionsMap.CANCEL_ORDER.name:
const confirmInfo = await this.cancelTradeConfirmInfo({
orderCode,
owner
});
this.$createDialog(
{
type: "confirm",
confirmBtn: { text: "取消订单" },
cancelBtn: { text: "保留订单" },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner
});
if (isOk) {
this.resetData();
this.fetchData(this.$route.params);
}
const txt = isOk ? "取消成功" : "取消失败";
this.$createToast({ txt, type: "txt" }).show();
}
},
createElement => {
return [
createElement(CancelConfirmInfo, {
slot: "content",
props: { confirmInfo }
})
];
}
).show();
break;
}
}
},
watch: {
$route() {}
}
};
</script>
<style lang="scss" scoped>
.content-wrapper {
height: calc(100vh - 200px);
overflow-x: hidden;
overflow-y: auto;
-webkit-box-orient: vertical;
.footer-wrapper {
display: flex;
margin-top: 40px;
.actions {
flex: 1;
}
}
.empty-wrapper {
margin: auto 0;
position: absolute;
top: 0;
bottom: 0;
}
.order-list-scroll-wrap {
.list-wrapper {
li {
padding: 40px 40px;
border-bottom: 1px solid #eee;
}
& :last-child {
border-bottom: 0;
}
}
}
}
</style>