Files
BlockChainH5/pages/user/order/servicesOrder.vue

230 lines
4.9 KiB
Vue

<template>
<view class="NumberWeight">
<!-- 订单分类 -->
<view class="nav">
<view :class="['nav-item', selectNavId === item.id ? 'nav-item-selected' : '']" v-for="(item, index) in navList" :key="index" @click="selectNav(item.id)">
{{ item.name }} {{ item.id === 'signed' && count.signed > 0 ? '(' + count.signed + ')' : '' }}
{{ item.id === 'completed' && count.completed > 0 ? '(' + count.completed + ')' : '' }} {{ item.id === 'init' && count.init > 0 ? '(' + count.init + ')' : '' }}
{{ item.id === 'delivered' && count.delivered > 0 ? '(' + count.delivered + ')' : '' }}
</view>
</view>
<!-- 有订单列表 -->
<block v-if="lists.length > 0">
<!-- 订单列表 -->
<view class="order-list" v-for="(item, index) in lists" :key="index">
<MallShipmentsTemplate :item="item" />
<view class="actions"><view class="nowPay" @click="goDetail(item.shipment_no)">查看详情</view></view>
</view>
</block>
<!-- 没有订单列表 -->
<no-list v-if="lists.length === 0" name="no-order" txt="暂无数据~" />
<u-toast ref="uToast" />
</view>
</template>
<script>
import MallShipmentsTemplate from '@/components/mall-shipments-template/mall-shipments-template';
import { mallShipmentsPostShop, mallShipmentsSign, mallShipmentsCancel } from '@/apis/interfaces/numberWeight';
export default {
components: {
MallShipmentsTemplate
},
data() {
return {
lists : [],
page : 1,
total : 0,
navList : [],
type : '', // post 快递单 空为自提单
selectNavId : 'signed',
count : {} // 订单数量
};
},
onLoad(e) {
this.navList = [
{
name: '已使用',
id: 'signed'
},
{
name: '已完成',
id: 'completed'
}
];
this.selectNavId = 'signed';
this.getList();
},
onShow() {
if (uni.getStorageSync('refresh')) {
this.reset();
}
},
onUnload() {
uni.setStorageSync('refresh', false);
},
onReachBottom() {
if (this.total > this.lists.length) {
this.page = this.page + 1;
this.getList();
} else {
this.$refs.uToast.show({
title: '吼吼吼~我是有底的~',
duration: 3000
});
}
},
methods: {
reset() {
this.page = 1;
this.total = 0;
this.lists = [];
this.getList();
uni.setStorageSync('refresh', false);
},
// 选择订单
selectNav(id) {
if (this.selectNavId !== id) {
this.selectNavId = id;
this.reset();
}
},
// 获取订单列表
getList() {
let data = {
pageSize: 4,
page: this.page,
state: this.selectNavId
};
let apiUrl = '';
apiUrl = 'mall/shipments/service';
data.channel = 'app';
mallShipmentsPostShop(apiUrl, data)
.then(res => {
this.count = res.count;
this.lists = this.lists.concat(res.lists.data);
this.total = res.lists.page.total;
})
.catch(err => {
this.$refs.uToast.show({
title: err.message,
duration: 3000
});
});
},
// 查看详情
goDetail(no) {
uni.navigateTo({
url: '/pages/property/order/servicesOrderInfo?no=' + no
});
}
}
};
</script>
<style lang="scss" scoped>
page {
width: 100%;
height: 100%;
}
.NumberWeight {
width: 100%;
min-height: 100vh;
box-sizing: border-box;
background-color: #f7f7f7;
// 订单nav
.nav {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
box-sizing: border-box;
font-size: $title-size * 0.95;
padding: 0 30rpx;
background-color: #fff;
color: #666;
border-top: solid 20rpx #f7f7f7;
position: sticky;
top: 0rpx;
z-index: 10000;
.nav-item {
border-bottom: solid 4rpx #fff;
padding: 30rpx 10rpx;
}
.nav-item-selected {
border-bottom: solid 4rpx $mian-color;
color: $mian-color;
}
}
// 订单列表
.order-list {
background-color: #fff;
border-radius: 20rpx;
min-height: 300rpx;
margin: 30rpx 20rpx 0 20rpx;
padding: 30rpx 30rpx 20rpx 30rpx;
// border-top: solid 4rpx #cacaca;
// 操作信息
.actions {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
box-sizing: border-box;
flex-wrap: wrap;
flex: 1;
font-size: 28rpx;
color: #fff;
border-top: solid 1rpx #eff4f2;
.nowPay {
padding: 4rpx 20rpx;
border-radius: 40rpx;
margin-left: 20rpx;
margin-top: 20rpx;
// background-color: $mian-color;
color: #999;
border: solid 1rpx #cacaca;
}
.cancelOrder {
padding: 10rpx 30rpx;
border-radius: 40rpx;
margin-left: 20rpx;
margin-top: 20rpx;
background-color: #dd524d;
}
.logistics {
background-color: $mian-color;
padding: 10rpx 30rpx;
border-radius: 40rpx;
margin-left: 20rpx;
margin-top: 20rpx;
}
.sign {
background-color: #dd524d;
padding: 10rpx 30rpx;
border-radius: 40rpx;
margin-left: 20rpx;
margin-top: 20rpx;
}
.evaluate {
background-color: $mian-color;
padding: 10rpx 30rpx;
border-radius: 40rpx;
margin-left: 20rpx;
margin-top: 20rpx;
}
}
}
}
</style>