Browse Source

houseInfo

panhui 6 năm trước cách đây
mục cha
commit
a0a0674a18

+ 24 - 0
lib/model/BindGameInfo.dart

@@ -0,0 +1,24 @@
+import 'package:json_annotation/json_annotation.dart';
+import 'GameInfo.dart';
+
+part 'BindGameInfo.g.dart';
+
+@JsonSerializable()
+class BindGameInfo {
+  BindGameInfo(this.id, this.gameId, this.userId, this.nickName,this.gameInfo);
+  int id;
+  int gameId;//游戏ID
+  int userId;//用户ID
+  String nickName;//用户昵称
+  GameInfo gameInfo;//游戏信息
+  factory BindGameInfo.fromJson(Map<String, dynamic> json) =>
+      _$BindGameInfoFromJson(json);
+
+  Map<String, dynamic> toJson() => _$BindGameInfoToJson(this);
+  // 命名构造函数
+  BindGameInfo.empty();
+  @override
+  String toString() {
+    return _$BindGameInfoToJson(this).toString();
+  }
+}

+ 30 - 0
lib/model/BindGameInfo.g.dart

@@ -0,0 +1,30 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'BindGameInfo.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+BindGameInfo _$BindGameInfoFromJson(Map<String, dynamic> json) {
+  return BindGameInfo(
+      json['id'] as int,
+      json['gameId'] as int,
+      json['userId'] as int,
+      json['nickName'] as String,
+      GameInfo.fromJson(json['gameInfo'] as Map));
+}
+
+// int id;
+// int gameId;//游戏ID
+// int userId;//用户ID
+// String nickName;//用户昵称
+//  GameInfo gameInfo;//游戏信息
+Map<String, dynamic> _$BindGameInfoToJson(BindGameInfo instance) =>
+    <String, dynamic>{
+      'id': instance.id,
+      'gameId': instance.gameId,
+      'userId': instance.userId,
+      'nickName': instance.nickName,
+      'gameInfo': instance.gameInfo
+    };

+ 4 - 4
lib/model/GameInfo.g.dart

@@ -14,10 +14,10 @@ GameInfo _$GameInfoFromJson(Map<String, dynamic> json) {
       json['typeFlag'] as int);
 }
 
- int id;
-  String gameName;//名称
-  String icon;//图标
-  int typeFlag;//类型
+//  int id;
+//   String gameName;//名称
+//   String icon;//图标
+//   int typeFlag;//类型
 Map<String, dynamic> _$GameInfoToJson(GameInfo instance) =>
     <String, dynamic>{
       'id': instance.id,

+ 50 - 0
lib/model/HouseInfo.dart

@@ -0,0 +1,50 @@
+import 'package:json_annotation/json_annotation.dart';
+import 'GameInfo.dart';
+import 'HouseLevel.dart';
+
+part 'HouseInfo.g.dart';
+
+@JsonSerializable()
+class HouseInfo {
+  HouseInfo(
+      this.id,
+      this.gameId,
+      this.userId,
+      this.seasonId,
+      this.houseName,
+      this.houseAbstract,
+      this.video,
+      // this.gameInfo,
+      this.maxNumber,
+      this.bonus,
+      this.houseType,
+      this.houseLevel,
+      this.gameHouseId,
+      this.gameHousePassword,
+      this.statusFlag);
+  int id;
+  int gameId; //游戏ID
+  int userId; //用户ID
+  int seasonId; //赛季ID
+  String houseName; //房间名称
+  String houseAbstract; //房间描述
+  String video; //视频
+  // GameInfo gameInfo; //游戏信息
+  int maxNumber; //最大加入人数
+  int bonus; //奖金
+  int houseType; //0为个人1为官方
+  HouseLevel houseLevel;
+  String gameHouseId; //游戏房间号
+  String gameHousePassword; //游戏密码
+  int statusFlag; //状态
+  factory HouseInfo.fromJson(Map<String, dynamic> json) =>
+      _$HouseInfoFromJson(json);
+
+  Map<String, dynamic> toJson() => _$HouseInfoToJson(this);
+  // 命名构造函数
+  HouseInfo.empty();
+  @override
+  String toString() {
+    return _$HouseInfoToJson(this).toString();
+  }
+}

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

@@ -0,0 +1,60 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'HouseInfo.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+HouseInfo _$HouseInfoFromJson(Map<String, dynamic> json) {
+  return HouseInfo(
+    json['id'] as int,
+    json['gameId'] as int,
+    json['userId'] as int,
+    json['seasonId'] as int,
+    json['houseName'] as String,
+    json['houseAbstract'] as String,
+    json['video'] as String,
+    // GameInfo.fromJson(json['gameInfo'] as Map),
+    json['maxNumber'] as int,
+    json['bonus'] as int,
+    json['houseType'] as int,
+    HouseLevel.fromJson(json['houseLevelInfo'] as Map),
+    json['gameHouseId'] as String,
+    json['gameHousePassword'] as String,
+    json['statusFlag'] as int,
+  );
+}
+
+//  int id;
+//   int gameId; //游戏ID
+//   int userId; //用户ID
+//   int seasonId; //赛季ID
+//   String houseName; //房间名称
+//   String houseAbstract; //房间描述
+//   String video; //视频
+//   GameInfo gameInfo; //游戏信息
+//   int maxNumber; //最大加入人数
+//   int bonus; //奖金
+//   int houseType; //0为个人1为官方
+//   HouseLevel houseLevel;
+//   String gameHouseId; //游戏房间号
+//   String gameHousePassword; //游戏密码
+//   int statusFlag; //状态
+Map<String, dynamic> _$HouseInfoToJson(HouseInfo instance) => <String, dynamic>{
+      'id': instance.id,
+      'gameId': instance.gameId,
+      'userId': instance.userId,
+      'seasonId': instance.seasonId,
+      'houseName': instance.houseName,
+      'houseAbstract': instance.houseAbstract,
+      'video': instance.video,
+      // 'gameInfo': instance.gameInfo,
+      'maxNumber': instance.maxNumber,
+      'bonus': instance.bonus,
+      'houseType': instance.houseType,
+      'houseLevel': instance.houseLevel,
+      'gameHouseId': instance.gameHouseId,
+      'gameHousePassword': instance.gameHousePassword,
+      'statusFlag': instance.statusFlag
+    };

+ 22 - 0
lib/model/HouseLevel.dart

@@ -0,0 +1,22 @@
+import 'package:json_annotation/json_annotation.dart';
+
+part 'HouseLevel.g.dart';
+
+@JsonSerializable()
+class HouseLevel {
+  HouseLevel(this.id, this.levelName, this.icon, this.entryCoin);
+  int id;
+  String levelName;//名称
+  String icon;//图标
+  int entryCoin;//加入金额
+  factory HouseLevel.fromJson(Map<String, dynamic> json) =>
+      _$HouseLevelFromJson(json);
+
+  Map<String, dynamic> toJson() => _$HouseLevelToJson(this);
+  // 命名构造函数
+  HouseLevel.empty();
+  @override
+  String toString() {
+    return _$HouseLevelToJson(this).toString();
+  }
+}

+ 23 - 0
lib/model/HouseLevel.g.dart

@@ -0,0 +1,23 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'HouseLevel.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+HouseLevel _$HouseLevelFromJson(Map<String, dynamic> json) {
+  return HouseLevel(json['id'] as int, json['levelName'] as String,
+      json['icon'] as String, json['entryCoin'] as int);
+}
+
+// String levelName;//名称
+// String icon;//图标
+// int entryCoin;//加入金额
+Map<String, dynamic> _$HouseLevelToJson(HouseLevel instance) =>
+    <String, dynamic>{
+      'id': instance.id,
+      'levelName': instance.levelName,
+      'icon': instance.icon,
+      'entryCoin': instance.entryCoin,
+    };

+ 119 - 7
lib/pages/BindGame.dart

@@ -6,6 +6,7 @@ import 'package:flutter_redux/flutter_redux.dart';
 import '../redux/AppState.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
+import '../model/BindGameInfo.dart';
 
 class BindGame extends StatefulWidget {
   @override
@@ -15,21 +16,69 @@ class BindGame extends StatefulWidget {
 class BindGameState extends State<BindGame> {
   String bindName = '';
   bool isBind = false;
+  BindGameInfo bindInfo;
 
-  void bindEvent() async{
+  void getBindInfo() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.get("bindGame/all", data: {
+      "gameId": 1,
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id
+    });
+    Toast.hide();
+    if (res.success) {
+      if (res.data.length > 0) {
+        print(res.data[0]);
+        setState(() {
+          isBind = true;
+          bindInfo = BindGameInfo.fromJson(res.data[0]);
+        });
+      } else {
+        setState(() {
+          isBind = false;
+        });
+      }
+    }
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    Future.delayed(Duration(milliseconds: 50), () {
+      getBindInfo();
+    });
+  }
+
+  void bindEvent() async {
     if (bindName == '') {
       Toast.show(context, '请输入绑定角色名称', 1500, 'info');
       return;
     }
-Toast.show(context, '加载中', -1, 'loading');
-    Result res = await HttpManager.post("assets/uploadFile", data: {
-      
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res = await HttpManager.post("bindGame/save", data: {
+      "gameId": 1,
+      "userId": StoreProvider.of<AppState>(context).state.userInfo.id,
+      "nickName": bindName
     });
     Toast.hide();
     if (res.success) {
-      
+      Toast.show(context, '绑定成功', 1000, 'success');
+      Future.delayed(Duration(milliseconds: 1000), () {
+        getBindInfo();
+      });
     } else {}
+  }
 
+  void cancelBind() async {
+    Toast.show(context, '加载中', -1, 'loading');
+    Result res =
+        await HttpManager.post("bindGame/del", data: {'id': bindInfo.id});
+    Toast.hide();
+    if (res.success) {
+      Toast.show(context, '解绑成功', 1000, 'success');
+      Future.delayed(Duration(milliseconds: 1000), () {
+        getBindInfo();
+      });
+    } else {}
   }
 
   @override
@@ -50,7 +99,7 @@ Toast.show(context, '加载中', -1, 'loading');
                   Container(
                     height: 220,
                     width: double.infinity,
-                    padding: EdgeInsets.symmetric(vertical: 15, horizontal: 34),
+                    // padding: EdgeInsets.symmetric(vertical: 15, horizontal: 34),
                     decoration: BoxDecoration(
                         image: DecorationImage(
                             image: AssetImage('images/img_chijizhanchang.png'),
@@ -68,10 +117,72 @@ Toast.show(context, '加载中', -1, 'loading');
   List<Widget> _bindWidegt() {
     List<Widget> widgetList = [];
     if (isBind) {
+      widgetList.add(Container(
+        height: 78,
+        padding: EdgeInsets.all(15),
+        decoration: BoxDecoration(
+            gradient: LinearGradient(
+                colors: [Color(0xFF464B6A), Color(0xFF35395E)],
+                begin: Alignment.topCenter,
+                end: Alignment.bottomCenter)),
+        child: Row(
+          children: <Widget>[
+            Image.network(bindInfo.gameInfo.icon, width: 48),
+            Container(
+              width: 10,
+            ),
+            Expanded(
+                flex: 1,
+                child: Column(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: <Widget>[
+                    Text(bindInfo.gameInfo.gameName,
+                        style: TextStyle(color: Colors.white, fontSize: 14)),
+                    Container(
+                      height: 5,
+                    ),
+                    Row(
+                      children: <Widget>[
+                        Text(
+                          "已绑定",
+                          style: TextStyle(
+                              color: Color(0xFF727785),
+                              fontSize: 13,
+                              fontWeight: FontWeight.w500),
+                        ),
+                        Container(
+                          width: 10,
+                        ),
+                        Text(
+                          bindInfo.nickName,
+                          style: TextStyle(
+                              color: Colors.white,
+                              fontSize: 13,
+                              fontWeight: FontWeight.w500),
+                        )
+                      ],
+                    )
+                  ],
+                )),
+            Container(
+                width: 50,
+                height: 30,
+                child: OutlineButton(
+                  padding: EdgeInsets.all(0),
+                  borderSide: BorderSide(color: Color(0xFFC2524D), width: 1),
+                  textColor: Color(0xFFC2524D),
+                  highlightedBorderColor: Color(0xFF9B4040),
+                  child: Text("解绑"),
+                  onPressed: () => cancelBind(),
+                ))
+          ],
+        ),
+      ));
     } else {
       widgetList = [
         Container(
-          margin: EdgeInsets.only(bottom: 10),
+          margin: EdgeInsets.only(bottom: 10, left: 45, right: 45),
           decoration: BoxDecoration(
             borderRadius: BorderRadius.all(Radius.circular(2)),
             color: Colors.white,
@@ -93,6 +204,7 @@ Toast.show(context, '加载中', -1, 'loading');
           ),
         ),
         Container(
+          margin: EdgeInsets.only(left: 45, right: 45, bottom: 15),
           width: double.infinity,
           height: 40,
           child: RaisedButton(

+ 42 - 41
lib/pages/HomePage.dart

@@ -66,48 +66,8 @@ class _HomePageState extends State<HomePage> {
         Expanded(
           child: Stack(
             children: <Widget>[
-              Positioned(
-                left: 0,
-                top: 0,
-                width: 48,
-                height: 48,
-                child: Material(
-                  color: Colors.transparent,
-                  child: Builder(
-                    builder: (context) => InkWell(
-                          onTap: () {
-                            Scaffold.of(context).openDrawer();
-                          },
-                          child: Padding(
-                            padding: EdgeInsets.all(12),
-                            child: Image.asset("images/home_icon_wode.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"),
-                    ),
-                  ),
-                ),
-              ),
               Container(
+                
                   child: Swiper(
                 index: nowIndex,
                 itemCount: seasonList.length,
@@ -180,6 +140,47 @@ class _HomePageState extends State<HomePage> {
                   );
                 },
               )),
+              Positioned(
+                left: 0,
+                top: 0,
+                width: 48,
+                height: 48,
+                child: Material(
+                  color: Colors.transparent,
+                  child: Builder(
+                    builder: (context) => InkWell(
+                          onTap: () {
+                            Scaffold.of(context).openDrawer();
+                          },
+                          child: Padding(
+                            padding: EdgeInsets.all(12),
+                            child: Image.asset("images/home_icon_wode.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,

+ 19 - 8
lib/pages/roomInfo.dart

@@ -9,6 +9,10 @@ import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import '../redux/AppState.dart';
+import '../model/HouseInfo.dart';
+import '../net/HttpManager.dart';
+import '../net/Result.dart';
+import '../styles/totast.dart';
 
 class RoomInfo extends StatefulWidget {
   RoomInfo({Key key, this.roomId}) : super(key: key);
@@ -25,6 +29,7 @@ class RoomInfoState extends State<RoomInfo>
   TabController mController;
   ScrollController _perController;
   Map roomInfo;
+  HouseInfo houseInfo;
   Map colorInfo;
   List joinList = [];
   bool isJoin = true;
@@ -340,7 +345,10 @@ class RoomInfoState extends State<RoomInfo>
         child: RaisedButton(
           disabledColor: Color(0xFF914244),
           disabledTextColor: Color(0xFF252532),
-          child: Text('等待开始中',style: TextStyle(fontSize: 16),),
+          child: Text(
+            '等待开始中',
+            style: TextStyle(fontSize: 16),
+          ),
           onPressed: null,
         ),
       );
@@ -409,14 +417,17 @@ class RoomInfoState extends State<RoomInfo>
   }
 
   void getRoomInfo() async {
-    final response = await Dio().get(domain + 'houseInfo/getOne',
-        queryParameters: {"id": widget.roomId});
-    final res = json.decode(response.toString());
-    if (res['success']) {
+    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"];
+        roomInfo = res.data;
+        houseInfo=HouseInfo.fromJson(res.data);
       });
-      print(roomInfo);
-    }
+       print(houseInfo);
+    } else {}
   }
 }