Blame view

src/pages/custom-service/components/clarms-comp.js 3.37 KB
simon committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 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 91 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
import {
	mapGetters,
	mapActions,
	mapState
} from "vuex";

import api from '@/api/api'
import {
	httpGet,
	httpPost
} from '@/api/fetch-api.js'

import ClarmsModalOne from '@/components/clarms/clarms-plugins-modal1.vue';
import ClarmsModalTwo from '@/components/clarms/clarms-plugins-modal2.vue';
import ClarmsVerifyForm from '@/components/clarms/clarms-plugins-verifyform.vue';
import ClarmsMaterial from '@/components/clarms/clarms-plugins-material.vue';

// 用户没有登录
// 		校验成功
// 		校验失败
// 用户已经登录
// 	    没有保单
// 		    校验成功
// 		    校验失败
// 	    有保单

export default {
	data() {
		return {
			step: 0, // 1是表单;2是报案页面;3=信息不完整
			showModal1: false,
			showModal2: false,
			agress: false,
			reservationTypes: [],
			cid: false,
			// 可以理赔的客户信息
			customerList: []
		}
	},
	components: {
		ClarmsVerifyForm,
		ClarmsMaterial,
		ClarmsModalOne,
		ClarmsModalTwo
	},
	computed: {
		...mapState({
			userInfo: state => state.userInfo
		}),
		i18n() {
			return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
		},
	},
	methods: {
		toClarms() {
			this.$router.push({
				path: "/clarms",
				query: {}
			});
		},
		initData() {
			// this.step = 2;
			// return;
			if (this.userInfo && this.userInfo.name) {
				this.loadCidIfLogin();
				sessionStorage.removeItem("clarmsRequestCid")
			} else {
				let cid = sessionStorage.getItem("clarmsRequestCid");
				if (cid) {
					this.cid = cid;
					this.checkCid();
				} else {
					this.step = 1;
				}
			}
		},
		loadCidIfLogin() {
			let param = {
				sid: this.userInfo.sid
			};
			httpPost({
				url: api.getCidByLogin,
				sid: true,
				data: param
			}).then(res => {
				if (res) {
					this.cid = res;
					this.checkCid();
				} else {
					this.step = 3;
				}
			}).catch(e => {
				this.step = 1;
			});
		},
		checkCid() {
			let param = {
				cid: this.cid
			}
			httpPost({
				url: api.clarmsCustomerList,
				data: param
			}).then(res => {
				sessionStorage.removeItem("clarmsRequestCid");
				if (res) {
					this.customerList = res.insuredInfoList;
					this.step = 2;
				}
				// if (res && res.insuredInfoList && res.insuredInfoList.length > 0) {
				//     this.customerList = res.insuredInfoList;
				//     this.step = 2;
				// } else {
				//     sessionStorage.removeItem("clarmsRequestCid");
				//     this.step = 1;
				// }
			}).catch(e => {
				sessionStorage.removeItem("clarmsRequestCid");
				this.step = 1;
			});
		},
		handleInsuredInfo(data) {
			this.cid = data.cid;
			this.customerList = data.list;
			this.step = 2;
		},
		handleShowModal(modalIndex) {
			console.log(modalIndex);
			if (modalIndex == 1) {
				this.showModal1 = true;
			} else if (modalIndex == 2) {
				this.showModal2 = true;
			}
		},
		gotoInformationPage() {
			let c = this.$route.fullPath;
			this.$router.push({
				path: "/infomation/improve",
				query: {
					c: c,
					a: 1
				}
			});
		},
		logoutAction() {
			this.sid = false;
			this.hadQueryCustomerList = false;
			this.customerList = [];
			this.step = 1;
		},
		loginAction() {
			this.sid = false;
			this.hadQueryCustomerList = false;
			this.customerList = [];
		}
	},
	watch: {
		userInfo(val) {
			if (val && val.name) {
				this.loginAction();
			} else {
				this.logoutAction();
			}
		}
	},
	mounted() {
		this.initData();
	},
	created() {}
}