<template>
	<view class="login-container">

		<image class="photo-imge" src="/static/index/workjoin/bgc.png" />
		<image class="old-imge" src="/static/index/workjoin/ren.png" />
		<view class="under-container" @touchstart.stop @touchmove.stop @touchend.stop>
			<view class="white-card">
				<image class="left-img"
					:src="type=== `1` ? `/static/index/workjoin/man.png` : `/static/index/workjoin/bgcren.png`" />
				<view class="card-font">
					<view style="font-size: 30rpx;font-weight: 600;margin: 20rpx 0 30rpx 0;">
						{{type=== `1` ? `机构加盟`:`员工入驻`}}
					</view>
					<view style="color: #666666;font-size: 25rpx;">
						护理院日常护理涵盖生活照料、健康监测、康复护理及心理关怀，为老人提供贴心照护。
					</view>
				</view>
			</view>
			<view class="white-ball" @click="goback">
				<image class="ball-imge" src="/static/index/workjoin/x.png" />
			</view>
			<view class="shu-father">
				<view class="shu"></view>
				<view class="shu-font">{{ type==="1" ? `机构加盟审核列表` : `员工入驻审核列表` }}</view>

			</view>

			<view class="under-scroll">
				<scroll-view scroll-y refresher-enabled :refresher-triggered="isRefreshing"
					@refresherrefresh="onRefresh" style="height: 100%;width: 100%;">
					<view v-for="(item,index) in workArray" :key="index">
						<view class="white-small">
							<view style="width: 100%;margin-bottom: 80rpx;font-size: 25rpx;">
								{{item.comName}}申请入驻加盟护理单元，提交时间:{{item.updateTime}}，审核结果:{{item.status==1 ? "审核中" :item.status==2?`审核完成`:item.status==3?`驳回`:`待提交`  }}
								{{item.status==3?`，驳回备注:${item.content}`:``}}
							</view>
							<view class="button-heng">
								<view class="blue-button" v-if="item.status==3||item.status==0" @click="again(item)">
									修改申请
								</view>
								<view class="white-button" @click="jumpToAll(item)">
									查看详情
								</view>
							</view>

						</view>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		reactive,
		ref
	} from 'vue';
	import {
		onLoad,
		onPullDownRefresh
	} from '@dcloudio/uni-app'
	import {
		getMessageList
	} from '@/pages/addjigou/api/addjigou.js'
	const type = ref(0)
	const workArray = ref([])
	const isRefreshing = ref(false)
	const onRefresh = () => {
	  console.log("下拉刷新被触发")
	  isRefreshing.value = true
		getMessageList(uni.getStorageSync('tel')).then(res => {
			workArray.value = [];
			workArray.value = res.result;
			 isRefreshing.value = false 
		})
	}
	// 页面加载时接收 URL 参数
	onLoad((options) => {
		// options.type 即为你在 URL 里传的 number
		type.value = options.type || ''
		if (type.value) {
			getMessageList(uni.getStorageSync('tel')).then(res => {
				workArray.value = res.result
			})
		}

	})


	const goback = () => {
		uni.navigateBack()
	}

	const again = (item) => {
		uni.setStorageSync("baddata", item)
		uni.setStorageSync('specicalid', item.id);
		uni.navigateTo({
			url: `/pages/addjigou/name`
		});
	}

	const jumpToAll = (element) => {
		uni.navigateTo({
			url: `/pages/addjigou/all?element=${JSON.stringify(element)}`
		});
	}
</script>

<style lang="scss" scoped>
	.login-container {
		display: flex;
		flex-direction: column;
		min-height: 100vh;
		width: 100%;
		background-color: rgb(239, 241, 252);
		position: relative;

		.title {
			margin-top: 70rpx;
			align-items: center;

			.title-imge {
				width: 100rpx;
				height: 105rpx;
				margin-left: 100rpx;
			}

			.title-font {
				font-size: 35rpx;
				font-weight: 600;
				margin-left: 105rpx;
				margin-top: 10rpx;
			}
		}

		.photo-imge {
			position: absolute;
			top: 0rpx;
			left: 0;
			width: 100%;
			height: 100vh;
		}

		.old-imge {
			position: absolute;
			right: 50%;
			transform: translateX(50%);
			top: 0rpx;
			width: 550rpx;
			height: 750rpx;
		}

		.under-container {
			position: fixed;
			left: 0;
			bottom: 0;
			width: 100%;
			height: 100%;
			background-color: rgb(236, 238, 244);
			box-shadow: 10rpx 10rpx 20rpx rgba(0, 0, 0, 0.1);
			display: flex;
			flex-direction: column;
			align-items: center;
			z-index: 1;
		}
	}

	.white-card {
		margin-top: 30rpx;
		width: 94%;
		background-color: #fff;
		height: 320rpx;
		border-radius: 45rpx;
		display: flex;
		align-items: center;
		position: relative;

		.left-img {
			width: 150rpx;
			height: 250rpx;
			margin-left: 50rpx;
			// margin-top: 35rpx;

		}

		.card-font {
			margin-left: 60rpx;
			// margin-top: 50rpx;
			width: 380rpx;
		}
	}

	.white-ball {
		position: absolute;
		right: 60rpx;
		top: 60rpx;
		width: 75rpx;
		height: 75rpx;
		border-radius: 50%;
		border: 1rpx solid #b1b1b1;
		display: flex;
		justify-content: center;
		align-items: center;

		.ball-imge {
			width: 30rpx;
			height: 30rpx;
		}
	}

	.shu-father {
		display: flex;
		margin: 30rpx 0;
		width: 100%;

		.shu {
			background: linear-gradient(to bottom, #00C9FF, #0076FF);
			margin: 0 5%;
			width: 15rpx;
			border-radius: 10rpx;
			height: 35rpx;
			margin-right: 3%;
		}

		.shu-font {
			color: #666666;
		}
	}

	.under-scroll {
		width: 100%;
		height: calc(100% - 460rpx);

		.white-small {
			width: 94%;
			margin-left: 3%;
			background-color: #fff;
			border-radius: 30rpx;
			padding: 30rpx;
			margin-bottom: 30rpx;
			font-size: 25rpx;
			color: #999999;
			position: relative;
		}
	}

	.button-heng {
		// width: 100%;
		display: flex;
		justify-content: flex-end;
		position: absolute;
		bottom: 30rpx;
		right: 0;

		.white-button {
			width: 180rpx;
			height: 60rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			background: linear-gradient(to bottom, #F3F3F5, #DEE4E9);
			border-radius: 30rpx;
			color: black;
			margin-right: 20rpx;
		}

		.blue-button {
			width: 180rpx;
			height: 60rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			background: linear-gradient(to right, #00C9FF, #0076FF);
			margin-right: 20rpx;
			border-radius: 30rpx;
			color: #fff;
		}
	}
</style>