diff --git a/src/common/UrlTool.js b/src/common/UrlTool.js index 6f4adbd3e..175fb56bb 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -258,3 +258,9 @@ export function publicSearchs(Placeholder,onSearch,onInputs,onChanges,loadings) allowClear={true} >) } + +export function getUrlToken(name, str) { + const reg = new RegExp(`(^|&)${ name}=([^&]*)(&|$)`); + const r = str.substr(1).match(reg); + if (r != null) return decodeURIComponent(r[2]); return null; +} \ No newline at end of file diff --git a/src/common/educoder.js b/src/common/educoder.js index 3756b1d78..e8592c87e 100644 --- a/src/common/educoder.js +++ b/src/common/educoder.js @@ -6,7 +6,7 @@ export { getUploadLogoActionUrl as getUploadLogoActionUrl, getImageUrl as getImageUrl,getImage as getImage, getmyUrl as getmyUrl, getRandomNumber as getRandomNumber, getUrl as getUrl, publicSearchs as publicSearchs, getRandomcode as getRandomcode, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl , getUploadActionUrl as getUploadActionUrl, getUploadActionUrltwo as getUploadActionUrltwo, getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth - , getTaskUrlById as getTaskUrlById, TEST_HOST, htmlEncode as htmlEncode, getupload_git_file as getupload_git_file, getcdnImageUrl as getcdnImageUrl,getTestImage as getTestImage,getLogoImageUrl as getLogoImageUrl + , getTaskUrlById as getTaskUrlById, TEST_HOST, htmlEncode as htmlEncode, getupload_git_file as getupload_git_file, getcdnImageUrl as getcdnImageUrl,getTestImage as getTestImage,getLogoImageUrl as getLogoImageUrl,getUrlToken as getUrlToken } from './UrlTool'; export { setmiyah as setmiyah } from './Component'; diff --git a/src/home/FifthSection/index.jsx b/src/home/FifthSection/index.jsx index b6c8bffa3..830a4d806 100644 --- a/src/home/FifthSection/index.jsx +++ b/src/home/FifthSection/index.jsx @@ -2,7 +2,7 @@ import React, { memo, useState, useEffect } from 'react'; import { Collapse, Button } from 'antd'; import moment from 'moment'; import Line from '../Line'; -import { getTaskCategory } from '../../military/task/api'; +import { getTaskCategory, getTaskAdminList } from '../../military/task/api'; import { taskModeIdArr } from '../../military/task/static'; import './index.scss'; @@ -51,11 +51,27 @@ function getSomeDayAfter(initailDate, nDay) { return moment(new Date(initailDate).setDate(new Date(initailDate).getDate() + nDay)).format('YYYY-MM-DD'); } -function FifthSection({ fifth,history }) { +function FifthSection({ fifth, history }) { const [taskCategoryArr, setTaskCategoryArr] = useState([]); const [taskArr, serTaskArr] = useState(taskArrMock); + useEffect(() => { + const params = { + curPage: 1, + pageSize: 3, + orderBy: 'visitsDesc', + isDelete: '0', + recommend: '1', + }; + getTaskAdminList(params).then(data => { + if (data) { + serTaskArr(data.rows); + } + }) + }, []); + + // 获取分类数据 useEffect(() => { getTaskCategory().then(data => { @@ -102,6 +118,11 @@ function FifthSection({ fifth,history }) { }); }, []); + function goTask(item){ + history.push(`/task?type=${item.id}`) + // console.log(item); + } + return ( @@ -110,7 +131,7 @@ function FifthSection({ fifth,history }) {