<template>
	<view class="container">
		<view class="user-info-box">
			<view class="box-l">
				<view class="img-box">
					<u-avatar :src="workbenchInfo.photographUrl || defaultImg" size="121rpx"
						mode="aspectFill"></u-avatar>
				</view>
				<view class="info-r">
					<view class="info-r-top">
						<span class="name">{{workbenchInfo.name || '-'}}</span>
					</view>
					<span class="phone">{{workbenchInfo.phoneNumber || '-'}}</span>
				</view>
			</view>
			<view class="box-r">
				<span class="btn" @click="toDept">查看管理科室</span>
			</view>

		</view>
		<view class="num-box flex-ac">
			<view class="num-item flex-ac">
				<view class="num-item-l">
					<span class="name">今日订单数</span>
					<span class="num">{{workbenchInfo.todayCount || 0}}</span>
				</view>
				<image src="/static/copy.png" mode="aspectFill"></image>
			</view>
			<view class="num-item flex-ac">
				<view class="num-item-l">
					<span class="name">总订单数</span>
					<span class="num">{{workbenchInfo.orderCount || 0}}</span>
				</view>
				<image src="/static/copy.png" mode="aspectFill"></image>
			</view>
		</view>

		<view class="order-box flex-dc">
			<view class="title-box flex-box-c-b">
				<span class="title">订单管理</span>
				<span class="more" @click="toPath(0)">查看全部></span>
			</view>
			<view class="order-list flex-box-a">
				<view class="order-item flex-box-cloum" v-for="item,index in orderType" :key="index"
					@click="toPath(item.index)">
					<image :src="item.icon" mode="aspectFill"></image>
					<span class="name">{{item.name}}</span>
				</view>
			</view>
		</view>

		<view class="order-box flex-dc">
			<view class="title-box flex-box-c-b">
				<span class="title">应用中心</span>
			</view>
			<view class="order-list flex-box-a">
				<view class="order-item flex-box-cloum" @click="toPath(2)">
					<image src="@/static/my/icon-04.png" mode="aspectFill"></image>
					<span class="name">待服务</span>
					<u-badge type="error" max="99" :value="workbenchInfo.waitConfirmedCount" :offset="[-10, -10]"
						absolute></u-badge>
				</view>
				<view class="order-item flex-box-cloum" @click="toRefund">
					<image src="@/static/my/icon-04.png" mode="aspectFill"></image>
					<span class="name">退款售后</span>
					<u-badge type="error" max="99" :value="workbenchInfo.waitRefundCount" :offset="[-10, -10]"
						absolute></u-badge>
				</view>
				<view class="order-item flex-box-cloum" @click="toPage">
					<image src="@/static/my/icon-04.png" mode="aspectFill"></image>
					<span class="name">护工管理</span>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getManageInfo,
	} from '@/api/hospital.js'
	export default {
		data() {
			return {

				defaultImg: require('@/static/default-head-photo.png'),
				workbenchInfo: {

				},
				orderType: [{
					index: 1,
					name: '待确认',
					icon: require('@/static/my/icon-04.png'),
				}, {
					index: 2,
					name: '待服务',
					icon: require('@/static/my/icon-04.png'),
				}, {
					index: 3,
					name: '服务中',
					icon: require('@/static/my/icon-04.png'),
				}, {
					index: 4,
					name: '待评价',
					icon: require('@/static/my/icon-04.png'),
				}, {
					index: 5,
					name: '已完成',
					icon: require('@/static/my/icon-04.png'),
				}, ],
				quickOrder: [{
					index: 1,
					name: '待服务',
					icon: require('@/static/my/icon-04.png'),
					value: 100
				}, {
					index: 2,
					name: '退款售后',
					icon: require('@/static/my/icon-04.png'),
					value: 10
				}, {
					index: 3,
					name: '护工管理',
					icon: require('@/static/my/icon-04.png'),
					value: 100
				}, ]
			}
		},
		onLoad() {
			this.getManageInfo()
		},
		methods: {
			//获取信息
			getManageInfo() {
				let that = this;
				getManageInfo().then(res => {
						if (res.code == 200) {
							let data = res.data;
							this.workbenchInfo = data;
							// data.unshift({
							// 	value: '全部',
							// 	code: undefined,
							// })
							// this.typeList = data;
						}

					})
					.catch((err) => {
						console.log(err);
					})
			},
			
			

			//查看管理科室
			toDept() {
				uni.navigateTo({
					url: '/pages/workbench/managementDept',
				})
			},
			toPath(val) {
				uni.navigateTo({
					url: '/pages/workbench/order/list?type=' + val
				})
			},

			toPage() {
				if (this.workbenchInfo.manageNursingFlag == 'Y') {
					uni.navigateTo({
						url: '/pages/workbench/caregiverManage?type=guanli',
					})

				} else {
					uni.showToast({
						title: '您没有权限',
						icon: 'none',
						duration: 2000,
					})
				}
			},
			
			toRefund(){
				uni.navigateTo({
						url: '/pages/workbench/refundOrder',
						
				})
			},

			//下拉刷新回调函数
			onPullDownRefresh() {
				// wx.setStorageSync('isChangeBanner', true);
				this.getManageInfo();
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 30rpx;

		.user-info-box {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx;
			background-color: #fff;
			border-radius: 20rpx;

			.box-l {
				display: flex;
				align-items: center;

				.info-r {
					display: flex;
					flex-direction: column;
					margin-left: 25rpx;

					.info-r-top {
						display: flex;
						align-items: center;
						margin-bottom: 10rpx;

						.name {
							display: inline-flex;
							font-size: 36rpx;
							height: 36rpx;
							line-height: 36rpx;
							justify-content: center;
							font-weight: bold;
						}

						.status {
							display: inline-flex;
							font-size: 24rpx;
							margin-left: 10rpx;
							height: 40rpx;
							line-height: 40rpx;
							padding: 0 20rpx;
							background-color: #FFF9D9;
							color: #B16E55;
							border-radius: 50rpx;

						}
					}

					.phone {
						font-size: 28rpx;
						color: #101010;
					}

				}

			}

			.box-r {
				.btn {
					font-size: 28rpx;
					color: #B16E55;
				}
			}
		}

		.num-box {
			margin-top: 20rpx;

			.num-item {
				width: 48%;
				padding: 20rpx;
				background-color: #fff;
				border-radius: 20rpx;
				justify-content: center;

				&:first-child {
					margin-right: 20rpx;

				}

				.num-item-l {
					display: flex;
					align-items: center;
					flex-direction: column;
					margin-right: 20rpx;

					.name {
						font-size: 36rpx;
						color: #101010;

					}

					.num {
						font-size: 36rpx;
						font-weight: bold;
						color: #101010;

					}

				}

				image {
					width: 40rpx;
					height: 40rpx;
					border-radius: 50%;
				}
			}
		}

		.order-box {
			background-color: #fff;
			padding: 20rpx;
			border-radius: 20rpx;
			margin-top: 20rpx;

			.title-box {
				margin-bottom: 20rpx;

				.title {
					font-size: 36rpx;
					font-weight: bold;
					color: #101010;
				}

				.more {
					font-size: 28rpx;
					color: #9a9a9a;
				}
			}

			.order-list {
				.order-item {
					position: relative;
					margin: 20rpx 0;

					image {
						width: 90rpx;
						height: 90rpx;
					}

					.name {
						margin-top: 15rpx;
						font-size: 28rpx;
						color: #101010;
					}
				}
			}

		}
	}
</style>