Commit ebce654f by 姜雷

添加部分接口请求

parent e5457ee5
......@@ -6,22 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no, viewport-fit=cover, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<script src="//g.alicdn.com/fdilab/lib3rd/viewport-units-buggyfill/0.6.2/??viewport-units-buggyfill.hacks.min.js,viewport-units-buggyfill.min.js"></script>
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>成都师范后勤管理</title>
</head>
<body>
......@@ -29,18 +16,7 @@
You need to enable JavaScript to run this app.
</noscript>
<div id="root">
载入中。。。
</div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script> window.onload = function () { window.viewportUnitsBuggyfill.init({ hacks: window.viewportUnitsBuggyfillHacks }); } </script>
</body>
......
......@@ -2,12 +2,46 @@ import fetch from './fetch';
export const fetchPublicCarList = entity =>
fetch({
url: '/app/publicCarController/pageList',
url: '/publicCar/app/pageList4PublicCar',
params: entity,
});
export const applyPublicCar = entity =>
fetch({
url: '/app/publicCarController/addPublicCar',
url: '/publicCar/app/addPublicCar',
params: entity,
});
export const fetchApplyPublicCarList = entity =>
fetch({
url: '/publicCar/app/pageListAdmin4PublicCar',
params: entity,
});
export const dealPublicCar = entity =>
fetch({
url: '/publicCar/app/deal4PublicCar',
params: entity,
});
export const fetchRepairList = entity =>
fetch({
url: '/repair/app/pageList4Repair',
params: entity,
});
export const reportRepair = entity =>
fetch({
url: '/repair/app/addRepair',
params: entity,
});
export const fetchReportRepairList = entity =>
fetch({
url: '/repair/app/pageListAdmin4Repair',
params: entity,
});
export const dealRepair = entity =>
fetch({
url: '/repair/app/deal4Repair',
params: entity,
});
import React, { Component } from 'react';
import '../styles/App.css';
import { is_weixn } from '../utils';
import { APP_ID } from '../config';
import UserInfoContext, { defaultUserinfo } from '../context/userinfo-context';
import { Route, Switch } from 'react-router-dom';
import Home from './Home/Index';
import Report from './report/report';
import Login from './Login/Login';
import PublicCarList from './PublicCar/PublicCarList';
import PublicCarApply from './PublicCar/PublicCarApply';
import NoMatch from './NoMatch';
class App extends Component {
constructor(props) {
......@@ -35,20 +36,40 @@ class App extends Component {
const { search } = props.location;
const paramsString = search.substring(1);
const searchParams = new URLSearchParams(paramsString);
const openid = searchParams.get('openid');
// const state = searchParams.get('state');
console.log(isWx, openid);
const code = searchParams.get('code');
const state = searchParams.get('state');
console.log(isWx, code, state);
if (!isWx) {
return <div>请在微信客户端打开链接</div>;
} else if (!openid) {
} else if (!code) {
let rUrl = encodeURIComponent('');
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APP_ID}&redirect_uri=${rUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
return <div>授权中。。。</div>;
} else {
return <Login {...props} openid={openid} />;
return <Login {...props} code={code} />;
}
};
getParams = str => {
let obj = {};
const searchParams = new URLSearchParams(str);
let keys = searchParams.keys();
for (const key of keys) {
obj[key] = searchParams.get(key);
}
return obj;
};
validateUserinfo = props => {
console.log(props);
setTimeout(() => {
const { history, location } = props;
let params = this.getParams(location.search);
// history.push('/login');
console.log('redirect', params, history);
}, 1000);
return <Home />;
};
updateUserInfo = data => {
this.setState({
userContext: {
......@@ -64,10 +85,12 @@ class App extends Component {
<div className="App">
<UserInfoContext.Provider value={userContext}>
<Switch>
<Route exact path="/" render={this.renderLogin} />
<Route exact path="/" render={this.validateUserinfo} />
<Route path="/report" component={Report} />
<Route path="/login" component={Login} />
<Route path="/PublicCarList" component={PublicCarList} />
<Route path="/PublicCarApply" component={PublicCarApply} />
<Route component={NoMatch} />
</Switch>
</UserInfoContext.Provider>
</div>
......
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import styles from './style.css';
export class Index extends React.Component {
static propTypes = {
name: PropTypes.string,
};
render() {
return (
<div>
Home
<br />
<Link to="/report">report</Link>
<br />
<Link to="/report">report</Link>
<br />
<Link to="/report">report</Link>
</div>
);
return <div className={styles.LoadPage}>加载中。。。</div>;
}
}
......
.LoadPage {
margin: 60px 24px 0;
}
import React from 'react';
class Index extends React.Component {
render() {
return <div>404 NoMatch</div>;
}
}
export default Index;
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}
.App-title {
font-size: 1.5em;
}
.App-intro {
font-size: large;
}
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.box {
display: flex;
justify-content: center;
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ html {
margin: 0;
padding: 0;
font-family: sans-serif;
overflow: hidden;
}
figure,
p {
......@@ -46,10 +47,10 @@ img {
[w-750-190] {
aspect-ratio: '750:190';
}
.bb1px {
:global(.bb1px) {
position: relative;
}
.bb1px::after {
:global(.bb1px::after) {
content: '';
display: block;
position: absolute;
......@@ -62,10 +63,10 @@ img {
background: #dcdcdc;
transform: scaleY(0.5);
}
.bt1px {
:global(.bt1px) {
position: relative;
}
.bt1px::after {
:global(.bt1px::after) {
content: '';
display: block;
position: absolute;
......@@ -78,20 +79,20 @@ img {
background: #dcdcdc;
transform: scaleY(0.5);
}
.ellipsis {
:global(.ellipsis) {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.ellipsis-2lines {
:global(.ellipsis-2lines) {
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
}
#root,
.App {
:global(#root),
:global(.App) {
width: 100%;
height: 100%;
position: relative;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment