|
|
@@ -65,15 +65,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
userInfo = {};
|
|
|
- Future.delayed(Duration(seconds: 1),(){
|
|
|
- print('开始');
|
|
|
- allToken = StoreProvider.of<CountState>(context).state.usetoken;
|
|
|
- getUserInfo();
|
|
|
- });
|
|
|
+ Future.delayed(Duration(seconds: 1), () {
|
|
|
+ print('开始');
|
|
|
+ allToken = StoreProvider.of<CountState>(context).state.usetoken;
|
|
|
+ userInfo = StoreProvider.of<CountState>(context).state.userInfo;
|
|
|
+ if (!userInfo.containsKey('id')) {
|
|
|
+ getUserInfo();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@override
|
|
|
void dispose() {
|
|
|
super.dispose();
|
|
|
@@ -322,7 +323,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
children: <Widget>[
|
|
|
Container(
|
|
|
padding: EdgeInsets.only(
|
|
|
- left: 35,
|
|
|
+ left: ScreenUtil().setWidth(15),
|
|
|
bottom: 50,
|
|
|
top: 50 + MediaQueryData.fromWindow(window).padding.top),
|
|
|
margin: EdgeInsets.only(bottom: 10),
|
|
|
@@ -332,25 +333,25 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
child: Row(
|
|
|
children: <Widget>[
|
|
|
Container(
|
|
|
- margin: EdgeInsets.only(right: 8),
|
|
|
- width: 86.0,
|
|
|
- height: 86.0,
|
|
|
+ margin: EdgeInsets.only(right: ScreenUtil().setWidth(8)),
|
|
|
+ width: ScreenUtil().setWidth(86),
|
|
|
+ height: ScreenUtil().setWidth(86),
|
|
|
child: CircleAvatar(
|
|
|
- backgroundImage: NetworkImage(
|
|
|
- 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2884107401,3797902000&fm=27&gp=0.jpg'),
|
|
|
+ backgroundImage: NetworkImage(userInfo.containsKey('icon')?userInfo['icon']:''),
|
|
|
),
|
|
|
),
|
|
|
Column(
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
children: <Widget>[
|
|
|
Container(
|
|
|
+ width: ScreenUtil().setWidth(175),
|
|
|
padding: EdgeInsets.only(bottom: 3),
|
|
|
- child: Text('粉条',
|
|
|
+ child: Text(userInfo.containsKey('nickname')?userInfo['nickname']:'',
|
|
|
style: TextStyle(
|
|
|
fontSize: 27,
|
|
|
fontWeight: FontWeight.w500,
|
|
|
- color: Colors.white)),
|
|
|
+ color: Colors.white),overflow: TextOverflow.ellipsis),
|
|
|
),
|
|
|
Row(
|
|
|
children: <Widget>[
|
|
|
@@ -362,7 +363,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
width: 20,
|
|
|
),
|
|
|
),
|
|
|
- Text('5324',
|
|
|
+ Text(userInfo.containsKey('moneyCoin')?userInfo['moneyCoin'].toString():'',
|
|
|
style: TextStyle(
|
|
|
fontSize: 16,
|
|
|
fontWeight: FontWeight.w900,
|
|
|
@@ -521,7 +522,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
final res = json.decode(response.toString());
|
|
|
print(res);
|
|
|
if (res['success']) {
|
|
|
- print(res['data']);
|
|
|
+ StoreProvider.of<CountState>(context)
|
|
|
+ .dispatch({"action": Actions.updateUser, "val": res['data']});
|
|
|
setState(() {
|
|
|
userInfo = res['data'];
|
|
|
});
|