set_alipay_page.dart 9.0 KB

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