<template>
	<view class="content" v-if="scheme != ''">
		<view class="schemes-header">
			<view class="schemes-user">您好！{{user.nickname}} {{user.sex == '男'? '先生': '女士'}}</view>
			<view class="schemes-text">以下是根据您的情况为您匹配的机构最佳方案。由于银行政策实时变动，该方案为预估方案，仅供参考，具体以协商为准，感谢您的支持！</view>
		</view>
		<!-- 卡片信息 -->
		<view class="schemes-block">
			<view class="schemes-info">
				<view class="schemes-flex schemes-flex-header">
					<view class="schemes-title">{{scheme.institution.title}}</view>
					<text class="schemes-type">{{scheme.business_type.title}}</text>
				</view>
				<view class="schemes-flex" v-for="(item, index) in scheme.base" :key="index">
					<view class="schemes-label">{{item.title}}</view>
					<text class="schemes-value">{{item.value || '-'}}</text>
				</view>
			</view>
			<view class="schemes-info schemes-footer">
				<view class="schemes-info-title">
					预估方案
					<text>YGFA</text>
				</view>
				<block v-if="scheme.params.length > 0">
					<view class="schemes-flex" v-for="(item, index) in scheme.params" :key="index">
						<view class="schemes-label">{{item.title}}</view>
						<text class="schemes-value">{{item.value || '-'}}</text>
					</view>
				</block>
				<block v-else>
					<view class="params-null">
						<u-empty
							mode="coupon"
							icon="http://cdn.uviewui.com/uview/empty/coupon.png"
							text="暂无预估方案"
						>
						</u-empty>
					</view>
				</block>
				<view class="schemes-tips">
					<view class="schemes-tips-title">须知：</view>
					<u-read-more
						:toggle="true"
						showHeight="200rpx"
						:shadowStyle="shadowStyle"
						closeText="阅读全文"
						color="#446EFE"
						textIndent="0em"
					>
						<text>{{scheme.business_type.notic}}</text>
					</u-read-more>
					<!-- <rich-text :nodes="content"></rich-text> -->
				</view>
			</view>
		</view>
		<!-- 温馨提示 -->
		<view class="notic">
			<text>{{scheme.business_type.sweet_notic}}</text>
		</view>
	</view>
</template>

<script>
	import { getSchemes } from '@/apis/interfaces/order.js'
	export default {
		data() {
			return {
				user  : { name : '', sex: '' },
				scheme: '',
				shadowStyle: {
					backgroundImage: "linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, #F6F6F6 80%)",
					paddingTop: "50px",
					marginTop: "-50px",
				}
			};
		},
		created() {
			this.getSchemesInfo()
		},
		methods: {
			getSchemesInfo(){
				getSchemes(this.$Route.query.id).then(res => {
					let { scheme, user } = res;
					this.scheme = scheme
					this.user   = user
					if(scheme == ''){
						uni.showModal({
							title		: '提示',
							content		: '暂未生成预约方案，请稍后再试',
							showCancel	: false,
							success		: ModalRes => {
								if(ModalRes.confirm){
									this.$Router.back()
								}
							}
						})
					}
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon : 'none'
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.content{
		padding-bottom: 50rpx;
		box-sizing: border-box;
	}
	// 温馨提示
	.notic{
		padding: 30rpx;
		color: #FBAF3B;
		font-size: 28rpx;
		line-height: 40rpx;
	}
	// 方案
	.schemes-block{
		border-radius: 20rpx;
		background: white;
		margin: -80rpx 30rpx 0;
		position: relative;
		.schemes-info{
			padding: 30rpx;
			box-sizing: border-box;
			position: relative;
			border-bottom: dashed 1rpx #EEEEEE;
			&.schemes-footer{
				border-bottom: none;
				position: relative;
				&::after{
					position: absolute;
					top: -20rpx;
					left: -20rpx;
					content: " ";
					width: 40rpx;
					height: 40rpx;
					background: #f8f8f8;
					border-radius: 50%;
				}
				&::before{
					position: absolute;
					top: -20rpx;
					right: -20rpx;
					content: " ";
					width: 40rpx;
					height: 40rpx;
					background: #f8f8f8;
					border-radius: 50%;
				}
			}
			.schemes-info-title{
				display: flex;
				justify-content: space-between;
				font-weight: bold;
				font-size: 40rpx;
				padding-bottom: 30rpx;
				color: $main-color;
				text{
					opacity: .3;
				}
			}
			.params-null{
				padding: 30rpx 0 50rpx;
			}
			.schemes-flex{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.schemes-title{
					font-weight: bold;
					font-size: 40rpx;
					line-height: 70rpx;
				}
				.schemes-type{
					background: white;
					color: $main-color;
					border:solid 1rpx $main-color;
					font-size: 28rpx;
					padding: 0 20rpx;
					line-height: 40rpx;
					border-radius: 20rpx;
				}
				&.schemes-flex-header{
					padding-bottom: 20rpx;
				}
				.schemes-label{
					line-height: 70rpx;
					font-size: 30rpx;
					width: 200rpx;
					color: #999999;
				}
				.schemes-value{
					width: calc( 100% - 200rpx );
					font-size: 30rpx;
					text-align: right;
				}
			}
			// 提示信息
			.schemes-tips{
				background: #F6F6F6;
				border-radius: 20rpx;
				margin-top: 30rpx;
				padding: 30rpx;
				font-size: 28rpx;
				color: #666;
				.schemes-tips-title{
					font-weight: bold;
					color: #111;
					padding-bottom: 20rpx;
				}
				text{
					line-height: 40rpx;
				}
			}
		}
	}
	// header
	.schemes-header{
		background: $main-color;
		padding: 30rpx 30rpx 150rpx;
		color: white;
		.schemes-user{
			font-size: 30rpx;
			padding-bottom: 20rpx;
		}
		.schemes-text{
			font-size: 30rpx;
			line-height: 45rpx;
		}
	}
</style>
