|
@@ -42,19 +42,29 @@ $().ready(function(){
|
|
|
|
|
|
function setCertificateData(result)
|
|
|
{
|
|
|
- $("#birthday").val(result.Certificate.Birthday.replace(/\./g,"-").substr(0,10));
|
|
|
- $("#certNumber").val(result.Certificate.IDNumber);
|
|
|
- $("#idIssued").val(result.Certificate.IDIssued);
|
|
|
- $("#issuedValidDate").val(result.Certificate.IssuedData+"-"+result.Certificate.ValidDate);
|
|
|
+ //$("#birthDay").val(result.Certificate.Birthday.replace(/\./g,"-").substr(0,10));
|
|
|
+ var birthday=result.Certificate.Birthday;
|
|
|
+ $("#birthDay").val(birthday.substring(0,4)+"-"+birthday.substring(4,6)+"-"+birthday.substring(6));
|
|
|
+ var returnAge=jsGetAge($("#birthDay").val());
|
|
|
+ $("#age").val(returnAge);
|
|
|
+ $("#idCard").val(result.Certificate.IDNumber);
|
|
|
+ //$("#idIssued").val(result.Certificate.IDIssued);
|
|
|
+ //$("#issuedValidDate").val(result.Certificate.IssuedData+"-"+result.Certificate.ValidDate);
|
|
|
|
|
|
- imgData =result.Certificate.Base64Photo;
|
|
|
- $("#id_img_pers").attr("src","data:image/jpg;base64,"+imgData);
|
|
|
- $("#personIdPhoto").val(imgData);
|
|
|
- $("#personPhoto").val("");
|
|
|
+ // imgData =result.Certificate.Base64Photo;
|
|
|
+ // $("#id_img_pers").attr("src","data:image/jpg;base64,"+imgData);
|
|
|
+ // $("#personIdPhoto").val(imgData);
|
|
|
+ // $("#personPhoto").val("");
|
|
|
|
|
|
$("#userName").val(result.Certificate.Name);
|
|
|
- $("#gender").val(result.Certificate.Sex);
|
|
|
- $("#nation").val(result.Certificate.Nation);
|
|
|
+ if(result.Certificate.Sex=="男"){
|
|
|
+ $("#gender").val(1);
|
|
|
+ $('#gender').selectpicker('refresh');
|
|
|
+ }else if(result.Certificate.Sex=="女"){
|
|
|
+ $("#gender").val(2);
|
|
|
+ $('#gender').selectpicker('refresh');
|
|
|
+ }
|
|
|
+ //$("#nation").val(result.Certificate.Nation);
|
|
|
$("#address").val(result.Certificate.Address);
|
|
|
}
|
|
|
|
|
@@ -179,3 +189,53 @@ function messageBox(paramsJson)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 根据出生日期算出年龄
|
|
|
+ * @param strBirthday
|
|
|
+ * @returns {number}
|
|
|
+ */
|
|
|
+function jsGetAge(strBirthday) {
|
|
|
+ var returnAge;
|
|
|
+ var strBirthdayArr = strBirthday.split("-");
|
|
|
+ var birthYear = strBirthdayArr[0];
|
|
|
+ var birthMonth = strBirthdayArr[1];
|
|
|
+ var birthDay = strBirthdayArr[2];
|
|
|
+ d = new Date();
|
|
|
+ var nowYear = d.getFullYear();
|
|
|
+ var nowMonth = d.getMonth() + 1;
|
|
|
+ var nowDay = d.getDate();
|
|
|
+
|
|
|
+ if (nowYear == birthYear) {
|
|
|
+ returnAge = 0;//同年 则为0岁
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var ageDiff = nowYear - birthYear; //年之差
|
|
|
+ if (ageDiff > 0) {
|
|
|
+ if (nowMonth == birthMonth) {
|
|
|
+ var dayDiff = nowDay - birthDay;//日之差
|
|
|
+ if (dayDiff < 0) {
|
|
|
+ returnAge = ageDiff - 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ returnAge = ageDiff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ var monthDiff = nowMonth - birthMonth;//月之差
|
|
|
+ if (monthDiff < 0) {
|
|
|
+ returnAge = ageDiff - 1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ returnAge = ageDiff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return returnAge;//返回周岁年龄
|
|
|
+}
|