Blame view

src/components/clarms/clarms-plugins-verifyform.js 3.48 KB
simon committed
1 2 3 4 5 6 7 8
/**
 * 组件描述:申请索偿申请组件
 */


import {
	mapState
} from "vuex";
joe committed
9 10
import api from '@/api/api'
import {
simon committed
11 12 13
	httpGet,
	httpPost,
	formdata
joe committed
14 15
} from '@/api/fetch-api.js'

simon committed
16 17 18
import {
	getPolicyIdTypeList
} from '@/utils/biz.js';
joe committed
19 20
import Vue from 'vue';
import DatePicker from '@/components/date-picker/date-picker.vue';
simon committed
21 22 23 24 25 26 27
import {
	Loading
} from 'vant';
import {
	Select,
	Option
} from 'element-ui';
joe committed
28

simon committed
29 30 31
import {
	ddMMyyyy2yyyyMMdd
} from '@utils/utils.js';
simon committed
32

joe committed
33 34
Vue.use(Select);
Vue.use(Option);
joe committed
35 36 37
Vue.use(Loading);

export default {
simon committed
38 39 40 41 42 43 44 45 46 47 48
	data() {
		return {
			birthdayIllegal: false,
			loading: false,
			showTips: false,
			data: {
				// firstName: "珊珊",
				// lastName: "王",
				// birthDate: "01-01-2000",
				// idNo: "84555455",
				// idType: "40"
joe committed
49

simon committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
				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) {
joe committed
91

simon committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
				}
			}
		},
		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 = ddMMyyyy2yyyyMMdd(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() {}
joe committed
185
}