<template>
	<view class="container">
		<view class="img">
			<img src="@/static/6.png" />
		</view>
		<view class="info">
			{{ info }}
		</view>

		<!-- 弹窗区域 -->
		<uni-popup ref="popup" :is-mask-click="false">
			<view class="pop">
				<image class="pop_img" src="/static/3.png" mode="aspectFill"></image>
				<!-- 关闭图标 -->
				<uni-icons class="pop_close" type="closeempty" color="#808080" size="20" @click="handleClose"></uni-icons>
				<view class="pop_title">温馨提示</view>
				<view class="pop_text" v-if="pageValue == 2">{{ tips.chooseDormitory }}</view>
				<view class="pop_text" v-if="pageValue == 3">{{ tips.carOrder }}</view>
				<view class="pop_btn" @click="handleFinish">去完成缴费</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
import { ref, nextTick } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getQueryString } from '../../utils/getParams.js'
import { getSettingsInfoReq } from '@/api/index.js'

const info = ref('')

const popup = ref()

// 页面类型
const pageValue = ref()

const tips = ref({})

onLoad((options) => {
	// console.log(options)
	if (options.pageValue) {
		pageValue.value = options.pageValue
	}
	// 获取设置数据
	getSettingsInfo()

	nextTick(() => {
		getMessage()
	})
})

const getMessage = () => {
	const message = getQueryString('message')
	if (message) {
		info.value = message

		if (message == '请先完成缴费') {
			popup.value.open()
		}
	} else {
		info.value = '404'
	}
}

// 获取设置数据
const getSettingsInfo = async () => {
	const res = await getSettingsInfoReq()
	// console.log(res)
	if (res.code == 200) {
		tips.value = res.data
	}
}

// 弹窗关闭图标回调
const handleClose = () => {
	popup.value.close()
}

// 去完成缴费回调
const handleFinish = () => {
	window.location.href = `https://pay.ncjti.edu.cn`
}
</script>

<style lang="scss" scoped>
.container {
	display: flex;
	flex-direction: column;
	align-items: center;

	.img {
		margin-top: 200rpx;
		width: 480rpx;
		height: 508rpx;

		img {
			width: 100%;
			height: 100%;
		}
	}

	.info {
		padding: 0 30rpx;
	}

	.pop {
		position: relative;
		box-sizing: border-box;
		padding: 150rpx 20rpx 50rpx;
		width: 659rpx;
		height: 728rpx;
		border-radius: 15rpx;
		background: linear-gradient(180deg, #ebf2ff 0%, #ffffff 100%);

		.pop_img {
			position: absolute;
			top: -103rpx;
			left: 227rpx;
			width: 206rpx;
			height: 206rpx;
		}

		.pop_close {
			position: absolute;
			top: 19rpx;
			right: 29rpx;
		}

		.pop_title {
			margin-bottom: 28rpx;
			font-size: 32rpx;
			font-weight: bold;
		}

		.pop_text {
			font-size: 28rpx;
			line-height: 50rpx;
		}

		.pop_btn {
			display: flex;
			align-items: center;
			justify-content: center;
			margin: 90rpx auto 0;
			width: 543rpx;
			height: 100rpx;
			color: #fff;
			font-size: 32rpx;
			border-radius: 8rpx;
			background-color: #0061ff;
		}
	}
}
</style>
