Authored by lea guo

订单类表优化

... ... @@ -40,6 +40,12 @@ export default {
if (val === "") {
clearInterval(this.timeoutId);
}
},
leftTime(val) {
if (!val) {
this.countDown = "";
clearInterval(this.timeoutId);
}
}
},
methods: {
... ... @@ -67,7 +73,6 @@ export default {
</script>
<style lang="scss" scoped>
.count-down-wrapper {
display: flex;
font-size: 32px;
... ... @@ -85,7 +90,7 @@ export default {
& > span {
padding: 0 9px;
@include num
@include num;
}
}
</style>
... ...
... ... @@ -21,10 +21,10 @@ export default {
'computeChangePrice',
'confirmChangePrice',
]),
...mapMutations(['filterOrderList', 'resetData']),
...mapMutations(['filterOrderList', 'resetData', 'resetOrderListItem']),
async onAction({ action, order, isDetail = false } = {}) {
const { owner = ownType.SELL, status } = this.$route.params;
const { owner = ownType.SELL, type, status } = this.$route.params;
const {
orderCode,
realPrice = '',
... ... @@ -47,6 +47,11 @@ export default {
if (isOk) {
if (isDetail) {
this.filterOrderList({
orderCode,
owner,
status,
});
this.$router.back();
} else {
this.filterOrderList({
... ... @@ -90,7 +95,16 @@ export default {
if (isOk) {
if (isDetail) {
this.fetchOrderDetail(this.$route.params);
const newOrder = await this.fetchOrderDetail(
this.$route.params,
);
// 重置订单列表中数据
this.resetOrderListItem({
order: newOrder,
owner,
status: type,
});
} else {
this.resetData(this.$route.params);
this.fetchData(this.$route.params);
... ... @@ -232,10 +246,12 @@ export default {
extra: JSON.stringify({
forward: {
name: isDetail ? 'buyOrderDetail' : 'OrderList',
params: isDetail ? {
owner: this.$route.params.owner,
code: bidData.orderCode,//改为新订单号
} : this.$route.params,
params: isDetail
? {
owner: this.$route.params.owner,
code: bidData.orderCode, //改为新订单号
}
: this.$route.params,
},
reportType: 'buy',
}),
... ...
... ... @@ -142,6 +142,9 @@ const { mapActions, mapState, mapGetters } = createNamespacedHelpers(
export default {
mixins: [orderActionMixin],
data() {
return { isFromList: false };
},
components: {
AddressInfo,
OrderItemInfo,
... ... @@ -167,6 +170,27 @@ export default {
asyncData({ store, router }) {
return store.dispatch(`${STORE_PATH}/fetchOrderDetail`, router.params);
},
beforeRouteEnter(to, from, next) {
// ...
next(vm => {
if (from.name === "OrderList") {
vm.$data.isFromList = true;
}
});
},
beforeRouteLeave(to, from, next) {
// ...
// if (!this.isFromList) {
// const { owner } = from.params;
// next({
// name: "OrderList",
// params: {
// owner
// }
// });
// }
next();
},
computed: {
...mapState(["orderDetail"]),
...mapGetters([
... ...
... ... @@ -60,13 +60,13 @@ export default {
);
},
toLinkParam: function() {
const { owner = ownType.SELL } = this.$route.params;
const { owner = ownType.SELL, status } = this.$route.params;
let linkParam = {
name:
owner === ownType.SELL
? detailRouteNames.SELL_ORDER_DETAIL
: detailRouteNames.BUY_ORDER_DETAIL,
params: { code: this.order.orderCode, owner }
params: { code: this.order.orderCode, owner, type: status }
};
if (this.isEntry) {
const { productId } = this.order.goodsInfo;
... ...
... ... @@ -12,8 +12,12 @@
<div class="item-info">
<div>
<div v-if="$route.params.owner === 'buy'" class="price-status">
<span class="price">¥{{specialBid ? goodsInfo.goodPrice : order.realPrice }}</span>
<span class="delivery-fee-tip" >{{specialBid ? '' : '(含运费)'}}</span>
<span class="price"
>¥{{ specialBid ? goodsInfo.goodPrice : order.realPrice }}</span
>
<span class="delivery-fee-tip">{{
specialBid ? "" : "(含运费)"
}}</span>
</div>
<div v-else class="price-status">
<span class="price">¥{{ goodsInfo.goodPrice }}</span>
... ... @@ -47,19 +51,23 @@ export default {
return this.$props.order.goodsInfo;
},
toLinkParam: function() {
const { owner = ownType.SELL } = this.$route.params;
const { owner = ownType.SELL, status } = this.$route.params;
return {
name:
owner === ownType.SELL
? detailRouteNames.SELL_ORDER_DETAIL
: detailRouteNames.BUY_ORDER_DETAIL,
params: { code: this.order.orderCode, owner }
params: { code: this.order.orderCode, owner, type: status }
};
},
specialBid: {
get() {
return this.order.bidType && (this.order.statuStr === '求购中' || this.order.statuStr === '待付定金')
return (
this.order.bidType &&
(this.order.statuStr === "求购中" ||
this.order.statuStr === "待付定金")
);
}
}
}
... ... @@ -111,7 +119,7 @@ export default {
color: #d0021b;
letter-spacing: 0;
font-weight: bold;
@include num
@include num;
}
.status {
... ...
<template>
<layout-app title="出售中" class="in-sale-list-wrapper">
<div class="content-wrapper">
<scroll
<LayoutScroll
@pulling-up="fetchData"
@pulling-down="onRefresh"
:options="options"
:data="orderList"
class="order-list-scroll-wrap"
ref="scroll"
>
<ul class="list-wrapper">
<li v-for="(order, i) in orderList" :key="i">
... ... @@ -31,7 +32,7 @@
tip="这里什么都没有..."
v-show="isShowEmpty"
/>
</scroll>
</LayoutScroll>
</div>
</layout-app>
</template>
... ... @@ -61,6 +62,11 @@ const {
export default {
// 订单操作
mixins: [orderInSaleActionMixin],
data() {
return {
scrollY: 0
};
},
components: {
Scroll,
OrderItem,
... ... @@ -95,6 +101,11 @@ export default {
router.params
);
},
activated() {
if (this.yoho.direction === "back") {
this.scrollY && this.$refs.scroll.scrollTo(this.scrollY);
}
},
methods: {
...mapActions(["fetchEntryOrderList", "fetchNotEntryOrderList"]),
...mapMutations(["resetData"]),
... ...
import {
getOrderStatus,
} from "constants/order-constants";
import { getOrderStatus } from 'constants/order-constants';
const routers = [
// 订单列表
... ... @@ -10,7 +8,7 @@ const routers = [
name: 'OrderList',
path: '/xianyu/:owner/order/list/:status?',
component: () => import('./order-list'),
props({params}) {
props({ params }) {
let { owner, status } = params;
status = getOrderStatus(owner, status);
... ... @@ -19,9 +17,6 @@ const routers = [
status,
};
},
meta: {
routerViewKey: 'OrderList',
},
},
// 出售订单列表
... ...
... ... @@ -120,20 +120,11 @@ export default {
}
},
activated() {
if (this.$yoho.direction === 'back') {
this.scrollY && this.$refs.scroll.scrollTo(this.scrollY);
if (this.scrollY) {
this.$refs.scroll.scrollTo(this.scrollY);
}
},
// // 获取订单数据
// asyncData({ store, router }) {
// let { owner, status } = router.params;
// status = getOrderStatus(owner, status);
// store.commit(`${STORE_PATH}/resetData`, { owner, status });
// return store.dispatch(`${STORE_PATH}/fetchOrderList`, { owner, status });
// },
beforeRouteEnter(to, from, next) {
next(vm => {
if (!detailRouterNames.includes(from.name)) {
... ... @@ -146,14 +137,21 @@ export default {
});
},
beforeRouteLeave(to, from, next) {
if (!detailRouterNames.includes(to.name)) {
this.scrollY = 0;
}
next();
},
beforeRouteUpdate(to, from, next) {
if (!detailRouterNames.includes(from.name)) {
let { owner, status } = to.params;
status = getOrderStatus(owner, status);
let { owner, status } = to.params;
status = getOrderStatus(owner, status);
this.resetData({ owner, status });
this.fetchOrderList({ owner, status });
}
this.scrollY = 0;
this.$refs.scroll.scrollTo(this.scrollY);
this.resetData({ owner, status });
this.fetchOrderList({ owner, status });
next();
},
methods: {
... ...
... ... @@ -38,6 +38,7 @@ export default function() {
if (res.code === 200) {
commit('initData', res.data);
}
return res.data || {};
},
},
};
... ...
... ... @@ -55,29 +55,44 @@ export default function() {
orderState.pullUpLoad = false;
}
},
filterOrderList(state, {
orderCode,
owner = ownType.SELL,
status = 1
}) {
filterOrderList(state, { orderCode, owner = ownType.SELL, status = 1 }) {
let orderState = state.orderListByType[orderStatusKey(owner, status)];
orderState.orderList = orderState.orderList.filter(
order => order.orderCode !== orderCode,
);
orderState.isShowEmpty = orderState.orderList.length === 0;
},
resetOrderListItem(state, { owner, status = 1, order }) {
let orderState = state.orderListByType[orderStatusKey(owner, status)];
orderState.orderList = orderState.orderList.map(item => {
if (item.orderCode === order.orderCode) {
const {
buttons = [],
statusDetail: { statuStr = '' } = {},
} = order;
// 详情接口取消时leftTime任返回值
const isIncludeDeleteAction = !!buttons.find(btn => {
return btn.code === 'del_order';
});
let { leftTime } = item;
leftTime = isIncludeDeleteAction ? 0 : leftTime;
item = { ...item, buttons, statuStr, leftTime };
}
return item;
});
},
setOrderStatus(state, currentStatus) {
state.currentStatus = +currentStatus;
},
setRouteParamStatus(state, status = 1) {
state.routeParamStatus = +status;
},
resetPartialData(state, {
owner = ownType.SELL,
status = 1
}) {
resetPartialData(state, { owner = ownType.SELL, status = 1 }) {
Object.assign(state.orderListByType[orderStatusKey(owner, status)], {
page: 1,
orderList: [],
... ... @@ -85,10 +100,7 @@ export default function() {
pullUpLoad: true,
});
},
resetData(state, {
owner = ownType.SELL,
status = 1
}) {
resetData(state, { owner = ownType.SELL, status = 1 }) {
const orderListState = initialOrderState();
state.orderListByType[orderStatusKey(owner, status)] = orderListState;
... ... @@ -104,13 +116,10 @@ export default function() {
* }
* r
*/
async fetchOrderList({
commit,
state
}, {
owner = ownType.SELL,
status = 1
}) {
async fetchOrderList(
{ commit, state },
{ owner = ownType.SELL, status = 1 },
) {
const { page } = state.orderListByType[orderStatusKey(owner, status)];
const res = await this.$api.post('/api/order/list', {
... ... @@ -211,7 +220,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 };
}
... ...