x1ongzhu 6 年之前
父節點
當前提交
e0a6569e6e

+ 25 - 2
lib/model/PlayerInfo.dart

@@ -10,8 +10,29 @@ part 'PlayerInfo.g.dart';
 class PlayerInfo {
   PlayerInfo.empty();
 
-  PlayerInfo(this.id, this.houseId, this.userId, this.statusFlag, this.userInfo, this.points, this.gameInfo, this.houseInfo, this.liveTime, this.score,
-      this.rank, this.ranking, this.houseRank, this.video, this.played, this.competitionInfo, this.createTime, this.dataError, this.resultError,this.competitionId);
+  PlayerInfo(
+      this.id,
+      this.houseId,
+      this.userId,
+      this.statusFlag,
+      this.userInfo,
+      this.points,
+      this.gameInfo,
+      this.houseInfo,
+      this.liveTime,
+      this.score,
+      this.rank,
+      this.ranking,
+      this.houseRank,
+      this.video,
+      this.played,
+      this.competitionInfo,
+      this.createTime,
+      this.dataError,
+      this.resultError,
+      this.competitionId,
+      this.startTime,
+      this.endTime);
 
   factory PlayerInfo.fromJson(Map<String, dynamic> json) => _$PlayerInfoFromJson(json);
 
@@ -35,6 +56,8 @@ class PlayerInfo {
   bool dataError;
   bool resultError;
   int competitionId;
+  int startTime;
+  int endTime;
 
   Map<String, dynamic> toJson() => _$PlayerInfoToJson(this);
 

+ 6 - 2
lib/model/PlayerInfo.g.dart

@@ -36,7 +36,9 @@ PlayerInfo _$PlayerInfoFromJson(Map<String, dynamic> json) {
       json['createTime'] as int,
       json['dataError'] as bool,
       json['resultError'] as bool,
-      json['competitionId'] as int);
+      json['competitionId'] as int,
+      json['startTime'] as int,
+      json['endTime'] as int);
 }
 
 Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
@@ -60,5 +62,7 @@ Map<String, dynamic> _$PlayerInfoToJson(PlayerInfo instance) =>
       'createTime': instance.createTime,
       'dataError': instance.dataError,
       'resultError': instance.resultError,
-      'competitionId': instance.competitionId
+      'competitionId': instance.competitionId,
+      'startTime': instance.startTime,
+      'endTime': instance.endTime
     };

+ 2 - 2
lib/net/HttpManager.dart

@@ -3,8 +3,8 @@ import 'Result.dart';
 import 'package:intl/intl.dart';
 
 class HttpManager {
-   static String baseUrl = 'http://123.58.240.138:8090/';
-//  static String baseUrl = 'http://192.168.50.132:8080/';
+  //  static String baseUrl = 'http://123.58.240.138:8090/';
+ static String baseUrl = 'http://192.168.123.90:8080/';
   static String token;
   static bool debug;
 

+ 16 - 9
lib/pages/Home.dart

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/services.dart';
 import 'package:shared_preferences/shared_preferences.dart';
+import 'package:wanna_battle/model/HouseInfo.dart';
 import 'package:wanna_battle/model/PlayerInfo.dart';
 import 'package:wanna_battle/net/Result.dart';
 import 'package:wanna_battle/styles/totast.dart';
@@ -17,6 +18,7 @@ import 'AppNotice.dart';
 import 'UserGuid.dart';
 import '../widget/Dialog.dart';
 import 'Appeal.dart';
+import 'RoomInfoNew.dart';
 
 class HomePage extends StatefulWidget {
   const HomePage({Key key}) : super(key: key);
@@ -155,7 +157,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
           SystemChannels.platform.invokeMethod('SystemNavigator.pop');
         } else {
           setState(() {
-          ts = _ts;
+            ts = _ts;
           });
           Toast.show(context, '再按一次退出', 1000, 'info');
         }
@@ -168,14 +170,19 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
     final Result res = await HttpManager.get('playerInfo/getErrorPlayerInfo');
     if (res.success) {
       final PlayerInfo playerInfo = PlayerInfo.fromJson(res.data);
-      showCustomDialog(
-        context,
-        '由于系统性能安全策略问题导致本次比赛结果上传失败,你可以上传本次比赛结果照片进行结果申诉',
-        isCancel: true,
-        onsubmit: () {
-          Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(playerInfo)));
-        },
-      );
+      final res1 = await HttpManager.get('houseInfo/getOne', data: {'id': playerInfo.houseId});
+      if (res1.success && res1.data != null) {
+        Navigator.push(
+          context,
+          CupertinoPageRoute(
+            builder: (context) => RoomInfo(
+                  HouseInfo.fromJson(res1.data),
+                  playerInfo: playerInfo,
+                  interrupted: true,
+                ),
+          ),
+        );
+      }
     }
   }
 }

+ 7 - 7
lib/pages/RoomInfoDetail.dart

@@ -185,9 +185,8 @@ class RoomInfoDetailState extends State<RoomInfoDetail> {
       case HouseStatus.SETTLEMENT:
         return Column(
           children: <Widget>[
-            (widget.playerInfo != null && (widget.playerInfo.dataError || widget.playerInfo.resultError))
-                ? Container(height: 10)
-                : Container(
+            (widget.playerInfo != null && widget.playerInfo.ranking != null && widget.playerInfo.liveTime != null && widget.playerInfo.score != null)
+                ? Container(
                     margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
                     color: SUB_COLOR,
                     padding: EdgeInsets.fromLTRB(15, 15, 0, 15),
@@ -212,7 +211,7 @@ class RoomInfoDetailState extends State<RoomInfoDetail> {
                                 child: Container(
                                   margin: EdgeInsets.only(left: 5),
                                   child: Text(
-                                    widget.playerInfo?.ranking?.toString() ?? '',
+                                    widget.playerInfo?.ranking?.toString() ?? '',
                                     style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
                                   ),
                                 ),
@@ -225,7 +224,7 @@ class RoomInfoDetailState extends State<RoomInfoDetail> {
                                 child: Container(
                                   margin: EdgeInsets.only(left: 5),
                                   child: Text(
-                                    widget.playerInfo?.liveTime != null ? (widget.playerInfo?.liveTime.toString() + '分钟') : '',
+                                    widget.playerInfo?.liveTime != null ? (widget.playerInfo?.liveTime.toString() + '分钟') : '',
                                     style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
                                   ),
                                 ),
@@ -238,7 +237,7 @@ class RoomInfoDetailState extends State<RoomInfoDetail> {
                                 child: Container(
                                   margin: EdgeInsets.only(left: 5),
                                   child: Text(
-                                    (widget.playerInfo?.score != null && widget.playerInfo.score > 0) ? widget.playerInfo.score.toString() : '',
+                                    (widget.playerInfo?.score != null && widget.playerInfo.score > 0) ? widget.playerInfo.score.toString() : '',
                                     style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
                                   ),
                                 ),
@@ -248,7 +247,8 @@ class RoomInfoDetailState extends State<RoomInfoDetail> {
                         ),
                       ],
                     ),
-                  ),
+                  )
+                : Container(height: 10),
             Container(
               margin: EdgeInsets.fromLTRB(15, 5, 15, 20),
               color: SUB_COLOR,

+ 49 - 23
lib/pages/RoomInfoNew.dart

@@ -23,7 +23,8 @@ import 'SecondRoomInfo.dart';
 class RoomInfo extends StatefulWidget {
   final HouseInfo houseInfo;
   final PlayerInfo playerInfo;
-  RoomInfo(this.houseInfo, {Key key, this.playerInfo}) : super(key: key);
+  final bool interrupted;
+  RoomInfo(this.houseInfo, {Key key, this.playerInfo, this.interrupted = false}) : super(key: key);
   @override
   State<StatefulWidget> createState() {
     return _RoomInfoState();
@@ -59,14 +60,18 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
       }
       refreshData();
     });
-    if (mHouseInfo.statusFlag == HouseStatus.WAIT) {
+    if (mHouseInfo.statusFlag == HouseStatus.WAIT || mHouseInfo.statusFlag == HouseStatus.START) {
       timer = Timer.periodic(Duration(seconds: 1), (timer) async {
         refreshData();
       });
       Future.delayed(Duration.zero, () async {
-        final battery = Battery();
-        final batteryLevel = await battery.batteryLevel;
-        showCustomDialog(context, (batteryLevel < 50 ? '系统检测到你的电量低于50%' : '') + ' 为了正常上传比赛结果,建议插上电源线保持电量充足', submitText: '知道了');
+        if (mHouseInfo.statusFlag == HouseStatus.START) {
+          showFinishDialog();
+        } else {
+          final battery = Battery();
+          final batteryLevel = await battery.batteryLevel;
+          showCustomDialog(context, (batteryLevel < 50 ? '系统检测到你的电量低于50%' : '') + ' 为了正常上传比赛结果,建议插上电源线保持电量充足', submitText: '知道了');
+        }
       });
     }
   }
@@ -203,6 +208,7 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
       if (success) {
         data['statusFlag'] = 2;
         data['played'] = true;
+        data['beginTime'] = DateTime.now().millisecondsSinceEpoch;
       } else {
         data['statusFlag'] = 6;
         data['played'] = false;
@@ -218,12 +224,12 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
         if (await canLaunch(url)) {
           Timer(Duration(seconds: 1), () async {
             await launch(url);
-            showSucessInfo();
+            showFinishDialog();
           });
         } else {
           showCustomDialog(context, '自动启动游戏失败,请手动切换到游戏app开始竞赛', submitText: '知道了');
           Timer(Duration(seconds: 10), () {
-            showSucessInfo();
+            showFinishDialog();
           });
         }
       } else {
@@ -232,24 +238,44 @@ class _RoomInfoState extends State<RoomInfo> with SingleTickerProviderStateMixin
     }
   }
 
-  void showSucessInfo() {
-    showCustomDialog(
-      context,
-      '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖',
-      title: '完成比赛',
-      submitText: '我已完成比赛',
-      onsubmit: () async {
-        // HttpManager.post('playerInfo/update', data: {'id': mPlayerInfo.id, 'statusFlag': 3});
-        await ScreenStreamPlugin.stop();
-        setState(() {
-          mPlayerInfo.statusFlag = 3;
-        });
-        refreshData();
-      },
-    );
+  void showFinishDialog() {
+    if (widget.interrupted) {
+      showCustomDialog(
+        context,
+        '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖',
+        title: '完成比赛',
+        submitText: '我已完成比赛',
+        onsubmit: () async {
+          await HttpManager.post('playerInfo/update', data: {
+            'id': mPlayerInfo.id,
+            'endTime': DateTime.now().millisecondsSinceEpoch,
+            'statusFlag': 9,
+          });
+          setState(() {
+            mPlayerInfo.statusFlag = 3;
+          });
+          refreshData();
+        },
+      );
+    } else {
+      showCustomDialog(
+        context,
+        '您已经完成比赛了吗,确认完成,那就点击下方完成竞赛按钮,上传本次成绩,祝您赢取大奖',
+        title: '完成比赛',
+        submitText: '我已完成比赛',
+        onsubmit: () async {
+          await HttpManager.post('playerInfo/update', data: {'id': mPlayerInfo.id, 'endTime': DateTime.now().millisecondsSinceEpoch});
+          await ScreenStreamPlugin.stop();
+          setState(() {
+            mPlayerInfo.statusFlag = 3;
+          });
+          refreshData();
+        },
+      );
+    }
   }
 
   void showStartFailDialog(type) {
-    showCustomDialog(context, (type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏') + ',系��已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
+    showCustomDialog(context, (type == 1 ? '由于您未在十秒内点击开始按钮' : '由于您未授权录屏') + ',系已经判定您放弃比赛,谢谢您的参与。', title: '很遗憾');
   }
 }

+ 83 - 84
lib/pages/TipInfo.dart

@@ -52,7 +52,7 @@ class TipInfoState extends State<TipInfo> {
       }
     });
 
-    if (notice.playerInfo.resultError) {
+    if (notice.playerInfo != null && (notice.playerInfo.ranking == null || notice.playerInfo.liveTime == null || notice.playerInfo.score == null)) {
       HttpManager.get('appealInfo/getOne', data: {
         'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
         'playerInfoId': notice.playerInfo.id,
@@ -116,7 +116,7 @@ class TipInfoState extends State<TipInfo> {
             child: Column(
               children: <Widget>[
                 Padding(
-                  padding: EdgeInsets.only(left: 15, right: 45),
+                  padding: EdgeInsets.only(left: 15, right: 15),
                   child: Column(
                     crossAxisAlignment: CrossAxisAlignment.start,
                     children: <Widget>[
@@ -138,30 +138,30 @@ class TipInfoState extends State<TipInfo> {
                     ],
                   ),
                 ),
-                Builder(
-                  builder: (context) {
-                    String content = '';
-                    if (notice.playerInfo.dataError || !notice.playerInfo.played) {
-                      content = '造成此情况等原因可能是:\n'
-                          '1、没有实际进行游戏比赛\n'
-                          '2、使用作弊手段进行游戏';
-                    } else if (notice.playerInfo.resultError) {
-                      content = '造成此情况等原因可能是:\n'
-                          '1、确认开始游戏后没有授权系统进行录屏\n'
-                          '2、视频没有录制到最后的分数名次结算页面就回到APP点击完成比赛了\n'
-                          '3、在游戏过程中,由于电量过低或系统安全性能策略问题导致本竞赛APP后台进程被退出\n'
-                          '4、游戏结束后没有在规定时间内返回APP点击完成比赛按钮';
-                    }
-                    return Container(
-                      margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
-                      width: double.infinity,
-                      child: Text(
-                        content,
-                        style: TextStyle(color: Color(0x99FFFFFF), fontSize: 13),
-                      ),
-                    );
-                  },
-                ),
+                // Builder(
+                //   builder: (context) {
+                //     String content = '';
+                //     if (notice.playerInfo.dataError || !notice.playerInfo.played) {
+                //       content = '造成此情况等原因可能是:\n'
+                //           '1、没有实际进行游戏比赛\n'
+                //           '2、使用作弊手段进行游戏';
+                //     } else if (notice.playerInfo.resultError) {
+                //       content = '造成此情况等原因可能是:\n'
+                //           '1、确认开始游戏后没有授权系统进行录屏\n'
+                //           '2、视频没有录制到最后的分数名次结算页面就回到APP点击完成比赛了\n'
+                //           '3、在游戏过程中,由于电量过低或系统安全性能策略问题导致本竞赛APP后台进程被退出\n'
+                //           '4、游戏结束后没有在规定时间内返回APP点击完成比赛按钮';
+                //     }
+                //     return Container(
+                //       margin: EdgeInsets.only(left: 15, right: 15, bottom: 20),
+                //       width: double.infinity,
+                //       child: Text(
+                //         content,
+                //         style: TextStyle(color: Color(0x99FFFFFF), fontSize: 13),
+                //       ),
+                //     );
+                //   },
+                // ),
                 houseInfo != null && type != 3 ? _houseWidget() : Container(),
                 resultWidget(),
                 Expanded(
@@ -280,73 +280,72 @@ class TipInfoState extends State<TipInfo> {
   }
 
   Widget resultWidget() {
-    if (!notice.playerInfo.played || notice.playerInfo.dataError || notice.playerInfo.resultError) {
-      return Container();
-    }
     return Column(
       children: <Widget>[
-        Container(
-          margin: EdgeInsets.fromLTRB(15, 0, 15, 5),
-          color: SUB_COLOR,
-          padding: EdgeInsets.fromLTRB(15, 15, 0, 15),
-          child: Column(
-            mainAxisAlignment: MainAxisAlignment.center,
-            crossAxisAlignment: CrossAxisAlignment.stretch,
-            children: <Widget>[
-              Text(
-                '和平精英游戏结果',
-                textAlign: TextAlign.left,
-                style: TextStyle(color: Color(0x99FFFFFF)),
-              ),
-              Container(
-                margin: EdgeInsets.only(top: 10),
-                child: Row(
+        (notice.playerInfo != null && notice.playerInfo.ranking != null && notice.playerInfo.liveTime != null && notice.playerInfo.score != null)
+            ? Container(
+                margin: EdgeInsets.fromLTRB(15, 0, 15, 5),
+                color: SUB_COLOR,
+                padding: EdgeInsets.fromLTRB(15, 15, 0, 15),
+                child: Column(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  crossAxisAlignment: CrossAxisAlignment.stretch,
                   children: <Widget>[
                     Text(
-                      '名次',
-                      style: TextStyle(color: Colors.white, fontSize: 14),
-                    ),
-                    Expanded(
-                      child: Container(
-                        margin: EdgeInsets.only(left: 5),
-                        child: Text(
-                          notice.playerInfo?.ranking?.toString() ?? '',
-                          style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
-                        ),
-                      ),
-                    ),
-                    Text(
-                      '时长',
-                      style: TextStyle(color: Colors.white, fontSize: 14),
+                      '和平精英游戏结果',
+                      textAlign: TextAlign.left,
+                      style: TextStyle(color: Color(0x99FFFFFF)),
                     ),
-                    Expanded(
-                      child: Container(
-                        margin: EdgeInsets.only(left: 5),
-                        child: Text(
-                          (notice.playerInfo?.liveTime ?? '') + '分钟',
-                          style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
-                        ),
-                      ),
-                    ),
-                    Text(
-                      '评分',
-                      style: TextStyle(color: Colors.white, fontSize: 14),
-                    ),
-                    Expanded(
-                      child: Container(
-                        margin: EdgeInsets.only(left: 5),
-                        child: Text(
-                          notice.playerInfo?.score?.toString() ?? '',
-                          style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
-                        ),
+                    Container(
+                      margin: EdgeInsets.only(top: 10),
+                      child: Row(
+                        children: <Widget>[
+                          Text(
+                            '名次',
+                            style: TextStyle(color: Colors.white, fontSize: 14),
+                          ),
+                          Expanded(
+                            child: Container(
+                              margin: EdgeInsets.only(left: 5),
+                              child: Text(
+                                notice.playerInfo?.ranking?.toString() ?? '',
+                                style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
+                              ),
+                            ),
+                          ),
+                          Text(
+                            '时长',
+                            style: TextStyle(color: Colors.white, fontSize: 14),
+                          ),
+                          Expanded(
+                            child: Container(
+                              margin: EdgeInsets.only(left: 5),
+                              child: Text(
+                                (notice.playerInfo?.liveTime ?? '') + '分钟',
+                                style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
+                              ),
+                            ),
+                          ),
+                          Text(
+                            '评分',
+                            style: TextStyle(color: Colors.white, fontSize: 14),
+                          ),
+                          Expanded(
+                            child: Container(
+                              margin: EdgeInsets.only(left: 5),
+                              child: Text(
+                                notice.playerInfo?.score?.toString() ?? '',
+                                style: TextStyle(color: Colors.yellow, fontSize: 14, fontWeight: FontWeight.bold),
+                              ),
+                            ),
+                          ),
+                        ],
                       ),
                     ),
                   ],
                 ),
-              ),
-            ],
-          ),
-        ),
+              )
+            : Container(),
         Container(
           margin: EdgeInsets.fromLTRB(15, 0, 15, 20),
           color: SUB_COLOR,

+ 9 - 27
lib/pages/TipList.dart

@@ -49,8 +49,7 @@ class TipListState extends State<TipList> {
     } else {}
     setState(() {
       tipList = list;
-      PageStorage.of(context)
-          .writeState(context, tipList, identifier: ValueKey('tipList'));
+      PageStorage.of(context).writeState(context, tipList, identifier: ValueKey('tipList'));
     });
   }
 
@@ -58,9 +57,7 @@ class TipListState extends State<TipList> {
   void initState() {
     super.initState();
     _mControll = ScrollController();
-    tipList = PageStorage.of(context)
-            .readState(context, identifier: ValueKey('tipList')) ??
-        [];
+    tipList = PageStorage.of(context).readState(context, identifier: ValueKey('tipList')) ?? [];
     Future.delayed(Duration.zero, () => getListPage());
     _mControll.addListener(() {
       if (_mControll.position.pixels == _mControll.position.maxScrollExtent) {
@@ -102,19 +99,14 @@ class TipListState extends State<TipList> {
                 if (tipList.isEmpty) {
                   return Text(
                     '数据正在火速加载中...',
-                    style: TextStyle(
-                        color: Colors.white30, fontSize: 13, height: 2),
+                    style: TextStyle(color: Colors.white30, fontSize: 13, height: 2),
                     textAlign: TextAlign.center,
                   );
                 }
                 return TipItem(
                     tipInfo: tipList[index],
                     tapInfo: () async {
-                      bool res = await Navigator.push(
-                          context,
-                          CupertinoPageRoute(
-                              builder: (context) =>
-                                  TipInfo(notice: tipList[index])));
+                      bool res = await Navigator.push(context, CupertinoPageRoute(builder: (context) => TipInfo(notice: tipList[index])));
                       if (res != null) {
                         setState(() {
                           tipList = [];
@@ -157,22 +149,10 @@ class TipItem extends StatelessWidget {
                   child: Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                     children: <Widget>[
-                      Text(
-                          readTimestamp(
-                              tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
-                          style: TextStyle(
-                              color: Color(0xFF9BA0AE), fontSize: 13)),
+                      Text(readTimestamp(tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'), style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 13)),
                       tipInfo.statusFlag == 0
-                          ? Text('未读',
-                              style: TextStyle(
-                                  color: PRIMARY_COLOR,
-                                  fontSize: 13,
-                                  fontWeight: FontWeight.bold))
-                          : Text('已读',
-                              style: TextStyle(
-                                  color: Colors.black,
-                                  fontSize: 13,
-                                  fontWeight: FontWeight.bold))
+                          ? Text('未读', style: TextStyle(color: PRIMARY_COLOR, fontSize: 13, fontWeight: FontWeight.bold))
+                          : Text('已读', style: TextStyle(color: Colors.black, fontSize: 13, fontWeight: FontWeight.bold))
                     ],
                   ),
                 ),
@@ -184,6 +164,8 @@ class TipItem extends StatelessWidget {
                   padding: EdgeInsets.only(top: 10, bottom: 15),
                   child: Text(
                     tipInfo.content,
+                    overflow: TextOverflow.ellipsis,
+                    maxLines: 2,
                     style: TextStyle(color: Colors.white, fontSize: 14),
                     textAlign: TextAlign.left,
                   ),