diff --git a/src/military/components/Upload.jsx b/src/military/components/Upload.jsx
index 71a94c32e..e1ab4cd05 100644
--- a/src/military/components/Upload.jsx
+++ b/src/military/components/Upload.jsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import { Upload, Button } from 'antd';
import { appendFileSizeToUploadFileAll } from 'educoder';
-import { httpUrl } from '../fetch';
+import { httpUrl } from '../task/fetch';
function Uploads({ className, size, actionUrl, fileList, showNotification, load }) {
const [files, setFiles] = useState(undefined);
diff --git a/src/military/components/config.js b/src/military/components/config.js
index 996a25289..320dd15f3 100644
--- a/src/military/components/config.js
+++ b/src/military/components/config.js
@@ -1,4 +1,4 @@
-import { httpUrl } from '../fetch';
+import { httpUrl } from '../task/fetch';
export const editorConfig = {
placeholder: '请输入',
diff --git a/src/military/fetch.js b/src/military/javaFetch.js
similarity index 78%
rename from src/military/fetch.js
rename to src/military/javaFetch.js
index bbf41f03c..829a50d4e 100644
--- a/src/military/fetch.js
+++ b/src/military/javaFetch.js
@@ -1,24 +1,20 @@
-import { notification,message } from 'antd';
+import { notification} from 'antd';
import axios from 'axios';
import cookie from 'react-cookies';
-
-let settings=JSON.parse(localStorage.chromesetting);
-let actionUrl = settings.api_urls? settings.api_urls.task :'https://task.osredm.com';
-if (window.location.href.indexOf('localhost') < 0) {
- axios.defaults.withCredentials = true;
-}
-export const httpUrl = actionUrl;
-
-const TokenKey = 'autologin_forge_military';
-
-// 创建axios实例
-const service = axios.create({
- baseURL: httpUrl,
- timeout: 10000, // 请求超时时间
-});
-
-// request拦截器
+export const TokenKey = 'autologin_forge_military';
+export default function javaFetch(actionUrl){
+ if (window.location.href.indexOf('localhost') < 0) {
+ axios.defaults.withCredentials = true;
+ }
+
+ // 创建axios实例
+ const service = axios.create({
+ baseURL: actionUrl,
+ timeout: 1800000, // 请求超时时间
+ });
+
+ // request拦截器
service.interceptors.request.use(config => {
if (cookie.load(TokenKey)) {
console.log(cookie.load(TokenKey));
@@ -26,11 +22,11 @@ service.interceptors.request.use(config => {
}
if (window.location.port === "3007") {
// 模拟token为登录用户
- const taskToken = sessionStorage.taskToken;
+ const osredmToken = sessionStorage.osredmToken;
if (config.url.indexOf('?') === -1) {
- config.url = `${config.url}?token=${taskToken}`;
+ config.url = `${config.url}?token=${osredmToken}`;
} else {
- config.url = `${config.url}&token=${taskToken}`;
+ config.url = `${config.url}&token=${osredmToken}`;
}
}
return config;
@@ -110,4 +106,5 @@ service.interceptors.response.use(
}
);
-export default service;
+ return service;
+}
\ No newline at end of file
diff --git a/src/military/notice/fetch.js b/src/military/notice/fetch.js
index 07e202610..38f2a078c 100644
--- a/src/military/notice/fetch.js
+++ b/src/military/notice/fetch.js
@@ -1,114 +1,10 @@
-import { notification } from 'antd';
-import axios from 'axios';
-import cookie from 'react-cookies';
+
+import javaFetch from '../javaFetch';
-let settings = JSON.parse(localStorage.chromesetting);
-let actionUrl = settings.api_urls ? settings.api_urls.notice : 'https://info.osredm.com';
-if (window.location.href.indexOf('localhost')< 0) {
- axios.defaults.withCredentials = true;
-}
+let settings=JSON.parse(localStorage.chromesetting);
+let actionUrl = settings.api_urls? settings.api_urls.notice :'https://info.osredm.com';
+
+const service = javaFetch(actionUrl);
export const httpUrl = actionUrl;
-
-const TokenKey = 'autologin_forge_military';
-
-
-// 创建axios实例
-const service = axios.create({
- baseURL: httpUrl,
- timeout: 10000, // 请求超时时间
-});
-
-// request拦截器
-service.interceptors.request.use(config => {
- if (cookie.load(TokenKey)) {
- console.log(cookie.load(TokenKey));
- config.headers['Authorization'] = cookie.load(TokenKey); // 让每个请求携带自定义token 请根据实际情况自行修改
- }
- if (window.location.port === "3007") {
- // 模拟token为登录用户
- const taskToken = sessionStorage.taskToken;
- if (config.url.indexOf('?') === -1) {
- config.url = `${config.url}?token=${taskToken}`;
- } else {
- config.url = `${config.url}&token=${taskToken}`;
- }
- }
- return config;
-}, error => {
- // Do something with request error
- console.log(error); // for debug
- Promise.reject(error);
-});
-// respone拦截器
-service.interceptors.response.use(
- response => {
- const res = response;
- if (res.status === 400) {
- notification.open({
- message: "提示",
- description: res.data.message || '验证失败',
- });
- return Promise.reject('error');
- }
- if (res.status === 401) {
- notification.open({
- message: "提示",
- description: res.data.message || '未授权,请登录!',
- });
- return Promise.reject('error');
- }
- if (res.status === 403) {
- notification.open({
- message: "提示",
- description: res.data.message || '无权限',
- });
- return Promise.reject('error');
- }
- if (res.status === 40001) {
- notification.open({
- message: "提示",
- description: '账户或密码错误!',
- });
- return Promise.reject('error');
- }
- if (response.status !== 200 && res.status !== 200) {
- notification.open({
- message: "提示",
- description: res.message,
- });
- } else {
- return response.data;
- }
- },
- error => {
- console.log(error);
- let res = error.response || {};
- if (res.status === 400) {
- notification.open({
- message: "提示",
- description: res.data.message || '操作失败',
- });
- return Promise.reject('error');
- }
- if (res.status === 401) {
- notification.open({
- message: "提示",
- description: res.data.message || '登录信息已过期',
- });
- return Promise.reject('error');
- }
- if (res.status === 403) {
- notification.open({
- message: "提示",
- description: res.data.message || '无权限!',
- });
- window.location.href = "/403";
- return Promise.reject('error');
- }
-
- return Promise.reject(error);
- }
-);
-
-export default service;
+export default service;
\ No newline at end of file
diff --git a/src/military/task/api.js b/src/military/task/api.js
index 06fe7318b..85645e2b8 100644
--- a/src/military/task/api.js
+++ b/src/military/task/api.js
@@ -1,6 +1,5 @@
-import fetch, { } from '../fetch';
+import fetch, { } from './fetch';
import { notification } from 'antd';
-import { func } from 'prop-types';
// 获取字典分类列表
export function getDictionary(id) {
@@ -121,10 +120,17 @@ export async function getTaskDetail(id) {
if (res.data) {
return res.data;
} else {
- notification.open({
- message: "提示",
- description: res.message || '请求错误',
- });
+ if(res.message&&res.message.indexOf('exist')>-1){
+ notification.open({
+ message: "提示",
+ description: "未查到该任务",
+ });
+ }else{
+ notification.open({
+ message: "提示",
+ description: res.message || '请求错误',
+ });
+ }
}
}
@@ -147,9 +153,9 @@ export function updateTask(data) {
}
//删除
-export function deleteTask(id) {
+export function deleteTask(id, isDelete) {
return fetch({
- url: '/api/tasks/' + id,
+ url: '/api/tasks/' + id + '?isDelete=' + isDelete,
method: 'DELETE',
});
}
@@ -500,7 +506,7 @@ export async function uploadPayProofList(params) {
}
// 管理员上传支付凭证
-export function uploadPayProof(data){
+export function uploadPayProof(data) {
return fetch({
url: `/api/sign/admin/paper/payment/${data.paperId}`,
method: 'post',
@@ -558,7 +564,7 @@ export function delayTask(data) {
return fetch({
url: `/api/tasks/backend/admin/task/delay/${data.taskId}`,
method: 'post',
- data:data.params,
+ data: data.params,
});
}
diff --git a/src/military/task/components/adminRouter/index.jsx b/src/military/task/components/adminRouter/index.jsx
index 89761ea5f..4132b4c58 100644
--- a/src/military/task/components/adminRouter/index.jsx
+++ b/src/military/task/components/adminRouter/index.jsx
@@ -30,7 +30,7 @@ export default props => {
支付报酬凭证上传
- 创客列表
+ 任务列表
创意征集评论
});
@@ -66,7 +66,8 @@ export default props => {
return