set_alipay_page.dart 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. TextEditingController name = TextEditingController();
  15. @override
  16. void initState() {
  17. // TODO: implement initState
  18. super.initState();
  19. if (MyCookie().userBean.aliPayAccount != null &&
  20. MyCookie().userBean.aliPayAccount != '') {
  21. controller.text = MyCookie().userBean.aliPayAccount;
  22. name.text = MyCookie().userBean.aliPayName;
  23. }
  24. }
  25. @override
  26. Widget build(BuildContext context) {
  27. return GestureDetector(
  28. onTap: () {
  29. MyTools().hideKeyboard(context);
  30. },
  31. behavior: HitTestBehavior.translucent,
  32. child: Scaffold(
  33. backgroundColor: Colors.white,
  34. body: Column(
  35. children: [
  36. MyViews().myAppBar('绑定支付宝账号', context, []),
  37. Expanded(
  38. child: SingleChildScrollView(
  39. child: Column(
  40. children: [
  41. Container(
  42. height: 10,
  43. color: MyColors.cF7F7F7,
  44. ),
  45. Container(
  46. child: MyViews().myText('支付宝账号 ', MyColors.c333333, 15),
  47. margin:
  48. EdgeInsets.symmetric(horizontal: 16, vertical: 17),
  49. ),
  50. Container(
  51. decoration: BoxDecoration(
  52. border: Border.all(color: MyColors.cE7E7E7, width: 1),
  53. borderRadius: BorderRadius.circular(4),
  54. ),
  55. margin: EdgeInsets.symmetric(horizontal: 16),
  56. padding: EdgeInsets.all(12),
  57. child: TextField(
  58. controller: controller,
  59. cursorColor: MyColors.cFF4233,
  60. cursorWidth: 1.0,
  61. onTap: () {},
  62. decoration: InputDecoration(
  63. border: InputBorder.none,
  64. disabledBorder: InputBorder.none,
  65. enabledBorder: InputBorder.none,
  66. focusedBorder: InputBorder.none,
  67. isDense: true,
  68. hintText: '请输入支付宝账号',
  69. hintStyle:
  70. TextStyle(color: MyColors.c999999, fontSize: 16),
  71. contentPadding:
  72. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
  73. ),
  74. maxLines: 1,
  75. style: TextStyle(
  76. color: MyColors.c333333,
  77. fontSize: 16,
  78. height: 1.3,
  79. letterSpacing: 0.2),
  80. keyboardType: TextInputType.text,
  81. onChanged: (t) {},
  82. ),
  83. ),
  84. Container(
  85. child: MyViews().myText('账号持有人姓名', MyColors.c333333, 15),
  86. margin:
  87. EdgeInsets.symmetric(horizontal: 16, vertical: 17),
  88. ),
  89. Container(
  90. decoration: BoxDecoration(
  91. border: Border.all(color: MyColors.cE7E7E7, width: 1),
  92. borderRadius: BorderRadius.circular(4),
  93. ),
  94. margin: EdgeInsets.symmetric(horizontal: 16),
  95. padding: EdgeInsets.all(12),
  96. child: TextField(
  97. controller: name,
  98. cursorColor: MyColors.cFF4233,
  99. cursorWidth: 1.0,
  100. onTap: () {},
  101. decoration: InputDecoration(
  102. border: InputBorder.none,
  103. disabledBorder: InputBorder.none,
  104. enabledBorder: InputBorder.none,
  105. focusedBorder: InputBorder.none,
  106. isDense: true,
  107. hintText: '请输入支付宝账号',
  108. hintStyle:
  109. TextStyle(color: MyColors.c999999, fontSize: 16),
  110. contentPadding:
  111. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
  112. ),
  113. maxLines: 1,
  114. style: TextStyle(
  115. color: MyColors.c333333,
  116. fontSize: 16,
  117. height: 1.3,
  118. letterSpacing: 0.2),
  119. keyboardType: TextInputType.text,
  120. onChanged: (t) {},
  121. ),
  122. ),
  123. Container(
  124. child: Text(
  125. '*应支付宝官方要求,提现必须提供支付宝账号和真实姓名',
  126. style: TextStyle(color: MyColors.cFF4233, fontSize: 12),
  127. ),
  128. margin: EdgeInsets.only(top: 10, left: 16, right: 16),
  129. ),
  130. Container(
  131. margin:
  132. EdgeInsets.symmetric(horizontal: 63, vertical: 157),
  133. child: GestureDetector(
  134. onTap: () {
  135. if (controller.text.isEmpty) {
  136. showToast('请填写支付宝账号');
  137. return;
  138. }
  139. if (name.text.isEmpty) {
  140. showToast('请填写账号绑定人姓名');
  141. return;
  142. }
  143. MyTools().hideKeyboard(context);
  144. saveAlipayNum();
  145. },
  146. behavior: HitTestBehavior.translucent,
  147. child: Container(
  148. decoration: BoxDecoration(
  149. borderRadius: BorderRadius.circular(22.5),
  150. color: MyColors.cFF4233),
  151. height: 45,
  152. child: MyViews().myText('确定修改', Colors.white, 15),
  153. alignment: Alignment.center,
  154. ),
  155. ),
  156. )
  157. ],
  158. crossAxisAlignment: CrossAxisAlignment.start,
  159. ),
  160. ),
  161. ),
  162. ],
  163. ),
  164. ),
  165. );
  166. }
  167. void saveAlipayNum() {
  168. MyDio().update({
  169. "key": "user",
  170. "values": {
  171. "name": MyCookie().loginInformation.data.extra.name,
  172. "picture": MyCookie().loginInformation.data.extra.picture,
  173. "id": MyCookie().loginInformation.data.extra.id,
  174. "alipay_account": controller.text.toString(),
  175. "alipay_name": name.text.toString()
  176. }
  177. }, (response, hasError) {
  178. if (!hasError) {
  179. MyCookie().userBean.aliPayAccount = controller.text.toString();
  180. MyCookie().userBean.aliPayName = name.text.toString();
  181. Navigator.pop(context);
  182. }
  183. }, (error) {});
  184. }
  185. }