feat: 物流列表添加分页

merge-requests/24/head
xiaoguang 3 years ago
parent 889ea111be
commit ebaf192430

@ -10,7 +10,7 @@
disabled 是否禁用 true false disabled 是否禁用 true false
--> -->
<template> <template>
<button :class="`ui-button ${myClass}`" @click="click"> <button :class="`ui-button ${myClass}`" @click.stop="click">
<slot></slot> <slot></slot>
</button> </button>
</template> </template>

@ -45,7 +45,7 @@ export default {
methods: { methods: {
onConfirm() { onConfirm() {
this.$emit("confirm"); this.$emit("confirm");
this.visible = false; this.dialogVisible = false;
}, },
}, },
}; };

@ -11,17 +11,18 @@
<div class="home-logisitcs-label">我的物流</div> <div class="home-logisitcs-label">我的物流</div>
<!-- 无物流信息 --> <!-- 无物流信息 -->
<div <div
v-if="loadFinish && list.length === 0" v-if="loadFinish && total === 0"
class="home-logisitcs-empty flex flex-center flex-middle" class="home-logisitcs-empty flex flex-center flex-middle"
> >
<img src="~/assets/img/account/home/logisitcs-empty.png" /> <img src="~/assets/img/account/home/logisitcs-empty.png" />
</div> </div>
<!-- 有物流信息 --> <!-- 有物流信息 -->
<div v-else v-loading="loading"> <div v-else v-loading="loading">
<div class="home-logisitcs-content"> <div v-infinite-scroll="handleListload" class="home-logisitcs-content">
<div <div
v-for="item in list" v-for="item in list"
:key="item.orderId" :key="item.orderId"
@click="onJumpOrderDetail(item.orderId)"
class="home-logisitcs-content__item flex flex-middle flex-between" class="home-logisitcs-content__item flex flex-middle flex-between"
> >
<div class="logisitcs-content-item__info flex flex-start"> <div class="logisitcs-content-item__info flex flex-start">
@ -68,6 +69,11 @@ export default {
data() { data() {
return { return {
selectOrderId: 0, selectOrderId: 0,
query: {
pageIndex: 1,
length: 15,
},
total: 0,
confirmOrderVisible: false, confirmOrderVisible: false,
list: [], list: [],
loading: false, loading: false,
@ -81,11 +87,14 @@ export default {
// //
async getLogisticsList() { async getLogisticsList() {
this.loading = true; this.loading = true;
const { result } = await ApiGetOrderLogisticsList(); const { result } = await ApiGetOrderLogisticsList({ ...this.query });
this.loading = false; this.loading = false;
this.loadFinish = true; this.loadFinish = true;
if (result) { if (result) {
this.list = result.map((item) => { const { total, records } = result;
this.total = total;
if (records && records.length > 0) {
const formatRecords = records.map((item) => {
const goods = item.products || [{ productImageUrl: "" }]; const goods = item.products || [{ productImageUrl: "" }];
const logisticsList = item.logistics.logisticsDataList || [ const logisticsList = item.logistics.logisticsDataList || [
{ context: "暂无物流信息" }, { context: "暂无物流信息" },
@ -96,12 +105,25 @@ export default {
logisticsContext: logisticsList[0].context, // logisticsContext: logisticsList[0].context, //
}; };
}); });
this.list = this.list.concat(formatRecords);
}
} }
}, },
onOrderConfirm({ orderId }) { onOrderConfirm({ orderId }) {
this.selectOrderId = orderId; this.selectOrderId = orderId;
this.confirmOrderVisible = true; this.confirmOrderVisible = true;
}, },
//
handleListload() {
if (this.total > 0 && this.list.length < this.total) {
//
this.query.pageIndex += 1;
this.getLogisticsList();
}
},
onJumpOrderDetail(id) {
this.$router.push(`/account/order/detail?id=${id}`);
},
// //
async handleOrderEnsure() { async handleOrderEnsure() {
@ -110,7 +132,9 @@ export default {
}); });
this.confirmOrderVisible = false; this.confirmOrderVisible = false;
if (result) { if (result) {
Message.success("收货成功"); Message.success("确认收货成功");
this.list = [];
this.query.pageIndex = 1;
this.getLogisticsList(); this.getLogisticsList();
} }
}, },
@ -154,6 +178,7 @@ export default {
} }
.home-logisitcs-content__item { .home-logisitcs-content__item {
margin-bottom: 30px; margin-bottom: 30px;
cursor: pointer;
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }

@ -68,8 +68,8 @@ export const ApiGetOrderLogistics = ({orderId}) =>
* 获取物流列表 * 获取物流列表
* @param {*} params * @param {*} params
*/ */
export const ApiGetOrderLogisticsList = () => export const ApiGetOrderLogisticsList = (params) =>
ToAsyncAwait(axiosTk.get(`${BASE_URL}/app/tradeOrder/listReceiveOrder`)); ToAsyncAwait(axiosTk.get(`${BASE_URL}/app/tradeOrder/listReceiveOrder`, { params }));
/** /**
* 确认收货 * 确认收货

Loading…
Cancel
Save