panhui 7 lat temu
rodzic
commit
6ad6a20893

BIN
images/2x/home_icon_yuan.png


BIN
images/2x/icon_paihangbang_01.png


BIN
images/2x/icon_paihangbang_02.png


BIN
images/2x/icon_paihangbang_03.png


BIN
images/2x/img_kaishiyouxi.png


BIN
images/2x/ph_yinpai_no1.png


BIN
images/2x/ph_yinpai_no2.png


BIN
images/2x/ph_yinpai_no3.png


BIN
images/3x/home_icon_yuan.png


BIN
images/3x/icon_paihangbang_01.png


BIN
images/3x/icon_paihangbang_02.png


BIN
images/3x/icon_paihangbang_03.png


BIN
images/3x/img_kaishiyouxi.png


BIN
images/3x/ph_yinpai_no1.png


BIN
images/3x/ph_yinpai_no2.png


BIN
images/3x/ph_yinpai_no3.png


BIN
images/home_icon_yuan.png


BIN
images/icon_paihangbang_01.png


BIN
images/icon_paihangbang_02.png


BIN
images/icon_paihangbang_03.png


BIN
images/img_kaishiyouxi.png


BIN
images/ph_yinpai_no1.png


BIN
images/ph_yinpai_no2.png


BIN
images/ph_yinpai_no3.png


+ 2 - 1
lib/model/HouseInfo.dart

@@ -14,7 +14,7 @@ class HouseInfo {
       this.houseName,
       this.houseAbstract,
       this.video,
-      // this.gameInfo,
+      this.playerNumber,
       this.maxNumber,
       this.bonus,
       this.houseType,
@@ -30,6 +30,7 @@ class HouseInfo {
   String houseAbstract; //房间描述
   String video; //视频
   // GameInfo gameInfo; //游戏信息
+  int playerNumber;//加入人数
   int maxNumber; //最大加入人数
   int bonus; //奖金
   int houseType; //0为个人1为官方

+ 3 - 0
lib/model/HouseInfo.g.dart

@@ -16,6 +16,7 @@ HouseInfo _$HouseInfoFromJson(Map<String, dynamic> json) {
     json['houseAbstract'] as String,
     json['video'] as String,
     // GameInfo.fromJson(json['gameInfo'] as Map),
+    json['playerNumber']as int,
     json['maxNumber'] as int,
     json['bonus'] as int,
     json['houseType'] as int,
@@ -34,6 +35,7 @@ HouseInfo _$HouseInfoFromJson(Map<String, dynamic> json) {
 //   String houseAbstract; //房间描述
 //   String video; //视频
 //   GameInfo gameInfo; //游戏信息
+  // int playerNumber;//加入人数
 //   int maxNumber; //最大加入人数
 //   int bonus; //奖金
 //   int houseType; //0为个人1为官方
@@ -50,6 +52,7 @@ Map<String, dynamic> _$HouseInfoToJson(HouseInfo instance) => <String, dynamic>{
       'houseAbstract': instance.houseAbstract,
       'video': instance.video,
       // 'gameInfo': instance.gameInfo,
+      'playerNumber':instance.playerNumber,
       'maxNumber': instance.maxNumber,
       'bonus': instance.bonus,
       'houseType': instance.houseType,

+ 26 - 0
lib/model/PlayerInfo.dart

@@ -0,0 +1,26 @@
+import 'package:json_annotation/json_annotation.dart';
+import 'UserInfo.dart';
+
+part 'PlayerInfo.g.dart';
+
+@JsonSerializable()
+class PlayerInfo {
+  PlayerInfo(
+      this.id, this.houseId, this.userId, this.statusFlag, this.userInfo,this.bonus);
+  int id;
+  int houseId; //房间id
+  int userId; //用户id
+  int statusFlag; //状态 0加入 1准备 2开始 3结束 6未比赛
+  UserInfo userInfo;
+  int bonus;//奖金
+  factory PlayerInfo.fromJson(Map<String, dynamic> json) =>
+      _$PlayerInfoFromJson(json);
+
+  Map<String, dynamic> toJson() => _$PlayerInfoToJson(this);
+  // 命名构造函数
+  PlayerInfo.empty();
+  @override
+  String toString() {
+    return _$PlayerInfoToJson(this).toString();
+  }
+}

+ 33 - 0
lib/model/PlayerInfo.g.dart

@@ -0,0 +1,33 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'PlayerInfo.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+PlayerInfo _$PlayerInfoFromJson(Map<String, dynamic> json) {
+  return PlayerInfo(
+      json['id'] as int,
+      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);
+}
+
+//  int id;
+//   int houseId;//房间id
+//   int userId;//用户id
+//   int statusFlag;//状态 0加入 1准备 2开始 3结束 6未比赛
+//   UserInfo userInfo;
+Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
+    <String, dynamic>{
+      'id': instance.id,
+      'houseId': instance.houseId,
+      'userId': instance.userId,
+      'statusFlag': instance.statusFlag,
+      'userInfo': instance.userInfo != null ? instance.userInfo : Map(),
+      'bonus': instance.bonus
+    };

+ 27 - 0
lib/model/SystemNotice.dart

@@ -0,0 +1,27 @@
+import 'package:json_annotation/json_annotation.dart';
+
+part 'SystemNotice.g.dart';
+
+@JsonSerializable()
+class SystemNotice {
+  SystemNotice(this.id, this.gameId, this.houseId, this.userId,this.seasonId,this.content,this.icon,this.statusFlag,this.createTime);
+  int id;
+  int gameId;//游戏ID
+  int houseId;//房间ID
+  int userId;//用户ID
+  int seasonId;//赛季ID
+  String content;//内容
+  String icon;//图标
+  int statusFlag;//状态
+  int createTime;//创建时间
+  factory SystemNotice.fromJson(Map<String, dynamic> json) =>
+      _$SystemNoticeFromJson(json);
+
+  Map<String, dynamic> toJson() => _$SystemNoticeToJson(this);
+  // 命名构造函数
+  SystemNotice.empty();
+  @override
+  String toString() {
+    return _$SystemNoticeToJson(this).toString();
+  }
+}

+ 42 - 0
lib/model/SystemNotice.g.dart

@@ -0,0 +1,42 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'SystemNotice.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+SystemNotice _$SystemNoticeFromJson(Map<String, dynamic> json) {
+  return SystemNotice(
+      json['id'] as int,
+      json['gameId'] as int,
+      json['houseId'] as int,
+      json['userId'] as int,
+      json['seasonId'] as int,
+      json['content'] as String,
+      json['icon'] as String,
+      json['statusFlag'] as int,
+      json['createTime'] as int);
+}
+
+// int id;
+//   int gameId;//游戏ID
+//   int houseId;//房间ID
+//   int userId;//用户ID
+//   int seasonId;//赛季ID
+//   String content;//内容
+//   String icon;//图标
+//   int statusFlag;//状态
+//   int createTime;//创建时间
+Map<String, dynamic> _$SystemNoticeToJson(SystemNotice instance) =>
+    <String, dynamic>{
+      'id': instance.id,
+      'gameId': instance.gameId,
+      'houseId': instance.houseId,
+      'userId': instance.userId,
+      'seasonId': instance.seasonId,
+      'icon': instance.icon,
+      'content': instance.content,
+      'statusFlag': instance.statusFlag,
+      'createTime': instance.createTime,
+    };

+ 94 - 77
lib/pages/HomePage.dart

@@ -5,10 +5,12 @@ import './CreateRoom.dart';
 import 'RoomList.dart'; //房间列表
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_swiper/flutter_swiper.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
 import '../model/CompetitionSeason.dart';
 import '../styles/totast.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
+import 'TipList.dart';
 
 class HomePage extends StatefulWidget {
   @override
@@ -38,11 +40,14 @@ class _HomePageState extends State<HomePage> {
   @override
   void initState() {
     super.initState();
-    getSeasonInfo();
+    Future.delayed(const Duration(seconds: 1), () {
+      getSeasonInfo();
+    });
   }
 
   @override
   Widget build(BuildContext context) {
+    ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
     return Scaffold(
       drawer: HomeDrawer(),
       body: Container(
@@ -67,79 +72,83 @@ class _HomePageState extends State<HomePage> {
           child: Stack(
             children: <Widget>[
               Container(
-                
-                  child: Swiper(
-                index: nowIndex,
-                itemCount: seasonList.length,
-                scrollDirection: Axis.horizontal,
-                loop: true,
-                onTap: (index) {
-                  setState(() {
-                   nowIndex=index; 
-                  });
-                },
-                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',
-                                    ),
-                                  ),
-                                  Text(
-                                    "K",
-                                    style: TextStyle(
-                                      color: Colors.white,
-                                      fontSize: 36,
-                                      fontFamily: 'DINEngschrift',
-                                    ),
-                                  )
-                                ],
-                              ),
-                            ),
-                            Positioned(
-                              bottom: 30,
-                              left: 0,
-                              right: 0,
-                              child: Column(
-                                children: <Widget>[
-                                  // Text(
-                                  //   "当前排名",
-                                  //   style: TextStyle(
-                                  //       color: Colors.white, fontSize: 13),
-                                  // ),
-                                  // Text(
-                                  //   "98686",
-                                  //   style: TextStyle(
-                                  //       color: Colors.white, fontSize: 13),
-                                  // )
-                                ],
-                              ),
-                            )
-                          ],
-                        )),
-                  );
-                },
-              )),
+                  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) {
+                            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',
+                                              ),
+                                            ),
+                                            Text(
+                                              "K",
+                                              style: TextStyle(
+                                                color: Colors.white,
+                                                fontSize: 36,
+                                                fontFamily: 'DINEngschrift',
+                                              ),
+                                            )
+                                          ],
+                                        ),
+                                      ),
+                                      Positioned(
+                                        bottom: 30,
+                                        left: 0,
+                                        right: 0,
+                                        child: Column(
+                                          children: <Widget>[
+                                            // Text(
+                                            //   "当前排名",
+                                            //   style: TextStyle(
+                                            //       color: Colors.white, fontSize: 13),
+                                            // ),
+                                            // Text(
+                                            //   "98686",
+                                            //   style: TextStyle(
+                                            //       color: Colors.white, fontSize: 13),
+                                            // )
+                                          ],
+                                        ),
+                                      )
+                                    ],
+                                  )),
+                            );
+                          },
+                        )
+                      : Container()),
               Positioned(
                 left: 0,
                 top: 0,
@@ -190,11 +199,13 @@ class _HomePageState extends State<HomePage> {
                   crossAxisAlignment: CrossAxisAlignment.center,
                   children: <Widget>[
                     Text(
-                      seasonList[nowIndex].season,
+                      seasonList.length > 0 ? seasonList[nowIndex].season : '',
                       style: TextStyle(color: Colors.white, fontSize: 14),
                     ),
                     Text(
-                      seasonList[nowIndex].gameInfo.gameName,
+                      seasonList.length > 0
+                          ? seasonList[nowIndex].gameInfo.gameName
+                          : '',
                       style: TextStyle(color: Colors.white, fontSize: 14),
                     )
                   ],
@@ -249,7 +260,13 @@ class _HomePageState extends State<HomePage> {
               HomeMenu(
                 "images/home_icon_youjian.png",
                 "邮件",
-                onTapHomeMenu: () {},
+                onTapHomeMenu: () {
+                   Navigator.push(
+                      context,
+                      new CupertinoPageRoute(
+                          builder: (context) => new TipList()));
+                  
+                },
               ),
             ],
           ),

+ 136 - 0
lib/pages/StartWindow.dart

@@ -0,0 +1,136 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'OpenRoom.dart'; //创建房间
+
+class StartWindow extends StatefulWidget {
+  @override
+  StartWindowState createState() => StartWindowState();
+}
+
+class StartWindowState extends State<StartWindow> {
+  int _num = 10;
+  bool isNext = true;
+  getNum() async {
+    if (!isNext) {
+      Navigator.of(context).pop(true);
+      return;
+    }
+    await Future.delayed(const Duration(seconds: 1));
+    if (_num == 0) {
+      if (isNext) {
+        Navigator.pop(context);
+      }
+      return;
+    }
+    if (isNext) {
+      setState(() {
+        _num--;
+      });
+      getNum();
+    } else {
+      Navigator.of(context).pop(true);
+      return;
+    }
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    getNum();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
+    return GestureDetector(
+      // onTap: () {
+      //   Navigator.of(context).pop();
+      // },
+      child: WillPopScope(
+        child: Scaffold(
+          backgroundColor: Color(0xCC000000),
+          body: Container(
+            child: Center(
+                child: Container(
+              padding: EdgeInsets.only(top: 29, bottom: 21),
+              width: ScreenUtil().setWidth(272),
+              height: ScreenUtil().setWidth(319),
+              decoration: BoxDecoration(
+                  image: DecorationImage(
+                image: AssetImage('images/img_kaishiyouxi.png'),
+              )),
+              child: Column(
+                mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                children: <Widget>[
+                  Text('点击确认开始游戏',
+                      style: TextStyle(
+                          color: Color(0xFFFDC372),
+                          fontSize: 20,
+                          fontWeight: FontWeight.w600)),
+                  _centerContent(),
+                  RaisedButton(
+                    textTheme: ButtonTextTheme.primary,
+                    child: Text('确认'),
+                    onPressed: () {
+                      isNext = false;
+                    },
+                  )
+                ],
+              ),
+            )),
+          ),
+        ),
+        onWillPop: () {},
+      ),
+    );
+  }
+
+  Widget _centerContent() {
+    return Container(
+      width: ScreenUtil().setWidth(131),
+      height: ScreenUtil().setWidth(131),
+      decoration: BoxDecoration(
+        borderRadius: BorderRadius.all(Radius.circular(100)),
+        gradient: LinearGradient(
+          colors: [Color(0xFFC18C4A), Color(0xFFE2AD5C)],
+          begin: Alignment.topCenter,
+          end: Alignment.bottomCenter,
+        ),
+      ),
+      child: Center(
+        child: Container(
+          width: ScreenUtil().setWidth(80),
+          height: ScreenUtil().setWidth(80),
+          decoration: BoxDecoration(
+            borderRadius: BorderRadius.all(Radius.circular(100)),
+            color: Color(0xFFF5C271),
+          ),
+          child: Center(
+            child: Container(
+              width: ScreenUtil().setWidth(60),
+              height: ScreenUtil().setWidth(60),
+              decoration: BoxDecoration(
+                borderRadius: BorderRadius.all(Radius.circular(100)),
+                gradient: LinearGradient(
+                  colors: [Color(0xFFDF605C), Color(0xFFB34B48)],
+                  begin: Alignment.topLeft,
+                  end: Alignment.bottomRight,
+                ),
+              ),
+              child: Center(
+                child: Text(
+                  "$_num",
+                  style: TextStyle(
+                      color: Colors.white,
+                      fontSize: 32,
+                      fontWeight: FontWeight.w600),
+                ),
+              ),
+            ),
+          ),
+        ),
+      ),
+    );
+  }
+}

+ 52 - 0
lib/pages/TipList.dart

@@ -0,0 +1,52 @@
+import 'package:flutter/material.dart';
+import '../styles/colors.dart';
+import 'dart:ui';
+import '../styles/totast.dart';
+
+class TipList extends StatefulWidget {
+  @override
+  TipListState createState() => TipListState();
+}
+
+class TipListState extends State<TipList> {
+  
+  @override
+  Widget build(BuildContext context) {
+    return new WillPopScope(
+        child: Scaffold(
+            appBar: AppBar(
+              backgroundColor: PRIMARY_COLOR,
+              title: Text('通知列表'),
+              centerTitle: true,
+              elevation: 0,
+            ),
+            body: RefreshIndicator(
+              color: PRIMARY_COLOR,
+              backgroundColor: BG_COLOR,
+              onRefresh: () async {
+                await new Future.delayed(const Duration(seconds: 1));
+              },
+              child: Container(
+                color: BG_COLOR,
+                child: ListView.builder(
+                    itemCount: 3,
+                    itemBuilder: (BuildContext context, int index) {
+                      return TipItem();
+                    }),
+              ),
+            )),
+        onWillPop: () {
+          Toast.hide();
+          print("返回键点击了");
+          Navigator.pop(context);
+        });
+  }
+}
+
+class TipItem extends StatelessWidget{
+   @override
+  Widget build(BuildContext context) {
+
+  }
+}
+

+ 556 - 127
lib/pages/roomInfo.dart

@@ -13,6 +13,8 @@ import '../model/HouseInfo.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import '../styles/totast.dart';
+import 'StartWindow.dart';
+import '../model/PlayerInfo.dart';
 
 class RoomInfo extends StatefulWidget {
   RoomInfo({Key key, this.roomId}) : super(key: key);
@@ -25,29 +27,190 @@ class RoomInfo extends StatefulWidget {
 class RoomInfoState extends State<RoomInfo>
     with SingleTickerProviderStateMixin {
   List<Map> tabList;
-
   TabController mController;
-  ScrollController _perController;
   Map roomInfo;
   HouseInfo houseInfo;
   Map colorInfo;
-  List joinList = [];
   bool isJoin = true;
+  PlayerInfo playerInfo;
+
+//获取房间信息
+  void getRoomInfo() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res =
+        await HttpManager.get("houseInfo/getOne", data: {"id": widget.roomId});
+    Toast.hide();
+    if (res.success) {
+      setState(() {
+        roomInfo = res.data;
+        houseInfo = HouseInfo.fromJson(res.data);
+      });
+      if (houseInfo.statusFlag == 0) {
+        getNowStatus();
+      }
+    } else {}
+  }
+
+//隔一秒检查是否开始
+  getNowStatus() async {
+    await Future.delayed(const Duration(seconds: 1));
+    Result res = await HttpManager.get("houseInfo/getPlayerNum",
+        data: {"id": widget.roomId});
+    if (res.success) {
+      if (houseInfo.statusFlag == 0 && res.data["statusFlag"] == 2) {
+        showStart();
+      }
+      setState(() {
+        houseInfo.playerNumber = res.data["playerNumber"];
+        houseInfo.statusFlag = res.data["statusFlag"];
+        houseInfo.bonus = res.data["bonus"];
+      });
+    }
+    if (houseInfo.statusFlag == 0) {
+      getNowStatus();
+    }
+  }
+
+//开始比赛确认按钮
+  showStart() async {
+    final result = await 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 StartWindow();
+        }));
+
+    Toast.show(context, '加载中', -1, 'loading');
+    Map<String, dynamic> data = {"id": playerInfo.id};
+    if (result == null) {
+      data['statusFlag'] = 6;
+    } else {
+      data['statusFlag'] = 2;
+    }
+    Toast.hide();
+    Result res = await HttpManager.post("playerInfo/update", data: data);
+    if (res.success) {
+      if (data['statusFlag'] == 2) {
+        //加入比赛成功,开始录屏
+        Future.delayed(Duration(milliseconds: 100), () => showSucessInfo());
+      } else {
+        // showBackDialog();
+        Future.delayed(Duration(milliseconds: 100), () => showBackDialog());
+      }
+    }
+  }
+
+//开始录屏提示框
+  showSucessInfo() {
+    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: () {
+                HttpManager.post("playerInfo/update",
+                    data: {'id': playerInfo.id, 'statusFlag': 3});
+                Navigator.of(context).pop();
+              },
+            ),
+          ],
+        );
+      },
+    ).then((val) {
+      Navigator.of(context).pop();
+    });
+  }
+
+//未确认比赛弹窗
+  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) {
+      print(val);
+      Navigator.of(context).pop();
+    });
+  }
 
+//检查加入信息
   checkJoinInfo() async {
-    Result res = await HttpManager.get("playerInfo/check", data: {
+    Result res = await HttpManager.get("playerInfo/getOne", data: {
       "userId": StoreProvider.of<AppState>(context).state.userInfo.id,
       "houseId": widget.roomId
     });
-    print(res.error);
     if (res.success) {
-      setState(() {
-        isJoin = false;
-      });
-    } else if (res.error == '玩家已存在') {
+      print(res.data);
+      if (res.data == null) {
+        setState(() {
+          isJoin = false;
+        });
+      } else {
+        playerInfo = PlayerInfo.fromJson(res.data);
+        setState(() {
+          isJoin = true;
+        });
+      }
+    }
+    // if (res.success) {
+    //
+    // } else if (res.error == '玩家已存在') {
+    //   setState(() {
+    //     isJoin = true;
+    //   });
+    // }
+  }
+
+//加入房间
+  joinRoom() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.post("houseInfo/join", data: {
+      "houseId": widget.roomId,
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id
+    });
+    Toast.hide();
+    if (res.success) {
+      Toast.show(context, '加入成功', 1500, 'success');
       setState(() {
         isJoin = true;
       });
+    } else {
+      Toast.show(context, res.error, 1500, 'info');
     }
   }
 
@@ -69,10 +232,10 @@ class RoomInfoState extends State<RoomInfo>
       "白银": Color(0xFFAFCAD8),
       "青铜": Color(0xFFE18D50),
     };
-    _perController = ScrollController();
     getRoomInfo();
     Future.delayed(Duration(milliseconds: 100), () {
       checkJoinInfo();
+      // showBackDialog();
     });
   }
 
@@ -80,52 +243,64 @@ class RoomInfoState extends State<RoomInfo>
   void dispose() {
     super.dispose();
     mController.dispose();
-    _perController.dispose();
   }
 
   @override
   Widget build(BuildContext context) {
     ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
+    int status = 0;
+    if (houseInfo != null) {
+      status = houseInfo.statusFlag;
+    }
     // TODO: implement build
-    return new Scaffold(
-      appBar: AppBar(
-        backgroundColor: PRIMARY_COLOR,
-        title: Container(
-          child: TabBar(
-            controller: mController,
-            labelColor: Colors.white,
-            unselectedLabelColor: Colors.white.withOpacity(0.5),
-            labelStyle: TextStyle(fontSize: 16.0),
-            indicatorColor: Colors.white,
-            indicatorWeight: 3,
-            indicatorSize: TabBarIndicatorSize.label,
-            tabs: tabList.map((item) {
-              return Tab(
-                text: item['title'],
-              );
-            }).toList(),
+    return new WillPopScope(
+      child: Scaffold(
+        appBar: AppBar(
+          backgroundColor: PRIMARY_COLOR,
+          title: Container(
+            child: TabBar(
+              controller: mController,
+              labelColor: Colors.white,
+              unselectedLabelColor: Colors.white.withOpacity(0.5),
+              labelStyle: TextStyle(fontSize: 16.0),
+              indicatorColor: Colors.white,
+              indicatorWeight: 3,
+              indicatorSize: TabBarIndicatorSize.label,
+              tabs: tabList.map((item) {
+                return Tab(
+                  text: item['title'],
+                );
+              }).toList(),
+            ),
           ),
+          centerTitle: true,
+          elevation: 0,
+          actions: <Widget>[
+            Container(
+              padding: EdgeInsets.only(right: 30, left: 20),
+              child: Image.asset(
+                'images/icon_fenxiang.png',
+                width: 24,
+              ),
+            )
+          ],
         ),
-        centerTitle: true,
-        elevation: 0,
-        actions: <Widget>[
-          Container(
-            padding: EdgeInsets.only(right: 30, left: 20),
-            child: Image.asset(
-              'images/icon_fenxiang.png',
-              width: 24,
-            ),
-          )
-        ],
+        body: Container(
+            color: BG_SUB_COLOR,
+            child: TabBarView(
+              controller: mController,
+              children: [
+                _firstPage(),
+                SecondPage(roomId: widget.roomId, status: status)
+              ],
+            )),
+        floatingActionButton: _joinBtn(),
+        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
       ),
-      body: Container(
-          color: BG_SUB_COLOR,
-          child: TabBarView(
-            controller: mController,
-            children: [_firstPage(), _secondPage(context)],
-          )),
-      floatingActionButton: _joinBtn(),
-      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
+      onWillPop: () {
+        Toast.hide();
+        Navigator.of(context).pop();
+      },
     );
   }
 
@@ -141,6 +316,18 @@ class RoomInfoState extends State<RoomInfo>
             ? houseLevelInfo["feeRatio"] * roomInfo["bonus"]
             : 0;
 
+    String topImg =
+        'http://images.liqucn.com/img/h22/h70/img_localize_8e824debdd9ee29522690f36680e2d8e_600x337.png';
+    int statuFlag = 0;
+    if (houseInfo != null) {
+      if (houseInfo.video != null) {
+        topImg = houseInfo.video;
+      }
+      if (houseInfo.statusFlag != null) {
+        statuFlag = houseInfo.statusFlag;
+      }
+    }
+
     return Container(
       child: RefreshIndicator(
           color: PRIMARY_COLOR,
@@ -154,9 +341,7 @@ class RoomInfoState extends State<RoomInfo>
             child: Container(
               child: Column(
                 children: <Widget>[
-                  Image.network(
-                      'http://bpic.588ku.com/illus_pic/18/12/10/3678774e601145684677d48e17bb3486.jpg',
-                      width: double.infinity),
+                  Image.network(topImg, width: double.infinity),
                   Container(
                       padding: EdgeInsets.only(top: 10),
                       child: Row(
@@ -205,9 +390,13 @@ class RoomInfoState extends State<RoomInfo>
                         width: 20,
                       ),
                       Text(
-                        roomInfo['playerNumber'].toString() +
+                        (houseInfo != null
+                                ? houseInfo.playerNumber.toString()
+                                : '0') +
                             '/' +
-                            roomInfo['maxNumber'].toString(),
+                            (houseInfo != null
+                                ? houseInfo.maxNumber.toString()
+                                : '0'),
                         style: TextStyle(
                             fontSize: 14,
                             fontWeight: FontWeight.w500,
@@ -246,8 +435,8 @@ class RoomInfoState extends State<RoomInfo>
                         ),
                         Text(
                           'X' +
-                              (houseLevelInfo.containsKey('entryCoin')
-                                  ? houseLevelInfo['entryCoin'].toString()
+                              (houseInfo != null
+                                  ? houseInfo.bonus.toString()
                                   : '0'),
                           style: TextStyle(
                             color: PRIMARY_COLOR,
@@ -258,26 +447,30 @@ class RoomInfoState extends State<RoomInfo>
                       ],
                     ),
                   ),
-                  Container(
-                    width: double.infinity,
-                    margin: EdgeInsets.only(top: 25, left: 15, right: 15),
-                    padding: EdgeInsets.only(
-                        top: 15, left: 15, right: 10, bottom: 15),
-                    decoration: BoxDecoration(
-                        borderRadius: BorderRadius.only(
-                            topLeft: Radius.circular(0),
-                            topRight: Radius.circular(8),
-                            bottomLeft: Radius.circular(8),
-                            bottomRight: Radius.circular(8)),
-                        gradient: LinearGradient(
-                          begin: Alignment.topRight,
-                          colors: [Color(0xFF464B6A), Color(0xFF35395E)],
-                        )),
-                    child: Text(
-                      '加入房间后,请在此页面耐心等待,竞赛即将开始时,玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换',
-                      style: TextStyle(color: Colors.white, fontSize: 13),
-                    ),
-                  ),
+                  statuFlag != 4
+                      ? Container(
+                          width: double.infinity,
+                          margin: EdgeInsets.only(top: 25, left: 15, right: 15),
+                          padding: EdgeInsets.only(
+                              top: 15, left: 15, right: 10, bottom: 15),
+                          decoration: BoxDecoration(
+                              borderRadius: BorderRadius.only(
+                                  topLeft: Radius.circular(0),
+                                  topRight: Radius.circular(8),
+                                  bottomLeft: Radius.circular(8),
+                                  bottomRight: Radius.circular(8)),
+                              gradient: LinearGradient(
+                                begin: Alignment.topRight,
+                                colors: [Color(0xFF464B6A), Color(0xFF35395E)],
+                              )),
+                          child: Text(
+                            '加入房间后,请在此页面耐心等待,竞赛即将开始时,玩家有10秒的时间进行确认,点击确认方可正式进入竞赛,若没有点击,则视为自动放弃此次竞赛,已支付金币概不退换',
+                            style: TextStyle(color: Colors.white, fontSize: 13),
+                          ),
+                        )
+                      : RankContent(
+                          roomId: widget.roomId,
+                        ),
                   Container(
                     width: double.infinity,
                     height: 48 + ScreenUtil().setHeight(40),
@@ -290,12 +483,9 @@ class RoomInfoState extends State<RoomInfo>
   }
 
   Widget _joinBtn() {
-    Map houseLevelInfo = roomInfo.isNotEmpty ? roomInfo["houseLevelInfo"] : {};
-
-    int joinMoney = houseLevelInfo.containsKey('entryCoin')
-        ? houseLevelInfo['entryCoin']
-        : 0;
-    if (!isJoin) {
+    int joinMoney = houseInfo != null ? houseInfo.houseLevel.entryCoin : 0;
+    int statusFlag = houseInfo != null ? houseInfo.statusFlag : 1;
+    if (!isJoin && statusFlag == 0) {
       return Container(
         width: ScreenUtil().setWidth(375),
         height: 48 + ScreenUtil().setHeight(40),
@@ -305,39 +495,53 @@ class RoomInfoState extends State<RoomInfo>
             left: 15,
             right: 15),
         child: RaisedButton(
-          textColor: Colors.white,
-          child: Row(
-            mainAxisAlignment: MainAxisAlignment.center,
-            children: <Widget>[
-              Image.asset(
-                'images/icon_jinbi_da_bai.png',
-                width: 20,
-              ),
-              Container(
-                margin: EdgeInsets.only(left: 6),
-                child: Text(
-                  'X' + joinMoney.toString(),
-                  style: TextStyle(
-                      color: Colors.white,
-                      fontSize: 16,
-                      fontWeight: FontWeight.w500),
+            textColor: Colors.white,
+            child: Row(
+              mainAxisAlignment: MainAxisAlignment.center,
+              children: <Widget>[
+                Image.asset(
+                  'images/icon_jinbi_da_bai.png',
+                  width: 20,
                 ),
-              ),
-              Container(
-                  margin: EdgeInsets.only(left: 20),
+                Container(
+                  margin: EdgeInsets.only(left: 6),
                   child: Text(
-                    '加入房间',
+                    'X' + joinMoney.toString(),
                     style: TextStyle(
                         color: Colors.white,
                         fontSize: 16,
                         fontWeight: FontWeight.w500),
-                  ))
-            ],
+                  ),
+                ),
+                Container(
+                    margin: EdgeInsets.only(left: 20),
+                    child: Text(
+                      '加入房间',
+                      style: TextStyle(
+                          color: Colors.white,
+                          fontSize: 16,
+                          fontWeight: FontWeight.w500),
+                    ))
+              ],
+            ),
+            onPressed: () => joinRoom()),
+      );
+    } else if (isJoin && statusFlag == 0) {
+      return Container(
+        width: double.infinity,
+        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+        height: 88,
+        child: RaisedButton(
+          disabledColor: Color(0xFF914244),
+          disabledTextColor: Color(0xFF252532),
+          child: Text(
+            '等待开始中',
+            style: TextStyle(fontSize: 16),
           ),
-          onPressed: () => {},
+          onPressed: null,
         ),
       );
-    } else if (roomInfo['statusFlag'] == 0) {
+    } else if (isJoin && statusFlag == 3) {
       return Container(
         width: double.infinity,
         padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
@@ -346,7 +550,22 @@ class RoomInfoState extends State<RoomInfo>
           disabledColor: Color(0xFF914244),
           disabledTextColor: Color(0xFF252532),
           child: Text(
-            '等待开始中',
+            '正在结算中',
+            style: TextStyle(fontSize: 16),
+          ),
+          onPressed: null,
+        ),
+      );
+    } else if (isJoin && statusFlag == 4) {
+      return Container(
+        width: double.infinity,
+        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
+        height: 88,
+        child: RaisedButton(
+          disabledColor: Color(0xFF727785),
+          disabledTextColor: Color(0xFF15151D),
+          child: Text(
+            '已结束',
             style: TextStyle(fontSize: 16),
           ),
           onPressed: null,
@@ -356,26 +575,243 @@ class RoomInfoState extends State<RoomInfo>
       return Container();
     }
   }
+}
+
+class RankContent extends StatefulWidget {
+  RankContent({Key key, this.roomId}) : super(key: key);
+  final String roomId; // 用来储存传递过来的值
+  @override
+  RankContentState createState() => RankContentState();
+}
+
+class RankContentState extends State<RankContent> {
+  List<PlayerInfo> topList = [];
+  getTopList() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.get("playerInfo/rankPage",
+        data: {"houseId": widget.roomId, "currentPage": 1, "pageNumber": 3});
+    Toast.hide();
+    List<PlayerInfo> list = [];
+    if (res.success) {
+      for (var item in res.data['pp']) {
+        PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
+        list.add(jonPlayer);
+      }
+    } else {}
+    setState(() {
+      topList = list;
+    });
+  }
+
+  @override
+  void initState() {
+    // TODO: implement initState
+    super.initState();
+    getTopList();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      width: double.infinity,
+      height: 180,
+      margin: EdgeInsets.only(top: 15),
+      child: Row(
+        mainAxisAlignment: MainAxisAlignment.center,
+        crossAxisAlignment: CrossAxisAlignment.end,
+        children: <Widget>[_rankItem(2), _rankItem(1), _rankItem(3)],
+      ),
+    );
+  }
+
+  Widget _rankItem(int _num) {
+    if (_num > topList.length) {
+      return Container();
+    }
+    List colorList = [
+      [Color(0xFFD48E00), Color(0xFFFECF01)],
+      [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
+      [Color(0xFFE77023), Color(0xFFF89E58)]
+    ];
+    return Container(
+      padding: EdgeInsets.only(left: 15, right: 15, top: _num == 1 ? 0 : 15),
+      width: 107,
+      child: Column(
+        crossAxisAlignment: CrossAxisAlignment.center,
+        children: <Widget>[
+          Container(
+            child: Stack(
+              children: <Widget>[
+                Positioned(
+                  top: 0,
+                  left: _num == 1 ? 19 : 14,
+                  child: Center(
+                    child: Image.asset(
+                      'images/icon_paihangbang_0' + '$_num.png',
+                      width: 32,
+                    ),
+                  ),
+                ),
+                Container(
+                  margin: EdgeInsets.only(top: 27, bottom: 20),
+                  width: _num == 1 ? 70 : 60,
+                  height: _num == 1 ? 70 : 60,
+                  decoration: BoxDecoration(
+                    gradient: LinearGradient(
+                        colors: colorList[_num - 1],
+                        begin: Alignment.topLeft,
+                        end: Alignment.bottomRight),
+                    borderRadius: BorderRadius.all(Radius.circular(100)),
+                  ),
+                  child: Center(
+                      child: Container(
+                    width: _num == 1 ? 60 : 50,
+                    height: _num == 1 ? 60 : 50,
+                    child: CircleAvatar(
+                        backgroundImage:
+                            NetworkImage(topList[_num - 1].userInfo.icon)),
+                  )),
+                ),
+                Positioned(
+                  bottom: 0,
+                  child: Center(
+                    child: Image.asset(
+                      'images/ph_yinpai_no' + '$_num.png',
+                      width: 67,
+                    ),
+                  ),
+                ),
+              ],
+            ),
+          ),
+          Text(
+            topList[_num - 1].userInfo.nickname,
+            style: TextStyle(
+              color: Color(0xFFFDC372),
+              fontSize: 12,
+            ),
+            overflow: TextOverflow.ellipsis,
+            textAlign: TextAlign.center,
+          ),
+          SizedBox(
+            height: 5,
+          ),
+          Row(
+            mainAxisAlignment: MainAxisAlignment.center,
+            children: <Widget>[
+              Image.asset('images/icon_jinbi_xiao_hong.png', width: 20),
+              Text('x' + (topList[_num - 1].bonus!=null?topList[_num - 1].bonus.toString():'0'),
+                  style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
+            ],
+          )
+        ],
+      ),
+    );
+  }
+}
+
+class SecondPage extends StatefulWidget {
+  SecondPage({Key key, this.roomId, this.status}) : super(key: key);
+  final String roomId; // 用来储存传递过来的值
+  final int status;
+  @override
+  SecondPageState createState() => SecondPageState();
+}
+
+class SecondPageState extends State<SecondPage> {
+  List<PlayerInfo> joinList = [];
+  int currentPage = 1;
+  bool ismore = true;
+  ScrollController _perController;
+
+  //获取房间用户
+  getPlayerPage() async {
+    ismore = false;
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.get("playerInfo/rankPage", data: {
+      "houseId": widget.roomId,
+      "currentPage": currentPage,
+      "pageNumber": 20
+    });
+    Toast.hide();
+    List<PlayerInfo> list = joinList;
+    if (currentPage == 1) {
+      list = [];
+    }
+    if (res.success) {
+      print(res.data['pp']);
+      for (var item in res.data['pp']) {
+        PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
+        list.add(jonPlayer);
+      }
+      if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
+        ismore = true;
+      }
+    } else {}
+    setState(() {
+      joinList = list;
+    });
+    print(joinList);
+  }
+
+  @override
+  void initState() {
+    // TODO: implement initState
+    super.initState();
+    _perController = ScrollController();
+    currentPage = 1;
+    getPlayerPage();
+    _perController.addListener(() {
+      if (_perController.position.pixels ==
+          _perController.position.maxScrollExtent) {
+        if (ismore) {
+          currentPage++;
+          getPlayerPage();
+        }
+      }
+    });
+  }
 
-  Widget _secondPage(BuildContext context) {
+  @override
+  void dispose() {
+    // TODO: implement dispose
+    super.dispose();
+    _perController.dispose();
+  }
+
+  @override
+  Widget build(BuildContext context) {
     return RefreshIndicator(
       color: PRIMARY_COLOR,
       backgroundColor: BG_SUB_COLOR,
       displacement: 10,
       onRefresh: () async {
         await new Future.delayed(const Duration(seconds: 1));
+        currentPage = 1;
+        getPlayerPage();
       },
       child: ListView.builder(
           physics: AlwaysScrollableScrollPhysics(),
           controller: _perController,
-          itemCount: 3,
+          itemCount: joinList.length + 1,
           itemBuilder: (BuildContext context, int index) {
-            return person_item({}, index);
+            if (index < joinList.length) {
+              return person_item(joinList[index], index);
+            } else {
+              return Container(
+                padding: EdgeInsets.all(15),
+                child: Text(
+                  '其他人员正在火速赶来中...',
+                  style: TextStyle(color: Colors.white30),
+                  textAlign: TextAlign.center,
+                ),
+              );
+            }
           }),
     );
   }
 
-  Widget person_item(Map info, int index) {
+  Widget person_item(PlayerInfo info, int index) {
     return Container(
       width: double.infinity,
       height: 60,
@@ -395,13 +831,13 @@ class RoomInfoState extends State<RoomInfo>
               height: 36,
               child: CircleAvatar(
                 backgroundImage: NetworkImage(
-                    'http://bpic.588ku.com/original_pic/19/01/10/c21f0c83a0029a820d47e4828559353f.jpg'),
+                    info.userInfo != null ? info.userInfo.icon : ''),
               ),
             ),
             Expanded(
               flex: 1,
               child: Text(
-                '邱好好',
+                info.userInfo != null ? info.userInfo.nickname : '',
                 style: TextStyle(
                   color: Colors.white,
                   fontSize: 14,
@@ -409,25 +845,18 @@ class RoomInfoState extends State<RoomInfo>
                 maxLines: 1,
                 overflow: TextOverflow.ellipsis,
               ),
-            )
+            ),
+            widget.status == 4 && index < 3
+                ? Image.asset(
+                    'images/icon_paihangbang_0' +
+                        (index + 1).toString() +
+                        '.png',
+                    width: 32,
+                  )
+                : Container()
           ],
         ),
       ),
     );
   }
-
-  void getRoomInfo() async {
-    Toast.show(context, '加载中', -1, 'loading');
-    Result res =
-        await HttpManager.get("houseInfo/getOne", data: {"id": widget.roomId});
-    Toast.hide();
-    if (res.success) {
-      print(res.data);
-      setState(() {
-        roomInfo = res.data;
-        houseInfo=HouseInfo.fromJson(res.data);
-      });
-       print(houseInfo);
-    } else {}
-  }
 }

+ 3 - 3
lib/pages/roomList.dart

@@ -41,10 +41,10 @@ class RoomListState extends State<RoomList> {
   List statusList = [
     {"name": '不限状态', "val": ''},
     {"name": '等待中', "val": '0'},
-    {"name": '准备中', "val": '1'},
+    // {"name": '准备中', "val": '1'},
     {"name": '已经开始', "val": '2'},
-    {"name": '已经结束', "val": '3'},
-    {"name": '正在结算', "val": '4'}
+    {"name": '正在结算', "val": '3'},
+    {"name": '结算完成', "val": '4'}
   ];
 
   @override