queenwuli
2021-01-19 a3a48da30bdea132d2bfbb47fa2ccf83f1937c45
hive-app/common/jssdk/httpUtils.js
@@ -9,7 +9,7 @@
    baseUrl: '/api',
    // #endif
    // #ifndef H5
    baseUrl: 'http://120.27.238.55:8801',
    baseUrl: 'http://test.hive.jyymatrix.cc',
    // #endif
   handleToken(url){
      let token = StorageUtil.getStorage('userInfo','token');
@@ -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,
@@ -57,8 +63,10 @@
                     }
                  });
               }
               extraObj.isShowLoad && uni.hideLoading()
             },
            fail: (error) => {
               extraObj.isShowLoad && uni.hideLoading()
               reject(error);
            }
         });
@@ -72,6 +80,9 @@
   },
   getToken(){
      return StorageUtil.getStorage('userInfo','token')
   },
   getUserFunction(){
      return StorageUtil.getStorage('userInfo','userFunction')
   }
 }
 export default httpUtils;