<template>
	<view class="page">
		
		<navbar
		:title="uid ? '用户订单信息' : '订单中心'"
		:leftClick="uid"
		@leftClick="$utils.navigateBack"
		/>
		
		<uv-tabs :list="tabs" 
		:activeStyle="{color : '#FD5100', fontWeight : 600}"
		lineColor="#FD5100"
		lineHeight="8rpx"
		lineWidth="50rpx"
		@click="clickTabs"></uv-tabs>
		
		<view v-if="orderList.records.length > 0" class="list">
			<view class="item" 
			v-for="(item, index) in orderList.records"
			@click="toOrderDetail(item.id)"
			:key="index">
	
				<view class="top">
					<view class="service">
						<text>{{ tabs[item.type + 1].name }}</text>
					</view>
					<view class="status">
						<text> {{item.status_dictText}}</text>
					</view>
				</view>
	
				<view class="content">
	
					<view class="left">
						<image mode="aspectFill" :src="item.pic"></image>
					</view>
	
					<view class="right">
						<view class="text-hidden-1">
							客户姓名：{{item.userName}}
						</view>
						<view class="text-hidden-1">
							产品规格：{{item.sku}}
						</view>
						<view class="text-hidden-1">
							租赁地址：{{item.userAddress}}
						</view>
						<!-- <view class="text-hidden-1">
							总计时间：{{item.useTime}}分钟
						</view> -->
						
					</view>
	
				</view>
	
				<view class="bottom">
					<view class="pay">
						
						<!-- 水洗店不展示 -->
						<!-- <view class="price"
						v-if="!userShop && item.type != 0 && item.type != 1">
							总金额：<text class="num">{{ item.orderPay }}元</text>
						</view> -->
						<view
						v-if="item.washPay && item.type == 1">
							水洗费用：{{ item.washPay }}元
						</view>
						
						<!-- 水洗店不展示 -->
						<view
						v-if="!userShop && item.rentPay && item.type == 1">
							租赁费用：{{ item.rentPay }}元
						</view>
					</view>
					<view class="">
						
						<!-- 水洗店不展示 -->
						<view class="price"
						v-if="!userShop && item.type == 1 && item.orderPay">
							总金额：<text class="num">{{ item.orderPay }}元</text>
						</view>
						<view class="b1">
							查看物流
						</view>
					</view>
					<!-- <view @click.stop="toPayOrder(item)" class="b2" v-if="item.state == 0">
						立即付款
					</view>
					<view class="b1" @click.stop="moreOrder(item.projectId,toPlaceorder)" v-if="item.state == 3">
						再来一单
					</view>
					<view class="b2" @click.stop="toEvaluate(item.id,item.projectId,item.technicianId)" v-if="item.state == 3">
						立即评价
					</view>
					<view class="b2" @click.stop="moreOrder(item.projectId,toPlaceorder)" v-if="item.state == 4">
						再来一单
					</view> -->
				</view>
	
			</view>
		</view>
		
		<uv-empty
		v-else
		text="空空如也"
		textSize="30rpx"
		iconSize="200rpx"
		icon="list"></uv-empty>
		
		<tabber select="2" v-if="!uid"/>
	</view>
</template>

<script>
	import tabber from '@/components/base/tabbar.vue'
	import { mapGetters } from 'vuex'
	export default {
		components : {
			tabber,
		},
		computed : {
			...mapGetters(['userShop']),
		},
		data() {
			return {
				tabs: [{
						name: '全部'
					},
					{
						name: '租赁押金'
					},
					{
						name: '水洗租赁'
					},
					{
						name: '破损换货'
					},
					{
						name: '退货退款'
					}
				],
				queryParams: {
					pageNo: 1,
					pageSize: 10
				},
				// orderList: [
				// 	{
				// 		money : 99.99,
				// 		address : '广东省广州市越秀区城南故事C3栋2802',
				// 		name : '李**',
				// 		phone : '150*****091',
				// 		unit : '120*40*75【桌子尺寸】',
				// 		image : 'https://img95.699pic.com/photo/50058/1378.jpg_wh860.jpg',
				// 		state_dictText : '已完成',
				// 	}
				// ], //订单列表数据
				orderList : {
					records : [],
					total : 0,
				},
				type : -1,
				uid : 0,
			}
		},
		onLoad(args) {
			this.uid = args.uid
		},
		onShow() {
			this.orderPage()
		},
		//滚动到屏幕底部
		onReachBottom() {
			if(this.queryParams.pageSize < this.orderList.total){
				this.queryParams.pageSize += 10
				this.orderPage()
			}
		},
		methods: {
			orderPage(){
				let queryParams = {
					...this.queryParams,
				}
				if(this.type != -1){
					queryParams.type = this.type
				}
				
				// 水洗店查询用户订单
				if(this.uid != 0){
					queryParams.uid = this.uid
				}
				this.$api('orderPage', queryParams, res => {
					if(res.code == 200){
						this.orderList = res.result
					}
				})
			},
			//点击tab栏
			clickTabs({ index, name }) {
				if (index == 0) {
					this.type = -1;
				} else {
					this.type = index - 1;
				}
				this.queryParams.pageSize = 10
				this.orderPage()
			},
			//跳转订单详情页面
			toOrderDetail(id) {
				uni.navigateTo({
					url: '/pages_order/order/orderDetail?id=' + id
				})
			},
			getOrderList(){
				
			},
		}
	}
</script>

<style scoped lang="scss">
	.page{
	}
	.list {
		.item {
			width: calc(100% - 40rpx);
			background-color: #fff;
			margin: 20rpx;
			box-sizing: border-box;
			border-radius: 16rpx;
			padding: 30rpx;
	
			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 30rpx;
	
				.service {}
	
				.status {
					font-size: 26rpx;
					font-weight: 600;
				}
			}
	
			.content {
				display: flex;
				margin: 10rpx 0;
	
				.left {
					width: 150rpx;
					height: 150rpx;
					border-radius: 10rpx;
	
					image {
						width: 150rpx;
						height: 150rpx;
						border-radius: 10rpx;
					}
				}
	
				.right {
					width: calc(100% - 160rpx);
					color: #777;
					font-size: 24rpx;
					padding-left: 20rpx;
					line-height: 40rpx;
					background-color: #F8F8F8;
				}
			}
	
			.bottom {
				display: flex;
				justify-content: space-between;
				font-size: 25rpx;
				.price {
					font-weight: 900;
					text {
						color: #ff780099;
						font-size: 30rpx;
					}
				}
				.b1 {
					border: 1px solid #777;
					color: #777;
					box-sizing: border-box;
					display: flex;
					justify-content: center;
					align-items: center;
				}
	
				.b2 {
					background: linear-gradient(178deg, #4FD3BC, #60C285);
					color: #fff;
				}
	
				.b1,.b2 {
					margin: 12rpx;
					border-radius: 28rpx;
					padding: 8rpx 28rpx;
					margin-bottom: 0;
				}
			}
		}
	}
</style>
