clarms.js
3.23 KB
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
import {
mapGetters,
mapActions,
mapState
} from "vuex";
import api from '@/api/api'
import {
httpGet,
httpPost
} from '@/api/fetch-api.js'
import ClarmsVerifyForm from './clarms-plugins-verifyform.vue';
import ClarmsMaterial from './clarms-plugins-material.vue';
// 用户没有登录
// 校验成功
// 校验失败
// 用户已经登录
// 没有保单
// 校验成功
// 校验失败
// 有保单
export default {
data() {
return {
step: 0, // 1是表单;2是报案页面
agress: false,
reservationTypes: [],
cid: false,
// 可以理赔的客户信息
customerList: []
}
},
components: {
ClarmsVerifyForm,
ClarmsMaterial
},
computed: {
...mapState({
userInfo: state => state.userInfo
}),
i18n() {
return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
},
},
methods: {
initData() {
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 = 1;
}
}).catch(e => {
this.step = 1;
});
},
checkCid() {
let param = {
cid: this.cid
}
httpPost({ url: api.clarmsCustomerList, data: param }).then(res => {
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;
});
},
logoutAction() {
console.log("logoutAction");
this.sid = false;
this.hadQueryCustomerList = false;
this.customerList = [];
this.step = 1;
},
loginAction() {
console.log("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() { }
}