Pārlūkot izejas kodu

Merge branch 'master' of http://git.izouma.com/panhui/mobileCyberGamesApp

x1ongzhu 6 gadi atpakaļ
vecāks
revīzija
c54fb43bd1
2 mainītis faili ar 101 papildinājumiem un 29 dzēšanām
  1. 98 25
      lib/pages/openRoom.dart
  2. 3 4
      lib/pages/roomInfo.dart

+ 98 - 25
lib/pages/openRoom.dart

@@ -27,9 +27,14 @@ class OpenRoom extends StatefulWidget {
 
 class OpenRoomState extends State<OpenRoom> {
   TextStyle titleStyle = TextStyle(color: Colors.white, fontSize: 14);
-  TextStyle valStyle = TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
+  TextStyle valStyle =
+      TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
 
-  Map<String, dynamic> editRoomInfo = {"gameId": 1, "houseLevel": 1, "maxNumber": 10};
+  Map<String, dynamic> editRoomInfo = {
+    "gameId": 1,
+    "houseLevel": 1,
+    "maxNumber": 10
+  };
   List<GameInfo> gameList = [];
   List<HouseLevel> levelList = [];
 
@@ -61,14 +66,33 @@ class OpenRoomState extends State<OpenRoom> {
       Toast.show(context, '请选择房间等级', 1500, 'info');
       return;
     }
-    if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHouseId'] == null || editRoomInfo['gameHouseId'] == '')) {
+    if (editRoomInfo['houseType'] == '1' &&
+        (editRoomInfo['gameHouseId'] == null ||
+            editRoomInfo['gameHouseId'] == '')) {
       Toast.show(context, '请录入游戏房间号', 1500, 'info');
       return;
     }
-    if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHousePassword'] == null || editRoomInfo['gameHousePassword'] == '')) {
+    if (editRoomInfo['houseType'] == '1' &&
+        (editRoomInfo['gameHousePassword'] == null ||
+            editRoomInfo['gameHousePassword'] == '')) {
       Toast.show(context, '请录入游戏房间密码', 1500, 'info');
       return;
     }
+    if (StoreProvider.of<AppState>(context).state.userInfo.moneyCoin != null) {
+      HouseLevel chooseLevelInfo = HouseLevel.empty();
+      for (var item in levelList) {
+        if (item.id.toString() == editRoomInfo['houseLevel'].toString()) {
+          chooseLevelInfo = item;
+        }
+      }
+      if (StoreProvider.of<AppState>(context).state.userInfo.moneyCoin <
+          chooseLevelInfo.entryCoin) {
+        return;
+      }
+    } else {
+      return;
+    }
+
     bool hasPermission = await ScreenStreamPlugin.checkPermission();
     if (!hasPermission) {
       showDialog(
@@ -90,15 +114,23 @@ class OpenRoomState extends State<OpenRoom> {
       );
       return;
     }
-    editRoomInfo['createUser'] = StoreProvider.of<AppState>(context).state.userInfo.id;
+    editRoomInfo['createUser'] =
+        StoreProvider.of<AppState>(context).state.userInfo.id;
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.post("houseInfo/save", data: editRoomInfo);
     Toast.hide();
     if (res.success) {
-      HttpManager.post("houseInfo/join", data: {"houseId": res.data, "userId": StoreProvider.of<AppState>(context).state.userInfo.id});
+      HttpManager.post("houseInfo/join", data: {
+        "houseId": res.data,
+        "userId": StoreProvider.of<AppState>(context).state.userInfo.id
+      });
       Toast.show(context, '创建成功', 1500, 'success');
       Future.delayed(Duration(milliseconds: 1500), () {
-        Navigator.pushReplacement(context, new CupertinoPageRoute(builder: (context) => new RoomInfo(roomId: res.data.toString())));
+        Navigator.pushReplacement(
+            context,
+            new CupertinoPageRoute(
+                builder: (context) =>
+                    new RoomInfo(roomId: res.data.toString())));
       });
     } else {}
   }
@@ -115,7 +147,11 @@ class OpenRoomState extends State<OpenRoom> {
         gameList = _list;
         if (res.data.length > 0) {
           editRoomInfo['gameId'] = res.data[0]['id'];
-          editRoomInfo['houseName'] = StoreProvider.of<AppState>(context).state.userInfo.nickname + '的' + res.data[0]['shortName'] + '房间';
+          editRoomInfo['houseName'] =
+              StoreProvider.of<AppState>(context).state.userInfo.nickname +
+                  '的' +
+                  res.data[0]['shortName'] +
+                  '房间';
           editRoomInfo['houseAbstract'] = res.data[0]['profile'] ?? '';
         }
       });
@@ -176,7 +212,8 @@ class OpenRoomState extends State<OpenRoom> {
                 child: FlatButton(
                   highlightColor: PRIMARY_COLOR,
                   padding: EdgeInsets.only(right: 0),
-                  child: Text('规则', style: TextStyle(color: Colors.white, fontSize: 13)),
+                  child: Text('规则',
+                      style: TextStyle(color: Colors.white, fontSize: 13)),
                   onPressed: () {},
                 ),
               )
@@ -237,8 +274,11 @@ class OpenRoomState extends State<OpenRoom> {
                           Padding(
                             padding: EdgeInsets.only(top: 12),
                             child: Text(
-                              editRoomInfo.containsKey('video') ? '已选择' : '不上传则自动使用官方默认视频',
-                              style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 13),
+                              editRoomInfo.containsKey('video')
+                                  ? '已选择'
+                                  : '不上传则自动使用官方默认视频',
+                              style: TextStyle(
+                                  color: Color(0xFF9BA0AE), fontSize: 13),
                             ),
                           )
                         ],
@@ -348,17 +388,24 @@ class OpenRoomState extends State<OpenRoom> {
                           children: <Widget>[
                             Padding(
                               padding: EdgeInsets.only(right: 6),
-                              child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
+                              child: Image.asset('images/icon_jinbi_da_bai.png',
+                                  width: 20),
                             ),
                             Text(
                               '×' + (chooseLevelInfo.entryCoin ?? 0).toString(),
-                              style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                              style: TextStyle(
+                                  color: Colors.white,
+                                  fontSize: 16,
+                                  fontWeight: FontWeight.w500),
                             ),
                             Padding(
                               padding: EdgeInsets.only(left: 20),
                               child: Text(
                                 '创建房间',
-                                style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
+                                style: TextStyle(
+                                    color: Colors.white,
+                                    fontSize: 16,
+                                    fontWeight: FontWeight.w500),
                               ),
                             )
                           ],
@@ -455,14 +502,19 @@ class OpenRoomState extends State<OpenRoom> {
     new Picker(
         confirmText: '确定',
         cancelText: "取消",
-        adapter: PickerDataAdapter<String>(pickerdata: new JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(
+            pickerdata: new JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
         onConfirm: (Picker picker, List value) {
           setState(() {
             editRoomInfo['gameId'] = gameList[value[0]].id;
-            editRoomInfo['houseName'] = StoreProvider.of<AppState>(context).state.userInfo.nickname + '的' + gameList[value[0]].shortName + '房间';
+            editRoomInfo['houseName'] =
+                StoreProvider.of<AppState>(context).state.userInfo.nickname +
+                    '的' +
+                    gameList[value[0]].shortName +
+                    '房间';
             editRoomInfo['houseAbstract'] = gameList[value[0]].profile ?? '';
           });
         }).showModal(this.context);
@@ -478,7 +530,8 @@ class OpenRoomState extends State<OpenRoom> {
     new Picker(
         confirmText: '确定',
         cancelText: "取消",
-        adapter: PickerDataAdapter<String>(pickerdata: new JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(
+            pickerdata: new JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -498,7 +551,8 @@ class OpenRoomState extends State<OpenRoom> {
     new Picker(
         confirmText: '确定',
         cancelText: "取消",
-        adapter: PickerDataAdapter<String>(pickerdata: new JsonDecoder().convert(PickerData)),
+        adapter: PickerDataAdapter<String>(
+            pickerdata: new JsonDecoder().convert(PickerData)),
         changeToFirst: true,
         textAlign: TextAlign.left,
         columnPadding: const EdgeInsets.all(8.0),
@@ -514,7 +568,14 @@ typedef int OnTapHomeMenu();
 typedef ValueChanged<T> = void Function(T value);
 
 class ChooseContent extends StatelessWidget {
-  ChooseContent({Key key, this.title, this.val, this.chooseLevelInfo, this.isLevel = false, this.onTapHomeMenu}) : super(key: key);
+  ChooseContent(
+      {Key key,
+      this.title,
+      this.val,
+      this.chooseLevelInfo,
+      this.isLevel = false,
+      this.onTapHomeMenu})
+      : super(key: key);
   final String title;
   final String val;
   final OnTapHomeMenu onTapHomeMenu;
@@ -549,15 +610,24 @@ class ChooseContent extends StatelessWidget {
                         ),
                         Padding(
                           padding: EdgeInsets.only(left: 20, right: 2),
-                          child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
+                          child: Image.asset('images/icon_jinbi_da_bai.png',
+                              width: 20),
                         ),
                         Text(
                           '×' + (chooseLevelInfo.entryCoin ?? 0).toString(),
-                          style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500),
+                          style: TextStyle(
+                              color: Colors.white,
+                              fontSize: 15,
+                              fontWeight: FontWeight.w500),
                         )
                       ],
                     )
-                  : Text(val ?? '', style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500), textAlign: TextAlign.right),
+                  : Text(val ?? '',
+                      style: TextStyle(
+                          fontSize: 15,
+                          color: Colors.white,
+                          fontWeight: FontWeight.w500),
+                      textAlign: TextAlign.right),
             ),
             Image.asset('images/icon_inter.png', width: 24)
           ],
@@ -569,7 +639,8 @@ class ChooseContent extends StatelessWidget {
 }
 
 class InputContent extends StatefulWidget {
-  InputContent({Key key, this.title, this.value, this.onTextChange}) : super(key: key);
+  InputContent({Key key, this.title, this.value, this.onTextChange})
+      : super(key: key);
   final String title;
   final String value;
   final ValueChanged onTextChange;
@@ -602,14 +673,16 @@ class InputContentState extends State<InputContent> {
       child: TextField(
         controller: _controller,
         textAlign: TextAlign.end,
-        style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
+        style: TextStyle(
+            fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
         maxLength: 10,
         decoration: InputDecoration(
             hintText: "请输入" + widget.title,
             hintStyle: TextStyle(color: Color(0xFF727785), fontSize: 13),
             prefixIcon: Padding(
               padding: EdgeInsets.symmetric(vertical: 12),
-              child: Text(widget.title, style: TextStyle(fontSize: 14, color: Colors.white)),
+              child: Text(widget.title,
+                  style: TextStyle(fontSize: 14, color: Colors.white)),
             ),
             border: InputBorder.none,
             counterStyle: TextStyle(fontSize: 0)),

+ 3 - 4
lib/pages/roomInfo.dart

@@ -238,7 +238,7 @@ class RoomInfoState extends State<RoomInfo>
               '请一定点击“确定”或“允许”此操作',
               ',系统会自动跳转打开游戏app,若长时间没有自动跳转,请手动打开游戏app进行比赛,在游戏比赛结束后,请',
               '一定要点击查看游戏最后的分数名次结算页面',
-              ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功传本次成绩。从游戏开始一小时之内必须返回全民App点击完成比赛,否则判定游戏失败,祝你取得好成绩。'
+              ',返回游戏主页,最后再切换到我们竞赛app中,点击完成比赛,方可成功传本次成绩。从游戏开始一小时之内必须返回全民App点击完成比赛,否则判定游戏失败,祝你取得好成绩。'
             ]);
             changeScroll();
           });
@@ -506,7 +506,7 @@ class RoomInfoState extends State<RoomInfo>
                           ),
                           Text(
                             (houseInfo != null
-                                    ? houseInfo.playerNumber.toString()
+                                    ? (houseInfo.playerNumber??0).toString()
                                     : '0') +
                                 '/' +
                                 (houseInfo != null
@@ -661,7 +661,6 @@ class RoomInfoState extends State<RoomInfo>
         ),
       );
     } else if (isJoin && statusFlag == 8) {
-    
       return Container(
         width: double.infinity,
         padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
@@ -670,7 +669,7 @@ class RoomInfoState extends State<RoomInfo>
           disabledColor: Color(0xFF914244),
           disabledTextColor: Color(0xFF252532),
           child: Text(
-             '正在结算中',
+             '正在努力解析视频中',
             style: TextStyle(fontSize: 16),
           ),
           onPressed: null,