<template>
	<view class="main bg-white">
		<u-dropdown>
			<u-dropdown-item v-model="value1" :title="textcontent" @change="typechange" :options="options1"></u-dropdown-item>
			<u-dropdown-item v-model="value2" :title="options2[value2].label" @change="paychange" :options="options2"></u-dropdown-item>
			<u-dropdown-item v-model="value3" :title="options3[value3].label" @change="timechange" :options="options3"></u-dropdown-item>
		</u-dropdown>
		<view class="margin-lr-sm bg-white">
			<view class="margin-top-sm" v-for="(item,index) in ordersList" :key="index" style="border-radius: 16rpx;box-shadow: 0 0 50rpx 0 rgba(0, 0, 0, 0.1);">
				<view class="flex justify-between align-center bg-white" style="padding: 28rpx;border-radius: 16rpx;">
					<view class="jinxing">
						<text style="display: inline-block;width: 12rpx;height: 12rpx;border-radius: 50%;background-color:#EEAA3F;margin-right: 8rpx;"></text>
						<text v-if="item.order_status==3">进行中</text>
						<text v-else-if="item.order_status==1">未支付</text>
						<text v-else-if="item.order_status==2">待接单</text>
						<text v-else-if="item.order_status==4">已完成</text>
						<text v-else>已取消</text>
					</view>
					<text class="phonezi" v-if="item.product_type==3">门诊预约</text>
					<text class="phonezi" v-else-if="item.product_type==4">计免预约</text>
					<text class="phonezi" v-else>儿保预约</text>
				</view>
				<view class="" style="background: #FBFBFB;padding: 28rpx; border-radius: 16rpx;">
					<view class="nametaile flex align-center">
						<u-avatar v-if="item.product_type==3" :src="item.docter.avatar" mode="circle"></u-avatar>
						<u-avatar v-else :src="item.organization.docter[0].avatar" mode="circle"></u-avatar>
						<text v-if="item.product_type==3" class="margin-left-sm">{{item.docter.name}}</text>
						<text v-else class="margin-left-sm">{{item.organization.docter[0].name}}</text>
						<text class="text_style" v-for="(itm,idx) in item.docter.label" :key="index">{{itm}}</text>
					</view>
					<view class="textstyle margin-top-xs flex align-center justify-between">
						<text style="color: #333333;" v-if="item.product_type==3">科室：{{item.docter.office.name}}
							{{item.docter.qualification.name}}</text>
					</view>
					<view class="textstyle margin-top-xs flex align-center justify-between">
						<text style="color: #333333;">编号：{{item.order_sn}}</text>
					</view>
					<view class="textstyle margin-top-xs">
						<text style="color: #333333;">下单时间：{{item.created_at}}</text>
					</view>
				</view>
			</view>
		</view>
		<u-empty text="暂无数据" mode="order" :show="show" margin-top="250"></u-empty>
		<view class="cu-tabbar-height"></view>
		<view class="cu-tabbar-height"></view>
	</view>
</template>

<script>
	export default {
		onLoad(options) {
			if (this.value1 == 3) {
				this.textcontent = "门诊预约"
			}
		},
		mounted() {
			this.getordersList()
			console.log(this.value1)
		},
		data() {
			return {
				value1: 3, //全部类型
				value2: 0, //全部状态
				value3: 0, //时间正序
				options1: [{
						value: 3,
						label: "门诊预约"
					},
					{
						value: 4,
						label: "计免预约"
					},
					{
						value: 5,
						label: "儿保预约"
					},
				],
				options2: [{
						value: 0,
						label: "全部状态"
					},
					{
						value: 1,
						label: "未支付"
					},
					{
						value: 2,
						label: "待接单"
					},
					{
						value: 3,
						label: "进行中"
					},
					{
						value: 4,
						label: "已完成"
					},
					{
						value: 5,
						label: "已取消"
					},
				],
				options3: [{
						value: 0,
						label: "时间正序"
					},
					{
						value: 1,
						label: "时间倒序"
					},
				],
				ordersList: [],
				pageindex: 1,
				show: false,
				textcontent: ""
			}
		},
		methods: {
			typechange(value) {
				this.value1 = value
				if (value == 3) {
					this.textcontent = "门诊预约"
				} else if (value == 4) {
					this.textcontent = "计免预约"
				} else if (value == 5) {
					this.textcontent = "儿保预约"
				}
				this.ordersList = []
				this.getordersList()
			},
			paychange(value) {
				this.value2 = value
				this.ordersList = []
				this.getordersList()
			},
			timechange(value) {
				this.value3 = value
				this.ordersList = []
				this.getordersList()
			},
			getordersList: async function() {
				let res = await this.$request.post("/api/v1/order/orderList", {
					page: this.pageindex,
					list_type: 2,
					product_type: this.value1,
					order_status: this.value2,
					time_sort: this.value3
				})
				console.log(this.value1)
				if (res.status == 0) {
					this.ordersList = this.ordersList.concat(res.data.data)
				}
				console.log(this.ordersList)
				if (this.ordersList.length == 0) {
					this.show = true
				} else {
					this.show = false
				}
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.main {}

	.text_style {
		font-weight: 400;
		margin-left: 15rpx;
		background-color: #E5F5FF;
		color: #0B73B9;
		width: 100rpx;
		height: 28rpx;
		font-size: 20rpx;
		border-radius: 10rpx;
		text-align: center;
		align-items: center;
	}

	.nametaile {
		font-size: 30rpx;
		font-weight: 500;
		color: #333333;
	}

	.textstyle {
		font-size: 26rpx;
		color: #666666;
		font-weight: 400;
	}

	.phonezi {
		width: 160rpx;
		height: 54rpx;
		background: #F6F6F6;
		border-radius: 27rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #666666;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.jinxing {
		height: 30rpx;
		font-size: 30rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #EEAA3F;
		display: flex;
		align-items: center;
	}
</style>
