Commit 4ba71484 by Sweet Zhang

改bug和弹窗

parent 8b993217
......@@ -9,10 +9,6 @@ import api from '@api/api.ts'
Vue.config.productionTip = false;
Vue.prototype.axios = axios;
Vue.prototype.$api = api;
import { numberToCurrencyNo } from './util/numberPipe';
// 配置全局过滤器,实现数字千分位格式
Vue.filter('numberToCurrency', numberToCurrencyNo)
App.mpType = 'app'
const app = new Vue({
api,
......
......@@ -92,7 +92,7 @@
name:'dataImport',
onLoad() {
this.bindPickerChange({detail:{value:this.index}});
this.calcuteData = uni.getStorageSync('calcuteData');
this.calcuteData = uni.getStorageSync('calcuteData') ? JSON.parse(uni.getStorageSync('calcuteData')) : null;
},
methods:{
// 选择间隔
......@@ -193,8 +193,24 @@
this.pasteData = '';
this.irrAndSimpleInfos.forEach(item=>item.cashValue='');
},
// 开始计算
calcuteIrr(){
this.policyYearLists = this.irrAndSimpleInfos.filter(item=>item.cashValue!=='')
if(this.policyYearLists.length<=0){
uni.showModal({
title: '必填提醒',
content:`系统检测到您并未录入有效的现金价值数据!`,
showCancel:false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return;
}
console.log(this.policyYearLists)
for(let i=0;i<this.policyYearLists.length;i++){
if(this.policyYearLists[i].cashValue<0 || isNaN(this.policyYearLists[i].cashValue)){
......
<template>
<!-- <view v-show="irrFlag == false" > -->
<!-- 没有关注公众号须先关注公众号才可以使用 -->
<view class="qrcodeContainer" v-show="isNeedOfficialAccountQrcode">
<view class="qrcodeContent">
<img src="../../static/images/qrcodeBg.png" alt="" srcset="">
</view>
</view>
<!-- 已关注公众号用户 -->
<view class="content" v-show="!isNeedOfficialAccountQrcode">
<view class="banner">
<img src="/static/images/policyIrrBanner.png" alt="" srcset="">
......@@ -53,7 +54,6 @@
</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'">
......@@ -167,9 +167,9 @@
</view>
<view class="resultTd" v-for="item in resIrrAndSimpleResInfos">
<text>{{item.nyear}}</text>
<text>{{item.cashValue | numberToCurrency}}</text>
<text class="resultNumber">{{(item.simpleValue*100).toFixed(3)}}%</text>
<text class="resultNumber">{{(item.irrValue * 100).toFixed(3)}}%</text>
<text>{{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>
......@@ -186,9 +186,7 @@
@click="calcute(1)" v-show="calcuteMethod==1"
>开始计算</button>
</view>
</form>
</scroll-view>
</view>
<!-- </view> -->
......@@ -206,7 +204,6 @@
export default {
data() {
return {
scrollTop:0,
isNeedOfficialAccountQrcode:true,
calcuteType:'1', //计算类型(1:增额; 2:年金)
withdrawalType:'1', //提领方式(1:正常提领; 2:减保取现)
......@@ -237,13 +234,17 @@
},
onLoad() {
if(dataHandling.getQueryString('isBack') == 1){
console.log(dataHandling.getQueryString('isBack'));
this.irrAndSimpleCalcuteParam.paymentPeriod = uni.getStorageSync('calcuteData').paymentPeriod;
this.irrAndSimpleCalcuteParam.annualPremium = uni.getStorageSync('calcuteData').annualPremium;
this.irrAndSimpleCalcuteParam.allFirstPayment = uni.getStorageSync('calcuteData').allFirstPayment;
this.businessType = uni.getStorageSync('calcuteData').businessType;
this.calcuteType = uni.getStorageSync('calcuteData').calcuteType;
this.yearWithdrawalInfos = uni.getStorageSync('calcuteData').yearWithdrawalInfos;
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;
}
console.log('111',typeof this.yearWithdrawalInfos)
}else{
//初始化删除上次批量计算结果
uni.removeStorageSync('resIrrAndSimpleResInfos');
......@@ -280,6 +281,23 @@
}
},
methods: {
// 封装报错弹窗
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('用户点击取消');
}
}
});
return;
},
// 当有万能账户时,提领信息清空
withdrawalTypeInit(){
if(this.irrAndSimpleCalcuteParam.allFirstPayment>0) {
......@@ -314,70 +332,34 @@
}else if(this.calcuteMethod === '2'){
//批量
if(!this.irrAndSimpleCalcuteParam.paymentPeriod || this.irrAndSimpleCalcuteParam.paymentPeriod==0){
uni.showToast({
title: '请填写交费年限且交费年限必须大于0',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`交费年限为必填项且必须大于0`);
}
if(!this.irrAndSimpleCalcuteParam.annualPremium){
uni.showToast({
title: '请填写年交保费',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`年交保费为必填项`);
}
if(this.yearWithdrawalInfos.length>0){
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){
uni.showToast({
title: `请输入第${i+1}行提领开始日期和结束日期,且该日期必须大于0`,
duration: 2000,
icon: 'none'
})
return;
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`);
}else{
if(this.yearWithdrawalInfos[i].withdrawalEnd < this.yearWithdrawalInfos[i].withdrawalStart){
uni.showToast({
title: `第${i+1}行,提领开始日期必须小于等于提领结束日期!`,
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`第${i+1}行,起领年度必须小于等于止领年度!`);
}
}
if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount'] && this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<0){
uni.showToast({
title: `第${i+1}行,提领金额必须大于0`,
duration: 2000,
icon: 'none'
})
return;
if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount'] && this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<=0){
this.errorDialog(2,`第${i+1}行,提领金额必须大于0`);
}else{
if(!this.yearWithdrawalInfos[i]['yearWithdrawalAmount']){
uni.showToast({
title: `请输入第${i+1}行,提领金额`,
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`请输入第${i+1}行,提领金额`);
}
}
}
//年金提领信息校验
if(this.calcuteType == 2){
if(this.calcuteType == '2'){
if(!this.yearWithdrawalInfos[i]['withdrawalStart'] || this.yearWithdrawalInfos[i]['withdrawalStart']<0){
uni.showToast({
title: '请输入提领信息保单年度,且年度值必须大于0',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`请输入提领信息保单年度,且年度值必须大于0`);
}
}
}
......@@ -392,7 +374,7 @@
businessNo:this.businessNo,
businessType:this.businessType
}
uni.setStorageSync('calcuteData',calcuteData)
uni.setStorageSync('calcuteData',JSON.stringify(calcuteData))
uni.navigateTo({
url: '/pages/dataImport/data-import'
});
......@@ -406,7 +388,6 @@
if(calcuteMethod === '1'){
this.irrAndSimple = {nyear:null,cashValue:null};
this.irrAndSimpleInfos = [].concat([{nyear:null,cashValue:null}]);
console.log(this.irrAndSimple)
}
//切换单次还是批量时,清空结果
this.resultShowFlag = false;
......@@ -415,7 +396,6 @@
},
changeWithdrawalType(){
this.withdrawalType = !this.withdrawalType;
console.log(this.withdrawalType)
if(!this.withdrawalType){
this.yearWithdrawalInfos = [].concat([{withdrawalType:'2',
withdrawalStart:null,
......@@ -445,72 +425,29 @@
},
// 计算接口
irrAndSimpleCalte(){
if(!this.irrAndSimpleCalcuteParam.paymentPeriod){
uni.showToast({
title: '请填写交费年限!',
duration: 2000,
icon: 'none'
})
return;
if(!this.irrAndSimpleCalcuteParam.paymentPeriod || this.irrAndSimpleCalcuteParam.paymentPeriod <= 0){
this.errorDialog(1,`交费年限为必填项且必须大于0`);
}else{
if(this.irrAndSimpleCalcuteParam.paymentPeriod >50 ){
uni.showToast({
title: '交费年限一般不大于50年,请确认!',
duration: 2000,
icon: 'none'
})
return;
}
if(this.irrAndSimpleCalcuteParam.paymentPeriod <= 0 ){
uni.showToast({
title: '交费年限必须大于0',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`交费年限一般不大于50年,请确认!`);
}
}
if(!this.irrAndSimpleCalcuteParam.annualPremium){
uni.showToast({
title: '请填写年交保费!',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`年交保费为必填项!`);
}else{
if(this.irrAndSimpleCalcuteParam.annualPremium > 1000000000){
uni.showToast({
title: '年交保费不能大于1,000,000,000',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`年交保费不能大于1,000,000,000!`);
}
if(this.irrAndSimpleCalcuteParam.annualPremium <= 0){
uni.showToast({
title: '年交保费必须大于0',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`年交保费必须大于0!`);
}
}
if(this.irrAndSimpleCalcuteParam.allFirstPayment && this.irrAndSimpleCalcuteParam.allFirstPayment < 0){
uni.showToast({
title: '万能账户首年交费信息须大于或等于0',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`万能账户首年交费信息须大于或等于0!`);
}
if(this.businessType == 2){
if(!this.mobile){
uni.showToast({
title: '保存时手机号必填',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`保存时手机号必填!`);
}
}
//提领信息判断
......@@ -518,87 +455,42 @@
for (let i = 0; i < this.yearWithdrawalInfos.length; i++) {
//增额提领信息校验
if(this.calcuteType == 1){
if(!this.yearWithdrawalInfos[i].withdrawalStart || !this.yearWithdrawalInfos[i].withdrawalEnd){
uni.showToast({
title: `请输入第${i+1}行提领开始日期和结束日期,且该日期必须大于0`,
duration: 2000,
icon: 'none'
})
return;
if(!this.yearWithdrawalInfos[i].withdrawalStart || !this.yearWithdrawalInfos[i].withdrawalEnd || this.yearWithdrawalInfos[i].withdrawalStart<=0 || this.yearWithdrawalInfos[i].withdrawalEnd<=0){
this.errorDialog(2,`请输入第${i+1}行起领年度和止领年度,且该日期必须大于0!`);
}else{
if(this.yearWithdrawalInfos[i].withdrawalEnd < this.yearWithdrawalInfos[i].withdrawalStart){
uni.showToast({
title: `第${i+1}行,提领开始日期必须小于等于提领结束日期!`,
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`第${i+1}行,起领年度必须小于等于止领年度!`);
}
}
if(this.yearWithdrawalInfos[i]['yearWithdrawalAmount'] && this.yearWithdrawalInfos[i]['yearWithdrawalAmount']<0){
uni.showToast({
title: `第${i+1}行,提领金额必须大于0`,
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`第${i+1}行,提领金额必须大于0!`);
}else{
if(!this.yearWithdrawalInfos[i]['yearWithdrawalAmount']){
uni.showToast({
title: `请输入第${i+1}行,提领金额`,
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`请输入第${i+1}行,提领金额!`);
}
}
}
//年金提领信息校验
if(this.calcuteType == 2){
if(!this.yearWithdrawalInfos[i]['withdrawalStart'] || this.yearWithdrawalInfos[i]['withdrawalStart']<0){
uni.showToast({
title: '请输入提领信息保单年度,且年度值必须大于0',
duration: 2000,
icon: 'none'
})
return;
if(!this.yearWithdrawalInfos[i]['withdrawalStart'] || this.yearWithdrawalInfos[i]['withdrawalStart']<=0){
this.errorDialog(2,`请输入提领信息保单年度,且年度值必须大于0!`);
}
}
}
}
if(this.calcuteMethod == 1){
if(!this.irrAndSimple.nyear && this.irrAndSimple.nyear!=0){
uni.showToast({
title: '请输入现金价值年度!',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`请输入现金价值年度!`);
}else{
if(this.irrAndSimple.nyear>105){
uni.showToast({
title: '现金价值年度不能大于105!',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`现金价值年度不能大于105!`);
}
if(this.irrAndSimple.nyear<=0){
uni.showToast({
title: '现金价值年度必须大于0!',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(2,`现金价值年度必须大于0!`);
}
}
if(!this.irrAndSimple.nyear){
uni.showToast({
title: '生存总利益未输入!',
duration: 2000,
icon: 'none'
})
return;
this.errorDialog(1,`生存总利益未输入!`);
}
}
const params = {
......@@ -615,10 +507,15 @@
withdrawalType:this.withdrawalType?'1':'2',
decimal: 5
};
api.irrAndSimpleCalcute(params).then(res=>{
console.log(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;
......@@ -638,7 +535,7 @@
},
resetData(){
this.irrAndSimpleCalcuteParam = {};
this.yearWithdrawalInfos = [{withdrawalType:1,
this.yearWithdrawalInfos = [{withdrawalType:'1',
withdrawalStart:undefined,
withdrawalEnd:undefined,
yearWithdrawalAmount:undefined}];
......
......@@ -14,7 +14,7 @@
<title>sfp</title>
<!--preload-links-->
<!--app-context-->
<script type="module" crossorigin src="/sfp/assets/index.ac2778ca.js"></script>
<script type="module" crossorigin src="/sfp/assets/index.154fcd7e.js"></script>
<link rel="stylesheet" href="/sfp/assets/index.13d2da89.css">
</head>
<body>
......
export function numberToCurrencyNo(value) {
debugger;
if (!value) return 0;
// 获取整数部分
const intPart = Math.trunc(value)
// 整数部分处理,增加,
const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
// 预定义小数部分
let floatPart = ''
// 将数值截取为小数部分和整数部分
const valueArray = value.toString().split('.')
if (valueArray.length === 2) { // 有小数部分
floatPart = valueArray[1].toString() // 取得小数部分
return intPartFormat + '.' + floatPart
}
return intPartFormat + floatPart
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment