<template>
	<view class="page">
		
		<navbar
		title="订单中心"
		leftClick 
		@leftClick="$utils.navigateBack"
		/>
		
		<view class=""
		style="background-color: #fff;">
			<uv-tabs :list="tabs"
			lineColor="#B12026"
			lineHeight="8rpx"
			lineWidth="50rpx"
			:scrollable="false"
			@click="clickTabs"></uv-tabs>
		</view>
		
		<uv-empty
		v-if="orderList.length == 0"
		text="还没有订单呢!"
		textSize="30rpx"
		iconSize="200rpx"
		icon="list"></uv-empty>
		
		<view v-if="orderList.length > 0" class="list">
			<view class="item" 
			v-for="(item, index) in orderList" 
			@click="toOrderDetail(item.travelWaresOrder.id)"
			:key="index">
	
				<view class="top">
					<view class="service">
						<text>{{item.travelWares.waresTitle}}</text>
						<!-- <text>{{item.type_dictText}}</text> -->
					</view>
					<view class="status">
						<text> {{ statusTitle[item.travelWaresOrder.status] }}</text>
					</view>
				</view>
	
				<view class="content">
	
					<view class="left">
						<image mode="aspectFill" 
						:src="item.travelWares.waresImage"></image>
					</view>
	
					<view class="right">
						<view class="text-hidden-1">
							商品名称：{{item.travelWares.waresTitle}}
						</view>
						<view class="text-hidden-1">
							客户姓名：{{item.travelWaresOrder.userName}}
						</view>
						<view class="text-hidden-1">
							收货地址：{{item.travelWaresOrder.userAddress}}
						</view>
						
					</view>
	
				</view>
	
				<view class="bottom">
					<view class="price">
						总价格：<text class="num">{{item.travelWaresOrder.price}}元</text>
					</view>
					<!-- <view class="b1">
						查看物流
					</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>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex'
	export default {
		components : {
		},
		computed : {
			...mapGetters(['userShop']),
		},
		data() {
			return {
				statusTitle : ['待支付', '待发货', '待收货', '已完成'],
				tabs: [
					{
						name: '全部'
					},
					{
						name: '待支付'
					},
					{
						name: '待发货'
					},
					{
						name: '待收货'
					},
					{
						name: '已完成'
					},
				],
				queryParams: {
					pageNo: 1,
					pageSize: 10
				},
				orderList: [], //订单列表数据
				state : -1,
				total : 0,
			}
		},
		computed : {
		},
		onShow() {
			this.getOrderList()
		},
		methods: {
			//点击tab栏
			clickTabs({index}) {
				if (index == 0) {
					this.state = -1;
				} else {
					this.state = index - 1;
				}
				this.getOrderList()
			},
			//跳转订单详情页面
			toOrderDetail(id) {
				uni.navigateTo({
					url: '/pages_order/order/orderDetail?id=' + id
				})
			},
			getOrderList(){
				let queryParams = {
					...this.queryParams,
				}
				if(this.state != -1){
					queryParams.status = this.state
				}
				this.$api('queryWaresOrderList', queryParams, res => {
					if(res.code == 200){
						this.orderList = res.result
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.page{
		padding-bottom: 200rpx;
	}
	.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;
					display: flex;
					flex-direction: column;
					justify-content: space-around;
				}
			}
	
			.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;
				}
	
				.b2 {
					background: linear-gradient(178deg, #4FD3BC, #60C285);
					color: #fff;
				}
	
				view {
					margin: 12rpx;
					border-radius: 28rpx;
					padding: 8rpx 28rpx;
					margin-bottom: 0;
				}
			}
		}
	}
</style>
