set_alipay_page.dart 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import 'package:bbyyy/https/MyDio.dart';
  2. import 'package:bbyyy/my_tools/my_colors.dart';
  3. import 'package:bbyyy/my_tools/my_cookie.dart';
  4. import 'package:bbyyy/my_tools/my_tools.dart';
  5. import 'package:bbyyy/my_tools/my_views.dart';
  6. import 'package:flutter/cupertino.dart';
  7. import 'package:flutter/material.dart';
  8. class SetAlipayPage extends StatefulWidget {
  9. @override
  10. _SetAlipayPageState createState() => _SetAlipayPageState();
  11. }
  12. class _SetAlipayPageState extends State<SetAlipayPage> {
  13. TextEditingController controller = TextEditingController();
  14. @override
  15. void initState() {
  16. // TODO: implement initState
  17. super.initState();
  18. if(MyCookie().userBean.aliPayAccount!=null&&MyCookie().userBean.aliPayAccount!=''){
  19. controller.text = MyCookie().userBean.aliPayAccount;
  20. }
  21. }
  22. @override
  23. Widget build(BuildContext context) {
  24. return GestureDetector(
  25. onTap: () {
  26. MyTools().hideKeyboard(context);
  27. },
  28. behavior: HitTestBehavior.translucent,
  29. child: Scaffold(
  30. backgroundColor: Colors.white,
  31. body: Column(
  32. children: [
  33. MyViews().myAppBar('绑定支付宝账号', context, []),
  34. Expanded(
  35. child: SingleChildScrollView(
  36. child: Column(
  37. children: [
  38. Container(
  39. height: 10,
  40. color: MyColors.cF7F7F7,
  41. ),
  42. Container(
  43. child: MyViews().myText('绑定支付宝账号 ', MyColors.c333333, 15),
  44. margin:
  45. EdgeInsets.symmetric(horizontal: 16, vertical: 17),
  46. ),
  47. Container(
  48. decoration: BoxDecoration(
  49. border: Border.all(color: MyColors.cE7E7E7, width: 1),
  50. borderRadius: BorderRadius.circular(4),
  51. ),
  52. margin: EdgeInsets.symmetric(horizontal: 16),
  53. padding: EdgeInsets.all(12),
  54. child: TextField(
  55. controller: controller,
  56. cursorColor: MyColors.cFF4233,
  57. cursorWidth: 1.0,
  58. onTap: () {},
  59. decoration: InputDecoration(
  60. border: InputBorder.none,
  61. disabledBorder: InputBorder.none,
  62. enabledBorder: InputBorder.none,
  63. focusedBorder: InputBorder.none,
  64. isDense: true,
  65. hintText: '请输入支付宝账号',
  66. hintStyle:
  67. TextStyle(color: MyColors.c999999, fontSize: 16),
  68. contentPadding:
  69. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
  70. ),
  71. maxLines: 1,
  72. style: TextStyle(
  73. color: MyColors.c333333,
  74. fontSize: 16,
  75. height: 1.3,
  76. letterSpacing: 0.2),
  77. keyboardType: TextInputType.text,
  78. onChanged: (t) {},
  79. ),
  80. ),
  81. GestureDetector(
  82. onTap: () {
  83. if (controller.text.isEmpty) {
  84. showToast('请填写支付宝账号');
  85. return;
  86. }
  87. MyTools().hideKeyboard(context);
  88. saveAlipayNum();
  89. },
  90. behavior: HitTestBehavior.translucent,
  91. child: Container(
  92. decoration: BoxDecoration(
  93. borderRadius: BorderRadius.circular(22.5),
  94. color: MyColors.cFF4233),
  95. height: 45,
  96. margin:
  97. EdgeInsets.symmetric(horizontal: 63, vertical: 157),
  98. child: MyViews().myText('确定修改', Colors.white, 15),
  99. alignment: Alignment.center,
  100. ),
  101. )
  102. ],
  103. crossAxisAlignment: CrossAxisAlignment.start,
  104. ),
  105. ),
  106. ),
  107. ],
  108. ),
  109. ),
  110. );
  111. }
  112. void saveAlipayNum() {
  113. MyDio().update({
  114. "key": "user",
  115. "values": {
  116. "name": MyCookie().loginInformation.data.extra.name,
  117. "picture": MyCookie().loginInformation.data.extra.picture,
  118. "id": MyCookie().loginInformation.data.extra.id,
  119. "alipay_account": controller.text.toString()
  120. }
  121. }, (response, hasError) {
  122. if (!hasError) {
  123. MyCookie().userBean.aliPayAccount = controller.text.toString();
  124. Navigator.pop(context);
  125. }
  126. }, (error) {});
  127. }
  128. }