Authored by lea guo

修改订单状态

... ... @@ -36,30 +36,29 @@ export default {
components: {
Scroll
},
props: {
status: {
type: Number
},
owner: {
type: String
}
},
computed: {
...mapState(["currentStatus", "routeParamStatus"]),
...mapState(["routeParamStatus"]),
statusList: function() {
const { owner } = this.$route.params;
return owner === ownType.BUY
return this.owner === ownType.BUY
? buyerOrderStatusList
: sellerOrderStatusList;
},
status() {
return this.currentStatus || this.routeParamStatus;
}
},
activated() {
let {status} = this.$route.params || this.statusList[0].value
this.setOrderStatus(status)
},
methods: {
...mapMutations(["setOrderStatus", "resetPartialData"]),
...mapActions(["fetchOrderList"]),
onHandleClick(status) {
this.setOrderStatus(status);
this.$emit("change", status);
this.resetPartialData();
const { owner } = this.$route.params;
const { owner } = this;
this.fetchOrderList({ owner, status });
}
}
... ...
<template>
<layout-app :title="$route.params.owner === 'sell' ? '我的出售' : '我的订单'">
<status-nav />
<status-nav @change="change" :owner="owner" :status="currentStatus" />
<div class="content-wrapper">
<scroll
@pulling-up="fetchData"
... ... @@ -87,31 +87,39 @@ export default {
CountDown,
VideoPlayer
},
data() {
const { status = 1, owner } = this.$route.params;
return {
currentStatus: +status,
owner
};
},
computed: {
...mapState(["orderList", "pullUpLoad", "isShowEmpty"]),
options: function() {
return {
pullUpLoad: this.pullUpLoad,
pullDownRefresh: true
pullDownRefresh: this.isShowEmpty
? false
: {
txt: "更新成功"
}
};
}
},
// 获取订单数据
asyncData({ store, router }) {
const { owner, status } = router.params;
store.commit(`${STORE_PATH}/resetData`);
store.commit(`${STORE_PATH}/setOrderStatus`, status);
store.commit(`${STORE_PATH}/setRouteParamStatus`, status);
return store.dispatch(`${STORE_PATH}/fetchOrderList`, router.params);
activated() {
this.resetData();
this.fetchData();
},
methods: {
...mapActions(["fetchOrderList", "confirmReceipt"]),
...mapMutations(["resetData"]),
change(status) {
this.currentStatus = status;
},
fetchData() {
this.fetchOrderList(this.$route.params);
const { owner, currentStatus: status } = this;
this.fetchOrderList({ owner, status });
},
onRefresh() {
this.resetData();
... ...
... ... @@ -5,10 +5,6 @@ const initailData = () => ({
orderList: [], // 订单列表
// scroll 组件参数,是否触发上拉事件
pullUpLoad: true,
// 当前查询订单状态
currentStatus: null,
routeParamStatus: null,
isShowEmpty: false,
});
... ... @@ -37,12 +33,6 @@ export default function() {
);
state.isShowEmpty = state.orderList.length === 0;
},
setOrderStatus(state, currentStatus) {
state.currentStatus = +currentStatus;
},
setRouteParamStatus(state, status = 1) {
state.routeParamStatus = +status;
},
resetPartialData(state) {
state.page = 1;
state.orderList = [];
... ... @@ -51,14 +41,10 @@ export default function() {
},
resetData(state) {
const s = initailData();
const keyList = Object.keys(s);
const keyBlackList = ['currentStatus', 'routeParamStatus'];
for (const key of keyList) {
if (!keyBlackList.includes(key)) {
state[key] = s[key];
}
}
Object.keys(s).forEach(key => {
state[key] = s[key];
});
},
},
actions: {
... ... @@ -74,14 +60,14 @@ export default function() {
async fetchOrderList(
{
commit,
state: { page, currentStatus, routeParamStatus },
state: { page },
},
param = {},
) {
const { owner } = param;
const { owner, status } = param;
const res = await this.$api.get('/api/order/list', {
tabType: owner,
type: currentStatus || routeParamStatus || 1, // 1表示我的订单全部
type: status || 1, // 1表示我的订单全部
page,
});
... ...