YSUnionJoin.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. import 'dart:convert';
  2. import 'package:city_pickers/city_pickers.dart';
  3. import 'package:city_pickers/modal/result.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:webview_flutter/webview_flutter.dart';
  7. import 'package:ysairplane2/base/YSBase.dart';
  8. import 'package:ysairplane2/tools/YSNetWorking.dart';
  9. import 'package:ysairplane2/tools/YSTools.dart';
  10. class YSUnionJoin extends StatefulWidget {
  11. final String content;
  12. const YSUnionJoin({Key key, this.content = ''}) : super(key: key);
  13. @override
  14. _YSUnionJoinState createState() => _YSUnionJoinState();
  15. }
  16. class _YSUnionJoinState extends State<YSUnionJoin> {
  17. @override
  18. Widget build(BuildContext context) {
  19. return YSBase(
  20. ystitle: '顺翔航空',
  21. yscolor: Color(0xFFF5F6F8),
  22. yschild: Column(
  23. children: [
  24. Container(
  25. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(140),
  26. width: MediaQuery.of(context).size.width,
  27. padding: EdgeInsets.all(hsp(30)),
  28. child: WebView(
  29. javascriptMode: JavascriptMode.unrestricted,
  30. onWebViewCreated: (WebViewController webViewController) {
  31. webViewController.loadUrl(Uri.dataFromString(widget.content, mimeType: 'text/html', encoding: Encoding.getByName('utf-8')).toString());
  32. },
  33. ),
  34. ),
  35. GestureDetector(
  36. onTap: (){
  37. Navigator.pop(context);
  38. Navigator.of(context).push(
  39. CupertinoPageRoute(
  40. builder: (context){
  41. return YSUnionSubmit();
  42. }
  43. )
  44. );
  45. },
  46. child: Container(
  47. height: hsp(140),
  48. color: Colors.white,
  49. padding: EdgeInsets.only(left: hsp(50),right: hsp(50),top: hsp(20),bottom: hsp(20)),
  50. child: Container(
  51. decoration: BoxDecoration(
  52. color: Color(0xFF007AFF),
  53. borderRadius: BorderRadius.all(Radius.circular(5))
  54. ),
  55. alignment: Alignment.center,
  56. child: Text('加入我们',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
  57. ),
  58. ),
  59. )
  60. ],
  61. ),
  62. );
  63. }
  64. }
  65. class YSUnionSubmit extends StatefulWidget {
  66. const YSUnionSubmit({Key key}) : super(key: key);
  67. @override
  68. _YSUnionSubmitState createState() => _YSUnionSubmitState();
  69. }
  70. class _YSUnionSubmitState extends State<YSUnionSubmit> {
  71. List _array1 = ['姓名','身份证','地区'];
  72. String _province = '';
  73. String _city = '';
  74. String _area = '';
  75. TextEditingController _nameField = TextEditingController();
  76. TextEditingController _cardField = TextEditingController();
  77. TextEditingController _weChatField = TextEditingController();
  78. TextEditingController _aliField = TextEditingController();
  79. @override
  80. void dispose() {
  81. _nameField.dispose();
  82. _cardField.dispose();
  83. _weChatField.dispose();
  84. _aliField.dispose();
  85. super.dispose();
  86. }
  87. @override
  88. Widget build(BuildContext context) {
  89. return YSBase(
  90. ystitle: '加入我们',
  91. yscolor: Color(0xFFF5F6F8),
  92. yschild: Column(
  93. children: [
  94. Container(
  95. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(140),
  96. width: MediaQuery.of(context).size.width,
  97. child: SingleChildScrollView(
  98. child: Column(
  99. children: [
  100. Container(
  101. margin: EdgeInsets.only(top: hsp(20)),
  102. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  103. child: ListView.separated(
  104. itemCount: _array1.length,
  105. separatorBuilder: (context,index){
  106. return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),);
  107. },
  108. itemBuilder: (context,index){
  109. return Container(
  110. height: hsp(100),
  111. child: Row(
  112. children: [
  113. Container(
  114. width: hsp(200),
  115. child: Text(_array1[index],style: TextStyle(fontSize: zsp(32),color: Colors.black),),
  116. ),
  117. Container(
  118. width: MediaQuery.of(context).size.width-hsp(240),
  119. child: index==2?GestureDetector(
  120. onTap: () async{
  121. FocusScope.of(context).unfocus();
  122. Result result = await CityPickers.showCityPicker(
  123. context: context,
  124. );
  125. print(result);
  126. if(result!=null){
  127. _province = result.provinceName;
  128. _city = result.cityName;
  129. _area = result.areaName;
  130. setState(() {});
  131. }
  132. },
  133. behavior: HitTestBehavior.opaque,
  134. child: Row(
  135. children: [
  136. Container(
  137. width: MediaQuery.of(context).size.width-hsp(280),
  138. child: Text(_area.isEmpty?'请选择地区':'$_province $_city $_area',
  139. style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)),),
  140. alignment: Alignment.centerRight,
  141. ),
  142. Icon(Icons.chevron_right,size: hsp(40),color: Color(0xFF999999),)
  143. ],
  144. ),
  145. ):CupertinoTextField(
  146. placeholder: '请输入',
  147. style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)),
  148. textAlign: TextAlign.right,
  149. decoration: BoxDecoration(),
  150. controller: index==0?_nameField:_cardField,
  151. ),
  152. )
  153. ],
  154. ),
  155. );
  156. },
  157. shrinkWrap: true,
  158. ),
  159. color: Colors.white,
  160. ),
  161. Container(
  162. height: hsp(80),
  163. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  164. child: Text('收款信息',style: TextStyle(fontSize: zsp(28),color: Color(0xFF666666)),),
  165. alignment: Alignment.centerLeft,
  166. ),
  167. ListView.separated(
  168. itemCount: 2,
  169. itemBuilder: (context,index){
  170. return Container(
  171. color: Colors.white,
  172. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  173. child: Column(
  174. children: [
  175. Container(
  176. height: hsp(100),
  177. child: Row(
  178. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  179. children: [
  180. Text('类型',style: TextStyle(fontSize: zsp(32),color: Colors.black),),
  181. Text(index==0?'微信':'支付宝',style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)),)
  182. ],
  183. ),
  184. ),
  185. Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF5F6F8),),
  186. Container(
  187. height: hsp(100),
  188. child: Row(
  189. children: [
  190. Container(
  191. width: hsp(200),
  192. child: Text('账号:',style: TextStyle(fontSize: zsp(32),color: Colors.black),),
  193. ),
  194. Container(
  195. width: MediaQuery.of(context).size.width-hsp(240),
  196. padding: EdgeInsets.only(left: hsp(10)),
  197. child: CupertinoTextField(
  198. placeholder: '请输入',
  199. style: TextStyle(fontSize: zsp(32),color: Color(0xFF999999)),
  200. textAlign: TextAlign.right,
  201. decoration: BoxDecoration(),
  202. controller: index==0?_weChatField:_aliField,
  203. ),
  204. )
  205. ],
  206. ),
  207. ),
  208. ],
  209. ),
  210. );
  211. },
  212. separatorBuilder: (context,index){
  213. return Container(height: hsp(10),);
  214. },
  215. shrinkWrap: true,
  216. padding: EdgeInsets.all(0),
  217. physics: NeverScrollableScrollPhysics(),
  218. )
  219. ],
  220. ),
  221. ),
  222. ),
  223. GestureDetector(
  224. onTap: (){
  225. _postUnionData();
  226. },
  227. child: Container(
  228. height: hsp(140),
  229. color: Colors.white,
  230. padding: EdgeInsets.only(left: hsp(50),right: hsp(50),top: hsp(20),bottom: hsp(20)),
  231. child: Container(
  232. decoration: BoxDecoration(
  233. color: Color(0xFF007AFF),
  234. borderRadius: BorderRadius.all(Radius.circular(5))
  235. ),
  236. alignment: Alignment.center,
  237. child: Text('提交审核',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
  238. ),
  239. ),
  240. )
  241. ],
  242. ),
  243. );
  244. }
  245. _postUnionData() async{
  246. if(_nameField.text.isEmpty){
  247. ysFlutterToast(context, '请输入姓名');
  248. return;
  249. }
  250. if(_cardField.text.isEmpty){
  251. ysFlutterToast(context, '请输入身份证号码');
  252. return;
  253. }
  254. if(isIdCard(_cardField.text)==false){
  255. ysFlutterToast(context, '身份证号码格式错误');
  256. return;
  257. }
  258. if(_area.isEmpty){
  259. ysFlutterToast(context, '请选择地区');
  260. return;
  261. }
  262. if(_weChatField.text.isEmpty){
  263. ysFlutterToast(context, '请输入微信账号');
  264. return;
  265. }
  266. if(_aliField.text.isEmpty){
  267. ysFlutterToast(context, '请输入支付宝账号');
  268. return;
  269. }
  270. Map request = {};
  271. request['username'] = _nameField.text;
  272. request['cardid'] = _cardField.text;
  273. request['paymentAccountWx'] = _weChatField.text;
  274. request['paymentAccountAlipay'] = _aliField.text;
  275. request['servantsProvince'] = _province;
  276. request['servantsCity'] = _city;
  277. request['servantsArea'] = _area;
  278. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/servants/commit',parameter: request,isLoading: true,isToken: true);
  279. if(dict!=null){
  280. ysFlutterToast(context, '提交成功,待审核');
  281. Navigator.pop(context);
  282. }
  283. }
  284. }
  285. class YSUnionLoading extends StatelessWidget {
  286. final isLoading;
  287. final String msg;
  288. const YSUnionLoading({Key key, this.isLoading = true, this.msg = ''}) : super(key: key);
  289. @override
  290. Widget build(BuildContext context) {
  291. return YSBase(
  292. ystitle: '审核中',
  293. yscolor: Color(0xFFF5F6F8),
  294. yschild: Container(
  295. width: MediaQuery.of(context).size.width,
  296. child: Column(
  297. children: [
  298. Container(
  299. height: hsp(200),
  300. width: hsp(200),
  301. decoration: BoxDecoration(
  302. image: DecorationImage(image: AssetImage('lib/images/${isLoading==true?'审核中':'审核失败1'}.png'),)
  303. ),
  304. margin: EdgeInsets.only(top: hsp(200)),
  305. ),
  306. Container(
  307. margin: EdgeInsets.only(top: hsp(100)),
  308. padding: EdgeInsets.only(left: hsp(50),right: hsp(50)),
  309. child: Text(isLoading==true?'您的资料正在审核中\n一般在3个工作日内,完成审核。':
  310. '您的资料已被拒绝\n请重新提交。',style: TextStyle(fontSize: zsp(30),
  311. color: Color(0xFF333333)),textAlign: TextAlign.center,),
  312. ),
  313. Container(
  314. margin: EdgeInsets.only(top: hsp(80)),
  315. padding: EdgeInsets.only(left: hsp(50),right: hsp(50)),
  316. child: Text(msg,style: TextStyle(fontSize: zsp(30),
  317. color: Color(0xFF999999)),textAlign: TextAlign.center,),
  318. ),
  319. GestureDetector(
  320. onTap: (){
  321. Navigator.pop(context);
  322. if(isLoading==false){
  323. Navigator.of(context,rootNavigator: true).push(
  324. CupertinoPageRoute(
  325. builder: (context){
  326. return YSUnionSubmit();
  327. }
  328. )
  329. );
  330. }
  331. },
  332. child: Container(
  333. margin: EdgeInsets.only(top: hsp(100),left: hsp(100),right: hsp(100)),
  334. height: hsp(100),
  335. decoration: BoxDecoration(
  336. color: Color(0xFF007AFF),
  337. borderRadius: BorderRadius.all(Radius.circular(5))
  338. ),
  339. alignment: Alignment.center,
  340. child: Text('确定',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
  341. ),
  342. )
  343. ],
  344. ),
  345. ),
  346. );
  347. }
  348. }