x1ongzhu 6 лет назад
Родитель
Сommit
cef658804d

+ 0 - 0
android/app/proguard-rules.pro → android/app/proguard-rules.pro


+ 4 - 1
lib/main.dart

@@ -61,7 +61,10 @@ void main() async {
   ));
   final prefs = await SharedPreferences.getInstance();
   print(prefs.getString('token'));
-  HttpManager.token = prefs.getString('token') ?? "";
+  //测试token
+  // HttpManager.token=prefs.getString('token')??"eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIyZDExNzgzOS1lZTQxLTRmZjItOGMyYi0zMzdiNmVhYWE3ODUiLCJpc3MiOiJhZG1pbiIsImlhdCI6MTU1MTMzNjAxNiwic3ViIjoiODQ3MDIiLCJleHAiOjE1NTE1OTUyMTZ9.VFvZRMpAvrPos5FwgkaofVemgb5rAXVuGTOSiHcNEKw";
+  HttpManager.token = prefs.getString('token') ??
+      "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI0NWY0OGY2NS1jODQxLTRjNDgtYmY0My1jYTAwYzlkZjk5OWQiLCJpc3MiOiJhZG1pbiIsImlhdCI6MTU1MTMxNzAzMCwic3ViIjoiODQ3MDIiLCJleHAiOjE1NTE1NzYyMzB9.ILhuOwvblQKqVxNaLk9CbYas6aoUQAlzlZrTk4VLqY8";
   Result result = await HttpManager.get("userInfo/getUserInfo");
   AppState state = AppState.empty();
   if (result.success && result.data != null) {

+ 7 - 1
lib/model/PlayerInfo.dart

@@ -1,18 +1,24 @@
 import 'package:json_annotation/json_annotation.dart';
 import 'UserInfo.dart';
+import 'GameInfo.dart';
+import 'HouseInfo.dart';
 
 part 'PlayerInfo.g.dart';
 
 @JsonSerializable()
 class PlayerInfo {
   PlayerInfo(
-      this.id, this.houseId, this.userId, this.statusFlag, this.userInfo,this.bonus);
+      this.id, this.houseId, this.userId, this.statusFlag, this.userInfo,this.bonus,this.gameInfo,this.houseInfo,this.rank);
   int id;
   int houseId; //房间id
   int userId; //用户id
   int statusFlag; //状态 0加入 1准备 2开始 3结束 6未比赛
   UserInfo userInfo;
   int bonus;//奖金
+  GameInfo gameInfo;
+  HouseInfo houseInfo;
+  int rank;//名次
+  
   factory PlayerInfo.fromJson(Map<String, dynamic> json) =>
       _$PlayerInfoFromJson(json);
 

+ 10 - 5
lib/model/PlayerInfo.g.dart

@@ -12,9 +12,11 @@ PlayerInfo _$PlayerInfoFromJson(Map<String, dynamic> json) {
       json['houseId'] as int,
       json['userId'] as int,
       json['statusFlag'] as int,
-      UserInfo.fromJson(
-          json['userInfo'] != null ? json['userInfo'] as Map : Map()),
-      json['bonus'] as int);
+      json['userInfo'] != null ? UserInfo.fromJson(json['userInfo']) : null,
+      json['bonus'] as int,
+      json['gameInfo'] != null ? GameInfo.fromJson(json['gameInfo']) : null,
+      json['houseInfo'] != null ? HouseInfo.fromJson(json['houseInfo']) : null,
+      json['rank']??null);
 }
 
 //  int id;
@@ -28,6 +30,9 @@ Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
       'houseId': instance.houseId,
       'userId': instance.userId,
       'statusFlag': instance.statusFlag,
-      'userInfo': instance.userInfo != null ? instance.userInfo : Map(),
-      'bonus': instance.bonus
+      'userInfo': instance.userInfo,
+      'bonus': instance.bonus,
+      'gameInfo': instance.gameInfo,
+      'houseInfo': instance.houseInfo,
+      'rank':instance.rank
     };

+ 2 - 1
lib/model/UserInfo.dart

@@ -5,7 +5,7 @@ part 'UserInfo.g.dart';
 @JsonSerializable()
 class UserInfo {
   UserInfo(this.id, this.nickname, this.username, this.icon, this.phone,
-      this.sex, this.moneyCoin, this.moneyPoint,this.birthday);
+      this.sex, this.moneyCoin, this.moneyPoint,this.birthday,this.noticeFlag);
   int id;
   String nickname;
   String username;
@@ -15,6 +15,7 @@ class UserInfo {
   int moneyCoin; //余额
   double moneyPoint; //积分
   int birthday;
+  bool noticeFlag;//是否通知
   factory UserInfo.fromJson(Map<String, dynamic> json) =>
       _$UserInfoFromJson(json);
 

+ 4 - 2
lib/model/UserInfo.g.dart

@@ -16,7 +16,8 @@ UserInfo _$UserInfoFromJson(Map<String, dynamic> json) {
       json['sex'] as String,
       (json['moneyCoin'] as num)?.toInt(),
       (json['moneyPoint'] as num)?.toDouble(),
-      json['birthday'] as int);
+      json['birthday'] as int,
+      json['noticeFlag']=='Y');
 }
 
 Map<String, dynamic> _$UserInfoToJson(UserInfo instance) => <String, dynamic>{
@@ -28,5 +29,6 @@ Map<String, dynamic> _$UserInfoToJson(UserInfo instance) => <String, dynamic>{
       'sex': instance.sex,
       'moneyCoin': instance.moneyCoin,
       'moneyPoint': instance.moneyPoint,
-      'birthday': instance.birthday
+      'birthday': instance.birthday,
+      'noticeFlag':instance.noticeFlag
     };

+ 1 - 0
lib/net/HttpManager.dart

@@ -4,6 +4,7 @@ import 'package:intl/intl.dart';
 
 class HttpManager {
   static String baseUrl = "http://49.4.66.233:8201/";
+  // static String baseUrl='http://192.168.50.121:8080/';
   static String token;
   static bool debug;
 

+ 194 - 91
lib/pages/HomePage.dart

@@ -1,8 +1,11 @@
 import 'package:flutter/material.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import 'package:mobile_cyber_game_app/redux/AppState.dart';
 import '../widget/HomeDrawer.dart';
 import 'Setting.dart';
 import 'CreateRoom.dart';
 import 'RoomList.dart'; //房间列表
+import 'rankList.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_swiper/flutter_swiper.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -11,6 +14,7 @@ import '../styles/totast.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import 'TipList.dart';
+import '../model/UserInfo.dart';
 
 class HomePage extends StatefulWidget {
   @override
@@ -35,6 +39,15 @@ class _HomePageState extends State<HomePage> {
       });
       print(seasonList);
     } else {}
+
+    getUserInfo();
+  }
+
+  void getUserInfo() async {
+    Result res = await HttpManager.get("userInfo/getUserInfo");
+    if (res.success) {
+      StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateUser, "user": res.data});
+    } else {}
   }
 
   @override
@@ -54,8 +67,10 @@ class _HomePageState extends State<HomePage> {
         width: double.infinity,
         height: double.infinity,
         decoration: BoxDecoration(
-            gradient: LinearGradient(
-                colors: [Color.fromARGB(255, 177, 59, 56), Color.fromARGB(255, 147, 64, 61)], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
+            gradient: LinearGradient(colors: [
+          Color.fromARGB(255, 177, 59, 56),
+          Color.fromARGB(255, 147, 64, 61)
+        ], begin: Alignment.topCenter, end: Alignment.bottomCenter)),
         child: SafeArea(
           child: centerWidget(context),
         ),
@@ -63,58 +78,56 @@ class _HomePageState extends State<HomePage> {
     );
   }
 
-  Widget centerWidget(BuildContext context) => Column(
-        children: <Widget>[
-          Expanded(
-            child: Stack(
-              children: <Widget>[
-                Container(
-                    child: seasonList.length > 0
-                        ? Swiper(
-                            index: nowIndex,
-                            itemCount: seasonList.length,
-                            scrollDirection: Axis.horizontal,
-                            loop: true,
-                            onTap: (index) {
-                              setState(() {
-                                nowIndex = index;
-                              });
-                            },
-                            onIndexChanged: (index) {
-                              setState(() {
-                                nowIndex = index;
-                              });
-                            },
-                            itemBuilder: (context, index) => Center(
-                                  child: SizedBox(
-                                      width: 214,
-                                      height: 214,
-                                      child: Stack(
-                                        children: <Widget>[
-                                          Image.asset("images/home_icon_yuan.png"),
-                                          Center(
-                                            child: Row(
-                                              mainAxisAlignment: MainAxisAlignment.center,
-                                              crossAxisAlignment: CrossAxisAlignment.baseline,
-                                              textBaseline: TextBaseline.alphabetic,
-                                              children: <Widget>[
-                                                Text(
-                                                  (seasonList[index].bonus / 1000).toStringAsFixed(1),
-                                                  style: TextStyle(
-                                                    color: Colors.white,
-                                                    fontSize: 68,
-                                                    fontFamily: 'DINEngschrift',
-                                                  ),
-                                                ),
-                                                Text(
-                                                  "K",
-                                                  style: TextStyle(
-                                                    color: Colors.white,
-                                                    fontSize: 36,
-                                                    fontFamily: 'DINEngschrift',
-                                                  ),
-                                                )
-                                              ],
+  Widget centerWidget(BuildContext context) {
+    UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
+    return Column(
+      children: <Widget>[
+        Expanded(
+          child: Stack(
+            children: <Widget>[
+              Container(
+                  child: seasonList.length > 0
+                      ? Swiper(
+                          index: nowIndex,
+                          itemCount: seasonList.length,
+                          scrollDirection: Axis.horizontal,
+                          loop: true,
+                          onTap: (index) {
+                            Navigator.push(
+                                context,
+                                new CupertinoPageRoute(
+                                    builder: (context) => new RankList(
+                                        raceId: seasonList[index].id)));
+                          },
+                          onIndexChanged: (index) {
+                            setState(() {
+                              nowIndex = index;
+                            });
+                          },
+                          itemBuilder: (context, index) {
+                            return Center(
+                              child: SizedBox(
+                                  width: 214,
+                                  height: 214,
+                                  child: Stack(
+                                    children: <Widget>[
+                                      Image.asset("images/home_icon_yuan.png"),
+                                      Center(
+                                        child: Row(
+                                          mainAxisAlignment:
+                                              MainAxisAlignment.center,
+                                          crossAxisAlignment:
+                                              CrossAxisAlignment.baseline,
+                                          textBaseline: TextBaseline.alphabetic,
+                                          children: <Widget>[
+                                            Text(
+                                              (seasonList[index].bonus / 1000)
+                                                  .toStringAsFixed(1),
+                                              style: TextStyle(
+                                                color: Colors.white,
+                                                fontSize: 68,
+                                                fontFamily: 'DINEngschrift',
+                                              ),
                                             ),
                                           ),
                                           Positioned(
@@ -161,45 +174,132 @@ class _HomePageState extends State<HomePage> {
                     ),
                   ),
                 ),
-                Positioned(
-                  right: 0,
-                  top: 0,
-                  width: 48,
-                  height: 48,
-                  child: Material(
-                    color: Colors.transparent,
-                    child: InkWell(
-                      onTap: () {
-                        Navigator.push(context, new CupertinoPageRoute(builder: (context) => new Setting()));
-                      },
-                      child: Padding(
-                        padding: EdgeInsets.all(12),
-                        child: Image.asset("images/home_icon_shezhi.png"),
-                      ),
+              ),
+              Positioned(
+                right: 0,
+                top: 0,
+                width: 48,
+                height: 48,
+                child: Material(
+                  color: Colors.transparent,
+                  child: InkWell(
+                    onTap: () {
+                      Navigator.push(
+                          context,
+                          new CupertinoPageRoute(
+                              builder: (context) => new Setting()));
+                    },
+                    child: Padding(
+                      padding: EdgeInsets.all(12),
+                      child: Image.asset("images/home_icon_shezhi.png"),
                     ),
                   ),
                 ),
-                Positioned(
-                  bottom: 11,
-                  left: 0,
-                  right: 0,
-                  child: Column(
-                    mainAxisAlignment: MainAxisAlignment.center,
-                    crossAxisAlignment: CrossAxisAlignment.center,
-                    children: <Widget>[
-                      Text(
-                        seasonList.length > 0 ? seasonList[nowIndex].season : '',
-                        style: TextStyle(color: Colors.white, fontSize: 14),
-                      ),
-                      Text(
-                        seasonList.length > 0 ? seasonList[nowIndex].gameInfo.gameName : '',
-                        style: TextStyle(color: Colors.white, fontSize: 14),
-                      )
-                    ],
-                  ),
+              ),
+              Positioned(
+                bottom: 11,
+                left: 0,
+                right: 0,
+                child: Column(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  crossAxisAlignment: CrossAxisAlignment.center,
+                  children: <Widget>[
+                    Text(
+                      seasonList.length > 0 ? seasonList[nowIndex].season : '',
+                      style: TextStyle(color: Colors.white, fontSize: 14),
+                    ),
+                    Text(
+                      seasonList.length > 0
+                          ? seasonList[nowIndex].gameInfo.gameName
+                          : '',
+                      style: TextStyle(color: Colors.white, fontSize: 14),
+                    )
+                  ],
                 ),
-              ],
-            ),
+              ),
+              // Positioned(
+              //   bottom: 60,
+              //   left: 0,
+              //   child: FlatButton(
+              //     child: Text("stream"),
+              //     onPressed: () async {
+              //       bool success = await ScreenStreamPlugin.start(
+              //           'rtmp://49.4.66.233:1935/myapp/' +
+              //               userInfo.id.toString() +
+              //               '?playerInfoId=' +
+              //               '1234');
+              //       print('stream screen:' + success.toString());
+              //     },
+              //   ),
+              // ),
+              // Positioned(
+              //   bottom: 60,
+              //   right: 0,
+              //   child: FlatButton(
+              //     child: Text("stop stream"),
+              //     onPressed: () async {
+              //       bool success = await ScreenStreamPlugin.stop();
+              //       print('stop stream screen:' + success.toString());
+              //     },
+              //   ),
+              // )
+            ],
+          ),
+        ),
+        Container(
+          child: GridView.count(
+            physics: new BouncingScrollPhysics(),
+            shrinkWrap: true,
+            crossAxisCount: 2,
+            children: <Widget>[
+              HomeMenu(
+                "images/home_icon_fangjian.png",
+                "创建房间",
+                onTapHomeMenu: () {
+                  Navigator.of(context).push(PageRouteBuilder(
+                      opaque: false,
+                      transitionDuration: Duration(milliseconds: 300),
+                      transitionsBuilder: (BuildContext context,
+                          Animation<double> animation,
+                          Animation<double> secondaryAnimation,
+                          Widget child) {
+                        return FadeTransition(
+                          opacity: CurvedAnimation(
+                              parent: animation, curve: Curves.linear),
+                          child: child,
+                        );
+                      },
+                      pageBuilder: (BuildContext context, _, __) {
+                        return CreateRoom();
+                      }));
+                },
+              ),
+              HomeMenu(
+                "images/home_icon_kuaisu.png",
+                "快速进入",
+                onTapHomeMenu: () {},
+              ),
+              HomeMenu(
+                "images/home_icon_sousuo.png",
+                "搜索",
+                onTapHomeMenu: () {
+                  Navigator.push(
+                      context,
+                      new CupertinoPageRoute(
+                          builder: (context) => new RoomList()));
+                },
+              ),
+              HomeMenu(
+                "images/home_icon_youjian.png",
+                "邮件",
+                onTapHomeMenu: () {
+                  Navigator.push(
+                      context,
+                      new CupertinoPageRoute(
+                          builder: (context) => new TipList()));
+                },
+              ),
+            ],
           ),
           Container(
             child: GridView.count(
@@ -261,8 +361,11 @@ class HomeMenu extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Container(
-      decoration:
-          BoxDecoration(gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
+      decoration: BoxDecoration(
+          gradient: LinearGradient(
+              begin: Alignment.topCenter,
+              end: Alignment.bottomCenter,
+              colors: [Color(0xFF626C85), Color(0xFF3D3E6C)])),
       child: AspectRatio(
         aspectRatio: 1,
         child: Container(

+ 228 - 0
lib/pages/RecordList.dart

@@ -0,0 +1,228 @@
+import 'package:flutter/material.dart';
+import '../styles/colors.dart';
+import 'dart:ui';
+import 'package:flutter/cupertino.dart';
+import '../styles/totast.dart';
+import '../model/PlayerInfo.dart';
+import '../styles/totast.dart';
+import '../net/HttpManager.dart';
+import '../net/Result.dart';
+import '../model/HouseInfo.dart';
+import '../model/GameInfo.dart';
+import '../pages/RoomInfo.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import '../redux/AppState.dart';
+
+class RecordList extends StatefulWidget {
+  @override
+  RecordListState createState() => RecordListState();
+}
+
+class RecordListState extends State<RecordList> {
+  ScrollController _mControll;
+  List<PlayerInfo> playerList = [];
+
+  int currentPage = 1;
+  bool isMore = false;
+
+  void getListPage() async {
+    isMore = false;
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.get("playerInfo/page", data: {
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id,
+      "currentPage": currentPage,
+      "pageNumber": 20
+    });
+    Toast.hide();
+    List<PlayerInfo> list = playerList;
+    if (currentPage == 1) {
+      list = [];
+    }
+    if (res.success) {
+      for (var item in res.data['pp']) {
+        print(item['houseInfo']);
+        PlayerInfo tip = PlayerInfo.fromJson(item);
+        list.add(tip);
+      }
+      if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
+        isMore = true;
+      }
+    } else {}
+    setState(() {
+      playerList = list;
+    });
+    print(res.data['pp']);
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    _mControll = ScrollController();
+    _mControll.addListener(() {
+      if (_mControll.position.pixels == _mControll.position.maxScrollExtent) {
+        if (isMore) {
+          currentPage++;
+          getListPage();
+        }
+      }
+    });
+
+    Future.delayed(Duration(milliseconds: 100), () => getListPage());
+  }
+
+  @override
+  void dispose() {
+    _mControll.dispose();
+    super.dispose();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return new Scaffold(
+        appBar: AppBar(
+          backgroundColor: PRIMARY_COLOR,
+          title: Text('我的战绩'),
+          centerTitle: true,
+          elevation: 0,
+        ),
+        body: Container(
+          color: BG_SUB_COLOR,
+          child: RefreshIndicator(
+              color: PRIMARY_COLOR,
+              backgroundColor: BG_COLOR,
+              onRefresh: () async {
+                await new Future.delayed(const Duration(seconds: 1));
+                currentPage = 1;
+                getListPage();
+              },
+              child: ListView.builder(
+                  physics: AlwaysScrollableScrollPhysics(),
+                  controller: _mControll,
+                  itemCount: playerList.length != 0 ? playerList.length : 1,
+                  itemBuilder: (BuildContext context, int index) {
+                    if (playerList.length == 0) {
+                      return Text(
+                        '还没有战绩快去比赛吧...',
+                        style: TextStyle(
+                            color: Colors.white30, fontSize: 13, height: 2),
+                        textAlign: TextAlign.center,
+                      );
+                    }
+                    return houseItem(
+                      roomInfo: playerList[index].houseInfo,
+                      gameInfo: playerList[index].gameInfo,
+                    );
+                  })),
+        ));
+  }
+}
+
+class houseItem extends StatelessWidget {
+  houseItem({Key key, this.roomInfo, this.gameInfo}) : super(key: key);
+  final HouseInfo roomInfo;
+  final GameInfo gameInfo;
+  @override
+  Widget build(BuildContext context) {
+    if(roomInfo==null){
+      return Container();
+    }
+    return Container(
+      decoration: BoxDecoration(
+          gradient: LinearGradient(
+            colors: [Color(0xFF3F4261), Color(0xFF323456)],
+            begin: Alignment.topCenter,
+            end: Alignment.bottomCenter,
+          ),
+          border: Border(bottom: BorderSide(color: Colors.black, width: 1))),
+      child: Material(
+        color: Colors.transparent,
+        child: InkWell(
+          child: Padding(
+            padding: EdgeInsets.all(15),
+            child: Row(
+              children: <Widget>[
+                Image.network(
+                  gameInfo.icon,
+                  width: 48,
+                  height: 48,
+                ),
+                Container(
+                  width: 10,
+                ),
+                Expanded(
+                  flex: 1,
+                  child: Column(
+                    crossAxisAlignment: CrossAxisAlignment.start,
+                    children: <Widget>[
+                      Row(
+                        children: <Widget>[
+                          LimitedBox(
+                            maxWidth: 170,
+                            child: Text(
+                              roomInfo.houseName,
+                              style: TextStyle(
+                                  color: Colors.white,
+                                  fontSize: 14,
+                                  fontWeight: FontWeight.w500),
+                              maxLines: 1,
+                              overflow: TextOverflow.ellipsis,
+                            ),
+                          ),
+                          Container(
+                            margin: EdgeInsets.only(left: 6),
+                            child: Image.network(roomInfo.houseLevel.icon,
+                                width: 14),
+                          ),
+                          Container(
+                              margin: EdgeInsets.only(left: 1),
+                              child: Text(
+                                roomInfo.houseLevel.levelName,
+                                style: TextStyle(
+                                    color: Color(0xFFF9D881), fontSize: 9),
+                              )),
+                        ],
+                      ),
+                      Text(
+                        roomInfo.houseAbstract,
+                        style: TextStyle(
+                            fontSize: 12,
+                            fontWeight: FontWeight.w400,
+                            color: Color(0xFF9BA0AE)),
+                        maxLines: 2,
+                        overflow: TextOverflow.ellipsis,
+                      )
+                    ],
+                  ),
+                ),
+                Row(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  children: <Widget>[
+                    Image.asset('images/icon_renshu.png', width: 20),
+                    Text(
+                      (roomInfo.playerNumber != null
+                              ? roomInfo.playerNumber.toString()
+                              : '0') +
+                          '/' +
+                          roomInfo.maxNumber.toString(),
+                      style: TextStyle(
+                          fontSize: 14,
+                          fontWeight: FontWeight.w500,
+                          color: Color(0xFFB1B2C0)),
+                    )
+                  ],
+                )
+              ],
+            ),
+          ),
+          onTap: () {
+            Navigator.push(
+                context,
+                new CupertinoPageRoute(
+                    builder: (context) =>
+                        new RoomInfo(roomId: roomInfo.id.toString())));
+          },
+        ),
+      ),
+    );
+  }
+}

+ 11 - 6
lib/pages/StartWindow.dart

@@ -69,12 +69,17 @@ class StartWindowState extends State<StartWindow> {
                           fontSize: 20,
                           fontWeight: FontWeight.w600)),
                   _centerContent(),
-                  RaisedButton(
-                    textTheme: ButtonTextTheme.primary,
-                    child: Text('确认'),
-                    onPressed: () {
-                      isNext = false;
-                    },
+                  Container(
+                    width: double.infinity,
+                    height: 44,
+                    padding: EdgeInsets.symmetric(vertical: 42),
+                    child: RaisedButton(
+                      textTheme: ButtonTextTheme.primary,
+                      child: Text('确认'),
+                      onPressed: () {
+                        isNext = false;
+                      },
+                    ),
                   )
                 ],
               ),

+ 90 - 62
lib/pages/TipInfo.dart

@@ -30,7 +30,11 @@ class TipInfoState extends State<TipInfo> {
       setState(() {
         tipInfo = SystemNotice.fromJson(res.data);
       });
-      print(tipInfo);
+    }
+
+    if (tipInfo.statusFlag == 0 && tipInfo.typeFlag != 2) {
+      HttpManager.post("systemNotice/update",
+          data: {'id': tipInfo.id, "statusFlag": 1});
     }
 
     Result res2 = await HttpManager.get("houseInfo/getOne",
@@ -40,9 +44,10 @@ class TipInfoState extends State<TipInfo> {
         houseInfo = HouseInfo.fromJson(res2.data);
       });
     }
-    print(houseInfo);
   }
 
+  void updateHousInfo() {}
+
   @override
   void initState() {
     
@@ -53,68 +58,90 @@ class TipInfoState extends State<TipInfo> {
   @override
   Widget build(BuildContext context) {
     int type = tipInfo.typeFlag != null ? tipInfo.typeFlag : 0;
+    int status = tipInfo.statusFlag ?? 0;
     GameInfo gameInfo;
     if (tipInfo.gameInfo != null) {
       gameInfo = tipInfo.gameInfo;
     }
-    return new Scaffold(
-        appBar: AppBar(
-          backgroundColor: PRIMARY_COLOR,
-          title: Text('通知详情'),
-          centerTitle: true,
-          elevation: 0,
-        ),
-        body: Container(
-          color: Color(0xFF2B2B42),
-          width: double.infinity,
-          height: double.infinity,
-          child: Column(
-            children: <Widget>[
-              Padding(
-                padding: EdgeInsets.only(left: 15, right: 45),
-                child: Column(
-                  crossAxisAlignment: CrossAxisAlignment.start,
-                  children: <Widget>[
-                    Padding(
-                      padding: EdgeInsets.symmetric(vertical: 12),
-                      child: Text(
-                          readTimestamp(
-                              tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
-                          style:
-                              TextStyle(color: Colors.white24, fontSize: 13)),
-                    ),
-                    Container(
-                      height: 1,
-                      color: Colors.black26,
-                    ),
-                    Padding(
-                      padding: EdgeInsets.only(top: 10, bottom: 17),
-                      child: Text(
-                        tipInfo.content,
-                        style: TextStyle(color: Colors.white, fontSize: 14),
+    return new WillPopScope(
+      child: Scaffold(
+          appBar: AppBar(
+            backgroundColor: PRIMARY_COLOR,
+            title: Text('通知详情'),
+            centerTitle: true,
+            elevation: 0,
+          ),
+          body: Container(
+            color: Color(0xFF2B2B42),
+            width: double.infinity,
+            height: double.infinity,
+            child: Column(
+              children: <Widget>[
+                Padding(
+                  padding: EdgeInsets.only(left: 15, right: 45),
+                  child: Column(
+                    crossAxisAlignment: CrossAxisAlignment.start,
+                    children: <Widget>[
+                      Padding(
+                        padding: EdgeInsets.symmetric(vertical: 12),
+                        child: Text(
+                            readTimestamp(
+                                tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
+                            style:
+                                TextStyle(color: Colors.white24, fontSize: 13)),
                       ),
-                    )
-                  ],
-                ),
-              ),
-              houseInfo != null
-                  ? houseItem(roomInfo: houseInfo, gameInfo: gameInfo)
-                  : Container(),
-              type == 2
-                  ? Container(
-                      width: double.infinity,
-                      height: 48,
-                      padding: EdgeInsets.symmetric(horizontal: 15),
-                      child: RaisedButton(
-                        textColor: Colors.white,
-                        child: Text('立即领取'),
-                        onPressed: () {},
+                      Container(
+                        height: 1,
+                        color: Colors.black26,
                       ),
-                    )
-                  : Container()
-            ],
-          ),
-        ));
+                      Padding(
+                        padding: EdgeInsets.only(top: 10, bottom: 17),
+                        child: Text(
+                          tipInfo.content,
+                          style: TextStyle(color: Colors.white, fontSize: 14),
+                        ),
+                      )
+                    ],
+                  ),
+                ),
+                houseInfo != null
+                    ? houseItem(roomInfo: houseInfo, gameInfo: gameInfo)
+                    : Container(),
+                type == 2 && status == 0
+                    ? Container(
+                        width: double.infinity,
+                        height: 48,
+                        padding: EdgeInsets.symmetric(horizontal: 15),
+                        child: RaisedButton(
+                          textColor: Colors.white,
+                          child: Text('立即领取'),
+                          onPressed: () async {
+                            Toast.show(context, '加载中', -1, 'loading');
+                            Result res = await HttpManager.post(
+                                "playerInfo/receive",
+                                data: {"id": tipInfo.playerId});
+                            Toast.hide();
+                            print(res.data);
+                            if (res.success) {
+                              Toast.show(context, '领取成功', 1000, 'success');
+                              Future.delayed(Duration(milliseconds: 1000),
+                                  () => getInfo());
+                            } else {
+                              Toast.show(context, res.error, 1000, 'info');
+                            }
+                          },
+                        ),
+                      )
+                    : Container()
+              ],
+            ),
+          )),
+      onWillPop: () {
+        Navigator.of(context).pop(true);
+        Toast.hide();
+        return Future.value(false);
+      },
+    );
   }
 }
 
@@ -214,10 +241,11 @@ class houseItem extends StatelessWidget {
             ),
           ),
           onTap: () {
-             Navigator.push(context,
-                  new CupertinoPageRoute(builder: (context) => new RoomInfo(
-                    roomId:roomInfo.id.toString()
-                  )));
+            Navigator.push(
+                context,
+                new CupertinoPageRoute(
+                    builder: (context) =>
+                        new RoomInfo(roomId: roomInfo.id.toString())));
           },
         ),
       ),

+ 22 - 9
lib/pages/TipList.dart

@@ -59,6 +59,7 @@ class TipListState extends State<TipList> {
     _mControll.addListener(() {
       if (_mControll.position.pixels == _mControll.position.maxScrollExtent) {
         if (isMore) {
+          currentPage++;
           getListPage();
         }
       }
@@ -105,7 +106,22 @@ class TipListState extends State<TipList> {
                           textAlign: TextAlign.center,
                         );
                       }
-                      return TipItem(tipInfo: tipList[index]);
+                      return TipItem(
+                          tipInfo: tipList[index],
+                          tapInfo: () async {
+                            var res = await Navigator.push(
+                                context,
+                                new CupertinoPageRoute(
+                                    builder: (context) =>
+                                        new TipInfo(tipId: tipList[index].id)));
+                            if (res != null) {
+                              setState(() {
+                                tipList = [];
+                              });
+                              currentPage = 1;
+                              getListPage();
+                            }
+                          });
                     }),
               ),
             )),
@@ -118,10 +134,12 @@ class TipListState extends State<TipList> {
   }
 }
 
+typedef OnTapHomeMenu();
+
 class TipItem extends StatelessWidget {
-  TipItem({Key key, this.tipInfo}) : super(key: key);
+  TipItem({Key key, this.tipInfo, this.tapInfo}) : super(key: key);
   final SystemNotice tipInfo; // 用来储存传递过来的值
-
+  final OnTapHomeMenu tapInfo;
   @override
   Widget build(BuildContext context) {
     return Container(
@@ -177,12 +195,7 @@ class TipItem extends StatelessWidget {
               ],
             ),
           ),
-          onTap: () {
-            Navigator.push(
-                context,
-                new CupertinoPageRoute(
-                    builder: (context) => new TipInfo(tipId: tipInfo.id)));
-          },
+          onTap: tapInfo,
         ),
       ),
     );

+ 29 - 6
lib/pages/changeUserInfo.dart

@@ -66,13 +66,17 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                               fontSize: 16,
                               color: Color(0xFF727785),
                             ),
-                            textStyle: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
+                            textStyle: TextStyle(
+                                color: Colors.white,
+                                fontSize: 18,
+                                fontWeight: FontWeight.w500),
                             fieldCallBack: (content) {
                               setState(() {
                                 changeText = content;
                               });
                             },
-                            counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0),
+                            counterStyle:
+                                TextStyle(color: BG_SUB_COLOR, fontSize: 0),
                           ),
                         ),
                         Container(
@@ -85,7 +89,8 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                               highlightColor: Color(0xFF763434),
                               child: Text(
                                 "确定修改",
-                                style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
+                                style: TextStyle(
+                                    fontSize: 16, fontWeight: FontWeight.w500),
                               ),
                               onPressed: () async {
                                 if (changeText.isEmpty) {
@@ -93,13 +98,31 @@ class ChangeUserInfoState extends State<ChangeUserInfo> {
                                   return;
                                 }
                                 Toast.show(context, '加载中', -1, 'loading');
-                                Result res = await HttpManager.post('userInfo/update', data: {'id': userInfo.id, changekey: changeText});
+                                final Result res = await HttpManager.post(
+                                    'userInfo/update',
+                                    data: {
+                                      "id": userInfo.id,
+                                      changekey: changeText
+                                    });
                                 Toast.hide();
                                 if (res.success) {
-                                  Navigator.pop(context, true);
+                                  Result res2 = await HttpManager.get(
+                                      "userInfo/getUserInfo");
+                                  if (res2.success) {
+                                    StoreProvider.of<AppState>(context)
+                                        .dispatch({
+                                      "action": Actions.updateUser,
+                                      "user": res2.data
+                                    });
+                                    Toast.show(
+                                        context, '修改成功', 1000, 'success');
+                                    Future.delayed(Duration(milliseconds: 1000),
+                                        () {
+                                      Navigator.of(context).pop();
+                                    });
+                                  } else {}
                                 } else {
                                   Toast.show(context, res.error, 1500, 'info');
-                                  Navigator.pop(context);
                                 }
                               }),
                         ),

+ 188 - 149
lib/pages/rankList.dart

@@ -2,10 +2,16 @@ import 'package:flutter/material.dart';
 import '../styles/colors.dart';
 import 'dart:ui';
 import '../styles/totast.dart';
+import '../model/PlayerInfo.dart';
+import '../net/HttpManager.dart';
+import '../net/Result.dart';
+import 'package:flutter_redux/flutter_redux.dart';
+import '../redux/AppState.dart';
+import '../model/CompetitionSeason.dart';
 
 class RankList extends StatefulWidget {
   RankList({Key key, this.raceId}) : super(key: key);
-  final String raceId; // 用来储存传递过来的值
+  final int raceId; // 用来储存传递过来的值
   @override
   RankListState createState() => RankListState();
 }
@@ -13,118 +19,126 @@ class RankList extends StatefulWidget {
 class RankListState extends State<RankList> {
   String raceName = '2019';
   List raceNameList = ['2019', '2018', '2017'];
-  List rankList = [
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '568449',
-      "name": '汪大宝'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '56849',
-      "name": 'Crona'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '38449',
-      "name": 'Ewell'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '568449',
-      "name": '汪大宝'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '56849',
-      "name": 'Crona'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '38449',
-      "name": 'Ewell'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '568449',
-      "name": '汪大宝'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '56849',
-      "name": 'Crona'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '38449',
-      "name": 'Ewell'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '568449',
-      "name": '汪大宝'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '56849',
-      "name": 'Crona汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝汪大宝'
-    },
-    {
-      "icon":
-          'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-      "money": '38449',
-      "name": 'Ewell'
-    }
-  ];
-
+  List<PlayerInfo> rankList = [];
   ScrollController _mcontroller;
   bool scrollFlag = true;
   int currentPage = 1;
+  int raceId = 0;
+  List<CompetitionSeason> seasonList = [];
+  PlayerInfo myPlayInfo;
+
+  void getUserRank() async {
+    print('***********');
+
+    Result res = await HttpManager.get("playerInfo/seasonUserRank", data: {
+      "seasonId": raceId,
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id
+    });
+    print(res.data);
+    if (res.success && res.data != null) {
+      setState(() {
+        myPlayInfo = PlayerInfo.fromJson(res.data);
+      });
+    } else {
+      setState(() {
+        myPlayInfo = null;
+      });
+    }
+
+    currentPage = 1;
+    getListPage();
+  }
+
+  void getListPage() async {
+    scrollFlag = false;
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.get("playerInfo/seasonRankPage", data: {
+      "seasonId": raceId,
+      "currentPage": currentPage,
+      "pageNumber": 20
+    });
+    Toast.hide();
+    List<PlayerInfo> list = rankList;
+    if (currentPage == 1) {
+      list = [];
+    }
+    if (res.success) {
+      for (var item in res.data['pp']) {
+        PlayerInfo tip = PlayerInfo.fromJson(item);
+        list.add(tip);
+      }
+      if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
+        scrollFlag = true;
+      }
+    } else {}
+    setState(() {
+      rankList = list;
+    });
+
+    if (rankList.length == 0) {
+      showBackDialog();
+    }
+  }
+
+  //没有赛季排行数据弹窗
+  showBackDialog() {
+    showDialog<Null>(
+      context: context,
+      barrierDismissible: false,
+      builder: (BuildContext context) {
+        return new AlertDialog(
+          content: Container(
+            height: 50,
+            child: Text(
+              '该赛季暂未产生排行数据,尽情期待...',
+              style: TextStyle(color: Colors.black),
+            ),
+          ),
+          actions: <Widget>[
+            new FlatButton(
+              child: new Text('确定'),
+              onPressed: () {
+                Navigator.of(context).pop();
+              },
+            ),
+          ],
+        );
+      },
+    ).then((val) {
+      Navigator.of(context).pop();
+    });
+  }
+
+  void getSeasonInfo() async {
+    Result res = await HttpManager.get("competitionSeason/all");
+    if (res.success) {
+      List<CompetitionSeason> list = [];
+      for (var item in res.data) {
+        list.add(CompetitionSeason.fromJson(item));
+      }
+      setState(() {
+        seasonList = list;
+      });
+    } else {}
+  }
+
   @override
   void initState() {
+    raceId = widget.raceId;
     super.initState();
     _mcontroller = ScrollController();
     _mcontroller.addListener(() {
       if (_mcontroller.position.pixels ==
           _mcontroller.position.maxScrollExtent) {
         if (scrollFlag) {
-          print(currentPage);
-          // setState(() {
-          //   rankList.addAll([
-          //     {
-          //       "icon":
-          //           'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-          //       "money": '568449',
-          //       "name": '汪大宝'
-          //     },
-          //     {
-          //       "icon":
-          //           'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-          //       "money": '56849',
-          //       "name": 'Crona'
-          //     },
-          //     {
-          //       "icon":
-          //           'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg',
-          //       "money": '38449',
-          //       "name": 'Ewell'
-          //     }
-          //   ]);
-          // });
+          currentPage++;
+          getListPage();
         }
       }
     });
+
+    Future.delayed(Duration(milliseconds: 100), () => getUserRank());
+    getSeasonInfo();
   }
 
   @override
@@ -144,6 +158,7 @@ class RankListState extends State<RankList> {
                 backgroundColor: BG_COLOR,
                 onRefresh: () async {
                   await new Future.delayed(const Duration(seconds: 1));
+                  getUserRank();
                 },
                 child: CustomScrollView(
                   controller: _mcontroller,
@@ -155,64 +170,84 @@ class RankListState extends State<RankList> {
                   ],
                 )),
           ),
-          floatingActionButton: Container(
-            padding: EdgeInsets.only(left: 20,right: 15),
-            height: 48,
-            decoration: BoxDecoration(
-              gradient: LinearGradient(
-                begin: Alignment.topRight,
-                colors: [Color(0xFF59607A), Color(0xFF3C3C67)],
-              )
-            ),
-            child: Row(
-              children: <Widget>[
-                Container(
-                  width:30,
-                  height: 30,
-                  child: CircleAvatar(
-                    backgroundImage: NetworkImage('http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg'),
+          floatingActionButton: myPlayInfo == null
+              ? Container()
+              : Container(
+                  padding: EdgeInsets.only(left: 20, right: 15),
+                  height: 48,
+                  decoration: BoxDecoration(
+                      gradient: LinearGradient(
+                    begin: Alignment.topRight,
+                    colors: [Color(0xFF59607A), Color(0xFF3C3C67)],
+                  )),
+                  child: Row(
+                    children: <Widget>[
+                      Container(
+                        width: 30,
+                        height: 30,
+                        child: CircleAvatar(
+                            backgroundImage:
+                                NetworkImage(myPlayInfo.userInfo.icon ?? '')),
+                      ),
+                      Padding(
+                        padding: EdgeInsets.symmetric(horizontal: 10),
+                        child: Text(myPlayInfo.userInfo.nickname ?? '',
+                            style:
+                                TextStyle(color: Colors.white, fontSize: 14)),
+                      ),
+                      Image.asset('images/icon_jinbi_da_bai.png', width: 20),
+                      Padding(
+                        padding: EdgeInsets.only(left: 2),
+                        child: Text((myPlayInfo.bonus ?? 0).toString(),
+                            style: TextStyle(
+                                color: Colors.white,
+                                fontSize: 14,
+                                fontWeight: FontWeight.w500)),
+                      ),
+                      myPlayInfo.rank == null
+                          ? Container()
+                          : Expanded(
+                              flex: 1,
+                              child: Text(
+                                  '第 ' + myPlayInfo.rank.toString() + ' 名',
+                                  style: TextStyle(
+                                      color: Colors.white,
+                                      fontSize: 14,
+                                      fontWeight: FontWeight.w500),
+                                  textAlign: TextAlign.right),
+                            )
+                    ],
                   ),
                 ),
-                Padding(
-                  padding: EdgeInsets.symmetric(horizontal: 10),
-                  child: Text('粉条',style: TextStyle(color: Colors.white,fontSize: 14)),
-                ),
-                Image.asset('images/icon_jinbi_da_bai.png',width: 20),
-                Padding(
-                  padding: EdgeInsets.only(left: 2),
-                  child: Text('568449',style: TextStyle(color: Colors.white,fontSize: 14,fontWeight: FontWeight.w500)),
-                ),
-                Expanded(
-                  flex: 1,
-                  child: Text('第 28 名',style: TextStyle(color: Colors.white,fontSize: 14,fontWeight: FontWeight.w500),textAlign: TextAlign.right),
-                )
-              ],
-            ),
-          ),
           floatingActionButtonLocation:
               FloatingActionButtonLocation.centerDocked,
         ),
         onWillPop: () {
           Toast.hide();
-          print("返回键点击了");
           Navigator.pop(context);
           return Future.value(false);
         });
   }
 
   Widget _sliverAppBar() {
+    CompetitionSeason competitionSeason;
+    for (var item in seasonList) {
+      if (item.id == raceId) {
+        competitionSeason = item;
+      }
+    }
     return SliverAppBar(
         title: Text('排行榜'),
         centerTitle: true,
         actions: <Widget>[
           PopupMenuButton(
-              initialValue: raceName,
+              initialValue: raceId,
               child: Row(
                 crossAxisAlignment: CrossAxisAlignment.center,
                 mainAxisAlignment: MainAxisAlignment.center,
                 children: <Widget>[
                   Text(
-                    raceName + '赛季',
+                    competitionSeason != null ? competitionSeason.season : '',
                     style: TextStyle(
                         color: Colors.white,
                         fontSize: 13,
@@ -229,13 +264,14 @@ class RankListState extends State<RankList> {
               ),
               onSelected: (value) {
                 setState(() {
-                  raceName = value;
+                  raceId = value;
                 });
+                getUserRank();
               },
               itemBuilder: (BuildContext context) {
-                return raceNameList.map((choice) {
+                return seasonList.map((choice) {
                   return new PopupMenuItem(
-                      child: new Text(choice + '赛季'), value: choice);
+                      child: new Text(choice.season), value: choice.id);
                 }).toList();
               }),
         ],
@@ -278,7 +314,8 @@ class RankListState extends State<RankList> {
                       height: 36,
                       margin: EdgeInsets.only(right: 15),
                       child: CircleAvatar(
-                        backgroundImage: NetworkImage(rankList[index]['icon']),
+                        backgroundImage:
+                            NetworkImage(rankList[index].userInfo.icon),
                       ),
                     ),
                     Expanded(
@@ -287,7 +324,7 @@ class RankListState extends State<RankList> {
                         mainAxisAlignment: MainAxisAlignment.center,
                         crossAxisAlignment: CrossAxisAlignment.start,
                         children: <Widget>[
-                          Text(rankList[index]['name'],
+                          Text(rankList[index].userInfo.nickname,
                               style: TextStyle(
                                   color: PRIMARY_COLOR,
                                   fontSize: 14,
@@ -299,7 +336,7 @@ class RankListState extends State<RankList> {
                                   width: 20),
                               Padding(
                                 padding: EdgeInsets.only(left: 2),
-                                child: Text(rankList[index]['money'],
+                                child: Text(rankList[index].bonus.toString(),
                                     style: TextStyle(
                                       color: Colors.white,
                                       fontSize: 14,
@@ -384,7 +421,8 @@ class RankListState extends State<RankList> {
                                 blurRadius: 4.0)
                           ]),
                       child: CircleAvatar(
-                          backgroundImage: NetworkImage(rankList[0]['icon']))),
+                          backgroundImage:
+                              NetworkImage(rankList[0].userInfo.icon))),
                   Positioned(
                       bottom: 0,
                       left: 24,
@@ -395,7 +433,7 @@ class RankListState extends State<RankList> {
             ),
             Padding(
               padding: EdgeInsets.only(top: 7, bottom: 3),
-              child: Text(rankList[0]["name"],
+              child: Text(rankList[0].userInfo.nickname,
                   style: TextStyle(color: Color(0xFF2E3049), fontSize: 14)),
             ),
             Row(
@@ -404,7 +442,7 @@ class RankListState extends State<RankList> {
                   padding: EdgeInsets.only(right: 2),
                   child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
                 ),
-                Text(rankList[0]["money"],
+                Text(rankList[0].bonus.toString(),
                     style: TextStyle(
                         color: Colors.white,
                         fontSize: 14,
@@ -447,7 +485,7 @@ class RankListState extends State<RankList> {
                               ]),
                           child: CircleAvatar(
                               backgroundImage:
-                                  NetworkImage(rankList[1]['icon']))),
+                                  NetworkImage(rankList[1].userInfo.icon))),
                       Positioned(
                           bottom: 0,
                           left: 19,
@@ -458,7 +496,7 @@ class RankListState extends State<RankList> {
                 ),
                 Padding(
                   padding: EdgeInsets.only(top: 7, bottom: 3),
-                  child: Text(rankList[1]["name"],
+                  child: Text(rankList[1].userInfo.nickname,
                       style: TextStyle(color: Color(0xFF2E3049), fontSize: 14)),
                 ),
                 Row(
@@ -468,7 +506,7 @@ class RankListState extends State<RankList> {
                       child: Image.asset('images/icon_jinbi_da_bai.png',
                           width: 20),
                     ),
-                    Text(rankList[1]["money"],
+                    Text(rankList[1].bonus.toString(),
                         style: TextStyle(
                             color: Colors.white,
                             fontSize: 14,
@@ -507,7 +545,8 @@ class RankListState extends State<RankList> {
                                 blurRadius: 4.0)
                           ]),
                       child: CircleAvatar(
-                          backgroundImage: NetworkImage(rankList[2]['icon']))),
+                          backgroundImage:
+                              NetworkImage(rankList[2].userInfo.icon))),
                   Positioned(
                       bottom: 0,
                       left: 19,
@@ -518,7 +557,7 @@ class RankListState extends State<RankList> {
             ),
             Padding(
               padding: EdgeInsets.only(top: 7, bottom: 3),
-              child: Text(rankList[2]["name"],
+              child: Text(rankList[2].userInfo.nickname,
                   style: TextStyle(color: Color(0xFF2E3049), fontSize: 14)),
             ),
             Row(
@@ -527,7 +566,7 @@ class RankListState extends State<RankList> {
                   padding: EdgeInsets.only(right: 2),
                   child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
                 ),
-                Text(rankList[2]["money"],
+                Text(rankList[2].bonus.toString(),
                     style: TextStyle(
                         color: Colors.white,
                         fontSize: 14,

+ 66 - 31
lib/pages/setting.dart

@@ -30,6 +30,20 @@ class SettingState extends State<Setting> {
   String version = "";
   bool receiveMsg = false;
 
+  void getFilePath() async {
+    String filePath = await FilePicker.getFilePath(type: FileType.IMAGE);
+    File _file = File(filePath);
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.post("assets/uploadFile", data: {
+      "file": UploadFileInfo(_file, filePath),
+    });
+    Toast.hide();
+    if (res.success) {
+      updateUserInfo(StoreProvider.of<AppState>(context).state.userInfo,
+          res.data[0], 'icon');
+    } else {}
+  }
+
   @override
   void initState() {
     super.initState();
@@ -76,38 +90,45 @@ class SettingState extends State<Setting> {
                                 _cell(
                                     '头像',
                                     ClipOval(
-                                      child: Image.network(
-                                        userInfo.icon,
-                                        width: 36,
-                                        height: 36,
-                                        fit: BoxFit.cover,
-                                      ),
+                                      child: Image.network(userInfo.icon,
+                                          width: 36, height: 36),
                                     ), onTap: () {
-                                  _chooseImage(context);
+                                  getFilePath();
                                 }),
-                                _cell('昵称', userInfo.nickname, placeholder: '请填写昵称', onTap: () async {
-                                  bool success = await Navigator.push<bool>(
-                                      context, new CupertinoPageRoute(builder: (context) => new ChangeUserInfo(title: '昵称', val: userInfo.nickname)));
-                                  if (success) {
-                                    Toast.show(context, '修改成功', 1500, 'success');
-                                    getUserInfo();
-                                  }
+                                _cell('昵称', userInfo.nickname,
+                                    placeholder: '请填写昵称', onTap: () {
+                                  Navigator.push(
+                                      context,
+                                      new CupertinoPageRoute(
+                                          builder: (context) =>
+                                              new ChangeUserInfo(
+                                                  title: '昵称',
+                                                  val: userInfo.nickname)));
                                 }),
-                                _cell('性别', userInfo.sex, placeholder: '请添加性别信息', onTap: () {
+                                _cell('性别', userInfo.sex,
+                                    placeholder: '请添加性别信息', onTap: () {
                                   _chooseSex(context);
                                 }),
                                 _cell(
                                   '生日',
                                   DateFormat('yyyy-MM-dd').format(
-                                    DateTime.fromMillisecondsSinceEpoch(userInfo.birthday),
+                                    DateTime.fromMillisecondsSinceEpoch(
+                                        userInfo.birthday),
                                   ),
                                   placeholder: '选择生日',
                                   onTap: () {
                                     _chooseBirthday(context);
                                   },
                                 ),
-                                _cell('手机', userInfo.phone, showBorder: false, onTap: () async {
-                                  // Navigator.push(context, new CupertinoPageRoute(builder: (context) => new ChangeUserInfo(title: '手机号', val: userInfo.phone)));
+                                _cell('手机', userInfo.phone, showBorder: false,
+                                    onTap: () {
+                                  Navigator.push(
+                                      context,
+                                      new CupertinoPageRoute(
+                                          builder: (context) =>
+                                              new ChangeUserInfo(
+                                                  title: '手机号',
+                                                  val: userInfo.phone)));
                                 })
                               ]),
                               _sectionDivier(),
@@ -115,11 +136,10 @@ class SettingState extends State<Setting> {
                                 _cell(
                                     '是否接收消息',
                                     Switch(
-                                        value: true,
+                                        value: userInfo.noticeFlag,
                                         onChanged: (val) {
-                                          setState(() {
-                                            receiveMsg = val;
-                                          });
+                                          updateUserInfo(userInfo,
+                                              val ? 'Y' : 'N', 'noticeFlag');
                                         }),
                                     showBorder: false)
                               ]),
@@ -144,15 +164,20 @@ class SettingState extends State<Setting> {
                           highlightColor: Color(0xFF763434),
                           child: Text(
                             "退出登录",
-                            style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
+                            style: TextStyle(
+                                fontSize: 16, fontWeight: FontWeight.w700),
                           ),
                           onPressed: () {
                             Future.delayed(const Duration(seconds: 1), () {
-                              StoreProvider.of<AppState>(context).dispatch({"action": Actions.logout});
+                              StoreProvider.of<AppState>(context)
+                                  .dispatch({"action": Actions.logout});
                             });
 
                             Toast.show(context, '退出成功', 1500, 'success');
-                            Navigator.push(context, new MaterialPageRoute(builder: (context) => new LoginFirst()));
+                            Navigator.push(
+                                context,
+                                new MaterialPageRoute(
+                                    builder: (context) => new LoginFirst()));
                           }),
                     )
                   ],
@@ -167,10 +192,14 @@ class SettingState extends State<Setting> {
   }
 
   void updateUserInfo(userInfo, value, key) async {
+    print(userInfo);
+    print(value);
+    print(key);
     if (Toast.preToast == null) {
       Toast.show(context, '加载中', -1, 'loading');
     }
-    final Result res = await HttpManager.post('userInfo/update', data: {"id": userInfo.id, key: value});
+    final Result res = await HttpManager.post('userInfo/update',
+        data: {"id": userInfo.id, key: value});
     Toast.hide();
     if (res.success) {
       Toast.show(context, '修改成功', 1500, 'success');
@@ -183,7 +212,8 @@ class SettingState extends State<Setting> {
   void getUserInfo() async {
     Result res = await HttpManager.get("userInfo/getUserInfo");
     if (res.success) {
-      StoreProvider.of<AppState>(context).dispatch({"action": Actions.updateUser, "user": res.data});
+      StoreProvider.of<AppState>(context)
+          .dispatch({"action": Actions.updateUser, "user": res.data});
     } else {}
   }
 
@@ -217,13 +247,16 @@ class SettingState extends State<Setting> {
           );
         });
     if (sex != null) {
-      updateUserInfo(StoreProvider.of<AppState>(context).state.userInfo, sex, 'sex');
+      updateUserInfo(
+          StoreProvider.of<AppState>(context).state.userInfo, sex, 'sex');
     }
   }
 
   _chooseBirthday(BuildContext context) async {
     UserInfo userInfo = StoreProvider.of<AppState>(context).state.userInfo;
-    DateTime date = userInfo.birthday > 0 ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday) : DateTime.now();
+    DateTime date = userInfo.birthday > 0
+        ? DateTime.fromMillisecondsSinceEpoch(userInfo.birthday)
+        : DateTime.now();
     DateTime res = await showCupertinoModalPopup<DateTime>(
       context: context,
       builder: (BuildContext context) {
@@ -309,7 +342,8 @@ class SettingState extends State<Setting> {
     _image.readAsBytes().then((bytes) async {
       String encoded1 = 'data:image/jpeg;base64,' + base64Encode(bytes);
       FormData formData = new FormData.from({"base64": encoded1});
-      final response = await Dio().post(domain + 'assets/uploadImg', data: formData);
+      final response =
+          await Dio().post(domain + 'assets/uploadImg', data: formData);
       final res = json.decode(response.toString());
       if (res['success']) {
         updateUserInfo(userInfo, res['data'], 'icon');
@@ -330,7 +364,8 @@ class SettingState extends State<Setting> {
     );
   }
 
-  Widget _cell(String title, dynamic child, {String placeholder, void Function() onTap, bool showBorder = true}) {
+  Widget _cell(String title, dynamic child,
+      {String placeholder, void Function() onTap, bool showBorder = true}) {
     Widget secondChild;
     if (child == null || (child is String && child.length == 0)) {
       secondChild = Text(

+ 1 - 1
lib/styles/api.dart

@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
 import 'package:intl/intl.dart';
 
 String domain='http://49.4.66.233:8201/';
-// String domain='http://192.168.50.226:8080/'; //本地ip
+// String domain='http://192.168.50.121:8080/'; //本地ip
 
 String debugID='84671';//测试id
 

+ 7 - 1
lib/widget/HomeDrawer.dart

@@ -6,6 +6,7 @@ import '../redux/AppState.dart';
 import '../model/UserInfo.dart';
 import '../pages/MyWallet.dart'; //我的钱包
 import '../pages/BindGame.dart'; //游戏绑定
+import '../pages/RecordList.dart'; //我的战绩
 
 class HomeDrawer extends StatelessWidget {
   @override
@@ -95,7 +96,12 @@ class HomeDrawer extends StatelessWidget {
                         },
                       ),
                       Divder(),
-                      DrawerMenu("images/icon_zhanji.png", "我的战绩"),
+                      DrawerMenu("images/icon_zhanji.png", "我的战绩", onTap: () {
+                        Navigator.push(
+                            context,
+                            new CupertinoPageRoute(
+                                builder: (context) => new RecordList()));
+                      }),
                       Divder(),
                       DrawerMenu(
                         "images/icon_bangding.png",