<template>
	<view class="container safe-area-inset-bottom">
		<MessageNotification />
		<!-- 预约成功 -->
		<view class="paided">
			<text class="iconfont icon-emichenggong"></text>
			挂号成功
		</view>

		<!-- 确认 -->
		<view class="btn">
			<view class="back" @click="goOrder">
				确认
			</view>
		</view>

	</view>
</template>

<script>
	import {
		saveSpecialPrescriptionRegisterContext,
		tryCreateSpecialPrescriptionPatientRecord,
	} from '@/request/api/specialPrescription';

	export default {
		data() {
			return {
				register_id: "",
			}
		},
		onLoad(e) {
			this.register_id = e.id
			if (e.special_prescription_id) {
				const spCtx = {
					special_prescription_id: e.special_prescription_id,
					dose_count: e.special_prescription_dose_count || 1,
					doctor_id: e.doctor_id || '',
				}
				if (e.special_prescription_sku_id != null && e.special_prescription_sku_id !== '') {
					spCtx.sku_id = Number(e.special_prescription_sku_id)
				}
				saveSpecialPrescriptionRegisterContext(spCtx)
			}
			this.bindSpecialPrescriptionRecord()
		},
		methods: {
			async bindSpecialPrescriptionRecord() {
				await tryCreateSpecialPrescriptionPatientRecord(this.register_id)
			},
			// 确认
			goOrder() {
				uni.navigateTo({
					url: '/subPackages/register/register-info?id=' + this.register_id,
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 750rpx;
		min-height: 100vh;
		max-height: 100%;
		background: #F8FAFC;
		padding-bottom: env(safe-area-inset-bottom);

		.paided {
			width: 710rpx;
			height: 304rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			background: #FFFFFF;
			border-radius: 16rpx;
			font-size: 40rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #232323;
			padding: 48rpx;
			margin: 0 auto;

			.iconfont {
				font-size: 120rpx;
				color: #4175EE;
				margin: 0 0 32rpx 0;
			}
		}

		.btn {
			width: 750rpx;
			height: 110rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 12rpx 32rpx;
			margin-top: 44rpx;

			.back {
				width: 686rpx;
				height: 86rpx;
				text-align: center;
				line-height: 86rpx;
				background: #4175EE;
				border-radius: 198rpx;
				font-size: 32rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
			}
		}
	}
</style>
