<template>
	<view class="container">
		<view class="title">
		   <view>
				<text class="line"></text>个人声明
			</view>
		   <text class="page_mark">6/8</text>
		 </view>
		 <view class="content">
			<view class="ulBox">
			   <view class="liBox" v-for="personalStatements in dropOptionsInfoList" @click="selectStatements(personalStatements)"
			    >
				  <text class="iconfont icon-yuanxingweixuanzhong" v-if="!personalStatements.status"></text>
				  <text class="iconfont icon-selected-copy" v-if="personalStatements.status"></text>
			      <text class="itemName"> {{personalStatements.dropOptionName}}</text> 
			      <text class="iconfont icon-gougou" v-if="personalStatements.status"></text>
			    </view>
			</view>
		 </view>
		 <view class="fixed" @click="saveInfo()">
		   保存并下一步
		 </view>
	</view>
</template>

<script>
	import api from '../../api/api'
	export default{
		data(){
			return {
				dropOptionsInfoList:[],
				applyParam:{
					personalStatement:''
				},
				personalStatementList:[]
			}
		},
		components:{},
		onLoad(){
			this.dropOptionsQuery();
		},
		methods:{
			dropOptionsQuery(){
				api.dropOptionsQuery({code:'CFFP_Partner_Statements'}).then((res)=>{
					this.dropOptionsInfoList = res["data"]["dropMasterInfoList"][0]["dropOptionsInfoList"];
				})
			},
			selectStatements(personalStatements) {
			      if (personalStatements.status == 1) {
			        personalStatements.status = 0;
			      } else {
			        personalStatements.status = 1;
			      }
				console.log(this.dropOptionsInfoList)
			},
			saveInfo(){
				const selectedPersonalStatement = this.dropOptionsInfoList.filter((item) => {
				    return item.status == 1;
				});
				if (!selectedPersonalStatement.length) {
					uni.showToast({
						title: '请选择至少一项个人声明！',
						duration: 2000,
						icon: 'none'
					})
				return;
				}
				this.personalStatementList = [];
				for(let i=0;i<selectedPersonalStatement.length;i++){
					this.personalStatementList.push(selectedPersonalStatement[i]['dropOptionName']);
				}
				this.applyParam.personalStatement = this.personalStatementList .join(',');
				uni.setStorageSync('applyParam',JSON.stringify(this.applyParam))
				uni.navigateTo({
					url:'contract'
				})
				
			}
		}
	}
</script>

<style lang="scss">
	@import 'applyCommon.scss';
	.container {
		background-color: #FBFBFB;
	}
</style>