band_account.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. import 'package:liftmanager/res/gaps.dart';
  4. import 'package:liftmanager/net/api_service.dart';
  5. import 'package:liftmanager/utils/toast.dart';
  6. import 'package:liftmanager/widgets/app_bar.dart';
  7. import 'package:liftmanager/internal/search/search_router.dart';
  8. import 'package:liftmanager/widgets/app_search_bar.dart';
  9. import 'package:liftmanager/utils/image_utils.dart';
  10. import 'package:liftmanager/res/resources.dart';
  11. import 'package:liftmanager/routers/fluro_navigator.dart';
  12. import 'package:liftmanager/widgets/load_image.dart';
  13. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  14. import 'package:liftmanager/widgets/click_item.dart';
  15. import 'package:flutter_screenutil/flutter_screenutil.dart';
  16. import 'package:provider/provider.dart';
  17. import 'package:liftmanager/internal/account/account_router.dart';
  18. import 'package:liftmanager/common/common.dart';
  19. import 'package:liftmanager/internal/account/provider/user_provider.dart';
  20. import 'package:liftmanager/internal/account/model/user_info_entity.dart';
  21. import 'package:liftmanager/internal/team/team_router.dart';
  22. import 'package:liftmanager/common/user_db.dart';
  23. import 'package:liftmanager/internal/wode/page/edit_text_page.dart';
  24. import 'package:image_picker/image_picker.dart';
  25. import 'package:liftmanager/utils/utils.dart';
  26. import 'package:liftmanager/internal/wode/wode_router.dart';
  27. import 'package:flustars/flustars.dart' as FlutterStars;
  28. import 'package:liftmanager/widgets/text_field_item.dart';
  29. class BandAccount extends StatefulWidget {
  30. @override
  31. State<StatefulWidget> createState() {
  32. return BandAccountState();
  33. }
  34. }
  35. class BandAccountState extends State<BandAccount>
  36. with AutomaticKeepAliveClientMixin {
  37. // PersonalPageState({Key key}) : super(key: key);
  38. UserProvider provider = UserProvider();
  39. TextEditingController _nameController = new TextEditingController();
  40. TextEditingController _alipayController = new TextEditingController();
  41. @override
  42. void initState() {
  43. super.initState();
  44. getUserInfo();
  45. }
  46. ///获取用户信息
  47. void getUserInfo() {
  48. ApiService().userInfo(
  49. onSuccess: (data) {
  50. setUser(data);
  51. },
  52. onError: (code, msg) {});
  53. }
  54. void setUser(UserInfoEntity user) {
  55. provider.setUser(user);
  56. }
  57. updateUser(){
  58. NewApiService().updateUser({
  59. "userId":FlutterStars.SpUtil.getString(Constant.userId),
  60. "alipayAccount":_alipayController.text,
  61. "alipayRealName":_nameController.text
  62. }, onSuccess: (res) {
  63. getUserInfo();
  64. setState(() {});
  65. }, onError: (code, msg) {
  66. toasts(msg);
  67. });
  68. }
  69. @override
  70. void dispose() {
  71. super.dispose();
  72. }
  73. @override
  74. Widget build(BuildContext context) {
  75. double width = MediaQuery.of(context).size.width;
  76. double height = MediaQuery.of(context).size.height;
  77. return ChangeNotifierProvider<UserProvider>(
  78. create: (_) => provider,
  79. child: Container(
  80. child: Scaffold(
  81. resizeToAvoidBottomPadding: false,
  82. appBar: MyAppBar(
  83. centerTitle: "绑定账号",
  84. ),
  85. body: Consumer<UserProvider>(builder: (_, provider, __) {
  86. return ListView(
  87. padding: EdgeInsets.all(0.0),
  88. children: <Widget>[
  89. ClickItem(
  90. title: "支付宝账号",
  91. content: "${provider.user?.alipayAccount ?? ""}",
  92. onTap: () {
  93. // NavigatorUtils.push(context, BbsRouter.videoDetail);
  94. // Navigator.of(context).push(
  95. // MaterialPageRoute(
  96. // builder: (context) {
  97. // return EditTextPage(
  98. // title: "编辑支付宝账号",
  99. // value: provider.user?.alipayAccount ?? "",
  100. // mType: 0,
  101. // );
  102. // },
  103. // ),
  104. // ).then(
  105. // (value) {
  106. // if (value != null) {
  107. // print(value);
  108. // updateUser(value);
  109. // }
  110. // },
  111. // );
  112. if(provider.user?.alipayAccount != null){
  113. _alipayController.text = provider.user?.alipayAccount;
  114. }
  115. if(provider.user?.alipayRealName != null){
  116. _nameController.text = provider.user?.alipayRealName;
  117. }
  118. // showDialog(
  119. // context: context,
  120. // barrierDismissible: true, // 是否可以点击底部遮罩层取消dialog
  121. // // child: Text('data')
  122. // builder: (context) {
  123. // return Container(
  124. // color:Colors.white,
  125. // width: 300,
  126. // // width: width*0.6,
  127. // height: 300,
  128. // // height: height*0.6,
  129. // child: Column(
  130. // children: <Widget>[
  131. // TextFieldItem(
  132. // title: "支付宝账号",
  133. // isMust: true,
  134. // content: _alipayController.text,
  135. // controller: _alipayController,
  136. // hintText: "请输入您的支付宝账号",
  137. // ),
  138. // TextFieldItem(
  139. // title: "真实姓名",
  140. // isMust: true,
  141. // content: _nameController.text,
  142. // controller: _nameController,
  143. // hintText: "请输入您的真实姓名",
  144. // ),
  145. // Container(
  146. // child: Row(
  147. // children: <Widget>[
  148. // FlatButton(
  149. // color: Color(0xffcccccc),
  150. // child: Text('取消',style: TextStyle(color:Colors.white),),
  151. // onPressed: (){
  152. // Navigator.maybePop(context);
  153. // _nameController.text = "";
  154. // _alipayController.text = "";
  155. // },
  156. // ),
  157. // Container(
  158. // height:36,
  159. // decoration: BoxDecoration(
  160. // gradient: const LinearGradient(
  161. // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  162. // ),
  163. // child: FlatButton(
  164. // child: Text('确认',style: TextStyle(color:Colors.white),),
  165. // onPressed: (){
  166. // if(_alipayController.text == null || _alipayController.text.trim()==""){
  167. // toasts("请输入您的支付宝账号");
  168. // return;
  169. // }
  170. // if(_nameController.text == null || _nameController.text.trim()==""){
  171. // toasts("请输入您的真实姓名");
  172. // return;
  173. // }
  174. // updateUser();
  175. // },
  176. // ),
  177. // ),
  178. // ],
  179. // ),
  180. // )
  181. // ],
  182. // )
  183. // );
  184. // }
  185. // );
  186. showDialog(
  187. context: context,
  188. builder: (context) {
  189. return new AlertDialog(
  190. // title: new Text(""),
  191. content: Container(
  192. child:
  193. // Text("123")
  194. Column(
  195. crossAxisAlignment: CrossAxisAlignment.start,
  196. children: <Widget>[
  197. Container(
  198. child: Text(
  199. "您的支付宝账号:",
  200. textAlign: TextAlign.left,
  201. style: TextStyle(
  202. fontSize: ScreenUtil().setSp(18),
  203. ),
  204. ),
  205. ),
  206. SizedBox(
  207. height:10
  208. ),
  209. Container(
  210. height: ScreenUtil().setWidth(30),
  211. child: TextField(
  212. controller: _alipayController,
  213. decoration: InputDecoration(
  214. contentPadding: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(5),),
  215. border: OutlineInputBorder(
  216. borderRadius: BorderRadius.circular(2.0),
  217. ),
  218. hintText: '请输入您的支付宝账号', // hint 暗示
  219. errorBorder: InputBorder.none, // 当error时的border
  220. filled: false, // 背景色
  221. focusedBorder: OutlineInputBorder(), // 当focus时的border
  222. ),
  223. cursorColor: Color(0xFF999999),
  224. obscureText: false, // 输入变成**
  225. onChanged: (val) {
  226. // xxx
  227. },
  228. ),
  229. ),
  230. SizedBox(
  231. height:20
  232. ),
  233. Container(
  234. child: Text(
  235. "您的真实姓名:",
  236. textAlign: TextAlign.left,
  237. style: TextStyle(
  238. fontSize: ScreenUtil().setSp(18),
  239. ),
  240. ),
  241. ),
  242. SizedBox(
  243. height:10
  244. ),
  245. Container(
  246. height: ScreenUtil().setWidth(30),
  247. child: TextField(
  248. controller: _nameController,
  249. decoration: InputDecoration(
  250. contentPadding: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(5),),
  251. border: OutlineInputBorder(
  252. borderRadius: BorderRadius.circular(2.0),
  253. ),
  254. hintText: '请输入您的真实姓名', // hint 暗示
  255. errorBorder: InputBorder.none, // 当error时的border
  256. filled: false, // 背景色
  257. focusedBorder: OutlineInputBorder(), // 当focus时的border
  258. ),
  259. cursorColor: Color(0xFF999999),
  260. obscureText: false, // 输入变成**
  261. onChanged: (val) {
  262. // xxx
  263. },
  264. ),
  265. ),
  266. ],
  267. ),
  268. ),
  269. actions: <Widget>[
  270. new FlatButton(
  271. onPressed: () {
  272. Navigator.of(context).pop();
  273. _nameController.text = "";
  274. _alipayController.text = "";
  275. },
  276. child: new Text("取消"),
  277. ),
  278. new FlatButton(
  279. onPressed: () {
  280. if(_alipayController.text == null || _alipayController.text.trim()==""){
  281. toasts("请输入您的支付宝账号");
  282. return;
  283. }
  284. if(_nameController.text == null || _nameController.text.trim()==""){
  285. toasts("请输入您的真实姓名");
  286. return;
  287. }
  288. updateUser();
  289. Navigator.of(context).pop();
  290. },
  291. child: new Text("确认"),
  292. ),
  293. ],
  294. );
  295. });
  296. },
  297. ),
  298. ]);
  299. })),
  300. ));
  301. }
  302. @override
  303. bool get wantKeepAlive => true;
  304. }