YSMine.dart 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:shared_preferences/shared_preferences.dart';
  5. import 'package:ysairplane/code/YSCollection.dart';
  6. import 'package:ysairplane/code/YSFeedback.dart';
  7. import 'package:ysairplane/code/YSMoney.dart';
  8. import 'package:ysairplane/code/YSSetting.dart';
  9. import 'package:ysairplane/code/YSTabbar.dart';
  10. import 'package:ysairplane/code/YSUserInfo.dart';
  11. import 'package:ysairplane/code/YSVipCode.dart';
  12. import 'package:ysairplane/tools/YSNetWorking.dart';
  13. import 'package:ysairplane/tools/YSTools.dart';
  14. class YSMine extends StatefulWidget {
  15. @override
  16. _YSMineState createState() => _YSMineState();
  17. }
  18. class _YSMineState extends State<YSMine> with AutomaticKeepAliveClientMixin{
  19. Map _msgDict;
  20. @override
  21. // TODO: implement wantKeepAlive
  22. bool get wantKeepAlive => true;
  23. @override
  24. void initState() {
  25. Future.delayed(Duration(seconds: 0)).then((value){
  26. _getUserData();
  27. });
  28. super.initState();
  29. }
  30. @override
  31. Widget build(BuildContext context) {
  32. super.build(context);
  33. return Scaffold(
  34. backgroundColor: Color(0xFFF5F6F8),
  35. body: SingleChildScrollView(
  36. child: Column(
  37. children: [
  38. Container(
  39. height: MediaQuery.of(context).padding.top+200,
  40. width: MediaQuery.of(context).size.width,
  41. decoration: BoxDecoration(
  42. color: Color(0xFF00A8FF),
  43. // image: DecorationImage(
  44. // image: AssetImage('lib/images/top.png'),
  45. // fit: BoxFit.fill
  46. // ),
  47. ),
  48. child: Stack(
  49. children: [
  50. Container(
  51. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+30,left: MediaQuery.of(context).size.width-50),
  52. child: Icon(Icons.settings,size: 25,color: Colors.white,),
  53. ),
  54. Container(
  55. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+100,left: 20,right: 10),
  56. height: 70,
  57. width: 70,
  58. decoration: BoxDecoration(
  59. color: Colors.white,
  60. borderRadius: BorderRadius.all(Radius.circular(35))
  61. ),
  62. child: _msgDict!=null?ClipRRect(
  63. borderRadius: BorderRadius.all(Radius.circular(35)),
  64. child: CachedNetworkImage(
  65. imageUrl: '${_msgDict['avatar']}',
  66. fit: BoxFit.fill,
  67. ),
  68. ):Container(),
  69. ),
  70. Container(
  71. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+110,left: 100),
  72. width: MediaQuery.of(context).size.width-150,
  73. child: Text(_msgDict!=null?'${_msgDict['nickname']}':'',style: TextStyle(fontSize: 18,color: Colors.white,fontWeight: FontWeight.bold),overflow: TextOverflow.ellipsis,),
  74. ),
  75. if(_msgDict!=null)Container(
  76. margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+145,left: 100),
  77. child: Row(
  78. children: [
  79. Container(
  80. child: Row(
  81. children: [
  82. Text(getSecretStr('${_msgDict['phoneNumber']}'),style: TextStyle(fontSize: 10,color: Colors.white),),
  83. Icon(Icons.keyboard_arrow_right,size: 15,color: Colors.white,),
  84. ],
  85. ),
  86. height: 20,
  87. alignment: Alignment.center,
  88. padding: EdgeInsets.only(left: 10,right: 5),
  89. decoration: BoxDecoration(
  90. color: Color(0xFF009DFF).withOpacity(0.6),
  91. borderRadius: BorderRadius.all(Radius.circular(10))
  92. ),
  93. ),
  94. // GestureDetector(
  95. // onTap: (){
  96. // Navigator.of(context,rootNavigator: true).push(
  97. // CupertinoPageRoute(
  98. // builder: (context){
  99. // return YSVipCode();
  100. // }
  101. // )
  102. // );
  103. // },
  104. // child: Container(
  105. // child: Row(
  106. // children: [
  107. // Icon(Icons.crop_square,size: 15,color: Colors.white,),
  108. // Text('会员码',style: TextStyle(fontSize: 10,color: Colors.white),),
  109. // ],
  110. // ),
  111. // height: 20,
  112. // alignment: Alignment.center,
  113. // margin: EdgeInsets.only(left: 5),
  114. // padding: EdgeInsets.only(left: 5,right: 10),
  115. // decoration: BoxDecoration(
  116. // color: Color(0xFF009DFF).withOpacity(0.6),
  117. // borderRadius: BorderRadius.all(Radius.circular(10))
  118. // ),
  119. // ),
  120. // )
  121. ],
  122. )
  123. ),
  124. GestureDetector(
  125. onTap: (){
  126. Navigator.of(context,rootNavigator: true).push(
  127. CupertinoPageRoute(
  128. builder: (context){
  129. return YSUserInfo();
  130. }
  131. )
  132. );
  133. },
  134. child: Container(
  135. margin: EdgeInsets.only(left: MediaQuery.of(context).size.width-50,top: MediaQuery.of(context).padding.top+120),
  136. child: Icon(Icons.keyboard_arrow_right,size: 30,color: Colors.white,),
  137. ),
  138. )
  139. ],
  140. ),
  141. ),
  142. Container(
  143. child: ListView.separated(
  144. shrinkWrap: true,
  145. itemBuilder: (context,index){
  146. return GestureDetector(
  147. onTap: (){
  148. if(index==1){
  149. ShowNotification(true).dispatch(context);
  150. }else{
  151. Navigator.of(context,rootNavigator: true).push(
  152. CupertinoPageRoute(
  153. builder: (context){
  154. return index==0?YSMoney():index==2?YSCollection():index==3?YSFeedback():YSSetting();
  155. }
  156. )
  157. );
  158. }
  159. },
  160. child: Container(
  161. height: 50,
  162. color: Colors.white,
  163. padding: EdgeInsets.only(left: 15,right: 15),
  164. child: Row(
  165. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  166. children: [
  167. Row(
  168. children: [
  169. Container(
  170. child: Image.asset(index==0?'lib/images/money.png':index==1?'lib/images/travel.png':index==2?
  171. 'lib/images/collection.png':index==3?'lib/images/feedback.png':'lib/images/setting.png'),
  172. height: 20,
  173. width: 20,
  174. margin: EdgeInsets.only(right: 13),
  175. ),
  176. Text(index==0?'钱包':index==1?'行程':index==2?'收藏':index==3?'反馈':'设置',style: TextStyle(fontSize: 16,color: Color(0xFF000000)),)
  177. ],
  178. ),
  179. Icon(Icons.keyboard_arrow_right,size: 25,color: Color(0xFFCDCDCD),)
  180. ],
  181. ),
  182. ),
  183. );
  184. },
  185. separatorBuilder: (context,index){
  186. return Container(
  187. color: Color(0xFFF5F6F8),
  188. height: index==0||index==3?10:0.5,
  189. );
  190. },
  191. itemCount: 5,
  192. padding: EdgeInsets.all(0),
  193. physics: NeverScrollableScrollPhysics(),
  194. ),
  195. )
  196. ],
  197. ),
  198. ),
  199. );
  200. }
  201. _getUserData() async{
  202. SharedPreferences prefer = await SharedPreferences.getInstance();
  203. Map dict = await ysRequestHttp(context, type: requestType.get, api: '/app/applets/center/info', parameter: {},
  204. isLoading: false,refresh: (){},isToken: true);
  205. if(dict!=null){
  206. setState(() {
  207. _msgDict = dict['data'];
  208. prefer.setString('name', '${_msgDict['nickname']}');
  209. prefer.setString('phone', '${_msgDict['phoneNumber']}');
  210. prefer.setString('avatar', '${_msgDict['avatar']}');
  211. });
  212. }
  213. }
  214. }