<template>
	<view class="page">
		
		<navbar
		title="订单中心"
		leftClick 
		@leftClick="$utils.navigateBack"
		/>
		
		<uv-tabs :list="tabs" 
		:activeStyle="{color : '#A3D250', fontWeight : 600}"
		lineColor="#A3D250"
		lineHeight="8rpx"
		lineWidth="50rpx"
		:current="current"
		:scrollable="false"
		@click="clickTabs"></uv-tabs>
		
		<view class="list">
			<view class="item" 
			v-for="(item, index) in list"
			@click="toOrderDetail(item.id)"
			:key="index">
	
				<view class="top">
					<view class="service">
						<!-- <text>{{item.projectId_dictText}}</text>
						<text>{{item.type_dictText}}</text> -->
					</view>
					<view class="status">
						<text> {{ tabs[Number(item.state) + 1].name }}</text>
					</view>
				</view>
	
				<view class="content"
				:key="index"
				v-for="(good, index) in item.commonOrderSkuList">
	
					<view class="left">
						<image mode="aspectFill" 
						:src="good.image && good.image.split(',')[0]"></image>
					</view>
	
					<view class="right">
						<view class="text-hidden-1">
							商品：{{good.title}}
						</view>
						<view class="text-hidden-1">
							规格：{{good.sku}}
						</view>
						<view class="text-hidden-1">
							数量：{{good.num}}
						</view>
						<!-- <view class="text-hidden-1">
							总计时间：{{item.useTime}}分钟
						</view> -->
						
					</view>
	
				</view>
	
				<view class="bottom">
					<view class="price">
						实付款：<text class="num">{{item.price}}元</text>
					</view>
					
					<!-- <view class="b1">
						查看物流
					</view> -->
					
					<view @click.stop="toPayOrder(item)" class="b2" 
					v-if="item.state == 0">
						立即付款
					</view>
					
					<view class="b2"
					@click.stop="confirmOrder(item)"
					v-if="item.state == 2">
						确认收货
					</view>
				</view>
	
			</view>
		</view>
		
	</view>
</template>

<script>
	import { mapGetters } from 'vuex'
	import mixinsList from '@/mixins/list.js'
	import mixinsOrder from '@/mixins/order.js'
	export default {
		mixins : [mixinsList, mixinsOrder],
		components : {
		},
		computed : {
		},
		data() {
			return {
				tabs: [{
						name: '全部'
					},
					{
						name: '待付款'
					},
					{
						name: '待发货'
					},
					{
						name: '待收货'
					},
					{
						name: '已完成'
					}
				],
				current : 0,
				mixinsListApi : 'getOrderPageList',
			}
		},
		onLoad(args) {
			this.current = args.type || 0
			this.clickTabs({index : this.current})
		},
		onShow() {
		},
		methods: {
			//点击tab栏
			clickTabs({index}) {
				console.log(index);
				if (index == 0) {
					delete this.queryParams.state
				} else {
					this.queryParams.state = index - 1
				}
				this.getData()
			},
			//跳转订单详情页面
			toOrderDetail(id) {
				uni.navigateTo({
					url: '/pages_order/order/orderDetail?id=' + id
				})
			},
		}
	}
</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;
				}
	
				.b2 {
					background: $uni-color;
					color: #fff;
					display: flex;
					align-items: center;
					justify-content: center;
				}
	
				view {
					margin: 12rpx;
					border-radius: 28rpx;
					padding: 16rpx 48rpx;
					margin-bottom: 0;
				}
			}
		}
	}
</style>
