import 'dart:convert'; import 'package:city_pickers/city_pickers.dart'; import 'package:city_pickers/modal/result.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'package:ysairplane2/base/YSBase.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; class YSUnionJoin extends StatefulWidget { final String content; const YSUnionJoin({Key key, this.content = ''}) : super(key: key); @override _YSUnionJoinState createState() => _YSUnionJoinState(); } class _YSUnionJoinState extends State { @override Widget build(BuildContext context) { return YSBase( ystitle: '顺翔航空', yscolor: Color(0xFFF5F6F8), yschild: Column( children: [ Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(140), width: MediaQuery.of(context).size.width, padding: EdgeInsets.all(hsp(30)), child: WebView( javascriptMode: JavascriptMode.unrestricted, onWebViewCreated: (WebViewController webViewController) { webViewController.loadUrl(Uri.dataFromString(widget.content, mimeType: 'text/html', encoding: Encoding.getByName('utf-8')).toString()); }, ), ), GestureDetector( onTap: (){ Navigator.pop(context); Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSUnionSubmit(); } ) ); }, child: Container( height: hsp(140), color: Colors.white, padding: EdgeInsets.only(left: hsp(50),right: hsp(50),top: hsp(20),bottom: hsp(20)), child: Container( decoration: BoxDecoration( color: Color(0xFF007AFF), borderRadius: BorderRadius.all(Radius.circular(5)) ), alignment: Alignment.center, child: Text('加入我们',style: TextStyle(fontSize: zsp(30),color: Colors.white),), ), ), ) ], ), ); } } class YSUnionSubmit extends StatefulWidget { const YSUnionSubmit({Key key}) : super(key: key); @override _YSUnionSubmitState createState() => _YSUnionSubmitState(); } class _YSUnionSubmitState extends State { List _array1 = ['姓名','身份证','地区']; String _province = ''; String _city = ''; String _area = ''; TextEditingController _nameField = TextEditingController(); TextEditingController _cardField = TextEditingController(); TextEditingController _weChatField = TextEditingController(); TextEditingController _aliField = TextEditingController(); @override void dispose() { _nameField.dispose(); _cardField.dispose(); _weChatField.dispose(); _aliField.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '加入我们', yscolor: Color(0xFFF5F6F8), yschild: Column( children: [ Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(140), width: MediaQuery.of(context).size.width, child: SingleChildScrollView( child: Column( children: [ Container( margin: EdgeInsets.only(top: hsp(20)), padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), child: ListView.separated( itemCount: _array1.length, separatorBuilder: (context,index){ return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),); }, itemBuilder: (context,index){ return Container( height: hsp(100), child: Row( children: [ Container( width: hsp(200), child: Text(_array1[index],style: TextStyle(fontSize: zsp(32),color: Colors.black),), ), Container( width: MediaQuery.of(context).size.width-hsp(240), child: index==2?GestureDetector( onTap: () async{ FocusScope.of(context).unfocus(); Result result = await CityPickers.showCityPicker( context: context, ); print(result); if(result!=null){ _province = result.provinceName; _city = result.cityName; _area = result.areaName; setState(() {}); } }, behavior: HitTestBehavior.opaque, child: Row( children: [ Container( width: MediaQuery.of(context).size.width-hsp(280), child: Text(_area.isEmpty?'请选择地区':'$_province $_city $_area', style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)),), alignment: Alignment.centerRight, ), Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFF999999),) ], ), ):CupertinoTextField( placeholder: '请输入', style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)), textAlign: TextAlign.right, decoration: BoxDecoration(), controller: index==0?_nameField:_cardField, ), ) ], ), ); }, shrinkWrap: true, ), color: Colors.white, ), Container( height: hsp(80), padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), child: Text('收款信息',style: TextStyle(fontSize: zsp(28),color: Color(0xFF666666)),), alignment: Alignment.centerLeft, ), ListView.separated( itemCount: 2, itemBuilder: (context,index){ return Container( color: Colors.white, padding: EdgeInsets.only(left: hsp(20),right: hsp(20)), child: Column( children: [ Container( height: hsp(100), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('类型',style: TextStyle(fontSize: zsp(32),color: Colors.black),), Text(index==0?'微信':'支付宝',style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)),) ], ), ), Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),), Container( height: hsp(100), child: Row( children: [ Container( width: hsp(200), child: Text('账号:',style: TextStyle(fontSize: zsp(32),color: Colors.black),), ), Container( width: MediaQuery.of(context).size.width-hsp(240), padding: EdgeInsets.only(left: hsp(10)), child: CupertinoTextField( placeholder: '请输入', style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)), textAlign: TextAlign.right, decoration: BoxDecoration(), controller: index==0?_weChatField:_aliField, ), ) ], ), ), ], ), ); }, separatorBuilder: (context,index){ return Container(height: hsp(10),); }, shrinkWrap: true, padding: EdgeInsets.all(0), physics: NeverScrollableScrollPhysics(), ) ], ), ), ), GestureDetector( onTap: (){ _postUnionData(); }, child: Container( height: hsp(140), color: Colors.white, padding: EdgeInsets.only(left: hsp(50),right: hsp(50),top: hsp(20),bottom: hsp(20)), child: Container( decoration: BoxDecoration( color: Color(0xFF007AFF), borderRadius: BorderRadius.all(Radius.circular(5)) ), alignment: Alignment.center, child: Text('提交审核',style: TextStyle(fontSize: zsp(30),color: Colors.white),), ), ), ) ], ), ); } _postUnionData() async{ if(_nameField.text.isEmpty){ ysFlutterToast(context, '请输入姓名'); return; } if(_cardField.text.isEmpty){ ysFlutterToast(context, '请输入身份证号码'); return; } if(isIdCard(_cardField.text)==false){ ysFlutterToast(context, '身份证号码格式错误'); return; } if(_area.isEmpty){ ysFlutterToast(context, '请选择地区'); return; } if(_weChatField.text.isEmpty){ ysFlutterToast(context, '请输入微信账号'); return; } if(_aliField.text.isEmpty){ ysFlutterToast(context, '请输入支付宝账号'); return; } Map request = {}; request['username'] = _nameField.text; request['cardid'] = _cardField.text; request['paymentAccountWx'] = _weChatField.text; request['paymentAccountAlipay'] = _aliField.text; request['servantsProvince'] = _province; request['servantsCity'] = _city; request['servantsArea'] = _area; Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/servants/commit',parameter: request,isLoading: true,isToken: true); if(dict!=null){ ysFlutterToast(context, '提交成功,待审核'); Navigator.pop(context); } } } class YSUnionLoading extends StatelessWidget { final isLoading; final String msg; const YSUnionLoading({Key key, this.isLoading = true, this.msg = ''}) : super(key: key); @override Widget build(BuildContext context) { return YSBase( ystitle: '审核中', yscolor: Color(0xFFF5F6F8), yschild: Container( width: MediaQuery.of(context).size.width, child: Column( children: [ Container( height: hsp(200), width: hsp(200), decoration: BoxDecoration( image: DecorationImage(image: AssetImage('lib/images/${isLoading==true?'审核中':'审核失败1'}.png'),) ), margin: EdgeInsets.only(top: hsp(200)), ), Container( margin: EdgeInsets.only(top: hsp(100)), padding: EdgeInsets.only(left: hsp(50),right: hsp(50)), child: Text(isLoading==true?'您的资料正在审核中\n一般在3个工作日内,完成审核。': '您的资料已被拒绝\n请重新提交。',style: TextStyle(fontSize: zsp(30), color: Color(0xFF333333)),textAlign: TextAlign.center,), ), Container( margin: EdgeInsets.only(top: hsp(80)), padding: EdgeInsets.only(left: hsp(50),right: hsp(50)), child: Text(msg,style: TextStyle(fontSize: zsp(30), color: Color(0xFF999999)),textAlign: TextAlign.center,), ), GestureDetector( onTap: (){ Navigator.pop(context); if(isLoading==false){ Navigator.of(context,rootNavigator: true).push( CupertinoPageRoute( builder: (context){ return YSUnionSubmit(); } ) ); } }, child: Container( margin: EdgeInsets.only(top: hsp(100),left: hsp(100),right: hsp(100)), height: hsp(100), decoration: BoxDecoration( color: Color(0xFF007AFF), borderRadius: BorderRadius.all(Radius.circular(5)) ), alignment: Alignment.center, child: Text('确定',style: TextStyle(fontSize: zsp(30),color: Colors.white),), ), ) ], ), ), ); } }