<template>
		<!-- 已关注公众号用户 -->
		<view class="content">
			<view class="banner">
				<image src="/static/images/policyIrrBanner.png" mode="widthFix"></image>
				<!-- 使用说明 -->
				<text @click="instructionForUse()">使用说明</text>
				<commonHead></commonHead>
			</view>
			<scroll-view scroll-y="true" class="formInfoContainer" id="formInfoContainer">
				<view class="tabTitle">
					<text @click="switchTab('1')" :class="{ 'actived': calcuteType==='1' }">增额</text>
					<text @click="switchTab('2')" :class="{ 'actived': calcuteType==='2' }">年金</text>
				</view>
				<form>
					<!-- 保单信息 -->
					<view class="policyInfoContent">
						<view class="title">
							<view>保单信息</view>
							<!-- <button class="btn" style="font-size: 12px;margin: 0;padding: 0 30px;"
							@click="calcute(2)"
							>保存</button> -->
						</view>
						<view class="inputItem">
							<text>交费年限：</text>
							<view class="inputContent">
								<input class="uni-input" type="number" placeholder="请输入" 
								v-model.trim="irrAndSimpleCalcuteParam.paymentPeriod" maxlength="3"
								/><label for="">年</label>
							</view>
						</view>
						<view class="inputItem">
							<text>年交保费：</text>
							<view class="inputContent">
								<input class="uni-input" type="digit" placeholder="请输入"  maxlength="17"
								v-model.trim="irrAndSimpleCalcuteParam.annualPremium"
								/><label for="">元</label>
							</view>
						</view>
						<view class="inputItem" v-show="calcuteType==='2'">
							<text>万能账户首年交费<text style="font-size: 24rpx;">(如有)</text>：</text>
							<view class="inputContent">
								<input class="uni-input" type="digit" placeholder="请输入"  maxlength="17"
								v-model.trim="irrAndSimpleCalcuteParam.allFirstPayment" @input="withdrawalTypeInit()"
								/><label for="">元</label>
							</view>
						</view>
					</view>
					<!-- 提领信息 -->
					<view class="claimInfomationContent" v-if="!irrAndSimpleCalcuteParam.allFirstPayment || irrAndSimpleCalcuteParam.allFirstPayment=='' || irrAndSimpleCalcuteParam.allFirstPayment==0">		
						<view class="title">
							<text>提领信息</text>
							<view @click="changeWithdrawalType()" v-if="calcuteType=='1'">
								<view style="display: flex;">
									<view class="radioButton" :class="{'selected':!withdrawalType}"></view>
									<text style="margin-left: 10rpx;">减保取现</text>
								</view>
							</view>
							<view class="tips">
								<text>(如有减保取现，请点击右侧按钮填写减保领取信息)</text>
							</view>
						</view>
						<!-- 年金提领信息 -->
						<view class="annuityContent" v-if="calcuteType==='2'">
							<view v-for="item in yearWithdrawalInfos">
								<view class="inputItem">
									<text>从第几个保单年度开始提取：</text>
									<view class="inputContent">
										<input class="uni-input" type="number" placeholder="请输入" maxlength="3"
										v-model="item.withdrawalStart"/><label for="">年</label>
									</view>
								</view>
								<view class="inputItem">
									<text style="white-space: nowrap;">每年提取金额：</text>
									<view class="inputContent">
										<input class="uni-input" type="digit" placeholder="请输入" maxlength="17"
										v-model="item.yearWithdrawalAmount" /><label for="">元</label>
									</view>
								</view>
							</view>
							
						</view>
						<!-- 增额减保取现 -->
						<view class="reduceInsuranceContent" v-if="!withdrawalType && calcuteType==='1'" style="margin-top: 30rpx;position: relative;">
							<view class="tableTh">
								<text>起领年度(年初)</text>
								<text>止领年度(年末)</text>
								<text class="withdrawNumber">年提取金额（元）</text>
							</view>
							<view class="tableTd" v-for="(item,idx) in yearWithdrawalInfos">
								<input class="uni-input" type="number" placeholder="请输入" 
								v-model="item.withdrawalStart"/>
								<input class="uni-input" type="number" placeholder="请输入" 
								v-model="item.withdrawalEnd"/>
								<input class="uni-input withdrawNumber" type="digit" placeholder="请输入" maxlength="17"
								v-model="item.yearWithdrawalAmount"/>
								<view v-show="yearWithdrawalInfos.length>1">
									<text @click="reduce(idx)"><svg t="1662455801913" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3447" width="20" height="20"><path d="M512 0c-285.257143 0-512 226.742857-512 512s226.742857 512 512 512 512-226.742857 512-512-226.742857-512-512-512z m0 950.857143c-241.371429 0-438.857143-197.485714-438.857143-438.857143s197.485714-438.857143 438.857143-438.857143 438.857143 197.485714 438.857143 438.857143-197.485714 438.857143-438.857143 438.857143z" p-id="3448" fill="#CEB07D"></path><path d="M731.428571 475.428571h-438.857142c-21.942857 0-36.571429 14.628571-36.571429 36.571429s14.628571 36.571429 36.571429 36.571429h438.857142c21.942857 0 36.571429-14.628571 36.571429-36.571429s-14.628571-36.571429-36.571429-36.571429z" p-id="3449" fill="#CEB07D"></path></svg></text>
								</view>
							</view>
							<text @click="add()" style="position: absolute;right: 0;">
								<svg t="1662455996735" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4399" width="20" height="20"><path d="M512 0c-285.257143 0-512 226.742857-512 512s226.742857 512 512 512 512-226.742857 512-512-226.742857-512-512-512z m0 950.857143c-241.371429 0-438.857143-197.485714-438.857143-438.857143s197.485714-438.857143 438.857143-438.857143 438.857143 197.485714 438.857143 438.857143-197.485714 438.857143-438.857143 438.857143z" p-id="4400" fill="#CEB07D"></path><path d="M731.428571 475.428571h-182.857142v-182.857142c0-21.942857-14.628571-36.571429-36.571429-36.571429s-36.571429 14.628571-36.571429 36.571429v182.857142h-182.857142c-21.942857 0-36.571429 14.628571-36.571429 36.571429s14.628571 36.571429 36.571429 36.571429h182.857142v182.857142c0 21.942857 14.628571 36.571429 36.571429 36.571429s36.571429-14.628571 36.571429-36.571429v-182.857142h182.857142c21.942857 0 36.571429-14.628571 36.571429-36.571429s-14.628571-36.571429-36.571429-36.571429z" p-id="4401" fill="#CEB07D"></path></svg>
							</text>
						</view>
					</view>
					<!-- 现金价值信息 -->
					<view class="cashValueContent" :style="{marginTop:(calcuteType=='1'?'80rpx':'40rpx')}">
						<view class="title">
							<text>现金价值</text>
							<view class="calcTypeOption">
								<button class="mini-btn" type="default" size="mini" @click="initCashValue('1')" :class="{'actived':calcuteMethod=='1'}">单次</button>
								<button class="mini-btn" type="default" size="mini" @click="initCashValue('2')" :class="{'actived':calcuteMethod=='2'}">批量</button>
							</view>
						</view>
						<view class="simpleCalculateContent" v-show="calcuteMethod==='1'">
							<view class="inputItem">
								<text>第：</text>
								<view class="inputContent">
									<input class="uni-input" type="number" placeholder="请输入" min='1' maxlength="3"
									v-model="irrAndSimple.nyear"/>
									<label for="">年</label>
								</view>
							</view>
							<view class="inputItem">
								<text>{{irrAndSimpleCalcuteParam.allFirstPayment > 0 ? '总生存利益（现金价值+万能账户现价)' :'现金价值'}}:</text>
								<view class="inputContent">
									<input class="uni-input" type="digit" placeholder="请输入" min='1' maxlength="17"
									v-model="irrAndSimple.cashValue"/>
									<label for="">元</label>
								</view>
							</view>
						</view>
						<view class="batchCalculateContent" v-show="!resultShowFlag && calcuteMethod==='2'">
							<image src="/static/images/batchFileImport.png" mode="widthFix"></image>
							<text>暂无数据</text>
							<text style="font-size: 14px;margin-top: 10rpx;">点击下方按钮输入批量数据</text>
						</view>
					</view>
					<!-- 现金价值单利复利结果展示 -->
					<view class="resultContent" id="resultContent">
						<!-- 单次计算显示结果 -->
						<view id="simpleDataResult" class="simpleDataResult" v-if="resultShowFlag && calcuteMethod == '1'">
							<view class="inputItem">
								<text class="resultTitle">IRR复利</text>
								<text class="calcNumber">{{irrAndSimpleResInfos.length>0?(irrAndSimpleResInfos[0]['irrValue'] * 100).toFixed(3):null}}%</text>
							</view>
							<view class="inputItem">
								<text class="resultTitle">单利</text>
								<text class="calcNumber">{{irrAndSimpleResInfos.length>0?(irrAndSimpleResInfos[0]['simpleValue'] * 100).toFixed(3):null}}%</text>
							</view>
						</view>
						<!-- 批量计算显示结果 -->
						<view class="batchDataResult" v-if="resultShowFlag && calcuteMethod == '2'">
							<scroll-view scroll-y="true" class="scroll-Y">
								<view class="scroll-view-item">
									<view class="resultTh">
										<text>保单年度</text>
										<text>现金价值</text>
										<text>IRR复利</text>
										<text>单利</text>
									</view>
									<view class="resultTd" v-for="item in resIrrAndSimpleResInfos">
										<text>{{item.nyear}}</text>
										<text>{{numberConverter(item.cashValue)}}</text>
										<text class="resultNumber">{{(item.irrValue*100).toFixed(3)}}%</text>
										<text class="resultNumber">{{(item.simpleValue * 100).toFixed(3)}}%</text>
									</view>
								</view>
							</scroll-view>
						</view>
					</view>

					<foot></foot>
					<!-- 操作 -->
					<view class="optionContent">
						<button type="default" plain="true" form-type="reset"
						@click="resetData()">清空</button>
						<button type="default" plain="true"
						class="sfp_btn" @click="calcute(2)"
						v-show="calcuteMethod==2">输入批量数据</button>
						<button type="default" plain="true" class="sfp_btn" 
						@click="calcute(1)" v-show="calcuteMethod==1"
						>开始计算</button>
					</view>
				</form>
			</scroll-view>
		</view>
</template>

<script>
	import api from "../../api/api";
	import {nanoid} from 'nanoid';
	import dataHandling from "../../util/dataHandling";
	import dataImport from "../dataImport/data-import.vue";
	import { inject } from "vue";
	import foot from '../footer/footer.vue';
	import { toRefs, ref } from 'vue';
	import commonHead from '../header/header.vue';

	export default {
		data() {
			return {
				calcuteType:'1',   //计算类型(1:增额; 2:年金)
				withdrawalType:'1',        	//提领方式(1:正常提领; 2:减保取现)
				resultShowFlag:false,
				calcuteMethod:'1',         //计算方式(1:单次; 2:批量)
				businessType:1, //业务类型(1:计算; 2:保存)
				mobile:undefined,
				irrAndSimpleCalcuteParam:{},
				yearWithdrawal:{
					withdrawalType:undefined,
					withdrawalStart:undefined,
					withdrawalEnd:undefined,
					yearWithdrawalAmount:undefined,
				},
				irrAndSimple:{
					nyear:undefined,
					cashValue:undefined
				},
				yearWithdrawalInfos:[],
				irrAndSimpleInfos:[],
				irrAndSimpleResInfos:[] ,// 计算结果
				resIrrAndSimpleResInfos:[],
				irrFlag:Boolean = false,
			}
		},
		components:{
		     dataImport,
			 foot,
			 commonHead
		},
		onLoad() {
			if(dataHandling.getQueryString('isBack') == 1){
				const calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null;
				if(calcuteData){
					this.irrAndSimpleCalcuteParam.paymentPeriod = calcuteData.paymentPeriod;
					this.irrAndSimpleCalcuteParam.annualPremium = calcuteData.annualPremium;
					this.irrAndSimpleCalcuteParam.allFirstPayment = calcuteData.allFirstPayment;
					this.businessType = calcuteData.businessType;
					this.calcuteType = calcuteData.calcuteType;
					this.yearWithdrawalInfos = calcuteData.yearWithdrawalInfos;
					this.withdrawalType = calcuteData.withdrawalType;
				}
			}else{
				//初始化删除上次批量计算结果
				uni.removeStorageSync('resIrrAndSimpleResInfos');
			}
			if(this.yearWithdrawal.length>0){
				this.yearWithdrawalInfos.push({...this.yearWithdrawal,withdrawalType:this.withdrawalType?'1':'2'})
			}
		},
		methods: {
			checkToken(){
				api.checkToken().then(res=>{
					if(res['success']){}else{
						api.obtainToken().then(res=>{
							if(res.success){
								uni.setStorageSync('uni-token',res.data['token']);
							}
						})
					}
				})
			},
			getFollowData(e){
				this.isNeedOfficialAccountQrcode= ref(e);
				console.log('父组件拿到值了',e);
			},
			// 使用说明跳转
			instructionForUse(){
				window.location.href = 'https://mp.weixin.qq.com/s/ZmlFZv51Pr0qpKeFiebI3Q';
			},
			// 数字千分位处理
			numberConverter(val){
				return dataHandling.numberConverter(val)
			},
			// 封装报错弹窗
			errorDialog(type,content){
				// type 1 必填项校验 2 规则校验
				uni.showModal({
				  title: type===1 ? '必填项校验' : '规则校验',
				  content:content,
				  showCancel:false,
				  success: function (res) {
						  if (res.confirm) {
								  console.log('用户点击确定');
						  } else if (res.cancel) {
								  console.log('用户点击取消');
						  }
				  }
				});
			},
			// 当有万能账户时，提领信息清空
			withdrawalTypeInit(){
				if(this.irrAndSimpleCalcuteParam.allFirstPayment>0) {
					this.yearWithdrawalInfos=null
				}else{
					this.yearWithdrawalInfos = [].concat([{withdrawalType:'1',
					withdrawalStart:null,
					yearWithdrawalAmount:null}]);
				}
			},
			switchTab(e){
				if(this.calcuteType !=e){
					this.calcuteType = e;
					//点年金时初始化1条提领信息
					if(e=='2'){
						this.irrAndSimpleCalcuteParam.allFirstPayment = null;
						this.yearWithdrawalInfos = [].concat([{withdrawalType:'1',
						withdrawalStart:null,
						yearWithdrawalAmount:null}]);
					}else if(e=='1'){
						this.irrAndSimpleCalcuteParam.allFirstPayment = null;
						if(this.withdrawalType == '1'){
							this.yearWithdrawalInfos = [];
						}else{
							this.yearWithdrawalInfos = [].concat([{withdrawalType:'2',
							withdrawalStart:null,
							yearWithdrawalAmount:null,
							withdrawalEnd:null}]);
						}
					}
					this.resultShowFlag = false;
				}

			},
			// calcuteMethod判断单次还是批量；businessType判断保存还是计算
			calcute(businessType){
				if(this.calcuteMethod==='1'){
					// 计算
					this.irrAndSimpleCalte();
				}else if(this.calcuteMethod === '2'){
					//批量
					if(!this.irrAndSimpleCalcuteParam.paymentPeriod || this.irrAndSimpleCalcuteParam.paymentPeriod==0){
						this.errorDialog(1,`交费年限为必填项且必须大于0`);
						return false;
					}
					if(!this.irrAndSimpleCalcuteParam.annualPremium){
						this.errorDialog(1,`年交保费为必填项`);
						return false;
					}
					//提领信息判断
					if(this.yearWithdrawalInfos && this.yearWithdrawalInfos.length>0){
						for (let i = 0; i < this.yearWithdrawalInfos.length; i++) {
								//增额提领信息校验
								if(this.calcuteType == 1){
									if(!this.yearWithdrawalInfos[i].withdrawalStart || !this.yearWithdrawalInfos[i].withdrawalEnd || this.yearWithdrawalInfos[i].withdrawalStart<=0 || this.yearWithdrawalInfos[i].withdrawalEnd<=0){
										this.errorDialog(1,`请输入第${i+1}行提领起领年度和止领年度,且该保单年度必须大于0`);
										return false;
									}else{
										if(Number(this.yearWithdrawalInfos[i].withdrawalStart) > Number(this.yearWithdrawalInfos[i].withdrawalEnd)){
											this.errorDialog(2,`第${i+1}行,起领年度必须小于等于止领年度！`);
											return false;
										}
									}
									if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount'] && this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<=0){
										this.errorDialog(2,`第${i+1}行,提领金额必须大于0`);
										return false;
									}else if(Number(this.yearWithdrawalInfos[i]['yearWithdrawalAmount']) > 999999999999999){
										this.errorDialog(2,`第${i+1}行,提领金额必须小于999,999,999,999,999`);
										return false;
									}else{
										if(!this.yearWithdrawalInfos[i]['yearWithdrawalAmount']){
											this.errorDialog(1,`请输入第${i+1}行,提领金额`);
											return false;
										}
									}
								}
								//年金提领信息校验
								if(this.calcuteType == '2'){
									if(!this.yearWithdrawalInfos[i]['withdrawalStart'] || this.yearWithdrawalInfos[i]['withdrawalStart']<0){
										this.errorDialog(1,`请输入提领信息保单年度，且年度值必须大于0`);
										return false;
									}
									if(!this.yearWithdrawalInfos[i]['yearWithdrawalAmount']){
										this.errorDialog(1,'请输入提领金额');
										return false;
									}else{
										if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<0){
											this.errorDialog(1,'提领金额必须大于等于0');
											return false;
										}
										if(Number(this.yearWithdrawalInfos[i]['yearWithdrawalAmount']>999999999999999)){
											this.errorDialog(1,'提领金额必须小于999,999,999,999,999');
											return false;
										}
									}
								}
							}
						}
					// 输入批量数据，缓存当页数据
					const calcuteData = {
						paymentPeriod:this.irrAndSimpleCalcuteParam.paymentPeriod,
						annualPremium:this.irrAndSimpleCalcuteParam.annualPremium,
						allFirstPayment:this.irrAndSimpleCalcuteParam.allFirstPayment,
						yearWithdrawalInfos:this.yearWithdrawalInfos,
						calcuteType:this.calcuteType,
						businessNo:nanoid(),
						businessType:this.businessType,
						withdrawalType:this.withdrawalType,
						systemType:1,
						userId:uni.getStorageSync('cffp_userId')
					}
					uni.setStorageSync('calcuteData',JSON.stringify(calcuteData))
					uni.navigateTo({
						url: `/sfp/dataImport/data-import?isUniversalAccount=${this.irrAndSimpleCalcuteParam.allFirstPayment > 0 ? '1' : '0'}`
					});
					// this.irrFlag = true;
				}
			},
			//点击单次时初始化数据
			initCashValue(calcuteMethod){
				if(this.calcuteMethod != calcuteMethod){
					this.calcuteMethod = calcuteMethod;
					if(calcuteMethod === '1'){
						this.irrAndSimple = {nyear:null,cashValue:null};
						this.irrAndSimpleInfos = [].concat([{nyear:null,cashValue:null}]);
					}
					//切换单次还是批量时，清空结果
					this.resultShowFlag = false;
				}
				
			},
			changeWithdrawalType(){
				this.withdrawalType = !this.withdrawalType;
				if(!this.withdrawalType){
					this.yearWithdrawalInfos = [].concat([{withdrawalType:'2',
					withdrawalStart:null,
					withdrawalEnd:null,
					yearWithdrawalAmount:null,}]);
					console.log(this.yearWithdrawalInfos)
				}else{
					this.yearWithdrawalInfos = [];
				}
			},
			//提领信息+
			add(){
				this.yearWithdrawalInfos.push({
					withdrawalType:undefined,
					withdrawalStart:undefined,
					withdrawalEnd:undefined,
					yearWithdrawalAmount:undefined,
					withdrawalType:this.withdrawalType?'1':'2'
					})
			},
			//提领信息-
			reduce(idx){
				if(this.yearWithdrawalInfos.length>1){
					this.yearWithdrawalInfos.splice(idx,1)
				}
				
			},
			// 计算接口
			irrAndSimpleCalte(){
				if(!this.irrAndSimpleCalcuteParam.paymentPeriod || this.irrAndSimpleCalcuteParam.paymentPeriod <= 0){
					this.errorDialog(1,`交费年限为必填项且必须大于0`);
					return false;
				}else{
					if(this.irrAndSimpleCalcuteParam.paymentPeriod >50 ){
						this.errorDialog(2,`交费年限一般不大于50年，请确认！`);
						return false;
					}
				}
				if(!this.irrAndSimpleCalcuteParam.annualPremium){
					this.errorDialog(1,`年交保费为必填项!`);
					return false;
				}else{
					if(this.irrAndSimpleCalcuteParam.annualPremium > 999999999999999){
						this.errorDialog(2,`年交保费不能大于999,999,999,999,999！`);
						return false;
					}
					if(this.irrAndSimpleCalcuteParam.annualPremium <= 0){
						this.errorDialog(2,`年交保费必须大于0！`);
						return false;
					}
				} 
				if(this.irrAndSimpleCalcuteParam.allFirstPayment && this.irrAndSimpleCalcuteParam.allFirstPayment < 0){
					this.errorDialog(2,`万能账户首年交费须大于或等于0！`);
					return false;
				}
				if(this.irrAndSimpleCalcuteParam.allFirstPayment && this.irrAndSimpleCalcuteParam.allFirstPayment > 999999999999999){
					this.errorDialog(2,`万能账户首年交费必须小于999,999,999,999,999！`);
					return false;
				}
				if(this.businessType == 2){
					if(!this.mobile){
						this.errorDialog(1,`保存时手机号必填！`);
						return false;
					}
				}
				//提领信息判断
				if(this.yearWithdrawalInfos && this.yearWithdrawalInfos.length>0){
					for (let i = 0; i < this.yearWithdrawalInfos.length; i++) {
							//增额提领信息校验
							if(this.calcuteType == 1){
								if(!this.yearWithdrawalInfos[i].withdrawalStart || !this.yearWithdrawalInfos[i].withdrawalEnd || this.yearWithdrawalInfos[i].withdrawalStart<=0 || this.yearWithdrawalInfos[i].withdrawalEnd<=0){
									this.errorDialog(1,`请输入第${i+1}行提领起领年度和止领年度,且该保单年度必须大于0`);
									return false;
								}else{
									if(Number(this.yearWithdrawalInfos[i].withdrawalStart) > Number(this.yearWithdrawalInfos[i].withdrawalEnd)){
										this.errorDialog(2,`第${i+1}行,起领年度必须小于等于止领年度！`);
										return false;
									}
								}
								if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount'] && this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<=0){
									this.errorDialog(2,`第${i+1}行,提领金额必须大于0`);
									return false;
								}else if(Number(this.yearWithdrawalInfos[i]['yearWithdrawalAmount']) > 999999999999999){
									this.errorDialog(2,`第${i+1}行,提领金额必须小于999,999,999,999,999`);
									return false;
								}else{
									if(!this.yearWithdrawalInfos[i]['yearWithdrawalAmount']){
										this.errorDialog(1,`请输入第${i+1}行,提领金额`);
										return false;
									}
								}
							}
							//年金提领信息校验
							if(this.calcuteType == '2'){
								if(!this.yearWithdrawalInfos[i]['withdrawalStart'] || this.yearWithdrawalInfos[i]['withdrawalStart']<0){
									this.errorDialog(1,`请输入提领信息保单年度，且年度值必须大于0`);
									return false;
								}
								if(!this.yearWithdrawalInfos[i]['yearWithdrawalAmount']){
									this.errorDialog(1,'请输入提领金额');
									return false;
								}else{
									if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<0){
										this.errorDialog(1,'提领金额必须大于等于0');
										return false;
									}
									if(Number(this.yearWithdrawalInfos[i]['yearWithdrawalAmount']>999999999999999)){
										this.errorDialog(1,'提领金额必须小于999,999,999,999,999');
										return false;
									}
								}
							}
						}
					}
				if(this.calcuteMethod == 1){
					if(!this.irrAndSimple.nyear && this.irrAndSimple.nyear!=0){
						this.errorDialog(1,`请输入现金价值年度！`);
						return false;
					}else{
						if(Number(this.irrAndSimple.nyear)>105){
							this.errorDialog(2,`现金价值年度不能大于105！`);
							return false;
						}
						if(this.irrAndSimple.nyear<=0){
							this.errorDialog(2,`现金价值年度必须大于0！`);
							return false;
						}
					}
					if(!this.irrAndSimple.cashValue || this.irrAndSimple.cashValue<0){
						this.errorDialog(1,'请输入现金价值且现金价值只能大于或等于0！');
						return false;
					}else{
						if(Number(this.irrAndSimple.cashValue) > 999999999999999){
							this.errorDialog(1,'现金价值必须小于999,999,999,999,999');
							return false;
						}
					}
				}
				const params = {
					...this.irrAndSimpleCalcuteParam,
					calcuteType:this.calcuteType,
					businessType:this.businessType,
					calcuteMethod:this.calcuteMethod,
					businessNo:nanoid(),
					mobile: null,
					loginNo: null,
					wechat_openid: uni.getStorageSync('openId') || '',
					yearWithdrawalInfos:this.yearWithdrawalInfos,
					irrAndSimpleInfos:[].concat([this.irrAndSimple]),
					withdrawalType:this.withdrawalType?'1':'2',
					decimal: 5,
					systemType:1,
					userId:uni.getStorageSync('cffp_userId')
				};
				api.irrAndSimpleCalcute(params).then(res=>{
					if(res.success === true){
						// 出结果之后自动滑倒底部
						setTimeout(()=>{
							uni.pageScrollTo({
								duration:100,
								scrollTop:200000
							})
						},100)
						if(res.data.irrAndSimpleResInfos){
							this.irrAndSimpleResInfos = res.data.irrAndSimpleResInfos;
							this.resultShowFlag = true;
							
						}else{
							this.irrAndSimpleResInfos = [];
						}
					}else{
						if(res.data.calcuteCode=='0'){
							// 没有关注公众号
							this.isNeedOfficialAccountQrcode = true;
							return false;
						}
						this.irrAndSimpleResInfos = [];
						uni.showToast({
							title: res['message'],
							duration: 2000,
							icon: 'none'					
						})
					}
				})
			},
			resetData(){
				this.irrAndSimpleCalcuteParam = {};
				this.yearWithdrawalInfos = [];
				this.withdrawalType = '1';
				this.irrAndSimple = {nyear:undefined,cashValue:undefined};
				this.resultShowFlag = false;
			}
		},
		onShow() {
			if(uni.getStorageSync('resIrrAndSimpleResInfos')){
				this.resIrrAndSimpleResInfos = uni.getStorageSync('resIrrAndSimpleResInfos');
				this.calcuteMethod = '2';
				this.resultShowFlag = true;
			}
		},
		mounted() {
			this.checkToken();
		}
	
	}
</script>

<style>
	@import '../sfpCommon.css';
	@import 'index.css';
</style>
