Commit 446a923c authored by dragondean@qq.com's avatar dragondean@qq.com Committed by 332784038@qq.com

入仓单电话脱敏

parent 06a52e3f
......@@ -119,13 +119,14 @@ export default {
if (length <= 5) {
return phoneNumber.slice(0, -3) + '*'.repeat(Math.min(3, length));
}
// 保留的明文字符数
const plainLength = length - 5;
// 尾部保留的明文字符数
const after = Math.floor(plainLength / 2)
// 前面保留的明文字符数
const before = plainLength - after;
const mid = Math.floor(length / 2);
const offset = length % 2 === 0 ? 2 : 3;
const start = mid - offset;
const end = mid + 3;
return phoneNumber.slice(0, start) + '*'.repeat(5) + phoneNumber.slice(end);
return phoneNumber.slice(0, before) + '*'.repeat(5) + phoneNumber.slice(-after);
}
},
components: { },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment