UserPage.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import 'package:flutter/material.dart';
  2. import 'package:redux/redux.dart';
  3. import 'package:flutter_redux/flutter_redux.dart';
  4. import 'package:cached_network_image/cached_network_image.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import '../redux/AppState.dart';
  7. import '../model/UserInfo.dart';
  8. import '../pages/MyWallet.dart';
  9. import '../pages/BindGame.dart';
  10. import '../pages/RecordList.dart';
  11. import '../net/HttpManager.dart';
  12. import '../net/Result.dart';
  13. import '../redux/UserRedux.dart';
  14. import '../pages/UserChange.dart';
  15. import '../pages/MyTeam.dart';
  16. import '../pages/MyCode.dart';
  17. import '../widget/LinearButton.dart';
  18. import 'Setting.dart';
  19. import 'ShoppingMall.dart';
  20. import '../model/CustomerService.dart';
  21. class UserPage extends StatefulWidget {
  22. @override
  23. _UserPageState createState() => _UserPageState();
  24. }
  25. class _UserPageState extends State<UserPage> with WidgetsBindingObserver {
  26. CustomerService customerService;
  27. Future<void> getUserInfo() async {
  28. Result res = await HttpManager.get('userInfo/getUserInfo');
  29. if (res.success) {
  30. print(res.data);
  31. StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
  32. } else {}
  33. Result res2 = await HttpManager.get('customerService/random');
  34. if (res2.success) {
  35. setState(() {
  36. customerService = CustomerService.fromJson(res2.data);
  37. });
  38. }
  39. }
  40. @override
  41. void initState() {
  42. super.initState();
  43. Future.delayed(Duration.zero, () => getUserInfo());
  44. }
  45. @override
  46. Widget build(BuildContext context) {
  47. return StoreConnector<AppState, UserInfo>(
  48. converter: (Store store) => store.state.userInfo,
  49. builder: (context, userInfo) {
  50. return Scaffold(
  51. body: Container(
  52. color: Color(0xFF2E3049),
  53. height: double.infinity,
  54. width: double.infinity,
  55. child: SingleChildScrollView(
  56. child: Column(
  57. children: <Widget>[
  58. Container(
  59. height: 250,
  60. decoration: BoxDecoration(image: DecorationImage(image: AssetImage('images/info_img_bg.png'), fit: BoxFit.cover)),
  61. child: SafeArea(
  62. child: Column(
  63. mainAxisAlignment: MainAxisAlignment.center,
  64. children: <Widget>[
  65. InkWell(
  66. child: ClipOval(
  67. child: CachedNetworkImage(
  68. imageUrl: userInfo.icon,
  69. width: 76,
  70. height: 76,
  71. fit: BoxFit.cover,
  72. )),
  73. onTap: () {
  74. Navigator.push(context, CupertinoPageRoute(builder: (context) => UserChange()));
  75. },
  76. ),
  77. Container(
  78. height: 2,
  79. ),
  80. Text(
  81. userInfo.nickname,
  82. style: TextStyle(fontSize: 20, color: Colors.white, fontWeight: FontWeight.w700),
  83. ),
  84. Container(
  85. height: 5,
  86. ),
  87. Row(
  88. mainAxisAlignment: MainAxisAlignment.center,
  89. children: <Widget>[
  90. Text(
  91. '我的积分',
  92. style: TextStyle(fontSize: 14, color: Color(0xFFFFB726), fontWeight: FontWeight.w700),
  93. ),
  94. Container(
  95. width: 5,
  96. ),
  97. Image.asset('images/icon_jifen.png'),
  98. Text(
  99. 'x${userInfo.moneyCoin}',
  100. style: TextStyle(fontSize: 14, color: Color(0xFFFFB726), fontWeight: FontWeight.w700),
  101. ),
  102. Container(
  103. width: 10,
  104. ),
  105. customerService!=null?Text(
  106. '客服QQ:${customerService.qq}',
  107. style: TextStyle(fontSize: 14, color: Colors.white, fontWeight: FontWeight.w600),
  108. ):Container(),
  109. ],
  110. ),
  111. Container(
  112. height: 20,
  113. ),
  114. Row(
  115. mainAxisAlignment: MainAxisAlignment.spaceAround,
  116. children: <Widget>[
  117. // Container(
  118. // width: 165,
  119. // child: LinearButton(
  120. // btntext: '发起比赛',
  121. // btnHeight: 38.0,
  122. // colorList: [Colors.white, Colors.white],
  123. // textColor: Color(0xFF252532),
  124. // textSize: 13.0,
  125. // onTapHomeMenu: () {
  126. // Navigator.push(context, CupertinoPageRoute(builder: (context) => OpenRoom(roomFlag: '0')));
  127. // },
  128. // ),
  129. // ),
  130. Container(
  131. width: 250,
  132. child: LinearButton(
  133. btntext: '充值参赛券',
  134. btnHeight: 38.0,
  135. textSize: 13.0,
  136. onTapHomeMenu: () {
  137. Navigator.push(context, CupertinoPageRoute(builder: (context) => ShoppingMall()));
  138. },
  139. ))
  140. ],
  141. )
  142. ],
  143. ),
  144. ),
  145. ),
  146. DrawerMenu(
  147. 'images/info1.png',
  148. '我的参赛券',
  149. tipValue: userInfo.moneyTicket,
  150. onTap: () {
  151. Navigator.push(context, CupertinoPageRoute(builder: (context) => MyWallet()));
  152. },
  153. ),
  154. // Divder(),
  155. // DrawerMenu(
  156. // 'images/icon_fangka.png',
  157. // '房卡人数',
  158. // tipValue: userInfo.houseCard,
  159. // onTap: () {
  160. // Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomCardList()));
  161. // },
  162. // ),
  163. Divder(),
  164. DrawerMenu('images/icon_zhanji.png', '我的战绩', onTap: () {
  165. Navigator.push(context, CupertinoPageRoute(builder: (context) => RecordList()));
  166. }),
  167. Divder(),
  168. DrawerMenu(
  169. 'images/icon_bangding.png',
  170. '游戏绑定',
  171. onTap: () {
  172. Navigator.push(context, CupertinoPageRoute(builder: (context) => BindGame()));
  173. },
  174. ),
  175. Divder(),
  176. DrawerMenu(
  177. 'images/icon_tuandui.png',
  178. '我的团队',
  179. onTap: () {
  180. Navigator.push(context, CupertinoPageRoute(builder: (context) => MyTeam()));
  181. },
  182. ),
  183. Divder(),
  184. DrawerMenu(
  185. 'images/icon_tuiguangma.png',
  186. '我的推广码',
  187. onTap: () {
  188. Navigator.push(context, CupertinoPageRoute(builder: (context) => MyCode()));
  189. },
  190. )
  191. ],
  192. ),
  193. ),
  194. ),
  195. floatingActionButton: Container(
  196. width: 53,
  197. height: 130,
  198. // color: Colors.white,
  199. padding: EdgeInsets.fromLTRB(0, 90, 10, 0),
  200. child: GestureDetector(
  201. onTap: () {
  202. Navigator.push(context, CupertinoPageRoute(builder: (context) => Setting()));
  203. },
  204. child: Image.asset('images/info_icon_shezhi.png'))),
  205. floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
  206. );
  207. });
  208. }
  209. }
  210. typedef void OnDrawerMenuTap();
  211. class Divder extends StatelessWidget {
  212. @override
  213. Widget build(BuildContext context) {
  214. return Container(
  215. height: 1,
  216. padding: EdgeInsets.fromLTRB(55, 0, 15, 0),
  217. child: Container(
  218. decoration: BoxDecoration(color: Color(0x2E000000)),
  219. ),
  220. );
  221. }
  222. }
  223. class DrawerMenu extends StatelessWidget {
  224. final String icon;
  225. final String title;
  226. final OnDrawerMenuTap onTap;
  227. final num tipValue;
  228. DrawerMenu(this.icon, this.title, {this.onTap, this.tipValue});
  229. @override
  230. Widget build(BuildContext context) {
  231. return Container(
  232. height: 60,
  233. padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
  234. child: GestureDetector(
  235. onTap: onTap,
  236. child: Row(
  237. children: <Widget>[
  238. Image.asset(icon),
  239. Expanded(
  240. flex: 1,
  241. child: Container(
  242. margin: EdgeInsets.only(left: 16),
  243. child: Text(
  244. title,
  245. style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w400),
  246. ),
  247. ),
  248. ),
  249. tipValue != null
  250. ? Text(
  251. tipValue.toString(),
  252. style: TextStyle(fontSize: 13, color: Theme.of(context).primaryColor, fontWeight: FontWeight.w600),
  253. )
  254. : Container(),
  255. Image.asset('images/icon_inter.png')
  256. ],
  257. ),
  258. ),
  259. );
  260. }
  261. }