Commit be4ae64d by wangshuo

Merge branch '11-11' of gitlab.julyedu.com:baiguangyao/mr-julyedu into 11-11

parents 6281b1fa e3aa0c99
import React, {Component} from 'react'
import {SendMessageToApp} from '@/utils'
import {setCurrentUser, startFetchUser} from "@/store/userAction"
import {Button, Toast, WhiteSpace} from 'antd-mobile'
import cookie from 'js-cookie'
import {addDays} from "date-fns"
import {compose} from "redux";
import {connect} from "react-redux";
class ToAppDemo extends Component {
state = {
userInfoList: [],
userInfoList: [
],
}
componentDidMount() {
......@@ -29,6 +33,7 @@ class ToAppDemo extends Component {
userInfoList: result
})
if (this.state.userInfoList.length !== 0) {
this.props.startFetchUser()
this.appLogin()
}
}
......@@ -43,6 +48,26 @@ class ToAppDemo extends Component {
cookie.set("uname", item.uname, {expires, path: '/', domain: 'julyedu.com'});
cookie.set("avatar_file", item.avatar_file, {expires, path: '/', domain: 'julyedu.com'});
});
this.props.setCurrentUser(this.transformUser(this.state.userInfoList))
}
transformUser = res => {
let payload
res.map((item, index) => {
payload = {
hasError: false,
data: {
username: item.uname,
avatar: item.avatar_file,
token: item.token,
uid: item.uid
},
isFetching: false
}
})
return payload
}
......@@ -132,4 +157,10 @@ class ToAppDemo extends Component {
}
}
export default ToAppDemo
export default compose(
connect(
state => ({user: state.user}),
{setCurrentUser, startFetchUser}
)
)(ToAppDemo)
\ No newline at end of file
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