|
|
@@ -85,362 +85,6 @@ export const apiResquest = (prams) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export const apiResquestOutside = (prams) => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- let 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({
|
|
|
- timeout:10000,
|
|
|
- url: url,
|
|
|
- data: {
|
|
|
- ...prams.data
|
|
|
- },
|
|
|
- method: prams.method,
|
|
|
- header: {
|
|
|
- 'content-type': 'application/json;charset=utf-8',
|
|
|
- '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) {
|
|
|
- loginTimeout();
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- mask: true,
|
|
|
- icon: "none",
|
|
|
- position: "center",
|
|
|
- title: res.data.message,
|
|
|
- duration: 2000
|
|
|
- });
|
|
|
- resolve(res);
|
|
|
- }
|
|
|
- } else if (res.statusCode == 401) {
|
|
|
- loginTimeout();
|
|
|
- } 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 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({
|
|
|
- timeout:10000,
|
|
|
- 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) {
|
|
|
- loginTimeout();
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- mask: true,
|
|
|
- icon: "none",
|
|
|
- position: "center",
|
|
|
- title: res.data.message,
|
|
|
- duration: 2000
|
|
|
- });
|
|
|
- resolve(res);
|
|
|
- }
|
|
|
- } else if (res.statusCode == 401) {
|
|
|
- loginTimeout();
|
|
|
- } 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 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({
|
|
|
- timeout:10000,
|
|
|
- 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) {
|
|
|
- loginTimeout();
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- mask: true,
|
|
|
- icon: "none",
|
|
|
- position: "center",
|
|
|
- title: res.data.message,
|
|
|
- duration: 2000
|
|
|
- });
|
|
|
- resolve(res);
|
|
|
- }
|
|
|
- } else if (res.statusCode == 401) {
|
|
|
- loginTimeout();
|
|
|
- } 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) => {
|
|
|
- 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({
|
|
|
- timeout:10000,
|
|
|
- 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) {
|
|
|
- loginTimeout();
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- mask: true,
|
|
|
- icon: "none",
|
|
|
- position: "center",
|
|
|
- title: res.data.message,
|
|
|
- duration: 2000
|
|
|
- });
|
|
|
- resolve(res);
|
|
|
- }
|
|
|
- } else if (res.statusCode == 401) {
|
|
|
- loginTimeout();
|
|
|
- } 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) => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- 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 = {};
|
|
|
- }
|
|
|
-
|
|
|
- return uni.request({
|
|
|
- timeout:10000,
|
|
|
- url: url,
|
|
|
- data: {
|
|
|
- ...prams.data
|
|
|
- },
|
|
|
- method: prams.method,
|
|
|
- header: {
|
|
|
- 'content-type': 'application/json;charset=utf-8',
|
|
|
- '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) {
|
|
|
- loginTimeout();
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- mask: true,
|
|
|
- icon: "none",
|
|
|
- position: "center",
|
|
|
- title: res.data.message,
|
|
|
- duration: 2000
|
|
|
- });
|
|
|
- resolve(res);
|
|
|
- }
|
|
|
- } else if (res.statusCode == 401) {
|
|
|
- loginTimeout();
|
|
|
- } 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 function loginTimeout(params) {
|
|
|
uni.showToast({
|