优化下代码

This commit is contained in:
Your Name 2023-03-24 11:35:57 +08:00
parent a962ab339f
commit 52f8d90af7
2 changed files with 8 additions and 1 deletions

View File

@ -116,6 +116,13 @@ export function getUserInfo() {
return; return;
} }
let _userInfo = JSON.parse(desDecrypt(userInfo)); let _userInfo = JSON.parse(desDecrypt(userInfo));
if (isNull(userInfo)) {
uni.redirectTo({
url: "/pages/login/login"
});
return;
}
return _userInfo; return _userInfo;
} }

View File

@ -3,7 +3,7 @@
* @param {Object} _obj 判断对象 * @param {Object} _obj 判断对象
*/ */
const isNull = function(_obj){ const isNull = function(_obj){
if(_obj == null || _obj == undefined || _obj == ''){ if(!_obj || _obj == null || _obj == undefined || _obj == ''){
return true; return true;
} }
return false; return false;