| | |
| | | // 最新使用webSocket通信 |
| | | readCardWebSocket(resultObj) { |
| | | let _this = this; |
| | | |
| | | if (resultObj.code === 200 && resultObj.data.name != null) { |
| | | //回显相关数据 |
| | | _this.form.cusName = resultObj.data.name; |
| | |
| | | /^(\d{4})(\d{2})(\d{2})$/, |
| | | "$1-$2-$3" |
| | | ); |
| | | } else if (_this.form.cusIdcard) { |
| | | // 从身份证号码提取出生日期 |
| | | var org_birthday = _this.form.cusIdcard.substring(6, 14); |
| | | _this.form.cusBrithday = |
| | | org_birthday.substring(0, 4) + |
| | | "-" + |
| | | org_birthday.substring(4, 6) + |
| | | "-" + |
| | | org_birthday.substring(6, 8); |
| | | } |
| | | // 如果出生日期存在,计算年龄 |
| | | if (_this.form.cusBrithday) { |
| | | var birthdays = new Date(_this.form.cusBrithday); |
| | | let d = new Date(); |
| | | let age = |
| | | d.getFullYear() - |
| | | birthdays.getFullYear() - |
| | | (d.getMonth() < birthdays.getMonth() || |
| | | (d.getMonth() == birthdays.getMonth() && |
| | | d.getDate() < birthdays.getDate()) |
| | | ? 1 |
| | | : 0); |
| | | _this.form.age = age; // 赋值计算的年龄 |
| | | } |
| | | _this.form.cusAddr = resultObj.data.addres; |
| | | _this.form.cusIdcard = resultObj.data.card; |