<template>
	<view class="perfect">
		<view class="perfect-header">
			<text v-if="isFinish == 0">订单资料完善中</text>
			<text v-if="isFinish == 1">订单资料审核中</text>
			<text v-if="isFinish == 2">修改订单资料</text>
			<image class="cover" src="@/static/background/info_back.png" mode="widthFix"></image>
		</view>
		<view class="perfect-list">
			<view class="perfect-item" @click="onPerfect('WorkPerfectBasis', baseInfo.is_finish, baseInfo.business_order_user_id, baseInfo.is_my, baseInfo.user_base)">
				<view class="cover">
					<image class="cover-src" src="@/static/icons/tabs_show_01.png" mode="aspectFit"></image>
				</view>
				<view class="main">
					<view class="title nowrap">基础信息</view>
					<view class="submit nowrap">客户身份等基础信息</view>
				</view>
				<view class="state normal" v-if="baseInfo.is_finish == 0">待完善<u-icon class="arrow" color="#446EFE" name="arrow-right"></u-icon></view>
				<view class="state" v-else-if="baseInfo.is_finish == 2">待修改<u-icon class="arrow" color="#FFAB3F" name="arrow-right"></u-icon></view>
				<view class="state gray" v-else>已完善<u-icon class="arrow" color="gray" name="arrow-right"></u-icon></view>
			</view>
			<!-- 机构列表 -->
			<block v-for="(item, index) in businessArr" :key="index">
				<view class="perfect-item" @click="onPerfect('WorkPerfectInstitutions', item.is_finish, item.business_order_item_id, item.is_my, item.user_bank)">
					<view class="cover">
						<image class="cover-src" :src="item.institution.cover" mode="aspectFit"></image>
					</view>
					<view class="main">
						<view class="title nowrap">{{item.institution.title || '-'}}</view>
						<view class="submit nowrap">{{item.business_type.title || '-'}}</view>
					</view>
					<view class="state normal" v-if="item.is_finish == 0">待完善<u-icon class="arrow" color="#446EFE" name="arrow-right"></u-icon></view>
					<view class="state" v-else-if="item.is_finish == 2">待修改<u-icon class="arrow" color="#FFAB3F" name="arrow-right"></u-icon></view>
					<view class="state gray" v-else>已完善<u-icon class="arrow" color="gray" name="arrow-right"></u-icon></view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	import { perfect } from '@/apis/interfaces/order.js'
	export default {
		data() {
			return {
				orderId		: '',
				baseInfo	: {
					name	 : '',
					is_finish: 0
				},
				isFinish	: 0,
				businessArr	: []
			};
		},
		created() {
			this.orderId = this.$Route.query.orderId
		},
		onShow(){
			this.getPerfect()
		},
		methods: {
			// 获取基础资料
			getPerfect(){
				uni.showLoading({
					title	: '加载中...',
					mask	: true
				})
				perfect(this.$Route.query.orderId).then(res => {
					let { base, items, is_finish } = res;
					this.isFinish = is_finish;
					this.baseInfo = base;
					this.businessArr = items;
					if(is_finish == 1 && this.$Route.query.type == 'perfect'){
						this.$store.commit('setOrderId', this.$Route.query.orderId)
					}
					uni.hideLoading()
				}).catch(err => {
					uni.showToast({
						title: err.message,
						icon : 'none'
					})
				})
			},
			// 资料导航
			onPerfect(name, finish, itemId, isMy, user){
				if(finish == 1) {
					if(name === 'WorkPerfectBasis') this.$Router.push({ name: 'OrderPerfectBasisInfo',  params: { orderId: this.orderId, }})
					if(name === 'WorkPerfectInstitutions') this.$Router.push({ name: 'OrderPerfectInstitutionsInfo', params: { itemId }})
					return
				}
				this.$Router.push({
					name,
					params: {
						itemId : itemId,
						orderId: this.orderId,
						isMy,
						userBankId: user,
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.perfect{
		background: #f8f8f8;
		min-height: 100vh;
		// header
		.perfect-header{
			background: linear-gradient(180deg, $main-color, #6588ff);
			padding: 30rpx 50rpx 130rpx;
			position: relative;
			font-weight: bold;
			color: white;
			font-size: 46rpx;
			.cover{
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
			}
		}
		// 资料列表
		.perfect-list{
			position: relative;
			margin-top: -80rpx;
			padding: 0 50rpx;
			z-index: 1;
			.perfect-item{
				position: relative;
				display: flex;
				justify-content: space-between;
				align-items: center;
				background: white;
				border-radius: 20rpx;
				padding: 40rpx;
				box-shadow: 0 0 10rpx 10rpx rgba(0, 0, 0, .02);
				margin-bottom: 30rpx;
				overflow: hidden;
				.cover{
					width: 180rpx;
					height: 180rpx;
					position: absolute;
					right: 0;
					bottom: -30rpx;
					opacity: .15;
					transform: rotate(-45deg);
					&-src{
						width: 180rpx;
						height: 180rpx;
					}
					&::after{
						content: " ";
						position: absolute;
						top: 0;
						left: 0;
						width: 100%;
						height: 100%;
						background: linear-gradient(to top, #ffffff, rgba(255,255,255,0));
					}
				}
				.main{
					width: calc(100% - 200rpx);
					.title{
						font-weight: bold;
						font-size: 34rpx;
						line-height: 50rpx;
					}
					.submit{
						font-size: 28rpx;
						color: gray;
						line-height: 50rpx;
					}
				}
				.state{
					position: relative;
					z-index: 1;
					width: 200rpx;
					text-align: right;
					font-size: 30rpx;
					color: $text-price;
					.arrow{
						display: inline-block;
						vertical-align: middle;
						margin-bottom: 5rpx;
					}
					&.normal{
						color: $main-color;
					}
					&.gray{
						color: gray;
					}
				}
			}
		}
	}
</style>
