import 'package:bbyyy/https/MyDio.dart'; import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart'; import 'package:bbyyy/my_tools/my_colors.dart'; import 'package:bbyyy/my_tools/my_cookie.dart'; import 'package:bbyyy/my_tools/my_tools.dart'; import 'package:bbyyy/my_tools/my_views.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class SetAlipayPage extends StatefulWidget { @override _SetAlipayPageState createState() => _SetAlipayPageState(); } class _SetAlipayPageState extends State { TextEditingController controller = TextEditingController(); TextEditingController name = TextEditingController(); @override void initState() { // TODO: implement initState super.initState(); if (MyCookie().userBean.aliPayAccount != null && MyCookie().userBean.aliPayAccount != '') { controller.text = MyCookie().userBean.aliPayAccount; name.text = MyCookie().userBean.aliPayName; } } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { MyTools().hideKeyboard(context); }, behavior: HitTestBehavior.translucent, child: Scaffold( backgroundColor: Colors.white, body: Column( children: [ MyViews().myAppBar('绑定支付宝账号', context, [ // GestureDetector( // onTap: (){ // showSimpleDialog('确认删除该账号?', context, (){ // delAccountNumber(); // }); // }, // behavior: HitTestBehavior.translucent, // child: Container( // padding: EdgeInsets.symmetric(horizontal: 16,vertical: 5), // child: Text( // '删除', // style: TextStyle(color: MyColors.cFF4233, fontSize: 16), // ), // ), // ), ]), Expanded( child: SingleChildScrollView( child: Column( children: [ Container( height: 10, color: MyColors.cF7F7F7, ), Container( child: MyViews().myText('支付宝账号 ', MyColors.c333333, 15), margin: EdgeInsets.symmetric(horizontal: 16, vertical: 17), ), Container( decoration: BoxDecoration( border: Border.all(color: MyColors.cE7E7E7, width: 1), borderRadius: BorderRadius.circular(4), ), margin: EdgeInsets.symmetric(horizontal: 16), padding: EdgeInsets.all(12), child: TextField( controller: controller, cursorColor: MyColors.cFF4233, cursorWidth: 1.0, onTap: () {}, decoration: InputDecoration( border: InputBorder.none, disabledBorder: InputBorder.none, enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, isDense: true, hintText: '请输入支付宝账号', hintStyle: TextStyle(color: MyColors.c999999, fontSize: 16), contentPadding: const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5), ), maxLines: 1, style: TextStyle( color: MyColors.c333333, fontSize: 16, height: 1.3, letterSpacing: 0.2), keyboardType: TextInputType.text, onChanged: (t) {}, ), ), Container( child: MyViews().myText('账号持有人姓名', MyColors.c333333, 15), margin: EdgeInsets.symmetric(horizontal: 16, vertical: 17), ), Container( decoration: BoxDecoration( border: Border.all(color: MyColors.cE7E7E7, width: 1), borderRadius: BorderRadius.circular(4), ), margin: EdgeInsets.symmetric(horizontal: 16), padding: EdgeInsets.all(12), child: TextField( controller: name, cursorColor: MyColors.cFF4233, cursorWidth: 1.0, onTap: () {}, decoration: InputDecoration( border: InputBorder.none, disabledBorder: InputBorder.none, enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, isDense: true, hintText: '请填写账号绑定人姓名', hintStyle: TextStyle(color: MyColors.c999999, fontSize: 16), contentPadding: const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5), ), maxLines: 1, style: TextStyle( color: MyColors.c333333, fontSize: 16, height: 1.3, letterSpacing: 0.2), keyboardType: TextInputType.text, onChanged: (t) {}, ), ), Container( child: Text( '*应支付宝官方要求,提现必须提供支付宝账号和真实姓名', style: TextStyle(color: MyColors.cFF4233, fontSize: 12), ), margin: EdgeInsets.only(top: 10, left: 16, right: 16), ), Container( margin: EdgeInsets.symmetric(horizontal: 63, vertical: 157), child: GestureDetector( onTap: () { if (controller.text.isEmpty) { showToast('请填写支付宝账号'); return; } if (name.text.isEmpty) { showToast('请填写账号绑定人姓名'); return; } MyTools().hideKeyboard(context); saveAlipayNum(); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(22.5), color: MyColors.cFF4233), height: 45, child: MyViews().myText('确定修改', Colors.white, 15), alignment: Alignment.center, ), ), ) ], crossAxisAlignment: CrossAxisAlignment.start, ), ), ), ], ), ), ); } void saveAlipayNum() { EasyLoading.show(); MyDio().update({ "key": "user", "values": { "name": MyCookie().loginInformation.data.extra.name, "picture": MyCookie().loginInformation.data.extra.picture, "id": MyCookie().loginInformation.data.extra.id, "alipay_account": controller.text.toString(), "alipay_name": name.text.toString() } }, (response, hasError) { if (!hasError) { MyCookie().userBean.aliPayAccount = controller.text.toString(); MyCookie().userBean.aliPayName = name.text.toString(); showToast('绑定成功'); Navigator.pop(context); } }, (error) {}); } void delAccountNumber() { EasyLoading.show(); MyDio().update({ "key": "user", "values": { "name": MyCookie().loginInformation.data.extra.name, "picture": MyCookie().loginInformation.data.extra.picture, "id": MyCookie().loginInformation.data.extra.id, "alipay_account": '', "alipay_name": '' } }, (response, hasError) { if (!hasError) { controller.clear(); name.clear(); MyCookie().userBean.aliPayAccount = ''; MyCookie().userBean.aliPayName = ''; showToast('清除成功'); Navigator.pop(context); } }, (error) {}); } }