UserPage.dart 12 KB

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