|
|
|
@ -7,43 +7,41 @@ Page({
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
data: {},
|
|
|
|
data: {},
|
|
|
|
|
|
|
|
|
|
|
|
subCard: function (str, frontLen, endLen) {
|
|
|
|
maskIdCard: function (idCard) {
|
|
|
|
console.log(str);
|
|
|
|
if (!idCard || idCard.length !== 18) {
|
|
|
|
//str:要进行隐藏的变量 frontLen: 前面需要保留几位 endLen: 后面需要保留几位
|
|
|
|
return "******************"; // 如果身份证号码无效,则直接返回
|
|
|
|
var len = str.length - frontLen - endLen;
|
|
|
|
}
|
|
|
|
var xing = "";
|
|
|
|
// 只显示第一位和最后一位,中间用星号替换
|
|
|
|
for (var i = 0; i != len; i++) {
|
|
|
|
const masked = idCard.slice(0, 1) + '*'.repeat(idCard.length - 2) + idCard.slice(-1);
|
|
|
|
xing += "*";
|
|
|
|
return masked;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
let res = str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
|
|
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
|
|
console.log(app.globalData)
|
|
|
|
//登录=================================start
|
|
|
|
//登录=================================start
|
|
|
|
// debugger
|
|
|
|
// debugger
|
|
|
|
// if (app.globalData.isLogin) {
|
|
|
|
if (app.globalData.isLogin) {
|
|
|
|
// this.setData({
|
|
|
|
this.setData({
|
|
|
|
// isLogin: app.globalData.isLogin,
|
|
|
|
isLogin: app.globalData.isLogin,
|
|
|
|
// user: app.globalData.user,
|
|
|
|
user: app.globalData.user,
|
|
|
|
// card: this.subCard(app.globalData.user.idcard, 1, 1),
|
|
|
|
card: that.maskIdCard(app.globalData.user.idcard),
|
|
|
|
// healthTime: commonUtil.formatDateYMD(app.globalData.user.healthTime),
|
|
|
|
// healthTime: commonUtil.formatDateYMD(app.globalData.user.healthTime),
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
// } else {
|
|
|
|
} else {
|
|
|
|
// // 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
|
// 由于 userLogin 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
|
// // 所以此处加入 callback 以防止这种情况
|
|
|
|
// 所以此处加入 callback 以防止这种情况
|
|
|
|
// app.userLoginCallback = (res) => {
|
|
|
|
app.userLoginCallback = (res) => {
|
|
|
|
// this.setData({
|
|
|
|
this.setData({
|
|
|
|
// isLogin: app.globalData.isLogin,
|
|
|
|
isLogin: app.globalData.isLogin,
|
|
|
|
// user: app.globalData.user,
|
|
|
|
user: app.globalData.user,
|
|
|
|
// card: this.subCard(app.globalData.user.idcard, 1, 1),
|
|
|
|
card: this.maskIdCard(app.globalData.user.idcard, 1, 1),
|
|
|
|
// healthTime: commonUtil.formatDateYMD(app.globalData.user.healthTime),
|
|
|
|
// healthTime: commonUtil.formatDateYMD(app.globalData.user.healthTime),
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
// };
|
|
|
|
};
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|