diff --git a/src/forge/Information/Pages/headerPage.jsx b/src/forge/Information/Pages/headerPage.jsx index 5f9e93caf..f682c39ca 100644 --- a/src/forge/Information/Pages/headerPage.jsx +++ b/src/forge/Information/Pages/headerPage.jsx @@ -21,7 +21,7 @@ function HeaderPage(props){ },[id]) function getPersonList(){ - getHomePageList({id}).then(result=>{ + getHomePageList(id).then(result=>{ if(result){ setPersonList(result.data.rows); } @@ -29,7 +29,7 @@ function HeaderPage(props){ } function getNewsList(){ - gethomePageDocList({id}).then(result=>{ + gethomePageDocList(id).then(result=>{ if(result){ setNewsList(result.data.rows); } @@ -37,7 +37,7 @@ function HeaderPage(props){ } function getProjectList(){ - getAllList({id,isHomepage:1}).then(result=>{ + getAllList(id,{isHomepage:1}).then(result=>{ if(result){ setProjectList(result.data.rows); } diff --git a/src/forge/Information/Pages/main.jsx b/src/forge/Information/Pages/main.jsx index 014116dc3..e8617b5fb 100644 --- a/src/forge/Information/Pages/main.jsx +++ b/src/forge/Information/Pages/main.jsx @@ -10,7 +10,7 @@ import shijian from '../img/shijian.png'; import liulan from '../img/liulan.png'; import emptydata from '../../Images/nodata.png'; import DefaultImg from '../Component/defaultImg'; -import { httpUrl } from '../fetch'; +import { getNewsAllList , getNewsHotList } from '../api'; function Main(props){ const [ key , setKey ] = useState("1"); @@ -32,8 +32,7 @@ function Main(props){ },[id]) function getMainList(){ - const url = `${httpUrl}/cms/doc/open/zone/${id}/docOverviewList`; - axios.get(url).then(result=>{ + getNewsAllList(id).then(result=>{ if(result){ let rows = result.data.rows; setMainList(rows); @@ -50,9 +49,8 @@ function Main(props){ } function getHotList(){ - const url = `${httpUrl}/cms/doc/open/zone/${id}/hotDocList`; - axios.get(url,{ - params:{pageSize:15,pageNum:1} + getNewsHotList(id,{ + pageSize:15,pageNum:1 }).then(result=>{ if(result){ setHotList(result.data.rows); diff --git a/src/forge/Information/Pages/newsDetail.jsx b/src/forge/Information/Pages/newsDetail.jsx index f8d559b8a..8684724b3 100644 --- a/src/forge/Information/Pages/newsDetail.jsx +++ b/src/forge/Information/Pages/newsDetail.jsx @@ -4,7 +4,7 @@ import liulan from '../img/liulan.png'; import RenderHtml from '../../../components/render-html'; import { Base64 } from 'js-base64'; import axios from 'axios'; -import { httpUrl } from '../fetch'; +import { getNewsDetail } from '../api'; function NewsDetail(props){ const { deptId , id } = props.match.params; @@ -20,8 +20,7 @@ function NewsDetail(props){ },[id]) function getDetails(){ - const url = `${httpUrl}/cms/doc/open/${id}`; - axios.get(url).then(result=>{ + getNewsDetail(id).then(result=>{ if(result){ let data = result.data.data; setDetail(data); diff --git a/src/forge/Information/Pages/projectSource.jsx b/src/forge/Information/Pages/projectSource.jsx index 2ce0b9d6b..b093147e8 100644 --- a/src/forge/Information/Pages/projectSource.jsx +++ b/src/forge/Information/Pages/projectSource.jsx @@ -5,7 +5,7 @@ import { Input , Menu , Pagination , Spin } from 'antd'; import { Link } from 'react-router-dom'; import Nodata from '../../Nodata'; import axios from 'axios'; -import { httpUrl } from '../fetch'; +import { getProjectsLists , getProjectsTypeLists } from '../api'; const { Search } = Input; function ProjectSource(props){ @@ -35,14 +35,11 @@ function ProjectSource(props){ },[id,typeId,page,searchName]) function getLists(){ - const url = `${httpUrl}/zone/open/${id}/project/list`; - axios.get(url,{ - params:{ - pageNum:page, - name:searchName, - pageSize, - projectTypeId:typeId===0?undefined:typeId - } + getProjectsLists(id,{ + pageNum:page, + name:searchName, + pageSize, + projectTypeId:typeId===0?undefined:typeId }).then(result=>{ if(result){ setLists(result.data.rows); @@ -52,15 +49,14 @@ function ProjectSource(props){ }).catch(error=>{}) } - function getTypeList(){ - const url = `${httpUrl}/zone/open/${id}/projectType/list`; - axios.get(url).then(result=>{ + getProjectsTypeLists(id).then(result=>{ if(result){ setTypeList(result.data.rows); } }).catch(error=>{}) } + const menu = ( 更新时间排序 diff --git a/src/forge/Information/Pages/zoneVIP.jsx b/src/forge/Information/Pages/zoneVIP.jsx index 34043692a..0eee4127d 100644 --- a/src/forge/Information/Pages/zoneVIP.jsx +++ b/src/forge/Information/Pages/zoneVIP.jsx @@ -3,8 +3,7 @@ import Crown from '../img/crown.png'; import Nodata from '../../Nodata'; import { Link } from 'react-router-dom'; import { Spin } from 'antd'; -import { httpUrl } from '../fetch'; -import axios from 'axios'; +import { getVIPLists } from '../api'; function ZoneVIP(props){ @@ -21,8 +20,7 @@ function ZoneVIP(props){ },[id]) function getLists(){ - const url = `${httpUrl}/zone/open/${id}/member/overviewList`; - axios.get(url).then(response=>{ + getVIPLists(id).then(response=>{ if(response){ setVIPLists(response.data.rows); setIsSpin(false); diff --git a/src/forge/Information/api.js b/src/forge/Information/api.js index b7c147ff7..21f778128 100644 --- a/src/forge/Information/api.js +++ b/src/forge/Information/api.js @@ -2,38 +2,82 @@ import fetch from './fetch'; /**入口页接口***/ -export function getMainInfos(params) { +export function getMainInfos(deptId) { return fetch({ - url: `/zone/open/zoneName/${params.deptId}`, + url: `/zone/open/zoneName/${deptId}`, method: 'get', }); } -export function getCheckZoneRole(params) { +export function getCheckZoneRole(id) { return fetch({ - url: `/zone/zoneDetail/${params.id}/checkZoneRole`, + url: `/zone/open/zone/${id}/checkZoneRole`, method: 'get', }); } /********首页接口******/ -export function getHomePageList(params) { +export function getHomePageList(id) { return fetch({ - url: `/zone/open/${params.id}/member/homePageList`, + url: `/zone/open/${id}/member/homePageList`, method: 'get', }); } -export function gethomePageDocList(params) { +export function gethomePageDocList(id) { return fetch({ - url: `/cms/doc/open/zone/${params.id}/homePageDocList`, + url: `/cms/doc/open/zone/${id}/homePageDocList`, method: 'get', }); } -export function getAllList(params){ +export function getAllList(id,params){ return fetch({ - url:`/zone/open/${params.id}/project/list`, + url:`/zone/open/${id}/project/list`, method: 'get', params }) +} + +/**领域资讯 */ +export function getNewsAllList(id,params){ + return fetch({ + url:`/cms/doc/open/zone/${id}/docOverviewList`, + method: 'get', + params + }) +} +export function getNewsHotList(id,params){ + return fetch({ + url:`/cms/doc/open/zone/${id}/hotDocList`, + method: 'get', + params + }) +} +export function getNewsDetail(id){ + return fetch({ + url:`/cms/doc/open/${id}`, + method: 'get', + }) +} + +/**开源项目 */ +export function getProjectsLists(id,params){ + return fetch({ + url:`/zone/open/${id}/project/list`, + method: 'get', + params + }) +} +export function getProjectsTypeLists(id){ + return fetch({ + url:`/zone/open/${id}/projectType/list`, + method: 'get', + }) +} +/**专区会员 */ +export function getVIPLists(id){ + return fetch({ + url:`/zone/open/${id}/member/overviewList`, + method: 'get', + }) } \ No newline at end of file diff --git a/src/forge/Information/fetch.js b/src/forge/Information/fetch.js index 2f8ddb125..935f9531b 100644 --- a/src/forge/Information/fetch.js +++ b/src/forge/Information/fetch.js @@ -1,5 +1,5 @@ import axios from 'axios'; -import { message } from 'antd'; +import { message , notification } from 'antd'; function beforeFetch(actionUrl){ const service = axios.create({ @@ -10,12 +10,24 @@ function beforeFetch(actionUrl){ service.interceptors.response.use( response => { const res = response||{}; - if(res && res.data && res.data.code === 500){ + if(res && res.data && res.data.code === 404){ message.error("错误链接!"); window.location.href = '/nopage'; + return Promise.reject('error'); + }else if(res && res.data && res.data.code === 500){ + message.error(res.data.msg); + return Promise.reject('error'); }else{ return response; } + }, + error => { + console.log(error); + // notification.open({ + // message: "提示", + // description: error.message, + // }); + // return Promise.reject(error); } ) return service; diff --git a/src/forge/Information/index.jsx b/src/forge/Information/index.jsx index dacaea06d..1b61224be 100644 --- a/src/forge/Information/index.jsx +++ b/src/forge/Information/index.jsx @@ -44,7 +44,7 @@ function Index(props){ },[deptId]) function getDetail(){ - getMainInfos({deptId}).then(result=>{ + getMainInfos(deptId).then(result=>{ if(result){ let data = result.data.data; setData(data); @@ -58,8 +58,8 @@ function Index(props){ } function getAdminUrl(id){ - getCheckZoneRole({id}).then(response=>{ - if(response && response.data.code === 200){ + getCheckZoneRole(id).then(response=>{ + if(response && response.data && response.data.data){ setAdminUrl(response.data.data); }else{ setAdminUrl(undefined);