Commit e40e259b by 姜雷

统一传递userId

parent 6a02cfe6
...@@ -14,6 +14,7 @@ const service = axios.create({ ...@@ -14,6 +14,7 @@ const service = axios.create({
service.interceptors.request.use( service.interceptors.request.use(
conf => { conf => {
let userId = store.getUserId(); let userId = store.getUserId();
if (/post/.test(conf.method.toLocaleLowerCase())) { if (/post/.test(conf.method.toLocaleLowerCase())) {
let data = userId let data = userId
? { ? {
......
...@@ -15,6 +15,7 @@ import NoMatch from './NoMatch'; ...@@ -15,6 +15,7 @@ import NoMatch from './NoMatch';
import { wxAuth } from '../api/index'; import { wxAuth } from '../api/index';
import { Toast } from 'antd-mobile'; import { Toast } from 'antd-mobile';
import store from '../store/index';
class App extends Component { class App extends Component {
constructor(props) { constructor(props) {
...@@ -72,6 +73,7 @@ class App extends Component { ...@@ -72,6 +73,7 @@ class App extends Component {
console.log(res); console.log(res);
const { firstLogin, user, author } = res.data; const { firstLogin, user, author } = res.data;
this.updateUserInfo({ ...user, login: true, author }); this.updateUserInfo({ ...user, login: true, author });
store.updateUserId(user.userId);
if (firstLogin) { if (firstLogin) {
history.replace('/login'); history.replace('/login');
} else { } else {
......
...@@ -43,7 +43,7 @@ export class Index extends React.Component { ...@@ -43,7 +43,7 @@ export class Index extends React.Component {
} }
export default props => ( export default props => (
<UserInfoContext> <UserInfoContext.Consumer>
{({ userinfo }) => <Index userinfo={userinfo} {...props} />} {({ userinfo }) => <Index userinfo={userinfo} {...props} />}
</UserInfoContext> </UserInfoContext.Consumer>
); );
...@@ -72,7 +72,6 @@ class PublicCarApply extends Component { ...@@ -72,7 +72,6 @@ class PublicCarApply extends Component {
})) }))
); );
const entity = { const entity = {
userId: this.state.userId,
department: this.state.department, department: this.state.department,
name: this.state.name, name: this.state.name,
categoryName: categoryName, categoryName: categoryName,
......
...@@ -13,6 +13,7 @@ import Select from '../../components/Input/Select/Select'; ...@@ -13,6 +13,7 @@ import Select from '../../components/Input/Select/Select';
import { fetchRepairArea, fetchRepairTerm } from '../../api/index'; import { fetchRepairArea, fetchRepairTerm } from '../../api/index';
import { reportRepair } from '../../api/repairAdd'; import { reportRepair } from '../../api/repairAdd';
import Perview from '../../components/Perview/Perview'; import Perview from '../../components/Perview/Perview';
import store from '../../store/index';
class ReprtRepair extends Component { class ReprtRepair extends Component {
constructor(props) { constructor(props) {
...@@ -22,7 +23,6 @@ class ReprtRepair extends Component { ...@@ -22,7 +23,6 @@ class ReprtRepair extends Component {
termList: [], termList: [],
applyForm: { applyForm: {
name: '', name: '',
userId: '',
repairCellphone: '', repairCellphone: '',
applyIdentity: '学生', applyIdentity: '学生',
area: '', area: '',
...@@ -72,7 +72,6 @@ class ReprtRepair extends Component { ...@@ -72,7 +72,6 @@ class ReprtRepair extends Component {
this.setState({ this.setState({
applyForm: { applyForm: {
name: '', name: '',
userId: '',
repairCellphone: '', repairCellphone: '',
applyIdentity: '学生', applyIdentity: '学生',
area: '', area: '',
...@@ -167,7 +166,7 @@ class ReprtRepair extends Component { ...@@ -167,7 +166,7 @@ class ReprtRepair extends Component {
let term = this.state.termList.find( let term = this.state.termList.find(
i => i.value === this.state.applyForm.termId[0] i => i.value === this.state.applyForm.termId[0]
).label; ).label;
formData.append('userId', '1'); formData.append('userId', store.getUserId());
// product 需要登陆后的用户ID // product 需要登陆后的用户ID
formData.append('applyIdentity', this.state.applyForm.applyIdentity); formData.append('applyIdentity', this.state.applyForm.applyIdentity);
formData.append('area', area); formData.append('area', area);
......
...@@ -100,7 +100,6 @@ class RepairDeal extends Component { ...@@ -100,7 +100,6 @@ class RepairDeal extends Component {
onPress: () => onPress: () =>
dealRepair({ dealRepair({
id: id, id: id,
userId: '',
}) })
.then(res => { .then(res => {
Toast.fail(res.msg || '处理成功!'); Toast.fail(res.msg || '处理成功!');
......
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