From 6e54af776db885ad1a22ec582bdc97d7e1273c6c Mon Sep 17 00:00:00 2001 From: queenwuli <942534046@qq.com> Date: Wed, 13 Jan 2021 17:31:30 +0800 Subject: [PATCH] 系统优化 --- hive-app/common/jssdk/httpUtils.js | 30 +++++++++++++++++++++++++----- 1 files changed, 25 insertions(+), 5 deletions(-) diff --git a/hive-app/common/jssdk/httpUtils.js b/hive-app/common/jssdk/httpUtils.js index 51515d7..124b6f1 100644 --- a/hive-app/common/jssdk/httpUtils.js +++ b/hive-app/common/jssdk/httpUtils.js @@ -22,13 +22,19 @@ let timeStamp = new Date().getTime(); return encrypt.encrypt(token + '_' + timeStamp + '_' + url); }, - request (url, data = {}, method = 'GET', extraObj = {}) { + request (url, data = {}, method = 'GET', extraObj = {isShowLoad: false}) { let header = { 'Authorization': 'Bearer ' + this.handleToken(url), 'lang': 'zh_CN', 'content-type': 'application/json; charset=utf-8' } return new Promise((resolve, reject) => { + if(extraObj.isShowLoad){ + uni.showLoading({ + mask: true, + title: '加载中' + }) + } uni.request({ url: this.baseUrl + url, method, @@ -45,24 +51,38 @@ key: 'userInfo', success: (res) => { reject(result); + uni.navigateTo({ + url: '/pages/login/index?isNotLogin=1' + }) }, fail() { reject(result); + uni.navigateTo({ + url: '/pages/login/index' + }) } }); } + extraObj.isShowLoad && uni.hideLoading() }, fail: (error) => { + extraObj.isShowLoad && uni.hideLoading() reject(error); } }); }); }, isNotLogin(err) { - if (!err || !err.status) { - return false; - } - return err.status === 700014; + return !err || !err.status || err.status == 700014; + }, + getRoleInfo(){ + return StorageUtil.getStorage('userInfo','roleInfo') + }, + getToken(){ + return StorageUtil.getStorage('userInfo','token') + }, + getUserFunction(){ + return StorageUtil.getStorage('userInfo','userFunction') } } export default httpUtils; \ No newline at end of file -- Gitblit v1.9.1