...
|
...
|
@@ -77,6 +77,11 @@ import { orderStatusKey, getOrderStatus } from "constants/order-constants"; |
|
|
|
|
|
const STORE_PATH = "order/orderList";
|
|
|
|
|
|
const detailRouterNames = ["buyOrderDetail", "sellOrderDetail"];
|
|
|
const listRouterNames = ["OrderList", "InSaleOrderList"];
|
|
|
|
|
|
const refetchBackList = ["OrderList"];
|
|
|
|
|
|
const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
|
|
|
STORE_PATH
|
|
|
);
|
...
|
...
|
@@ -95,7 +100,8 @@ export default { |
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
scrollY: 0
|
|
|
scrollY: 0,
|
|
|
isScrollFetch: true
|
|
|
};
|
|
|
},
|
|
|
props: {
|
...
|
...
|
@@ -113,24 +119,51 @@ export default { |
|
|
loadingOptions() {
|
|
|
return {
|
|
|
hide: !this.viewOrderList || !this.viewOrderList.length,
|
|
|
noMore: this.orderStatus.page >= this.orderStatus.pagetotal
|
|
|
noMore: this.orderStatus.page > this.orderStatus.pagetotal
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
activated() {
|
|
|
if (this.$yoho.direction === "back") {
|
|
|
this.scrollY && this.$refs.scroll.scrollTo(this.scrollY);
|
|
|
if (this.scrollY) {
|
|
|
this.isScrollFetch = false;
|
|
|
this.$refs.scroll.scrollTo(this.scrollY);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 只有列表进入详情返回时不刷新列表
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
next(vm => {
|
|
|
let { owner, status, isRefetch = false } = to.params;
|
|
|
status = getOrderStatus(owner, status);
|
|
|
// if (detailRouterNames.includes(from.name)) {
|
|
|
// const { from: detailFrom } = vm.$store.state.order.orderDetail;
|
|
|
// if (listRouterNames.includes(detailFrom.name)) {
|
|
|
// isRefetch = false;
|
|
|
// }
|
|
|
// }
|
|
|
if (isRefetch || !from.name) {
|
|
|
vm.$store.commit(`${STORE_PATH}/resetData`, { owner, status });
|
|
|
vm.$store.dispatch(`${STORE_PATH}/fetchOrderList`, { owner, status });
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 获取订单数据
|
|
|
asyncData({ store, router }) {
|
|
|
let { owner, status } = router.params;
|
|
|
beforeRouteLeave(to, from, next) {
|
|
|
if (!detailRouterNames.includes(to.name)) {
|
|
|
this.scrollY = 0;
|
|
|
}
|
|
|
next();
|
|
|
},
|
|
|
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
let { owner, status } = to.params;
|
|
|
status = getOrderStatus(owner, status);
|
|
|
|
|
|
store.commit(`${STORE_PATH}/resetData`, { owner, status });
|
|
|
return store.dispatch(`${STORE_PATH}/fetchOrderList`, { owner, status });
|
|
|
this.scrollY = 0;
|
|
|
this.$refs.scroll.scrollTo(this.scrollY);
|
|
|
this.resetData({ owner, status });
|
|
|
this.fetchOrderList({ owner, status });
|
|
|
next();
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(["fetchOrderList", "confirmReceipt"]),
|
...
|
...
|
@@ -139,10 +172,14 @@ export default { |
|
|
this.scrollY = -y;
|
|
|
},
|
|
|
fetchData() {
|
|
|
if (this.isScrollFetch) {
|
|
|
this.fetchOrderList({
|
|
|
owner: this.owner,
|
|
|
status: this.status
|
|
|
});
|
|
|
} else {
|
|
|
this.isScrollFetch = true;
|
|
|
}
|
|
|
},
|
|
|
onRefresh() {
|
|
|
this.resetData({
|
...
|
...
|
|