<template>
	<view class="myorderForm">
		<loadlogo v-if="!loadlogo" />

		
		<view class="vtabs">
			<v-tabs
				:lineScale="0.25"
				:lineRadius="'100rpx 100rpx 0 0'"
				:lineHeight="'8rpx'"
				:fontSize="'32rpx'"
				:activeFontSize="'32rpx'"
				:bold="true"
				:height="'100rpx'"
				:paddingItem="'0 22rpx 20rpx'"
				:activeColor="'#333333'"
				:lineColor="'#333333'"
				:color="'#999999'"
				v-model="sort"
				:scroll="false"
				@change="vtabschange"
				:tabs="type=='1'?arr:brr"
			></v-tabs>
		</view>
		<view class="order-list" v-if="orderList.length > 0">
			<view  v-for="(item,index) in orderList" :key="index">
				<homemakingOrder ref="homemakingOrder" :orderItem="item" :hidefish="hidefish" @getoderList="getoderList" :type="type"></homemakingOrder>
			</view>
			<load-more :isMore="isMore"></load-more>
		</view>
		<view  v-else>			<image style="width: 750upx;height: 560upx;" :src="imgfixUrls + 'homemakingImg/wushuju.png'" mode=""></image>		</view>
		<TabBars :tabBarAct="0" pageType="18"></TabBars>
	</view>
</template>

<script>
import App from '@/common/js/app.js';
import vTabs from '@/components/v-tabs/v-tabs.vue';
import loadMore from '@/components/template/loadmore.vue';
import Loadlogo from '@/components/template/loadlogo.vue';
import homemakingOrder from '@/components/template/homemakingOrder.vue';
import TabBars from '@/components/template/tabBar.vue';
export default {
	data() {
		return {
			sort:0,
			page:1,
			orderList:[],
			total:1,
			isMore:true,
			loadlogo:false,
			pageOne:false,
			arr:['全部', '待支付','待服务','已完成'],
			brr:['全部', '待服务','待评价','已完成'],
			hidefish:0
		};
	},
	components: {
		vTabs,
		homemakingOrder,
		loadMore,
		Loadlogo,
		TabBars
	},
	onLoad(e) {
		this.type = e.type;
		this.getoderList()
	},
	onShow() {
		if(!this.pageOne) return
		this.getoderList(false,1)
	},
	onReachBottom() {
		if(this.total == this.page) return
		this.page++;
		this.isMore = false;
		this.getoderList(true,this.page)
	},
	methods:{
		getoderList(flag,page){
			let _this = this;
			let data = {
				page:page ||this.page,
				status:this.sort
			}
			let url = this.type == '1'?'&p=housekeep&do=memberOrderList':'&p=housekeep&do=artificerOrderList'
			App._post_form(
				url,
				data,
				res => {
					if(flag){
						_this.isMore = true;
						_this.orderList = _this.orderList.concat(res.data.list);
						_this.orderList.map(item=>{
							item.type = _this.type;
						})
						if(page == _this.page && page) return
						// debugger
						let pages = page + 1;
						_this.getoderList(true,pages);
					}else{
						console.log(res);
						_this.orderList = res.data.list;
						_this.total = res.data.total;
						_this.pageOne = true;
						_this.orderList.map(item=>{
							item.type = _this.type;
						})
						if(page == _this.page || !page) return
						_this.getoderList(true,page++);
					};
					_this.hidefish = res.data.hidefish;
				},
				false,
				() => {
					this.loadlogo = true;
				}
			);
		},
		vtabschange(e){
			console.log(e);
			this.sort = e;
			this.page = 1;
			this.getoderList()
		}
	}
};
</script>

<style>
page {
	background-color: #f8f8f8;
}
</style>
<style lang="scss" scoped>
.myorderForm {
	padding-bottom: 130upx;
	.order-list{
		padding: 0 30upx;
	}
}
</style>
