clarms-plugins-verifyform.js 3.41 KB
/**
 * 组件描述:申请索偿申请组件
 */


import {
	mapState
} from "vuex";
import api from '@/api/api'
import {
	httpGet,
	httpPost,
	formdata
} from '@/api/fetch-api.js'

import {
	getPolicyIdTypeList
} from '@/utils/biz.js';
import Vue from 'vue';
import DatePicker from '@/components/date-picker/date-picker.vue';
import {
	Loading
} from 'vant';
import {
	Select,
	Option
} from 'element-ui';


Vue.use(Select);
Vue.use(Option);
Vue.use(Loading);

export default {
	data() {
		return {
			birthdayIllegal: false,
			loading: false,
			showTips: false,
			data: {
				// firstName: "珊珊",
				// lastName: "王",
				// birthDate: "01-01-2000",
				// idNo: "84555455",
				// idType: "40"

				firstName: "",
				lastName: "",
				birthDate: "",
				idNo: "",
				idType: ""
			}
		}
	},
	components: {
		DatePicker
	},
	computed: {
		...mapState({
			userInfo: state => state.userInfo,
			policyList: state => state.policyList
		}),
		i18n() {
			return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
		},
		policyIdTypeList() {
			return getPolicyIdTypeList(this.$i18n.locale);
		},
		btnDisabled() {
			let b1 = this.data.firstName ? false : true;
			let b2 = this.data.lastName ? false : true;
			let b3 = this.data.birthDate ? false : true;
			let b4 = this.data.idType ? false : true;
			let b5 = this.data.idNo ? false : true;
			let b6 = this.birthdayIllegal;
			return b1 || b2 || b3 || b4 || b5 || b6;
		}
	},
	methods: {
		initData() {
			let dStr = sessionStorage.getItem("clarmsCheckForm");
			sessionStorage.removeItem("clarmsCheckForm");
			if (dStr) {
				try {
					let d = JSON.parse(dStr);
					this.data = d;
				} catch (e) {

				}
			}
		},
		cacheData() {
			let d = JSON.stringify(this.data);
			sessionStorage.setItem("clarmsCheckForm", d);
		},
		checkDate(data) {
			this.birthdayIllegal = data.disable;
		},
		toRegisterPage() {
			this.$router.push({
				path: "/register"
			});
		},
		toLoginPage() {
			this.$router.push({
				path: "/login"
			});
		},
		toContactUs() {
			this.cacheData();
			this.$router.push({
				path: "/custom/service?q=m1"
			});
		},
		// 提交申请
		handleConfirm() {
			if (this.btnDisabled) {
				return;
			}
			if (this.loading) {
				return;
			}
			this.loading = true;
			let param = JSON.parse(JSON.stringify(this.data));
			param.birthDate = param.birthDate;
			console.log(param);
			httpPost({
				url: api.getCidByVerify,
				data: param
			}).then(res => {
				if (res) {
					let cid = res;
					httpPost({
						url: api.clarmsCustomerList,
						data: {
							cid: cid
						}
					}).then(res => {
						this.loading = false;
						if (res && res.insuredInfoList && res.insuredInfoList.length > 0) {
							this.$emit("insuredInfoList", {
								cid: cid,
								list: res.insuredInfoList
							});
						} else {
							this.showTips = true;
						}
					}).catch(e => {
						this.loading = false;
						this.showTips = true;
					});
				} else {
					this.loading = false;
					this.showTips = true;
				}
			}).catch(e => {
				this.loading = false;
			});
		}
	},
	watch: {
		'data.firstName': function () {
			this.showTips = false;
		},
		'data.lastName': function () {
			this.showTips = false;
		},
		'data.birthDate': function () {
			this.showTips = false;
		},
		'data.idNo': function () {
			this.showTips = false;
		},
		'data.idType': function () {
			this.showTips = false;
		},
	},
	mounted() {
		this.initData();
	},
	created() {}
}