...
|
...
|
@@ -3,7 +3,7 @@ import { |
|
|
sellerOrderStatusList,
|
|
|
orderStatusKey,
|
|
|
ownType,
|
|
|
} from "constants/order-constants";
|
|
|
} from 'constants/order-constants';
|
|
|
|
|
|
function initialOrderState() {
|
|
|
return {
|
...
|
...
|
@@ -20,7 +20,10 @@ function initialOrderState() { |
|
|
const initialState = () => {
|
|
|
const orderListByType = {};
|
|
|
|
|
|
[[ownType.BUY, buyerOrderStatusList], [ownType.SELL, sellerOrderStatusList]].forEach(statusInfo => {
|
|
|
[
|
|
|
[ownType.BUY, buyerOrderStatusList],
|
|
|
[ownType.SELL, sellerOrderStatusList],
|
|
|
].forEach(statusInfo => {
|
|
|
statusInfo[1].forEach(orderStatus => {
|
|
|
const key = orderStatusKey(statusInfo[0], orderStatus.value);
|
|
|
|
...
|
...
|
@@ -30,10 +33,6 @@ const initialState = () => { |
|
|
|
|
|
return {
|
|
|
orderListByType,
|
|
|
|
|
|
// 当前查询订单状态
|
|
|
currentStatus: null,
|
|
|
routeParamStatus: null,
|
|
|
};
|
|
|
};
|
|
|
|
...
|
...
|
@@ -42,7 +41,7 @@ export default function() { |
|
|
namespaced: true,
|
|
|
state: initialState,
|
|
|
mutations: {
|
|
|
setOrderList(state, {res, owner, status}) {
|
|
|
setOrderList(state, { res, owner, status }) {
|
|
|
let { page, pagetotal, data = [] } = res;
|
|
|
const orderState = state.orderListByType[orderStatusKey(owner, status)];
|
|
|
|
...
|
...
|
@@ -56,7 +55,7 @@ export default function() { |
|
|
orderState.pullUpLoad = false;
|
|
|
}
|
|
|
},
|
|
|
filterOrderList(state, {orderCode, owner, status}) {
|
|
|
filterOrderList(state, { orderCode, owner, status }) {
|
|
|
const orderState = state.orderListByType[orderStatusKey(owner, status)];
|
|
|
|
|
|
orderState.orderList = orderState.orderList.filter(
|
...
|
...
|
@@ -64,21 +63,7 @@ export default function() { |
|
|
);
|
|
|
orderState.isShowEmpty = orderState.orderList.length === 0;
|
|
|
},
|
|
|
setOrderStatus(state, currentStatus) {
|
|
|
state.currentStatus = +currentStatus;
|
|
|
},
|
|
|
setRouteParamStatus(state, status = 1) {
|
|
|
state.routeParamStatus = +status;
|
|
|
},
|
|
|
resetPartialData(state, {owner, status}) {
|
|
|
Object.assign(state.orderListByType[orderStatusKey(owner, status)], {
|
|
|
page: 1,
|
|
|
orderList: [],
|
|
|
pagetotal: 0,
|
|
|
pullUpLoad: true,
|
|
|
});
|
|
|
},
|
|
|
resetData(state, {owner, status}) {
|
|
|
resetData(state, { owner, status } = {}) {
|
|
|
const orderListState = initialOrderState();
|
|
|
|
|
|
state.orderListByType[orderStatusKey(owner, status)] = orderListState;
|
...
|
...
|
@@ -94,7 +79,7 @@ export default function() { |
|
|
* }
|
|
|
* r
|
|
|
*/
|
|
|
async fetchOrderList({commit, state}, { owner, status }) {
|
|
|
async fetchOrderList({ commit, state }, { owner, status }) {
|
|
|
const { page } = state.orderListByType[orderStatusKey(owner, status)];
|
|
|
|
|
|
const res = await this.$api.get('/api/order/list', {
|
...
|
...
|
@@ -104,7 +89,7 @@ export default function() { |
|
|
});
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
commit('setOrderList', { res: res.data, owner, status});
|
|
|
commit('setOrderList', { res: res.data, owner, status });
|
|
|
}
|
|
|
},
|
|
|
|
...
|
...
|
@@ -125,7 +110,7 @@ export default function() { |
|
|
// data 为true时删除成功
|
|
|
if (code === 200) {
|
|
|
if (data) {
|
|
|
commit('filterOrderList', {orderCode, owner, status});
|
|
|
commit('filterOrderList', { orderCode, owner, status });
|
|
|
}
|
|
|
}
|
|
|
return data;
|
...
|
...
|
@@ -188,7 +173,9 @@ export default function() { |
|
|
},
|
|
|
);
|
|
|
|
|
|
return res.code === 200 ? res.data : res.message || '';
|
|
|
const { code, message } = res;
|
|
|
|
|
|
return code === 200 ? res : { code, message };
|
|
|
},
|
|
|
|
|
|
// 买家调价
|
...
|
...
|
@@ -199,7 +186,7 @@ export default function() { |
|
|
});
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
return { errMsg: '', isOk: true , bidData: res.data};
|
|
|
return { errMsg: '', isOk: true, bidData: res.data };
|
|
|
} else {
|
|
|
return { errMsg: res.message, isOk: false };
|
|
|
}
|
...
|
...
|
|