infomation-improve.js
4.9 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import api from '@/api/api'
import {
httpGet,
httpPost
} from '@/api/fetch-api.js'
import modalComp from '@/components/modal-comp/modal-comp.vue';
export default {
data() {
return {
key: 'value',
values: {
// 返回的token,串连整个流程,后台安全校验使用
vcodeuuid: "",
token: "",
deviceId: "",
imageBase64: "",
password: "",
passwordRepeat: ""
},
birthDate: "",
information: {
cnName: "joe",
sex: "M",
birthDate: "1990-01-01",
idNo: "111111111234567890",
idType: "1"
},
errorTips: {
e1: "",
e2: "",
e3: "",
e4: "",
e5: "",
},
modalVisiable: false,
targetPath: "",
modalIcon: "succ",
modalContent: ""
}
},
components: {
modalComp
},
computed: {
locale() {
return this.$i18n.locale || 'tc';
},
i18n() {
return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
},
sexCandidates() {
let i18n = this.$i18n.messages[this.$i18n.locale];
return i18n.infomationImprove.candidates.sex;
},
idTypeCandidates() {
let i18n = this.$i18n.messages[this.$i18n.locale];
return i18n.infomationImprove.candidates.idType;
}
},
methods: {
initData() {
},
onUpdateHandler() {
let b1 = this.checkCnName();
let b2 = this.checkIdNo();
let b3 = this.checkBirthday();
let b4 = this.checkSex();
let b5 = this.checkIdType();
let b = b1 & b2 & b3 & b4 & b5;
if (b) {
// console.log(this.birthDate);
// let y = this.birthDate.getFullYear();
// let m = this.birthDate.getMonth() + 1;
// let d = this.birthDate.getDate();
// let day = y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
this.information.birthDate = this.birthDate;
this.loadIdentify().then(() => {
httpPost({
url: api.updateInformation,
data: this.information,
sid: true
}).then(response => {
console.log(response);
});
});
}
},
loadIdentify() {
return new Promise((resolve, reject) => {
httpPost({
url: api.load,
data: {
clientNo: "501381573194155227"
}
}).then(response => {
console.log(response);
this.$store.commit("SET_USER_INFO", response.data);
resolve();
})
});
},
checkCnName() {
if (!this.information.cnName) {
let message = this.i18n.infomationImprove.errorTips.e1;
this.errorTips.e1 = message;
return false;
}
return true;
},
checkSex() {
if (!this.information.sex) {
let message = this.i18n.infomationImprove.errorTips.e2;
this.errorTips.e2 = message;
return false;
}
return true;
},
checkBirthday() {
if (!this.birthDate) {
let message = this.i18n.infomationImprove.errorTips.e3;
this.errorTips.e3 = message;
return false;
}
return true;
},
checkIdType() {
if (!this.information.idType) {
let message = this.i18n.infomationImprove.errorTips.e4;
this.errorTips.e4 = message;
return false;
}
return true;
},
checkIdNo() {
let message = this.i18n.infomationImprove.errorTips.e5;
if (!this.information.idNo) {
this.errorTips.e5 = message;
return false;
}
if (!this.information.idType) {
return true;
}
message = this.i18n.infomationImprove.errorTips.e6;
let idNo = this.information.idNo + "";
console.log(idNo);
console.log(idNo.length);
switch (this.information.idType) {
case "0": // 外國人永久居留身份證
if (/[a-z][A-Z]{3}[0-9]{12}/.test(idNo)) {
message = "";
}
message = "";
break;
case "1": // 身份證
message = idNo.length == 18 ? "" : message;
break;
case "2": // 護照
message = idNo.length > 3 && idNo.length < 50 ? "" : message;
break;
case "3": // 軍官證或士兵證
message = idNo.length > 6 && idNo.length < 50 ? "" : message;
break;
case "6": // 港澳通行證/回鄉證或台胞證
message = idNo.length > 5 && idNo.length < 50 ? "" : message;
break;
case "V": // 港澳台居民居住證
if ((/8[1|2]0000\\d{11}/.text(idNo) && (/\\d{15}/.test(idNo) || /\\d{17}/.test(idNo)))) {
message = "";
}
break;
case "W": //台灣居民居住證
if ((/830000\\d{11}/.text(idNo) && (/\\d{15}/.test(idNo) || /\\d{17}/.test(idNo)))) {
message = "";
}
break;
default:
message = "";
break;
}
return true;
},
modalCallback() {
this.modalVisiable = false;
if (this.targetPath) {
this.$router.push({
"path": this.targetPath
});
}
}
},
mounted() {
this.initData();
},
watch: {
'information.cnName': function () {
this.errorTips.e1 = "";
},
'information.sex': function () {
this.errorTips.e2 = "";
},
'birthDate': function () {
this.errorTips.e3 = "";
},
'information.idNo': function () {
this.errorTips.e4 = "";
},
'information.idType': function () {
this.errorTips.e5 = "";
}
},
created() { }
}