用户昵称与绑定账号的隐私显示

var third_name="哈利路亚";//用户昵称
var third_account="111111113@qq.com"
function  getThirdNameInfo() {
                let nameLength = third_name.length;//获取用户昵称长度
                if (nameLength == 2) {
                    third_name = third_name.substr(0, 1) + '*';
                } else if (nameLength < 8) {
                    var _name = third_name.substr(0, 1);
                    for (let i = 0; i < nameLength - 2; i++) {
                        _name = _name + '*';
                    }
                   third_name = _name + third_name.substr(nameLength - 1, 1);
                } else {
                   third_name = third_name.substr(0, 3) + '***....';
                }
                
            }
 function getThirdAccountInfo() {
        var accountLength = third_account.length;
        if (third_account.indexOf('@') > 0) {
            var accountEmail1 = third_account.split('@')[0]
            var accountEmail2 = third_account.split('@')[1]
            if (accountEmail1.length > 3) {
                var _s = '';
                for (var i = 0; i < accountEmail1.length - 3; i++) {        
                    _s += '*';      
                }
                third_account = accountEmail1.substr(0, 3) + _s + '@' + accountEmail2
            }
        } else {
            let _account = third_account.substr(0, 3);
            for (let i = 0; i < accountLength - 7; i++) {
                _account = _account + '*';
            }
            third_account = _account + third_account.substr(accountLength - 4, 4);
        }
    }
 getThirdAccountInfo() 
 getThirdNameInfo() 

posted @ 2018-02-26 11:51  Sarah119  Views(157)  Comments(0Edit  收藏  举报