TipInfo.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. import 'package:flutter/material.dart';
  2. import '../styles/colors.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'dart:ui';
  5. import '../styles/totast.dart';
  6. import '../model/SystemNotice.dart';
  7. import '../net/HttpManager.dart';
  8. import '../net/Result.dart';
  9. import '../model/HouseInfo.dart';
  10. import '../model/GameInfo.dart';
  11. import '../pages/RoomInfo.dart';
  12. import '../widget/SuccessfulReception.dart';
  13. import '../widget/LinearButton.dart';
  14. import '../model/PlayerInfo.dart';
  15. import '../widget/ScoreType.dart';
  16. import '../widget/HouseItem.dart';
  17. import '../redux/AppState.dart';
  18. import 'package:flutter_redux/flutter_redux.dart';
  19. import 'Appeal.dart';
  20. class TipInfo extends StatefulWidget {
  21. TipInfo({Key key, this.tipId}) : super(key: key);
  22. final int tipId;
  23. @override
  24. TipInfoState createState() => TipInfoState();
  25. }
  26. class TipInfoState extends State<TipInfo> {
  27. SystemNotice tipInfo = SystemNotice.fromJson({'content': '', 'createTime': DateTime.now().microsecondsSinceEpoch});
  28. HouseInfo houseInfo;
  29. PlayerInfo playerInfo;
  30. bool canAppeal = false;
  31. int appealState = 0;
  32. Future<void> getInfo() async {
  33. Toast.show(context, '加载中', -1, 'loading');
  34. Result res = await HttpManager.get('systemNotice/getOne', data: {'id': widget.tipId});
  35. Toast.hide();
  36. if (res.success) {
  37. setState(() {
  38. tipInfo = SystemNotice.fromJson(res.data);
  39. });
  40. }
  41. if (tipInfo.statusFlag == 0 && tipInfo.typeFlag != 2 && tipInfo.typeFlag != 3) {
  42. HttpManager.post('systemNotice/update', data: {'id': tipInfo.id, 'statusFlag': 1});
  43. }
  44. if (tipInfo.typeFlag == 3) {
  45. return;
  46. }
  47. Result res2 = await HttpManager.get('houseInfo/getOne', data: {'id': tipInfo.houseId});
  48. if (res2.success) {
  49. setState(() {
  50. houseInfo = HouseInfo.fromJson(res2.data);
  51. });
  52. }
  53. Result res3 = await HttpManager.get('playerInfo/getOne', data: {'userId': StoreProvider.of<AppState>(context).state.userInfo.id, 'houseId': tipInfo.houseId});
  54. if (res3.success) {
  55. playerInfo = PlayerInfo.fromJson(res3.data);
  56. print(res3.data);
  57. }
  58. HttpManager.get('appealInfo/getOne', data: {
  59. 'userId': StoreProvider.of<AppState>(context).state.userInfo.id,
  60. 'playerInfoId': playerInfo.id,
  61. }).then((res) {
  62. if (res.success && res.data != null) {
  63. setState(() {
  64. canAppeal = true;
  65. appealState = 1;
  66. });
  67. } else {
  68. setState(() {
  69. canAppeal = true;
  70. appealState = 0;
  71. });
  72. }
  73. });
  74. // showSuccess(1000);
  75. }
  76. void showSuccess(money) {
  77. Navigator.of(context).push(
  78. PageRouteBuilder(
  79. opaque: false,
  80. transitionDuration: Duration(milliseconds: 300),
  81. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  82. return FadeTransition(
  83. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  84. child: child,
  85. );
  86. },
  87. pageBuilder: (BuildContext context, _, __) {
  88. return SuccessfulReception(money: money);
  89. },
  90. ),
  91. );
  92. }
  93. @override
  94. void initState() {
  95. super.initState();
  96. Future.delayed(Duration.zero, () => getInfo());
  97. }
  98. @override
  99. Widget build(BuildContext context) {
  100. int type = tipInfo.typeFlag != null ? tipInfo.typeFlag : 0;
  101. int status = tipInfo.statusFlag ?? 0;
  102. GameInfo gameInfo;
  103. if (tipInfo.gameInfo != null) {
  104. gameInfo = tipInfo.gameInfo;
  105. }
  106. return WillPopScope(
  107. child: Scaffold(
  108. appBar: AppBar(
  109. // backgroundColor: PRIMARY_COLOR,
  110. title: Text('通知详情'),
  111. centerTitle: true,
  112. elevation: 0,
  113. ),
  114. body: Container(
  115. color: Color(0xFF2B2B42),
  116. width: double.infinity,
  117. height: double.infinity,
  118. child: SingleChildScrollView(
  119. child: Column(
  120. children: <Widget>[
  121. Padding(
  122. padding: EdgeInsets.only(left: 15, right: 15),
  123. child: Column(
  124. crossAxisAlignment: CrossAxisAlignment.start,
  125. children: <Widget>[
  126. Padding(
  127. padding: EdgeInsets.symmetric(vertical: 12),
  128. child: Text(readTimestamp(tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'), style: TextStyle(color: Colors.white24, fontSize: 13)),
  129. ),
  130. Container(
  131. height: 1,
  132. color: Colors.black26,
  133. ),
  134. Padding(padding: EdgeInsets.only(top: 10, bottom: 0), child: Text.rich(TextSpan(style: TextStyle(color: Colors.white, fontSize: 14), children: _tipContent(tipInfo.content, context)))),
  135. ],
  136. ),
  137. ),
  138. playerInfo != null && playerInfo.dataError
  139. ? Container(
  140. width: double.infinity,
  141. padding: EdgeInsets.fromLTRB(15, 5, 15, 20),
  142. child: DefaultTextStyle(
  143. style: TextStyle(
  144. fontSize: 13,
  145. color: Colors.white54,
  146. ),
  147. child: Column(
  148. crossAxisAlignment: CrossAxisAlignment.start,
  149. children: <Widget>[
  150. Text('造成此情况等原因可能是:'),
  151. Text('1、没有实际进行游戏比赛 '),
  152. Text('2、使用作弊手段进行游戏'),
  153. ],
  154. ),
  155. ),
  156. )
  157. : Container(
  158. height: 30,
  159. ),
  160. // tipInfo.typeFlag == 4
  161. // ? Padding(
  162. // padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  163. // child: DefaultTextStyle(
  164. // style: TextStyle(
  165. // fontSize: 13,
  166. // color: Colors.white54,
  167. // ),
  168. // child: Column(
  169. // crossAxisAlignment: CrossAxisAlignment.start,
  170. // children: <Widget>[
  171. // Text('造成此情况等原因可能是:'),
  172. // Text('1、确认开始游戏后没有授权系统进行录屏'),
  173. // Text('2、视频没有录制到最后的分数名次结算页面就回到APP点击完成比赛了 '),
  174. // Text('3、在游戏过程中,猿人点击APP后台进程被退出 '),
  175. // Text('4、没有实际进行游戏比赛 '),
  176. // Text('5、使用作弊手段录制视频'),
  177. // ],
  178. // ),
  179. // ),
  180. // )
  181. // : Container(),
  182. // tipInfo.typeFlag == 5
  183. // ? Padding(
  184. // padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  185. // child: DefaultTextStyle(
  186. // style: TextStyle(
  187. // fontSize: 13,
  188. // color: Colors.white54,
  189. // ),
  190. // child: Column(
  191. // crossAxisAlignment: CrossAxisAlignment.start,
  192. // children: <Widget>[
  193. // Text('造成此情况等原因可能是:'),
  194. // Text('1、游戏结束后没有在规定时间内返回APP点击完成比赛按钮'),
  195. // ],
  196. // ),
  197. // ),
  198. // )
  199. // : Container(
  200. // height: 30,
  201. // ),
  202. // houseInfo != null && tipInfo.typeFlag != 4 && tipInfo.typeFlag != 5 ? RankContent(roomId: houseInfo.id.toString()) : Container(),
  203. houseInfo != null && type != 3 ? HouseItem(houseInfo, gameInfo) : Container(),
  204. houseInfo != null && playerInfo != null && type != 3 ? _resultContent(houseInfo, playerInfo, tipInfo.typeFlag) : Container(),
  205. (type == 2 || type == 3)
  206. ? Container(
  207. width: double.infinity,
  208. height: 48,
  209. padding: EdgeInsets.symmetric(horizontal: 15),
  210. child: status == 0
  211. ? LinearButton(
  212. btntext: '立即领取',
  213. onTapHomeMenu: () async {
  214. Toast.show(context, '加载中', -1, 'loading');
  215. Result res = type == 2 ? await HttpManager.post('playerInfo/receive', data: {'id': tipInfo.playerId}) : await HttpManager.post('systemNotice/receive', data: {'id': widget.tipId});
  216. Toast.hide();
  217. if (res.success) {
  218. if (tipInfo.playerInfo != null) {
  219. showSuccess(tipInfo.playerInfo.bonus);
  220. } else {
  221. showSuccess(tipInfo.bonus);
  222. }
  223. getInfo();
  224. } else {
  225. Toast.show(context, res.error, 1000, 'info');
  226. }
  227. },
  228. )
  229. : LinearButton(btntext: '已领取', colorList: [Color(0xFFC99C09), Color(0xFFC7873E)], textColor: Color(0xFF252532)),
  230. )
  231. // RaisedButton(
  232. // textColor: Colors.white,
  233. // disabledColor: Color(0xFF763939),
  234. // disabledTextColor: Color(0xFF252532),
  235. // child: Text(status==0?'立即领取':'已领取'),
  236. // onPressed: status==0?() async {
  237. // Toast.show(context, '加载中', -1, 'loading');
  238. // Result res = type == 2
  239. // ? await HttpManager.post('playerInfo/receive',
  240. // data: {'id': tipInfo.playerId})
  241. // : await HttpManager.post('systemNotice/receive',
  242. // data: {'id': widget.tipId});
  243. // Toast.hide();
  244. // if (res.success) {
  245. // if (tipInfo.playerInfo != null) {
  246. // showSuccess(tipInfo.playerInfo.bonus);
  247. // } else {
  248. // showSuccess(tipInfo.bonus);
  249. // }
  250. // getInfo();
  251. // } else {
  252. // Toast.show(context, res.error, 1000, 'info');
  253. // }
  254. // }:null,
  255. // ),
  256. : Container(),
  257. // CustomPaint(
  258. // painter: CircleProgressBarPainter(
  259. // Color(0xFFDCA659), Color(0xFFAE4945), 0.0, 270.0, 360.0, 18.0),
  260. // size: Size(108.0, 108.0),
  261. // )
  262. ],
  263. ),
  264. ),
  265. ),
  266. floatingActionButton: _btnContent(),
  267. floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  268. ),
  269. onWillPop: () {
  270. Navigator.of(context).pop(true);
  271. Toast.hide();
  272. return Future.value(false);
  273. },
  274. );
  275. }
  276. Widget _btnContent() {
  277. if ((tipInfo.typeFlag == 4 || tipInfo.typeFlag == 5 || (playerInfo != null && playerInfo.dataError)) && canAppeal && appealState == 0) {
  278. return Container(
  279. width: double.infinity,
  280. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
  281. height: 88,
  282. child: LinearButton(
  283. btntext: '申诉结果',
  284. colorList: [Color(0xFFAF4946), Color(0xFFAF4946)],
  285. textColor: Colors.white,
  286. onTapHomeMenu: () async {
  287. final success = await Navigator.push(context, CupertinoPageRoute(builder: (context) => Appeal(playerInfo)));
  288. if (success != null && success) {
  289. Toast.show(context, '提交成功', 1500, 'success');
  290. setState(() {
  291. appealState = 1;
  292. });
  293. }
  294. },
  295. ));
  296. } else if (tipInfo.typeFlag != 3 && canAppeal && appealState == 1) {
  297. return Container(width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20), height: 88, child: LinearButton(btntext: '已提交申诉', colorList: [Color(0xFFAF4946), Color(0xFFAF4946)], textColor: Color(0xFF252532)));
  298. } else {
  299. return Container();
  300. }
  301. }
  302. List<TextSpan> _tipContent(content, context) {
  303. // String content = '很遗憾,你在2019-06-05 09:23开始的游戏竞赛 [15166的吃鸡房间],[无有效结果],无法获得奖励,该局参赛人数[2]人。';
  304. List<String> contentlist1 = content.split('[');
  305. List<Map> totalContent = [];
  306. contentlist1.forEach((item) {
  307. List _list = item.split(']');
  308. if (_list.length > 1) {
  309. totalContent.add({
  310. "content": _list[0],
  311. "isImport": true,
  312. });
  313. totalContent.add({
  314. "content": _list[1],
  315. "isImport": false,
  316. });
  317. } else {
  318. totalContent.add({
  319. "content": _list[0],
  320. "isImport": false,
  321. });
  322. }
  323. });
  324. List<TextSpan> _widgetList = [];
  325. totalContent.forEach((item) {
  326. if (item['isImport']) {
  327. _widgetList.add(TextSpan(text: ' ' + item['content'] + ' ', style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w600)));
  328. } else {
  329. _widgetList.add(TextSpan(text: item['content']));
  330. }
  331. });
  332. return _widgetList;
  333. }
  334. Widget _resultContent(HouseInfo houseInfo, PlayerInfo playerInfo, int typeFlag) {
  335. List jiangpaiImg = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png', 'images/jiangpai_bojin.png'];
  336. String img = '';
  337. if (playerInfo != null) {
  338. if (playerInfo.medal == 'platinum') {
  339. img = jiangpaiImg[3];
  340. } else if (playerInfo.medal == 'gold') {
  341. img = jiangpaiImg[0];
  342. } else if (playerInfo.medal == 'silver') {
  343. img = jiangpaiImg[1];
  344. } else if (playerInfo.medal == 'bronze') {
  345. img = jiangpaiImg[2];
  346. }
  347. }
  348. return Column(children: <Widget>[
  349. (typeFlag != 4 && typeFlag != 5 && playerInfo != null && !playerInfo.dataError && typeFlag!=0)
  350. ? Container(
  351. margin: EdgeInsets.fromLTRB(15, 10, 15, 0),
  352. padding: EdgeInsets.all(15),
  353. height: 80,
  354. decoration: BoxDecoration(color: Color(0xFF3A3E61), borderRadius: BorderRadius.all(Radius.circular(4))),
  355. child: Column(
  356. crossAxisAlignment: CrossAxisAlignment.start,
  357. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  358. children: <Widget>[
  359. Text('和平精英游戏结果', style: TextStyle(color: Colors.white54, fontSize: 13)),
  360. Row(
  361. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  362. children: <Widget>[
  363. Text.rich(TextSpan(children: [
  364. TextSpan(text: "名次 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  365. TextSpan(text: '${playerInfo.ranking}', style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14)),
  366. ])),
  367. Text.rich(TextSpan(children: [
  368. TextSpan(text: "时长 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  369. TextSpan(text: playerInfo.liveTime != null ? '${playerInfo.liveTime}' : '0', style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14)),
  370. ])),
  371. Text.rich(TextSpan(children: [
  372. TextSpan(text: "评分 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  373. TextSpan(text: '${playerInfo.score}', style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14)),
  374. ])),
  375. ],
  376. )
  377. ],
  378. ),
  379. )
  380. : Container(),
  381. Container(
  382. margin: EdgeInsets.symmetric(vertical: 5, horizontal: 15),
  383. padding: EdgeInsets.all(15),
  384. height: 140,
  385. decoration: BoxDecoration(color: Color(0xFF3A3E61), borderRadius: BorderRadius.all(Radius.circular(4))),
  386. child: Column(
  387. crossAxisAlignment: CrossAxisAlignment.start,
  388. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  389. children: <Widget>[
  390. Text('比赛结果', style: TextStyle(color: Colors.white54, fontSize: 13)),
  391. Row(
  392. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  393. children: <Widget>[Text("参数成员 ", style: TextStyle(color: Colors.white, fontSize: 14)), Text("${houseInfo.playerNumber}人 ", style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))],
  394. ),
  395. Row(
  396. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  397. children: <Widget>[Text("是否吃鸡 ", style: TextStyle(color: Colors.white, fontSize: 14)), Text(playerInfo.ranking == 1 ? '是' : '否', style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))],
  398. ),
  399. Row(
  400. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  401. children: <Widget>[
  402. Text("获得奖牌 ", style: TextStyle(color: Colors.white, fontSize: 14)),
  403. img != ''
  404. ? Row(
  405. children: <Widget>[
  406. Image.asset(
  407. img,
  408. width: 20,
  409. ),
  410. Text("+1", style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
  411. ],
  412. )
  413. : Text("无", style: TextStyle(color: Color(0xFFFFB726), fontWeight: FontWeight.w500, fontSize: 14))
  414. ],
  415. )
  416. ],
  417. ),
  418. )
  419. ]);
  420. }
  421. }
  422. //比赛结束排名
  423. class RankContent extends StatefulWidget {
  424. RankContent({Key key, this.roomId}) : super(key: key);
  425. final String roomId; // 用来储存传递过来的值
  426. @override
  427. RankContentState createState() => RankContentState();
  428. }
  429. class RankContentState extends State<RankContent> {
  430. List<PlayerInfo> topList = [];
  431. Future<void> getTopList() async {
  432. Toast.show(context, '加载中', -1, 'loading');
  433. Result res = await HttpManager.get('playerInfo/rankPage', data: {'houseId': widget.roomId, 'currentPage': 1, 'pageNumber': 3});
  434. Toast.hide();
  435. List<PlayerInfo> list = [];
  436. if (res.success) {
  437. for (var item in res.data['pp']) {
  438. PlayerInfo jonPlayer = PlayerInfo.fromJson(item);
  439. list.add(jonPlayer);
  440. }
  441. } else {}
  442. setState(() {
  443. topList = list;
  444. });
  445. }
  446. @override
  447. void initState() {
  448. super.initState();
  449. Future.delayed(Duration.zero, () {
  450. getTopList();
  451. });
  452. }
  453. @override
  454. Widget build(BuildContext context) {
  455. return Container(
  456. width: double.infinity,
  457. height: 180,
  458. margin: EdgeInsets.only(top: 15),
  459. child: Row(
  460. mainAxisAlignment: MainAxisAlignment.center,
  461. crossAxisAlignment: CrossAxisAlignment.end,
  462. children: <Widget>[_rankItem(2), _rankItem(1), _rankItem(3)],
  463. ),
  464. );
  465. }
  466. Widget _rankItem(int _num) {
  467. if (_num > topList.length) {
  468. return Container(
  469. width: 107,
  470. height: 60,
  471. );
  472. }
  473. List colorList = [
  474. [Color(0xFFD48E00), Color(0xFFFECF01)],
  475. [Color(0xFFC5C5C5), Color(0xFFE3E3E3)],
  476. [Color(0xFFE77023), Color(0xFFF89E58)]
  477. ];
  478. List imgList = ['images/jiangpai_huangjin.png', 'images/jiangpai_baiyin.png', 'images/jiangpai_qingtong.png'];
  479. return Container(
  480. padding: EdgeInsets.only(left: 15, right: 15, top: _num == 1 ? 0 : 15),
  481. width: 107,
  482. child: Column(
  483. crossAxisAlignment: CrossAxisAlignment.center,
  484. children: <Widget>[
  485. Container(
  486. child: Stack(
  487. children: <Widget>[
  488. Container(
  489. margin: EdgeInsets.only(top: 17, bottom: 20),
  490. width: _num == 1 ? 70 : 60,
  491. height: _num == 1 ? 70 : 60,
  492. decoration: BoxDecoration(
  493. gradient: LinearGradient(colors: colorList[_num - 1], begin: Alignment.topLeft, end: Alignment.bottomRight),
  494. borderRadius: BorderRadius.all(Radius.circular(100)),
  495. ),
  496. child: Center(
  497. child: Container(
  498. width: _num == 1 ? 60 : 50,
  499. height: _num == 1 ? 60 : 50,
  500. child: CircleAvatar(backgroundImage: NetworkImage(topList[_num - 1].userInfo.icon)),
  501. )),
  502. ),
  503. Positioned(
  504. bottom: 0,
  505. child: Center(
  506. child: Image.asset(
  507. 'images/ph_yinpai_no' + '$_num.png',
  508. width: 67,
  509. ),
  510. ),
  511. ),
  512. Positioned(
  513. top: 0,
  514. left: _num == 1 ? 19 : 14,
  515. child: Center(
  516. child: Image.asset(
  517. imgList[_num - 1],
  518. ),
  519. ),
  520. ),
  521. ],
  522. ),
  523. ),
  524. Text(
  525. topList[_num - 1].userInfo.nickname,
  526. style: TextStyle(
  527. color: Color(0xFFFDC372),
  528. fontSize: 12,
  529. ),
  530. overflow: TextOverflow.ellipsis,
  531. textAlign: TextAlign.center,
  532. ),
  533. // SizedBox(
  534. // height: 5,
  535. // ),
  536. // Row(
  537. // mainAxisAlignment: MainAxisAlignment.center,
  538. // children: <Widget>[
  539. // Image.asset('images/icon_jinbi_xiao_hong.png', width: 20),
  540. // Text('×' + (topList[_num - 1].bonus != null ? topList[_num - 1].bonus.toString() : '0'), style: TextStyle(color: PRIMARY_COLOR, fontSize: 12))
  541. // ],
  542. // )
  543. ],
  544. ),
  545. );
  546. }
  547. }