panhui 6 лет назад
Родитель
Сommit
09d50e8aa9

+ 2 - 1
lib/model/HouseInfo.dart

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

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

@@ -15,12 +15,14 @@ HouseInfo _$HouseInfoFromJson(Map<String, dynamic> json) {
     json['houseName'] as String,
     json['houseAbstract'] as String,
     json['video'] as String,
-    // GameInfo.fromJson(json['gameInfo'] as Map),
+    json['gameInfo'] != null ? GameInfo.fromJson(json['gameInfo']) : null,
     json['playerNumber'] as int,
     json['maxNumber'] as int,
     json['bonus'] as int,
     json['houseType'] as int,
-    HouseLevel.fromJson(json['houseLevelInfo'] as Map),
+    json['houseLevelInfo'] != null
+        ? HouseLevel.fromJson(json['houseLevelInfo'])
+        : null,
     json['gameHouseId'] as String,
     json['gameHousePassword'] as String,
     json['statusFlag'] as int,
@@ -51,7 +53,7 @@ Map<String, dynamic> _$HouseInfoToJson(HouseInfo instance) => <String, dynamic>{
       'houseName': instance.houseName,
       'houseAbstract': instance.houseAbstract,
       'video': instance.video,
-      // 'gameInfo': instance.gameInfo,
+      'gameInfo': instance.gameInfo,
       'playerNumber': instance.playerNumber,
       'maxNumber': instance.maxNumber,
       'bonus': instance.bonus,

+ 3 - 2
lib/model/SystemNotice.dart

@@ -1,12 +1,12 @@
 import 'package:json_annotation/json_annotation.dart';
 import 'GameInfo.dart';
 import 'HouseInfo.dart';
-
+import 'PlayerInfo.dart';
 part 'SystemNotice.g.dart';
 
 @JsonSerializable()
 class SystemNotice {
-  SystemNotice(this.id, this.gameId, this.houseId, this.userId,this.seasonId,this.content,this.icon,this.typeFlag,this.statusFlag,this.createTime,this.playerId,this.gameInfo,this.houseInfo);
+  SystemNotice(this.id, this.gameId, this.houseId, this.userId,this.seasonId,this.content,this.icon,this.typeFlag,this.statusFlag,this.createTime,this.playerId,this.gameInfo,this.houseInfo,this.playerInfo);
   int id;
   int gameId;//游戏ID
   int houseId;//房间ID
@@ -20,6 +20,7 @@ class SystemNotice {
   int playerId;//玩家id
   GameInfo gameInfo;//游戏信息
   HouseInfo houseInfo;//房间信息
+  PlayerInfo playerInfo;//玩家信息
 
   factory SystemNotice.fromJson(Map<String, dynamic> json) =>
       _$SystemNoticeFromJson(json);

+ 3 - 1
lib/model/SystemNotice.g.dart

@@ -20,7 +20,8 @@ SystemNotice _$SystemNoticeFromJson(Map<String, dynamic> json) {
       json['createTime'] as int,
       json['playerId'] as int,
       json['gameInfo'] != null ? GameInfo.fromJson(json['gameInfo']) : null,
-      json['houseInfo'] != null ? HouseInfo.fromJson(json['houseInfo']) : null);
+      json['houseInfo'] != null ? HouseInfo.fromJson(json['houseInfo']) : null,
+      json['playerInfo']!=null?PlayerInfo.fromJson(json['playerInfo']):null);
 }
 
 // int id;
@@ -50,4 +51,5 @@ Map<String, dynamic> _$SystemNoticeToJson(SystemNotice instance) =>
       'playerId': instance.playerId != null ? instance.playerId : 0,
       'gameInfo': instance.gameInfo != null ? instance.gameInfo : Map(),
       'HouseInfo': instance.houseInfo != null ? instance.houseInfo : Map(),
+      'playerInfo':instance.playerInfo
     };

+ 68 - 17
lib/pages/TipInfo.dart

@@ -9,6 +9,7 @@ import '../net/Result.dart';
 import '../model/HouseInfo.dart';
 import '../model/GameInfo.dart';
 import '../pages/RoomInfo.dart';
+import '../widget/SuccessfulReception.dart';
 
 class TipInfo extends StatefulWidget {
   TipInfo({Key key, this.tipId}) : super(key: key);
@@ -18,11 +19,13 @@ class TipInfo extends StatefulWidget {
 }
 
 class TipInfoState extends State<TipInfo> {
-  SystemNotice tipInfo = SystemNotice.fromJson({'content': '', "createTime": DateTime.now().microsecondsSinceEpoch});
+  SystemNotice tipInfo = SystemNotice.fromJson(
+      {'content': '', "createTime": DateTime.now().microsecondsSinceEpoch});
   HouseInfo houseInfo;
   getInfo() async {
     Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.get("systemNotice/getOne", data: {'id': widget.tipId});
+    Result res = await HttpManager.get("systemNotice/getOne",
+        data: {'id': widget.tipId});
     Toast.hide();
     if (res.success) {
       setState(() {
@@ -31,10 +34,12 @@ class TipInfoState extends State<TipInfo> {
     }
 
     if (tipInfo.statusFlag == 0 && tipInfo.typeFlag != 2) {
-      HttpManager.post("systemNotice/update", data: {'id': tipInfo.id, "statusFlag": 1});
+      HttpManager.post("systemNotice/update",
+          data: {'id': tipInfo.id, "statusFlag": 1});
     }
 
-    Result res2 = await HttpManager.get("houseInfo/getOne", data: {'id': tipInfo.houseId});
+    Result res2 = await HttpManager.get("houseInfo/getOne",
+        data: {'id': tipInfo.houseId});
     if (res2.success) {
       setState(() {
         houseInfo = HouseInfo.fromJson(res2.data);
@@ -42,7 +47,24 @@ class TipInfoState extends State<TipInfo> {
     }
   }
 
-  void updateHousInfo() {}
+  void showSuccess(money) {
+    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 SuccessfulReception(money: money);
+        },
+      ),
+    );
+  }
 
   @override
   void initState() {
@@ -79,7 +101,11 @@ class TipInfoState extends State<TipInfo> {
                     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)),
+                        child: Text(
+                            readTimestamp(
+                                tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
+                            style:
+                                TextStyle(color: Colors.white24, fontSize: 13)),
                       ),
                       Container(
                         height: 1,
@@ -95,7 +121,9 @@ class TipInfoState extends State<TipInfo> {
                     ],
                   ),
                 ),
-                houseInfo != null ? houseItem(roomInfo: houseInfo, gameInfo: gameInfo) : Container(),
+                houseInfo != null
+                    ? houseItem(roomInfo: houseInfo, gameInfo: gameInfo)
+                    : Container(),
                 type == 2 && status == 0
                     ? Container(
                         width: double.infinity,
@@ -106,11 +134,15 @@ class TipInfoState extends State<TipInfo> {
                           child: Text('立即领取'),
                           onPressed: () async {
                             Toast.show(context, '加载中', -1, 'loading');
-                            Result res = await HttpManager.post("playerInfo/receive", data: {"id": tipInfo.playerId});
+                            Result res = await HttpManager.post(
+                                "playerInfo/receive",
+                                data: {"id": tipInfo.playerId});
                             Toast.hide();
                             if (res.success) {
-                              Toast.show(context, '领取成功', 1000, 'success');
-                              Future.delayed(Duration(milliseconds: 1000), () => getInfo());
+                              if (tipInfo.playerInfo != null) {
+                                showSuccess(tipInfo.playerInfo.bonus);
+                                getInfo();
+                              }
                             } else {
                               Toast.show(context, res.error, 1000, 'info');
                             }
@@ -171,26 +203,34 @@ class houseItem extends StatelessWidget {
                             maxWidth: 170,
                             child: Text(
                               roomInfo.houseName,
-                              style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
+                              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),
+                            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),
+                                style: TextStyle(
+                                    color: Color(0xFFF9D881), fontSize: 9),
                               )),
                         ],
                       ),
                       Text(
                         roomInfo.houseAbstract,
-                        style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400, color: Color(0xFF9BA0AE)),
+                        style: TextStyle(
+                            fontSize: 12,
+                            fontWeight: FontWeight.w400,
+                            color: Color(0xFF9BA0AE)),
                         maxLines: 2,
                         overflow: TextOverflow.ellipsis,
                       )
@@ -202,8 +242,15 @@ class houseItem extends StatelessWidget {
                   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)),
+                      (roomInfo.playerNumber != null
+                              ? roomInfo.playerNumber.toString()
+                              : '0') +
+                          '/' +
+                          roomInfo.maxNumber.toString(),
+                      style: TextStyle(
+                          fontSize: 14,
+                          fontWeight: FontWeight.w500,
+                          color: Color(0xFFB1B2C0)),
                     )
                   ],
                 )
@@ -211,7 +258,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())));
           },
         ),
       ),

+ 24 - 18
lib/pages/roomList.dart

@@ -6,6 +6,8 @@ import '../widget/popupButton_my.dart';
 import 'dart:ui';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
+import '../model/HouseInfo.dart';
+import '../model/GameInfo.dart';
 
 class RoomList extends StatefulWidget {
   @override
@@ -13,7 +15,7 @@ class RoomList extends StatefulWidget {
 }
 
 class RoomListState extends State<RoomList> {
-  List roomList = [];
+  List<HouseInfo> roomList = [];
   int currentPage = 1;
   ScrollController _controller;
   bool scrollFlag = true;
@@ -123,10 +125,10 @@ class RoomListState extends State<RoomList> {
                     SliverFixedExtentList(
                       itemExtent: ScreenUtil().setWidth(78),
                       delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
-                        return RommItem(
+                        print(roomList[index].gameInfo);
+                        return HouseItem(
                           roomInfo: roomList[index],
-                          hasBorder: true,
-                          isRage: false,
+                          gameInfo:roomList[index].gameInfo
                         );
                       }, childCount: roomList.length),
                     )
@@ -363,12 +365,7 @@ class RoomListState extends State<RoomList> {
   }
 
   void getRoomInfo() async {
-    if (currentPage == 1) {
-      setState(() {
-        roomList = [];
-      });
-    }
-
+   
     Map<String, dynamic> data = {
       "currentPage": currentPage,
       "pageNumber": 20,
@@ -388,17 +385,26 @@ class RoomListState extends State<RoomList> {
     } else {
       data['statusStr'] = '0,4';
     }
+    List<HouseInfo> _allList=roomList;
+    if(currentPage==1){
+      _allList=[];
+    }
     Result res = await HttpManager.get("houseInfo/page", data: data);
     if (res.success && res.data['pp'] != null) {
-      setState(() {
-        roomList.addAll(res.data['pp']);
-      });
-      if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
-        scrollFlag = true;
-      } else {
-        scrollFlag = false;
+      for (var item in res.data['pp']) {
+        HouseInfo _temHouse=HouseInfo.fromJson(item);
+        _allList.add(_temHouse);
       }
-    } else {}
+      if (res.data['page']['currentPage'] < res.data['page']['totalPage']) {
+          scrollFlag = true;
+        } else {
+          scrollFlag = false;
+        }
+      } else {}
+
+    setState(() {
+     roomList=_allList; 
+    });
 
     // final response = await Dio().get(domain + 'houseInfo/page', data: data);
     // final res = json.decode(response.toString());

+ 65 - 0
lib/widget/SuccessfulReception.dart

@@ -0,0 +1,65 @@
+import 'package:flutter/material.dart';
+import 'dart:async';
+
+class SuccessfulReception extends StatefulWidget {
+  SuccessfulReception({Key key, this.money}) : super(key: key);
+  final int money;
+  @override
+  SuccessfulReceptionState createState() => SuccessfulReceptionState();
+}
+
+class SuccessfulReceptionState extends State<SuccessfulReception> {
+  @override
+  void initState() {
+    super.initState();
+    // Timer(Duration(seconds: 2), (){
+    //   Navigator.of(context).pop();
+    // });
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return GestureDetector(
+      onTap: () {
+        Navigator.of(context).pop();
+      },
+      child: Scaffold(
+        backgroundColor: Color(0xCC000000),
+        body: Container(
+          child: Center(
+              child: Container(
+                  padding: EdgeInsets.only(top: 29, bottom: 49),
+                  width: 212,
+                  height: 220,
+                  decoration: BoxDecoration(
+                      image: DecorationImage(
+                          image: AssetImage('images/img_kaishiyouxi.png'),
+                          fit: BoxFit.fill)),
+                  child: Column(
+                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
+                    crossAxisAlignment: CrossAxisAlignment.center,
+                    children: <Widget>[
+                      Text('领取成功',
+                          style: TextStyle(
+                              color: Color(0xFFC2524D),
+                              fontSize: 20,
+                              fontWeight: FontWeight.w600)),
+                      Row(
+                        mainAxisAlignment: MainAxisAlignment.center,
+                        children: <Widget>[
+                          Image.asset('images/icon_jinbi_xiao_hong.png',
+                              width: 39),
+                          Text(' X ' + widget.money.toString(),
+                              style: TextStyle(
+                                  color: Color(0xFFC2524D),
+                                  fontSize: 32,
+                                  fontWeight: FontWeight.w900))
+                        ],
+                      )
+                    ],
+                  ))),
+        ),
+      ),
+    );
+  }
+}

+ 101 - 123
lib/widget/room_item.dart

@@ -1,140 +1,118 @@
 import 'package:flutter/material.dart';
-import 'package:flutter_screenutil/flutter_screenutil.dart';
+import '../styles/colors.dart';
 import 'package:flutter/cupertino.dart';
+import 'dart:ui';
+import '../model/HouseInfo.dart';
+import '../model/GameInfo.dart';
 import '../pages/RoomInfo.dart';
-
-class RommItem extends StatelessWidget {
-  RommItem({this.roomInfo, this.hasBorder, this.isRage});
-  final Map roomInfo;
-  bool hasBorder = true;
-  bool isRage = false;
-
-
-
+class HouseItem extends StatelessWidget {
+  HouseItem({Key key, this.roomInfo, this.gameInfo}) : super(key: key);
+  final HouseInfo roomInfo;
+  final GameInfo gameInfo;
+  @override
   @override
   Widget build(BuildContext context) {
-    ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
-    Map houseLevelInfo =
-        roomInfo["houseLevelInfo"].isNotEmpty ? roomInfo["houseLevelInfo"] : {};
-
-        Map useRoomInfo=roomInfo.isNotEmpty?roomInfo:{};
-
-        Map gameInfo=roomInfo.containsKey('gameInfo')?roomInfo['gameInfo']:{};
-
-    Map imageInfo = {
-      "黄金": Image.asset('images/dengji_icon_huangjin.png',
-          width: ScreenUtil().setWidth(14)),
-      "白银": Image.asset('images/dengji_icon_baiyin.png',
-          width: ScreenUtil().setWidth(14)),
-      "青铜": Image.asset('images/dengji_icon_qingtong.png',
-          width: ScreenUtil().setWidth(14))
-    };
-
-    Map colorInfo = {
-      "黄金": Color(0xFFF9D881),
-      "白银": Color(0xFFAFCAD8),
-      "青铜": Color(0xFFE18D50),
-    };
-
-   
-
-      DecorationImage myIcon=DecorationImage(
-                    image: NetworkImage( gameInfo.containsKey('icon')?gameInfo["icon"]:''),
-                    fit: BoxFit.cover);
-
-    return FlatButton(
-      color: Color(0xFF464B6A),
-      highlightColor: Color(0xFF35395E),
-      textColor: Colors.white,
-      padding: EdgeInsets.all(0),
-      child: Container(
-        padding: EdgeInsets.all(ScreenUtil().setWidth(15)),
-        height: ScreenUtil().setWidth(78),
-        decoration: BoxDecoration(
-            gradient: LinearGradient(
-          begin: Alignment
-          
-          .bottomRight,
-          colors: [Color(0xFF35395E), Color(0xFF464B6A).withOpacity(0)],
-        )),
-        child: Row(
-          children: <Widget>[
-            Container(
-              width: ScreenUtil().setWidth(48),
-              decoration: BoxDecoration(
-                borderRadius: BorderRadius.all(Radius.circular(2)),
-                image:myIcon,
-              ),
-            ),
-            Expanded(
-              flex: 1,
-              child: Container(
-                margin: EdgeInsets.only(left: 10, right: 10),
-                child: Column(
-                  crossAxisAlignment: CrossAxisAlignment.start,
-                  children: <Widget>[
-                    Row(
-                      children: <Widget>[
-                        LimitedBox(
-                          maxWidth: ScreenUtil().setWidth(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: imageInfo[houseLevelInfo['levelName']],
-                        ),
-                        Container(
-                            margin: EdgeInsets.only(left: 1),
+    // 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(
-                              houseLevelInfo['levelName'],
+                              roomInfo.houseName,
                               style: TextStyle(
-                                  color: colorInfo[houseLevelInfo['levelName']],
-                                  fontSize: 9),
-                            )),
-                      ],
-                    ),
+                                  color: Colors.white,
+                                  fontSize: 14,
+                                  fontWeight: FontWeight.w500),
+                              maxLines: 1,
+                              overflow: TextOverflow.ellipsis,
+                            ),
+                          ),
+                          roomInfo.houseLevel.icon!=null?Container(
+                            margin: EdgeInsets.only(left: 6),
+                            child: Image.network(roomInfo.houseLevel.icon,
+                                width: 14),
+                          ):null,
+                          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['houseAbstract'],
+                      (roomInfo.playerNumber != null
+                              ? roomInfo.playerNumber.toString()
+                              : '0') +
+                          '/' +
+                          roomInfo.maxNumber.toString(),
                       style: TextStyle(
-                          fontSize: 12,
-                          fontWeight: FontWeight.w400,
-                          color: Color(0xFF9BA0AE)),
-                          maxLines:2,
-                          overflow:TextOverflow.ellipsis,
+                          fontSize: 14,
+                          fontWeight: FontWeight.w500,
+                          color: Color(0xFFB1B2C0)),
                     )
                   ],
-                ),
-              ),
-            ),
-            Row(
-              mainAxisAlignment: MainAxisAlignment.center,
-              children: <Widget>[
-                Image.asset('images/icon_renshu.png', width: 20),
-                Text((roomInfo.containsKey('playerNumber')?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())));
+          },
         ),
       ),
-      onPressed: () {
-         Navigator.push(context,
-                  new CupertinoPageRoute(builder: (context) => new RoomInfo(
-                    roomId:roomInfo['id'].toString()
-                  )));
-      },
     );
   }
 }