|
@@ -1,5 +1,9 @@
|
|
-import { config } from './config.js'
|
|
|
|
-import { tansParams } from "./util.js";
|
|
|
|
|
|
+import {
|
|
|
|
+ config
|
|
|
|
+} from './config.js'
|
|
|
|
+import {
|
|
|
|
+ tansParams
|
|
|
|
+} from "./util.js";
|
|
|
|
|
|
export const apiResquest = (prams) => {
|
|
export const apiResquest = (prams) => {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
@@ -8,12 +12,12 @@ export const apiResquest = (prams) => {
|
|
title: '加载中',
|
|
title: '加载中',
|
|
mask: true
|
|
mask: true
|
|
});
|
|
});
|
|
- // get请求映射params参数
|
|
|
|
- if (prams.method === 'GET' && prams.data) {
|
|
|
|
- url = url + '?' + tansParams(prams.data);
|
|
|
|
- url = url.slice(0, -1);
|
|
|
|
- prams.data = {};
|
|
|
|
- }
|
|
|
|
|
|
+ // get请求映射params参数
|
|
|
|
+ if (prams.method === 'GET' && prams.data) {
|
|
|
|
+ url = url + '?' + tansParams(prams.data);
|
|
|
|
+ url = url.slice(0, -1);
|
|
|
|
+ prams.data = {};
|
|
|
|
+ }
|
|
|
|
|
|
return uni.request({
|
|
return uni.request({
|
|
url: url,
|
|
url: url,
|
|
@@ -22,37 +26,130 @@ export const apiResquest = (prams) => {
|
|
},
|
|
},
|
|
method: prams.method,
|
|
method: prams.method,
|
|
header: {
|
|
header: {
|
|
- // 'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'content-type': 'application/json;charset=utf-8',
|
|
|
|
- 'Authorization':uni.getStorageSync('token')
|
|
|
|
|
|
+ 'content-type': 'application/json;charset=utf-8',
|
|
|
|
+ 'Authorization': uni.getStorageSync('token')
|
|
},
|
|
},
|
|
success: (res) => {
|
|
success: (res) => {
|
|
// 成功
|
|
// 成功
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
- if(res.data.code == 200){
|
|
|
|
- resolve(res);
|
|
|
|
- }else if(res.data.code == 401){
|
|
|
|
|
|
+ if (res.statusCode == 200) {
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
+ resolve(res);
|
|
|
|
+ } else if (res.data.code == 401) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: "登录超时,请重新登录~",
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ uni.removeStorageSync('token');
|
|
|
|
+ uni.removeStorageSync('userId');
|
|
|
|
+ uni.removeStorageSync('userType');
|
|
|
|
+ setTimeout(function() {
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/login',
|
|
|
|
+ });
|
|
|
|
+ }, 2000);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: "登录超时,请重新登录~",
|
|
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '连接异常,请联系管理员.',
|
|
duration: 2000
|
|
duration: 2000
|
|
});
|
|
});
|
|
- uni.removeStorageSync('token');
|
|
|
|
- uni.removeStorageSync('userId');
|
|
|
|
- uni.removeStorageSync('userType');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: '/pages/login',
|
|
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (err) => {
|
|
|
|
+ // 失败
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '出错啦~请联系管理员!',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ complete: () => {
|
|
|
|
+ // 完成
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+export const apiResquestForm = (prams) => {
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ let url = config.base_url + prams.url;
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '加载中',
|
|
|
|
+ mask: true
|
|
|
|
+ });
|
|
|
|
+ // get请求映射params参数
|
|
|
|
+ if (prams.method === 'GET' && prams.data) {
|
|
|
|
+ url = url + '?' + tansParams(prams.data);
|
|
|
|
+ url = url.slice(0, -1);
|
|
|
|
+ prams.data = {};
|
|
|
|
+ }
|
|
|
|
+ return uni.request({
|
|
|
|
+ url: url,
|
|
|
|
+ data: {
|
|
|
|
+ ...prams.data
|
|
|
|
+ },
|
|
|
|
+ method: prams.method,
|
|
|
|
+ header: {
|
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
+ 'Authorization': uni.getStorageSync('token')
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ // 成功
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ if (res.statusCode == 200) {
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
+ resolve(res);
|
|
|
|
+ } else if (res.data.code == 401) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: "登录超时,请重新登录~",
|
|
|
|
+ duration: 2000
|
|
});
|
|
});
|
|
- },2000);
|
|
|
|
- }else{
|
|
|
|
|
|
+ uni.removeStorageSync('token');
|
|
|
|
+ uni.removeStorageSync('userId');
|
|
|
|
+ uni.removeStorageSync('userType');
|
|
|
|
+ setTimeout(function() {
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/login',
|
|
|
|
+ });
|
|
|
|
+ }, 2000);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: res.data.msg,
|
|
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '连接异常,请联系管理员.',
|
|
duration: 2000
|
|
duration: 2000
|
|
});
|
|
});
|
|
resolve(res);
|
|
resolve(res);
|
|
@@ -62,9 +159,9 @@ export const apiResquest = (prams) => {
|
|
// 失败
|
|
// 失败
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
title: '出错啦~请联系管理员!',
|
|
title: '出错啦~请联系管理员!',
|
|
duration: 2000
|
|
duration: 2000
|
|
});
|
|
});
|
|
@@ -75,229 +172,179 @@ export const apiResquest = (prams) => {
|
|
});
|
|
});
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-export const apiResquestForm = (prams) => {
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- let url = config.base_url + prams.url;
|
|
|
|
- uni.showLoading({
|
|
|
|
- title: '加载中',
|
|
|
|
- mask: true
|
|
|
|
- });
|
|
|
|
- // get请求映射params参数
|
|
|
|
- if (prams.method === 'GET' && prams.data) {
|
|
|
|
- url = url + '?' + tansParams(prams.data);
|
|
|
|
- url = url.slice(0, -1);
|
|
|
|
- prams.data = {};
|
|
|
|
- }
|
|
|
|
- return uni.request({
|
|
|
|
- url: url,
|
|
|
|
- data: {
|
|
|
|
- ...prams.data
|
|
|
|
- },
|
|
|
|
- method: prams.method,
|
|
|
|
- header: {
|
|
|
|
- 'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'Authorization':uni.getStorageSync('token')
|
|
|
|
- },
|
|
|
|
- success: (res) => {
|
|
|
|
- // 成功
|
|
|
|
- uni.hideLoading()
|
|
|
|
- if(res.data.code == 200){
|
|
|
|
- resolve(res);
|
|
|
|
- }else if(res.data.code == 401){
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: "登录超时,请重新登录~",
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- uni.removeStorageSync('token');
|
|
|
|
- uni.removeStorageSync('userId');
|
|
|
|
- uni.removeStorageSync('userType');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: '/pages/login',
|
|
|
|
- });
|
|
|
|
- },2000);
|
|
|
|
- }else{
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: res.data.msg,
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- resolve(res);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail: (err) => {
|
|
|
|
- // 失败
|
|
|
|
- uni.hideLoading()
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: '出错啦~请联系管理员!',
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- complete: () => {
|
|
|
|
- // 完成
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
export const apiResquestJsonList = (prams) => {
|
|
export const apiResquestJsonList = (prams) => {
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- let url = config.base_url + prams.url;
|
|
|
|
- uni.showLoading({
|
|
|
|
- title: '加载中',
|
|
|
|
- mask: true
|
|
|
|
- });
|
|
|
|
- // get请求映射params参数
|
|
|
|
- if (prams.method === 'GET' && prams.data) {
|
|
|
|
- url = url + '?' + tansParams(prams.data);
|
|
|
|
- url = url.slice(0, -1);
|
|
|
|
- prams.data = {};
|
|
|
|
- }
|
|
|
|
- return uni.request({
|
|
|
|
- url: url,
|
|
|
|
- data: prams.data,
|
|
|
|
- method: prams.method,
|
|
|
|
- header: {
|
|
|
|
- 'content-type': 'application/json',
|
|
|
|
- 'Authorization':uni.getStorageSync('token')
|
|
|
|
- },
|
|
|
|
- success: (res) => {
|
|
|
|
- // 成功
|
|
|
|
- uni.hideLoading()
|
|
|
|
- if(res.data.code == 200){
|
|
|
|
- resolve(res);
|
|
|
|
- }else if(res.data.code == 401){
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: "登录超时,请重新登录~",
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- uni.removeStorageSync('token');
|
|
|
|
- uni.removeStorageSync('userId');
|
|
|
|
- uni.removeStorageSync('userType');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: '/pages/login',
|
|
|
|
- });
|
|
|
|
- },2000);
|
|
|
|
- }else{
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: res.data.msg,
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- resolve(res);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail: (err) => {
|
|
|
|
- // 失败
|
|
|
|
- uni.hideLoading()
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: '出错啦~请联系管理员!',
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- complete: () => {
|
|
|
|
- // 完成
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ let url = config.base_url + prams.url;
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '加载中',
|
|
|
|
+ mask: true
|
|
|
|
+ });
|
|
|
|
+ // get请求映射params参数
|
|
|
|
+ if (prams.method === 'GET' && prams.data) {
|
|
|
|
+ url = url + '?' + tansParams(prams.data);
|
|
|
|
+ url = url.slice(0, -1);
|
|
|
|
+ prams.data = {};
|
|
|
|
+ }
|
|
|
|
+ return uni.request({
|
|
|
|
+ url: url,
|
|
|
|
+ data: prams.data,
|
|
|
|
+ method: prams.method,
|
|
|
|
+ header: {
|
|
|
|
+ 'content-type': 'application/json',
|
|
|
|
+ 'Authorization': uni.getStorageSync('token')
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ // 成功
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ if (res.statusCode == 200) {
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
+ resolve(res);
|
|
|
|
+ } else if (res.data.code == 401) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: "登录超时,请重新登录~",
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ uni.removeStorageSync('token');
|
|
|
|
+ uni.removeStorageSync('userId');
|
|
|
|
+ uni.removeStorageSync('userType');
|
|
|
|
+ setTimeout(function() {
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/login',
|
|
|
|
+ });
|
|
|
|
+ }, 2000);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '连接异常,请联系管理员.',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (err) => {
|
|
|
|
+ // 失败
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '出错啦~请联系管理员!',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ complete: () => {
|
|
|
|
+ // 完成
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ })
|
|
}
|
|
}
|
|
export const apiResquestFormVideo = (prams) => {
|
|
export const apiResquestFormVideo = (prams) => {
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
- let url = uni.getStorageSync('cameraExtranetAgent') + prams.url;
|
|
|
|
- uni.showLoading({
|
|
|
|
- title: '加载中',
|
|
|
|
- mask: true
|
|
|
|
- });
|
|
|
|
- // get请求映射params参数
|
|
|
|
- if (prams.method === 'GET' && prams.data) {
|
|
|
|
- url = url + '?' + tansParams(prams.data);
|
|
|
|
- url = url.slice(0, -1);
|
|
|
|
- prams.data = {};
|
|
|
|
- }
|
|
|
|
- return uni.request({
|
|
|
|
- url: url,
|
|
|
|
- data: {
|
|
|
|
- ...prams.data
|
|
|
|
- },
|
|
|
|
- method: prams.method,
|
|
|
|
- header: {
|
|
|
|
- 'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'Authorization':uni.getStorageSync('token')
|
|
|
|
- },
|
|
|
|
- success: (res) => {
|
|
|
|
- // 成功
|
|
|
|
- uni.hideLoading()
|
|
|
|
- if(res.data.code == 200){
|
|
|
|
- resolve(res);
|
|
|
|
- }else if(res.data.code == 401){
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: "登录超时,请重新登录~",
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- uni.removeStorageSync('token');
|
|
|
|
- uni.removeStorageSync('userId');
|
|
|
|
- uni.removeStorageSync('userType');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: '/pages/login',
|
|
|
|
- });
|
|
|
|
- },2000);
|
|
|
|
- }else{
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: res.data.msg,
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- resolve(res);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- fail: (err) => {
|
|
|
|
- // 失败
|
|
|
|
- uni.hideLoading()
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: '出错啦~请联系管理员!',
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- complete: () => {
|
|
|
|
- // 完成
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ let url = uni.getStorageSync('cameraExtranetAgent') + prams.url;
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: '加载中',
|
|
|
|
+ mask: true
|
|
|
|
+ });
|
|
|
|
+ // get请求映射params参数
|
|
|
|
+ if (prams.method === 'GET' && prams.data) {
|
|
|
|
+ url = url + '?' + tansParams(prams.data);
|
|
|
|
+ url = url.slice(0, -1);
|
|
|
|
+ prams.data = {};
|
|
|
|
+ }
|
|
|
|
+ return uni.request({
|
|
|
|
+ url: url,
|
|
|
|
+ data: {
|
|
|
|
+ ...prams.data
|
|
|
|
+ },
|
|
|
|
+ method: prams.method,
|
|
|
|
+ header: {
|
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
+ 'Authorization': uni.getStorageSync('token')
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ // 成功
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ if (res.statusCode == 200) {
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
+ resolve(res);
|
|
|
|
+ } else if (res.data.code == 401) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: "登录超时,请重新登录~",
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ uni.removeStorageSync('token');
|
|
|
|
+ uni.removeStorageSync('userId');
|
|
|
|
+ uni.removeStorageSync('userType');
|
|
|
|
+ setTimeout(function() {
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/login',
|
|
|
|
+ });
|
|
|
|
+ }, 2000);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '连接异常,请联系管理员.',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: (err) => {
|
|
|
|
+ // 失败
|
|
|
|
+ uni.hideLoading()
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '出错啦~请联系管理员!',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ complete: () => {
|
|
|
|
+ // 完成
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ })
|
|
}
|
|
}
|
|
export const apiResquestTimer = (prams) => {
|
|
export const apiResquestTimer = (prams) => {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
let url = config.base_url + prams.url;
|
|
let url = config.base_url + prams.url;
|
|
- // get请求映射params参数
|
|
|
|
- if (prams.method === 'GET' && prams.data) {
|
|
|
|
- url = url + '?' + tansParams(prams.data);
|
|
|
|
- url = url.slice(0, -1);
|
|
|
|
- prams.data = {};
|
|
|
|
- }
|
|
|
|
|
|
+ // get请求映射params参数
|
|
|
|
+ if (prams.method === 'GET' && prams.data) {
|
|
|
|
+ url = url + '?' + tansParams(prams.data);
|
|
|
|
+ url = url.slice(0, -1);
|
|
|
|
+ prams.data = {};
|
|
|
|
+ }
|
|
|
|
|
|
return uni.request({
|
|
return uni.request({
|
|
url: url,
|
|
url: url,
|
|
@@ -306,37 +353,47 @@ export const apiResquestTimer = (prams) => {
|
|
},
|
|
},
|
|
method: prams.method,
|
|
method: prams.method,
|
|
header: {
|
|
header: {
|
|
- // 'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
- 'content-type': 'application/json;charset=utf-8',
|
|
|
|
- 'Authorization':uni.getStorageSync('token')
|
|
|
|
|
|
+ 'content-type': 'application/json;charset=utf-8',
|
|
|
|
+ 'Authorization': uni.getStorageSync('token')
|
|
},
|
|
},
|
|
success: (res) => {
|
|
success: (res) => {
|
|
// 成功
|
|
// 成功
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
- if(res.data.code == 200){
|
|
|
|
- resolve(res);
|
|
|
|
- }else if(res.data.code == 401){
|
|
|
|
- uni.showToast({
|
|
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: "登录超时,请重新登录~",
|
|
|
|
- duration: 2000
|
|
|
|
- });
|
|
|
|
- uni.removeStorageSync('token');
|
|
|
|
- uni.removeStorageSync('userId');
|
|
|
|
- uni.removeStorageSync('userType');
|
|
|
|
- setTimeout(function(){
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: '/pages/login',
|
|
|
|
|
|
+ if (res.statusCode == 200) {
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
+ resolve(res);
|
|
|
|
+ } else if (res.data.code == 401) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: "登录超时,请重新登录~",
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ uni.removeStorageSync('token');
|
|
|
|
+ uni.removeStorageSync('userId');
|
|
|
|
+ uni.removeStorageSync('userType');
|
|
|
|
+ setTimeout(function() {
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/login',
|
|
|
|
+ });
|
|
|
|
+ }, 2000);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: res.data.msg,
|
|
|
|
+ duration: 2000
|
|
});
|
|
});
|
|
- },2000);
|
|
|
|
- }else{
|
|
|
|
|
|
+ resolve(res);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
- title: res.data.msg,
|
|
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
|
|
+ title: '连接异常,请联系管理员.',
|
|
duration: 2000
|
|
duration: 2000
|
|
});
|
|
});
|
|
resolve(res);
|
|
resolve(res);
|
|
@@ -346,9 +403,9 @@ export const apiResquestTimer = (prams) => {
|
|
// 失败
|
|
// 失败
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
uni.showToast({
|
|
uni.showToast({
|
|
- mask:true,
|
|
|
|
- icon:"none",
|
|
|
|
- position:"center",
|
|
|
|
|
|
+ mask: true,
|
|
|
|
+ icon: "none",
|
|
|
|
+ position: "center",
|
|
title: '出错啦~请联系管理员!',
|
|
title: '出错啦~请联系管理员!',
|
|
duration: 2000
|
|
duration: 2000
|
|
});
|
|
});
|
|
@@ -358,4 +415,4 @@ export const apiResquestTimer = (prams) => {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
})
|
|
})
|
|
-}
|
|
|
|
|
|
+}
|