band_account.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. // provider.dispose();
  72. super.dispose();
  73. }
  74. @override
  75. Widget build(BuildContext context) {
  76. double width = MediaQuery.of(context).size.width;
  77. double height = MediaQuery.of(context).size.height;
  78. return ChangeNotifierProvider<UserProvider>(
  79. create: (_) => provider,
  80. child: Container(
  81. child: Scaffold(
  82. resizeToAvoidBottomPadding: false,
  83. appBar: MyAppBar(
  84. centerTitle: "绑定账号",
  85. ),
  86. body: Consumer<UserProvider>(builder: (_, provider, __) {
  87. return ListView(
  88. padding: EdgeInsets.all(0.0),
  89. children: <Widget>[
  90. ClickItem(
  91. title: "支付宝账号",
  92. content: "${provider.user?.alipayAccount ?? ""}",
  93. onTap: () {
  94. // NavigatorUtils.push(context, BbsRouter.videoDetail);
  95. // Navigator.of(context).push(
  96. // MaterialPageRoute(
  97. // builder: (context) {
  98. // return EditTextPage(
  99. // title: "编辑支付宝账号",
  100. // value: provider.user?.alipayAccount ?? "",
  101. // mType: 0,
  102. // );
  103. // },
  104. // ),
  105. // ).then(
  106. // (value) {
  107. // if (value != null) {
  108. // print(value);
  109. // updateUser(value);
  110. // }
  111. // },
  112. // );
  113. if(provider.user?.alipayAccount != null){
  114. _alipayController.text = provider.user?.alipayAccount;
  115. }
  116. if(provider.user?.alipayRealName != null){
  117. _nameController.text = provider.user?.alipayRealName;
  118. }
  119. // showDialog(
  120. // context: context,
  121. // barrierDismissible: true, // 是否可以点击底部遮罩层取消dialog
  122. // // child: Text('data')
  123. // builder: (context) {
  124. // return Container(
  125. // color:Colors.white,
  126. // width: 300,
  127. // // width: width*0.6,
  128. // height: 300,
  129. // // height: height*0.6,
  130. // child: Column(
  131. // children: <Widget>[
  132. // TextFieldItem(
  133. // title: "支付宝账号",
  134. // isMust: true,
  135. // content: _alipayController.text,
  136. // controller: _alipayController,
  137. // hintText: "请输入您的支付宝账号",
  138. // ),
  139. // TextFieldItem(
  140. // title: "真实姓名",
  141. // isMust: true,
  142. // content: _nameController.text,
  143. // controller: _nameController,
  144. // hintText: "请输入您的真实姓名",
  145. // ),
  146. // Container(
  147. // child: Row(
  148. // children: <Widget>[
  149. // FlatButton(
  150. // color: Color(0xffcccccc),
  151. // child: Text('取消',style: TextStyle(color:Colors.white),),
  152. // onPressed: (){
  153. // Navigator.maybePop(context);
  154. // _nameController.text = "";
  155. // _alipayController.text = "";
  156. // },
  157. // ),
  158. // Container(
  159. // height:36,
  160. // decoration: BoxDecoration(
  161. // gradient: const LinearGradient(
  162. // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  163. // ),
  164. // child: FlatButton(
  165. // child: Text('确认',style: TextStyle(color:Colors.white),),
  166. // onPressed: (){
  167. // if(_alipayController.text == null || _alipayController.text.trim()==""){
  168. // toasts("请输入您的支付宝账号");
  169. // return;
  170. // }
  171. // if(_nameController.text == null || _nameController.text.trim()==""){
  172. // toasts("请输入您的真实姓名");
  173. // return;
  174. // }
  175. // updateUser();
  176. // },
  177. // ),
  178. // ),
  179. // ],
  180. // ),
  181. // )
  182. // ],
  183. // )
  184. // );
  185. // }
  186. // );
  187. showDialog(
  188. context: context,
  189. builder: (context) {
  190. return new AlertDialog(
  191. // title: new Text(""),
  192. content: Container(
  193. child:
  194. // Text("123")
  195. Column(
  196. crossAxisAlignment: CrossAxisAlignment.start,
  197. children: <Widget>[
  198. Container(
  199. child: Text(
  200. "您的支付宝账号:",
  201. textAlign: TextAlign.left,
  202. style: TextStyle(
  203. fontSize: ScreenUtil().setSp(18),
  204. ),
  205. ),
  206. ),
  207. SizedBox(
  208. height:10
  209. ),
  210. Container(
  211. height: ScreenUtil().setWidth(30),
  212. child: TextField(
  213. controller: _alipayController,
  214. decoration: InputDecoration(
  215. contentPadding: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(5),),
  216. border: OutlineInputBorder(
  217. borderRadius: BorderRadius.circular(2.0),
  218. ),
  219. hintText: '请输入您的支付宝账号', // hint 暗示
  220. errorBorder: InputBorder.none, // 当error时的border
  221. filled: false, // 背景色
  222. focusedBorder: OutlineInputBorder(), // 当focus时的border
  223. ),
  224. cursorColor: Color(0xFF999999),
  225. obscureText: false, // 输入变成**
  226. onChanged: (val) {
  227. // xxx
  228. },
  229. ),
  230. ),
  231. SizedBox(
  232. height:20
  233. ),
  234. Container(
  235. child: Text(
  236. "您的真实姓名:",
  237. textAlign: TextAlign.left,
  238. style: TextStyle(
  239. fontSize: ScreenUtil().setSp(18),
  240. ),
  241. ),
  242. ),
  243. SizedBox(
  244. height:10
  245. ),
  246. Container(
  247. height: ScreenUtil().setWidth(30),
  248. child: TextField(
  249. controller: _nameController,
  250. decoration: InputDecoration(
  251. contentPadding: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(5),),
  252. border: OutlineInputBorder(
  253. borderRadius: BorderRadius.circular(2.0),
  254. ),
  255. hintText: '请输入您的真实姓名', // hint 暗示
  256. errorBorder: InputBorder.none, // 当error时的border
  257. filled: false, // 背景色
  258. focusedBorder: OutlineInputBorder(), // 当focus时的border
  259. ),
  260. cursorColor: Color(0xFF999999),
  261. obscureText: false, // 输入变成**
  262. onChanged: (val) {
  263. // xxx
  264. },
  265. ),
  266. ),
  267. ],
  268. ),
  269. ),
  270. actions: <Widget>[
  271. new FlatButton(
  272. onPressed: () {
  273. Navigator.of(context).pop();
  274. _nameController.text = "";
  275. _alipayController.text = "";
  276. },
  277. child: new Text("取消"),
  278. ),
  279. new FlatButton(
  280. onPressed: () {
  281. if(_alipayController.text == null || _alipayController.text.trim()==""){
  282. toasts("请输入您的支付宝账号");
  283. return;
  284. }
  285. if(_nameController.text == null || _nameController.text.trim()==""){
  286. toasts("请输入您的真实姓名");
  287. return;
  288. }
  289. updateUser();
  290. Navigator.of(context).pop();
  291. },
  292. child: new Text("确认"),
  293. ),
  294. ],
  295. );
  296. });
  297. },
  298. ),
  299. ]);
  300. })),
  301. ));
  302. }
  303. @override
  304. bool get wantKeepAlive => true;
  305. }