|
@@ -16,10 +16,10 @@ const program = {
|
|
|
};
|
|
|
const whiteCodes = [200, 201, 4444]
|
|
|
|
|
|
-export const $http = (url, method, data, json) => {
|
|
|
+export const $http = (url, method, data, json, loadingBool = true) => {
|
|
|
//设置请求前拦截器
|
|
|
http.interceptor.request = (config) => {
|
|
|
- if (url !== '/homepage/study') {
|
|
|
+ if (loadingBool && url !== '/homepage/study') {
|
|
|
uni.showLoading({
|
|
|
title: '加载中...'
|
|
|
})
|
|
@@ -35,7 +35,9 @@ export const $http = (url, method, data, json) => {
|
|
|
//设置请求结束后拦截器
|
|
|
http.interceptor.response = async (response) => {
|
|
|
//判断返回状态 执行相应操作
|
|
|
- uni.hideLoading()
|
|
|
+ if (loadingBool) {
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
const res = response.data;
|
|
|
if (whiteCodes.indexOf(res.code) < 0) {
|
|
|
if (res.code === 1001) {
|
|
@@ -100,24 +102,24 @@ async function doRequest(response, url) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function postJson(url, data) {
|
|
|
- return $http(url, 'POST', data)
|
|
|
+function postJson(url, data, loadingBool) {
|
|
|
+ return $http(url, 'POST', data, false, loadingBool)
|
|
|
}
|
|
|
|
|
|
-function get(url, data) {
|
|
|
- return $http(url, 'GET', data)
|
|
|
+function get(url, data, loadingBool) {
|
|
|
+ return $http(url, 'GET', data, false, loadingBool)
|
|
|
}
|
|
|
|
|
|
-function post(url, data) {
|
|
|
- return $http(url, 'POST', data, true)
|
|
|
+function post(url, data, loadingBool) {
|
|
|
+ return $http(url, 'POST', data, true, loadingBool)
|
|
|
}
|
|
|
|
|
|
-function put(url, data) {
|
|
|
- return $http(url, 'PUT', data, true)
|
|
|
+function put(url, data, loadingBool) {
|
|
|
+ return $http(url, 'PUT', data, true, loadingBool)
|
|
|
}
|
|
|
|
|
|
-function del(url, data) {
|
|
|
- return $http(url, 'DELETE', data, true)
|
|
|
+function del(url, data, loadingBool) {
|
|
|
+ return $http(url, 'DELETE', data, true, loadingBool)
|
|
|
}
|
|
|
|
|
|
export default {
|