You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
1.8 KiB
90 lines
1.8 KiB
|
|
var access = {
|
|
|
|
getAccess:function(k,userinfo){
|
|
if (userinfo && userinfo.access) {
|
|
return userinfo.access.indexOf(k) != -1;
|
|
}
|
|
return false;
|
|
},
|
|
|
|
hasAccess:function(arr,userinfo) {
|
|
if (userinfo && userinfo.access) {
|
|
return userinfo.access.some(_ => arr.indexOf(_) > -1);
|
|
}
|
|
return false;
|
|
},
|
|
|
|
/** 是否一级商户 */
|
|
isSuperType:function(userinfo){
|
|
if (this.getAccess(1002,userinfo)) {
|
|
return userinfo.userType == 2
|
|
}
|
|
if (this.getAccess(1003,userinfo) || this.getAccess(1004,userinfo)) {
|
|
return userinfo.userType == 1
|
|
}
|
|
return false;
|
|
},
|
|
/** 是否区级商户 */
|
|
isAreaType:function(userinfo){
|
|
if (this.getAccess(1002,userinfo)) {
|
|
return userinfo.userType == 1
|
|
}
|
|
if (this.getAccess(1003,userinfo) || this.getAccess(1004,userinfo)) {
|
|
return userinfo.userType == 2
|
|
}
|
|
return false;
|
|
},
|
|
/** 是否员工 */
|
|
isYuangongType:function(userinfo){
|
|
if (this.getAccess(1002,userinfo)) {
|
|
return userinfo.userType == 3
|
|
}
|
|
if (this.getAccess(1004,userinfo)) {
|
|
return userinfo.userType == 4
|
|
}
|
|
return false;
|
|
},
|
|
/** 是否三级 */
|
|
isThirdType:function(userinfo){
|
|
if (this.getAccess(1004,userinfo)) {
|
|
return userinfo.userType == 3
|
|
}
|
|
return false;
|
|
},
|
|
|
|
|
|
// 判断身份
|
|
checkidentity:function(userinfo) {
|
|
var res = {}
|
|
if (this.isSuperType(userinfo)) {
|
|
res = {
|
|
levelTxt: '一级',
|
|
levelVal: 1
|
|
}
|
|
} else if (this.isAreaType(userinfo)) {
|
|
res = {
|
|
levelTxt: '二级',
|
|
levelVal: 2
|
|
}
|
|
} else if (this.isThirdType(userinfo)) {
|
|
res = {
|
|
levelTxt: '店长',
|
|
levelVal: 3
|
|
}
|
|
/* } else if (this.isYuangongType(userinfo)) {
|
|
res = {
|
|
levelTxt: '员工',
|
|
levelVal: 3
|
|
} */
|
|
} else {
|
|
res = {
|
|
levelTxt: '用户',
|
|
levelVal: 4
|
|
}
|
|
}
|
|
return res
|
|
}
|
|
}
|
|
|
|
module.exports = access |