From b6c4d9fd6244ca394118fab555a5ff120e7b249c Mon Sep 17 00:00:00 2001 From: charlie <charlie@lvguanqingdeMacBook-Pro.local> Date: 星期二, 25 一月 2022 14:13:41 +0800 Subject: [PATCH] optimized: 顧問結案頁面的身份證字號驗證的地方,添加新舊居留證驗證邏輯 --- PAMapp/pages/appointment/_appointmentId/close/index.vue | 51 +++++++++++++++++++++++++++++++++++---------------- 1 files changed, 35 insertions(+), 16 deletions(-) diff --git a/PAMapp/pages/appointment/_appointmentId/close/index.vue b/PAMapp/pages/appointment/_appointmentId/close/index.vue index bc59019..43eaa0b 100644 --- a/PAMapp/pages/appointment/_appointmentId/close/index.vue +++ b/PAMapp/pages/appointment/_appointmentId/close/index.vue @@ -210,25 +210,44 @@ } checkIdentityId (id) { - const tab = "ABCDEFGHJKLMNPQRSTUVXYWZIO"; - const A1 = [ 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3 ]; - const A2 = [ 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 ]; - const Mx = [ 9,8,7,6,5,4,3,2,1,1 ]; + const tab = "ABCDEFGHJKLMNPQRSTUVXYWZIO"; + const A1 = [ 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3 ]; + const A2 = [ 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 ]; + const Mx = [ 9,8,7,6,5,4,3,2,1,1 ]; - if ( id.length != 10 ) return false; - let i = tab.indexOf( id.charAt(0) ); - if ( i == -1 ) return false; - let sum = A1[i] + A2[i]*9; + if ( id.length != 10 ) return false; + let i = tab.indexOf( id.charAt(0) ); + if ( i === -1 ) return false; + let sum = A1[i] + A2[i]*9; + for ( i=1; i<10; i+=1 ) { + let v = parseInt( id.charAt(i) ); + if (i === 1 && isNaN(v)) { + switch(id.charAt(i)) { + case 'A': + v = 0; + break; + case 'B': + v = 1; + break; + case 'C': + v = 2; + break; + case 'D': + v = 3; + break; + default: + return false + } + } else if ( i === 1 && ([1,2,8,9].indexOf(v) === -1) ) { + return false + } + if ( i > 1 && isNaN(v) ) return false; + sum = sum + v * Mx[i]; + } - for ( i=1; i<10; i++ ) { - const v = parseInt( id.charAt(i) ); - if ( isNaN(v) ) return false; - sum = sum + v * Mx[i]; + if ( sum % 10 != 0 ) return false; + return true; } - - if ( sum % 10 != 0 ) return false; - return true; -} get isSubmitBtnDisabled() { const { -- Gitblit v1.8.0