<template>
	<view class="container">
		<view class="header-box">
			<view class="search-box">
				<u-search
					v-model="searchForm.keyword"
					:clearabled="true"
					bg-color="#E5E5E5"
					:input-style="searchInputStyle"
					placeholder="搜索您想要的内容"
				></u-search>
			</view>
			<view class="tab-box">
				<u-tabs 
					name="label"
					:list="searchType"
					:is-scroll="true"
					v-model="searchForm.type"
					@change="onSearchTypeChange"
					font-size="24"
					:bold="false"
					inactive-color="#000000"
					active-color="#000000"
					:bar-style="{'background-color': '#2979ff'}"
					:gutter="25"
					height="45"
				></u-tabs>
			</view>
		</view>
		<view class="list-box">
			<view class="list-item-box" v-for="item in list" :key="item.id">
				<view class="title-box">
					{{item.title}}
				</view>
				<view class="main-box">
					<view class="info-box">
						<view class="info-item-box">
							<view class="label">
								订单编号:
							</view>
							<view class="text">
								{{item.number}}
							</view>
						</view>
						<view class="info-item-box">
							<view class="label">
								订单时间:
							</view>
							<view class="text">
								{{item.time}}
							</view>
						</view>
					</view>
					<view class="price-box">
						<view class="text" v-if="item.status === 1">
							实付款:&nbsp;¥{{item.price}}元
						</view>
						<view class="button" v-if="item.status === 0">
							已关闭
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="buttom-block"></view>
		<view class="bottom-box">
			<view class="button" @click="onToInvoiceApplication">
				发票申请
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	
	const searchInputStyle = {
		backgroundColor: '#E5E5E5'
	}
	const searchType = [
		{
			label: '全部',
			value: 0
		},
		{
			label: '市场研究',
			value: 1
		},
		{
			label: '继续教育',
			value: 2
		},
		{
			label: '会费',
			value: 3
		},
		{
			label: '业务水平认证考试',
			value: 4
		},
	]
	const searchForm = ref({
		keyword: '',
		type: 0
	})
	function onSearchTypeChange(val) {
		console.log('搜索表单', searchForm.value)
	}
	
	const list = ref([
		{
			id: '01',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '02',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 0
		},
		{
			id: '03',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '04',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '05',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '06',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '07',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '08',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '09',
			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
		{
			id: '10',
			title: '【市场研究】2024年10月广州市中介促成二手住宅市场交易简报',
			number: '123456789987654321',
			time: '2023年8月8日',
			price: '9.9',
			status: 1
		},
	])
	
	// 前往发票申请
	function onToInvoiceApplication() {
		uni.navigateTo({
			url: '/pages/InvoiceApplication/InvoiceApplication'
		})
	}
	
	onLoad(() => {
	})
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		width: 100vw;
		background-color: $uni-text-color-inverse;
		
		.header-box {
			padding: 0 20rpx;
			background-color: $uni-text-color-inverse;
			@include topMagnet();
		}
		
		.search-box {
			margin-bottom: 20rpx;
			::v-deep(.u-search) {
				background-color: #e5e5e5;
				border-radius: 50rpx;
				
				.u-action {
					width: 18%;
					background-color: $uni-color-primary;
					border-radius: 50rpx;
					color: $uni-text-color-inverse;
					margin-right: 8rpx;
					font-size: 28rpx;
					line-height: 50rpx;
					letter-spacing: 3rpx;
					text-align: center;
				}
			}
		}
		
		.list-box {
			padding: 0 20rpx;
			.list-item-box {
				padding: 20rpx;
				border-bottom: 5rpx solid #E6E6E6;
				&:active {
					background-color: $uni-bg-color-hover;
				}
				.title-box {
					font-size: $uni-title-font-size-3;
					font-weight: bold;
					margin-bottom: 20rpx;
					@include text-overflow()
				}
				.main-box {
					display: flex;
					justify-content: space-between;
					padding-left: 20rpx;
					.info-box {
						width: 50%;
						.info-item-box {
							display: flex;
							font-size: $uni-font-size-3;
							color: $uni-text-color-grey;
							line-height: 30rpx;
							.label {
								width: 80rpx;
							}
						}
					}
					.price-box {
						display: flex;
						align-items: flex-end;
						text-align: right;
						color: $uni-color-error;
						font-size: $uni-title-font-size-3;
						font-weight: bold;
						.button {
							background-color: #CCCCCC;
							color: $uni-text-color-inverse;
							padding: 6rpx 25rpx;
							border-radius: $uni-card-border-radius;
						}
					}
				}
			}
		}
	
		.buttom-block {
			height: 100rpx;
		}
		.bottom-box {
			text-align: center;
			font-size: $uni-title-font-size-2;
			background-color: $uni-bg-color-grey;
			
			@include bottomMagnet();
			.button {
				width: 100%;
				height: 100rpx;
				line-height: 100rpx;
				color: $uni-color-primary;
				letter-spacing: 2rpx;
				border: 1rpx solid #E9E9E9;
				&:active {
					background-color: $uni-bg-color-hover;
				}
			}
		}
	}
</style>