deming/pageE/order/Index.vue

213 lines
5.5 KiB
Vue
Raw Normal View History

2020-06-08 15:23:23 +08:00
<template>
<view class="order">
<view>
2020-08-04 19:08:04 +08:00
<u-tabs-swiper ref="tabs" :list="list" active-color="#FF780F" :current="current" font-size="26" @change="tabsChange" height="88" :gutter="30"></u-tabs-swiper>
2020-06-08 15:23:23 +08:00
</view>
2020-07-06 17:32:29 +08:00
<swiper :current="swiperCurrent" @animationfinish="animationfinish" :style="{ height: swiperHeight }">
<swiper-item class="swiper-item" v-for="(item, index) in list" :key="index">
2020-08-07 17:34:59 +08:00
<scroll-view scroll-y style="height: 100%;" @scrolltolower="reachBottom" class="order-scroll">
2020-06-19 18:07:11 +08:00
<view>
2020-07-06 17:32:29 +08:00
<view class="item-container" v-for="order in orderList" :key="order.order_id">
2020-07-28 20:47:31 +08:00
<OrderItem :order="order" @refreshOrderList="refreshOrderList" v-if="current != 4"></OrderItem>
<TryOrderItem :order="order" @refreshOrderList="refreshOrderList" v-else></TryOrderItem>
2020-06-19 18:07:11 +08:00
</view>
2020-06-08 15:23:23 +08:00
</view>
2020-07-07 17:47:00 +08:00
<u-empty text="暂无订单" mode="order" color="#000000" v-if="!orderList.length"></u-empty>
2020-08-07 17:34:59 +08:00
<u-loadmore :status="loadStatus[index]" bgColor="#ECECEC" margin-bottom="20" v-if="current != 4 && orderList.length>3" class="order-loadmore"></u-loadmore>
2020-06-08 15:23:23 +08:00
</scroll-view>
</swiper-item>
</swiper>
</view>
</template>
<script>
import OrderItem from '@/components/mine/order-item/index'
2020-07-28 20:47:31 +08:00
import TryOrderItem from '@/components/mine/order-item/try'
2020-06-08 15:23:23 +08:00
export default {
data() {
return {
list: [{
name: '全部'
}, {
name: '待支付'
}, {
2020-07-31 21:47:41 +08:00
name: '待发货'
2020-06-08 15:23:23 +08:00
}, {
name: '待收货'
}, {
name: '试穿试送'
2020-08-04 19:08:04 +08:00
},{
name: '拼团中'
2020-06-08 15:23:23 +08:00
}, {
name: '售后'
2020-07-31 21:47:41 +08:00
}, {
name: '待评价'
2020-06-08 15:23:23 +08:00
}],
2020-07-07 17:47:00 +08:00
orderList: [],
2020-08-04 19:08:04 +08:00
loadStatus: ['loadmore','loadmore','loadmore','loadmore','loadmore','loadmore','loadmore','loadmore'],
2020-06-19 18:07:11 +08:00
page: 0,
2020-07-10 09:03:19 +08:00
current: Number,
2020-06-19 18:07:11 +08:00
swiperCurrent: 0,
2020-07-06 17:32:29 +08:00
swiperHeight: '',
timer: true,
2020-06-08 15:23:23 +08:00
}
},
components: {
2020-07-28 20:47:31 +08:00
OrderItem,
TryOrderItem,
2020-06-08 15:23:23 +08:00
},
2020-07-06 17:32:29 +08:00
watch: {
2020-07-28 20:47:31 +08:00
current(value, origin) {
if((origin == 4 && value != 4) || (value == 4 && origin != 4)) {
this.orderList = [];
}
2020-07-06 17:32:29 +08:00
this.page = 0;
2020-07-31 21:47:41 +08:00
// reload 重新请求列表 loadmore 往列表里添加
if(value == 4) {
this.goodsTryOrderList({ load: 'reload' });
2020-07-27 17:59:47 +08:00
} else {
2020-07-31 21:47:41 +08:00
this.getOrderList({ load: 'reload' });
2020-07-27 17:59:47 +08:00
}
2020-07-06 17:32:29 +08:00
},
},
2020-06-08 15:23:23 +08:00
onLoad(option) {
2020-07-07 17:47:00 +08:00
const current = option.current ? Number(option.current) : 0;
this.current = current;
this.swiperCurrent = this.current;
2020-07-06 17:32:29 +08:00
this.setViewHeight();
2020-06-08 15:23:23 +08:00
},
2020-07-31 21:47:41 +08:00
// 下拉刷新
onPullDownRefresh() {
this.refreshOrderList();
},
2020-06-08 15:23:23 +08:00
methods: {
2020-07-14 17:43:15 +08:00
setOrderType() {
2020-07-06 17:32:29 +08:00
let type;
switch (this.current) {
case 1:
2020-07-31 21:47:41 +08:00
type = 1; // 待支付
2020-07-06 17:32:29 +08:00
break;
case 2:
2020-07-31 21:47:41 +08:00
type = 2; // 待发货
2020-07-06 17:32:29 +08:00
break;
case 3:
2020-07-31 21:47:41 +08:00
type = 3; // 待收货
2020-07-06 17:32:29 +08:00
break;
case 4:
type = -1; // 试穿试送
break;
case 5:
2020-08-04 19:08:04 +08:00
type = 9; // 拼团中
2020-07-31 21:47:41 +08:00
break;
case 6:
2020-08-04 19:08:04 +08:00
type = 8; // 售后
break;
case 7:
2020-07-31 21:47:41 +08:00
type = 4; // 待评价
2020-07-06 17:32:29 +08:00
break;
default:
type = -1;
break;
}
2020-07-14 17:43:15 +08:00
return type;
},
2020-07-28 20:47:31 +08:00
refreshOrderList() {
this.page = 0;
2020-07-31 21:47:41 +08:00
// if(this.current == 6) {
// this.getAfterSaleList({ load: 'reload' });
// } else
if(this.current == 4) {
this.goodsTryOrderList({ load: 'reload' });
2020-07-28 20:47:31 +08:00
} else {
2020-07-31 21:47:41 +08:00
this.getOrderList({ load: 'reload' });
2020-07-28 20:47:31 +08:00
}
},
2020-07-31 21:47:41 +08:00
// 普通
async getOrderList({ load = 'loadmore' } = {}) {
2020-07-14 17:43:15 +08:00
const type = this.setOrderType();
2020-07-06 17:32:29 +08:00
const res = await this.$u.api.getOrderList({
2020-06-30 18:06:50 +08:00
page: this.page,
2020-07-06 17:32:29 +08:00
type: type,
2020-07-14 10:13:27 +08:00
})
this.timer = true;
2020-07-31 21:47:41 +08:00
uni.stopPullDownRefresh(); // 结束刷新
2020-07-14 10:13:27 +08:00
if(res.errCode == 0) {
2020-07-31 21:47:41 +08:00
if(load == 'reload') this.orderList = res.data;
else if(load == 'loadmore') this.orderList.push(...res.data);
2020-07-14 10:13:27 +08:00
}
2020-08-06 17:52:25 +08:00
return res.data.length;
2020-07-14 10:13:27 +08:00
},
2020-07-31 21:47:41 +08:00
// 售后
async getAfterSaleList({ load = 'loadmore' } = {}) {
2020-07-14 10:13:27 +08:00
const res = await this.$u.api.getAfterSaleList({
page: this.page,
2020-06-30 18:06:50 +08:00
})
2020-07-07 17:47:00 +08:00
this.timer = true;
2020-07-06 17:32:29 +08:00
if(res.errCode == 0) {
2020-07-31 21:47:41 +08:00
if(load == 'reload') this.orderList = res.data;
else if(load == 'loadmore') this.orderList.push(...res.data);
2020-07-06 17:32:29 +08:00
}
2020-08-06 17:52:25 +08:00
return res.data.length;
2020-06-30 18:06:50 +08:00
},
2020-07-31 21:47:41 +08:00
// 试穿
async goodsTryOrderList({ load = 'loadmore' } = {}) {
2020-07-27 17:59:47 +08:00
const res = await this.$u.api.goodsTryOrderList({
page: this.page,
})
2020-07-31 21:47:41 +08:00
uni.stopPullDownRefresh(); // 结束刷新
2020-07-27 17:59:47 +08:00
this.timer = true;
if(res.errCode == 0) {
2020-07-31 21:47:41 +08:00
if(load == 'reload') this.orderList = res.data.list;
else if(load == 'loadmore') this.orderList.push(...res.data.list);
2020-07-27 17:59:47 +08:00
}
2020-08-06 17:52:25 +08:00
return res.data.list.length;
2020-07-27 17:59:47 +08:00
},
2020-06-19 18:07:11 +08:00
reachBottom() {
2020-08-07 17:34:59 +08:00
if(this.current == 4) return;
2020-07-06 17:32:29 +08:00
if(!this.timer) return false;
2020-07-07 17:47:00 +08:00
this.timer = false;
2020-06-19 18:07:11 +08:00
this.loadStatus.splice(this.current, 1, "loading");
this.page++;
2020-07-14 10:13:27 +08:00
let promise;
2020-07-31 21:47:41 +08:00
// if(this.current == 6) promise = this.getAfterSaleList();
// else
2020-08-07 17:34:59 +08:00
// if(this.current == 4) promise = this.goodsTryOrderList();
promise = this.getOrderList();
2020-08-06 17:52:25 +08:00
promise.then(length => {
2020-07-06 17:32:29 +08:00
this.loadStatus.splice(this.current, 1, "nomore");
2020-08-06 17:52:25 +08:00
if(length == 0) this.page--;
2020-07-06 17:32:29 +08:00
}).catch(() => {
2020-06-19 18:07:11 +08:00
this.loadStatus.splice(this.current, 1, "nomore");
2020-07-06 17:32:29 +08:00
this.page--;
})
2020-06-19 18:07:11 +08:00
},
2020-06-08 15:23:23 +08:00
tabsChange(index) {
2020-06-19 18:07:11 +08:00
this.current = Number(index);
2020-06-08 15:23:23 +08:00
this.swiperCurrent = Number(index);
},
animationfinish(e) {
let current = Number(e.detail.current);
this.swiperCurrent = current;
this.current = current;
2020-07-06 17:32:29 +08:00
},
setViewHeight() {
const sys = uni.getSystemInfoSync();
this.swiperHeight = sys.windowHeight - 88 / 2 + 'px';
},
2020-06-08 15:23:23 +08:00
}
};
</script>
<style lang="scss" scoped>
.order {
min-height: calc(100vh - var(--window-top));
background-color: #ECECEC;
display: flex;
flex-direction: column;
.swiper-item {
2020-08-07 17:34:59 +08:00
.order-scroll {
.item-container {
padding: 20rpx 30rpx;
}
2020-06-08 15:23:23 +08:00
}
}
}
</style>