YSSettleIn.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:ysairplane2/base/YSBase.dart';
  4. import 'package:ysairplane2/tools/YSNetWorking.dart';
  5. import 'package:ysairplane2/tools/YSTools.dart';
  6. class YSSettleIn extends StatefulWidget {
  7. @override
  8. _YSSettleInState createState() => _YSSettleInState();
  9. }
  10. class _YSSettleInState extends State<YSSettleIn> {
  11. TextEditingController _nameField = TextEditingController();
  12. TextEditingController _phoneField = TextEditingController();
  13. @override
  14. Widget build(BuildContext context) {
  15. return YSBase(
  16. ystitle: '入驻信息',
  17. ysright: GestureDetector(
  18. child: Text('保存',style: TextStyle(fontSize: zsp(36),color: Color(0xFF007AFF)),),
  19. onTap: (){
  20. _postSettleInData();
  21. },
  22. ),
  23. yscolor: Color(0xFFF5F6F8),
  24. yschild: ListView.builder(
  25. shrinkWrap: true,
  26. itemCount: 2,
  27. itemBuilder: (context,index){
  28. return Container(
  29. margin: EdgeInsets.only(top: hsp(10)),
  30. color: Colors.white,
  31. height: hsp(100),
  32. padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
  33. width: MediaQuery.of(context).size.width,
  34. child: Row(
  35. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  36. children: [
  37. Text(index==0?'姓名':'电话',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000)),),
  38. Container(
  39. width: MediaQuery.of(context).size.width-hsp(150),
  40. child: CupertinoTextField(
  41. placeholder: index==0?'请输入姓名':'请输入电话',
  42. style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000)),
  43. decoration: BoxDecoration(),
  44. controller: index==0?_nameField:_phoneField,
  45. keyboardType: index==0?TextInputType.text:TextInputType.phone,
  46. ),
  47. )
  48. ],
  49. ),
  50. );
  51. },
  52. ),
  53. );
  54. }
  55. _postSettleInData() async{
  56. if(_nameField.text.isEmpty){
  57. ysFlutterToast(context, '请输入姓名');
  58. return;
  59. }
  60. if(_phoneField.text.isEmpty){
  61. ysFlutterToast(context, '请输入电话');
  62. return;
  63. }
  64. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/appsettled/add',parameter: {'name':_nameField.text,'phone':_phoneField.text},
  65. refresh: (){_postSettleInData();},isLoading: true,isToken: true);
  66. if(dict!=null){
  67. ysFlutterToast(context, '入驻信息已提交');
  68. Navigator.pop(context);
  69. }
  70. }
  71. }