YSHelpPlane.dart 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:url_launcher/url_launcher.dart';
  4. import 'package:ysairplane/base/YSBase.dart';
  5. import 'package:ysairplane/tools/YSNetWorking.dart';
  6. import 'package:ysairplane/tools/YSTools.dart';
  7. import 'YSPay.dart';
  8. class YSHelpPlane extends StatefulWidget {
  9. @override
  10. _YSHelpPlaneState createState() => _YSHelpPlaneState();
  11. }
  12. class _YSHelpPlaneState extends State<YSHelpPlane> {
  13. bool _isDetail = false;
  14. bool _isOrder = false;
  15. Map _msgDict,_typeDict;
  16. String _numStr,_startStr,_endStr,_priceStr;
  17. TextEditingController _phone = TextEditingController();
  18. TextEditingController _des = TextEditingController();
  19. @override
  20. void initState() {
  21. Future.delayed(Duration(seconds: 0)).then((value){
  22. _getHelpPlaneData();
  23. });
  24. super.initState();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return YSBase(
  29. ystitle: '召唤直升机',
  30. yschild: Container(
  31. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  32. width: MediaQuery.of(context).size.width,
  33. color: Color(0xFFF1F2F4),
  34. child: Stack(
  35. children: [
  36. Column(
  37. children: [
  38. Container(
  39. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150),
  40. width: MediaQuery.of(context).size.width,
  41. color: Colors.white,
  42. child: Stack(
  43. children: [
  44. Container(
  45. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(550),
  46. width: MediaQuery.of(context).size.width,
  47. color: Color(0xFFF1F2F3),
  48. ),
  49. GestureDetector(
  50. onTap: (){
  51. if(_msgDict==null){
  52. ysFlutterToast(context, '呼叫信息获取失败');
  53. return;
  54. }
  55. showDialog(
  56. context: context,
  57. builder: (context){
  58. return CupertinoAlertDialog(
  59. title: Text('提示\n'),
  60. content: Text('是否拨打${_msgDict['emergencyCall']}'),
  61. actions: [
  62. CupertinoButton(
  63. child: Container(
  64. child: Text('取消',style: TextStyle(fontSize: 16,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  65. height: 40,
  66. alignment: Alignment.center,
  67. ),
  68. padding: EdgeInsets.all(0),
  69. onPressed: (){
  70. Navigator.pop(context);
  71. },
  72. ),
  73. CupertinoButton(
  74. child: Container(
  75. child: Text('确定',style: TextStyle(fontSize: 16,color: Color(0xFF292929),decoration: TextDecoration.none,fontWeight: FontWeight.normal),),
  76. height: 40,
  77. alignment: Alignment.center,
  78. ),
  79. padding: EdgeInsets.all(0),
  80. onPressed: (){
  81. Navigator.pop(context);
  82. launch('tel:${_msgDict['emergencyCall']}');
  83. },
  84. )
  85. ],
  86. );
  87. }
  88. );
  89. },
  90. child: Container(
  91. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(700),left: hsp(20)),
  92. width: wsp(250),
  93. height: hsp(70),
  94. alignment: Alignment.center,
  95. decoration: BoxDecoration(
  96. color: Color(0xFFF15204),
  97. borderRadius: BorderRadius.all(Radius.circular(50))
  98. ),
  99. child: Text('SOS 紧急呼叫',style: TextStyle(fontSize: zsp(30),color: Colors.white),),
  100. ),
  101. ),
  102. Container(
  103. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(700),left: MediaQuery.of(context).size.width-wsp(270)),
  104. width: wsp(250),
  105. height: hsp(70),
  106. child: Row(
  107. children: [
  108. Container(
  109. height: hsp(70),
  110. width: hsp(70),
  111. color: Colors.white,
  112. child: Icon(Icons.flight,size: hsp(50),color: Color(0xFF3262FF),),
  113. alignment: Alignment.center,
  114. ),
  115. Container(
  116. height: hsp(70),
  117. width: hsp(180),
  118. color: Color(0xFFE8EFFD),
  119. child: Text('${_msgDict==null?0:_msgDict['airportNum']}架飞机',style: TextStyle(fontSize: zsp(26),color: Color(0xFF3856A0),fontWeight: FontWeight.bold),),
  120. alignment: Alignment.center,
  121. ),
  122. ],
  123. )
  124. ),
  125. Container(
  126. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(150)-hsp(600)-2.5),
  127. decoration: BoxDecoration(
  128. color: Colors.white,
  129. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10)),
  130. ),
  131. height: hsp(600)+2.5,
  132. child: Column(
  133. children: [
  134. Container(
  135. child: Text('空中救援',style: TextStyle(fontSize: zsp(32),color: Color(0xFF212121),fontWeight: FontWeight.bold),),
  136. height: hsp(100),
  137. alignment: Alignment.center,
  138. ),
  139. Divider(color: Color(0xFFF1F2F4),height: 0.5,thickness: 0.5,),
  140. Container(
  141. height: hsp(500)+2,
  142. child: ListView.separated(
  143. itemBuilder: (context,index){
  144. return GestureDetector(
  145. onTap: (){
  146. if(index==1||index==2){
  147. FocusScope.of(context).unfocus();
  148. showModalBottomSheet(
  149. context: context,
  150. builder: (context){
  151. return index==1?YSPicker(dataArray: _msgDict['dtRescueTypeList'],title: 'name',choose: (value){
  152. print(value);
  153. setState(() {
  154. _typeDict = value;
  155. });
  156. },):YSPicker(dataArray: [for(int i=0;i<30;i++){'title':'${i+1}','id':i+1}],title: 'title',choose: (value){
  157. print(value);
  158. setState(() {
  159. _numStr = value['title'];
  160. });
  161. },);
  162. }
  163. );
  164. }
  165. },
  166. behavior: HitTestBehavior.opaque,
  167. child: Container(
  168. height: hsp(100),
  169. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  170. child: Row(
  171. children: [
  172. Container(child: Text(index==0?'救援地点':index==1?'救援类型':index==2?'涉险人数':index==3?'联系方式':'描述',style: TextStyle(fontSize: zsp(30),color: Color(0xFFA7A7A7)),),width: wsp(150),),
  173. Container(
  174. margin: EdgeInsets.only(left: wsp(20)),
  175. width: MediaQuery.of(context).size.width-wsp(230),
  176. child: index==0?Text(
  177. '长安文化中心',style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000),fontWeight: FontWeight.bold),
  178. ):index==1||index==2?Row(
  179. children: [
  180. Text(index==1?(_typeDict==null?'请选择救援类型':_typeDict['name']):(_numStr==null?'请选择险人数式':_numStr),style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),),
  181. Icon(Icons.keyboard_arrow_down,size: hsp(40),color: Color(0xFF999999),)
  182. ],
  183. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  184. ):CupertinoTextField(
  185. placeholder: index==3?'请输入联系方式':'请输入描述(20个字以内)',
  186. placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  187. style: TextStyle(fontSize: zsp(30),color: Color(0xFF999999)),
  188. decoration: BoxDecoration(),
  189. keyboardType: index==3?TextInputType.phone:TextInputType.text,
  190. maxLength: index==3?11:20,
  191. controller: index==3?_phone:_des,
  192. ),
  193. ),
  194. ],
  195. ),
  196. ),
  197. );
  198. },
  199. separatorBuilder: (context,index){
  200. return Divider(color: Color(0xFFF1F2F4),height: 0.5,thickness: 0.5,);
  201. },
  202. itemCount: 5,
  203. padding: EdgeInsets.all(0),
  204. ),
  205. )
  206. ],
  207. ),
  208. )
  209. ],
  210. ),
  211. ),
  212. GestureDetector(
  213. onTap: (){
  214. _getPriceData();
  215. },
  216. child: Container(
  217. height: hsp(100),
  218. margin: EdgeInsets.only(top: hsp(25)),
  219. width: MediaQuery.of(context).size.width-hsp(60),
  220. decoration: BoxDecoration(
  221. color: Color(0xFFF15103),
  222. borderRadius: BorderRadius.all(Radius.circular(5))
  223. ),
  224. child: Text('一键召唤直升机',style: TextStyle(fontSize: zsp(36),color: Colors.white,fontWeight: FontWeight.bold),),
  225. alignment: Alignment.center,
  226. ),
  227. ),
  228. ],
  229. ),
  230. if(_isOrder==true)GestureDetector(
  231. onTap: (){
  232. setState(() {
  233. _isOrder = false;
  234. });
  235. },
  236. child: Container(
  237. height: MediaQuery.of(context).size.height,
  238. width: MediaQuery.of(context).size.width,
  239. color: Colors.black54,
  240. child: GestureDetector(
  241. onTap: (){},
  242. child: Column(
  243. children: [
  244. Container(
  245. height: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)*0.8-hsp(120),
  246. width: MediaQuery.of(context).size.width,
  247. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)*0.2),
  248. decoration: BoxDecoration(
  249. color: Color(0xFFF1F2F3),
  250. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  251. ),
  252. child: Column(
  253. crossAxisAlignment: CrossAxisAlignment.start,
  254. children: [
  255. Container(
  256. height: hsp(100),
  257. decoration: BoxDecoration(
  258. color: Colors.white,
  259. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  260. ),
  261. padding: EdgeInsets.only(left: 15,right: 15),
  262. child: Row(
  263. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  264. children: [
  265. Container(width: wsp(50),),
  266. Text('订单确认',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  267. GestureDetector(
  268. child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  269. onTap: (){
  270. setState(() {
  271. _isDetail = false;
  272. });
  273. },
  274. ),
  275. ],
  276. ),
  277. ),
  278. Divider(height: 0.5,thickness: 0.5,color: Color(0xFFE5E5E5),),
  279. Container(
  280. height: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)*0.8-hsp(220)-0.5,
  281. child: SingleChildScrollView(
  282. padding: EdgeInsets.all(0),
  283. child: Column(
  284. children: [
  285. Container(
  286. height: hsp(500)+2,
  287. child: ListView.separated(
  288. itemBuilder: (context,index){
  289. return Container(
  290. height: hsp(100),
  291. color: Colors.white,
  292. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  293. child: Row(
  294. children: [
  295. Container(child: Text(index==0?'救援地点':index==1?'救援类型':index==2?'涉险人数':index==3?'联系方式':'描述',style: TextStyle(fontSize: zsp(30),color: Color(0xFFA7A7A7)),),width: wsp(150),),
  296. Container(
  297. margin: EdgeInsets.only(left: wsp(20)),
  298. width: MediaQuery.of(context).size.width-wsp(230),
  299. child: Text(index==0?'长安文化中心':index==1?'${_typeDict['name']}':index==2?_numStr:index==3?_phone.text:(_des.text.isEmpty?'无':_des.text),
  300. style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000),fontWeight: FontWeight.bold),)
  301. ),
  302. ],
  303. ),
  304. );
  305. },
  306. separatorBuilder: (context,index){
  307. return Divider(color: Color(0xFFF1F2F4),height: 0.5,thickness: 0.5,);
  308. },
  309. itemCount: 5,
  310. padding: EdgeInsets.all(0),
  311. ),
  312. ),
  313. Container(
  314. child: RichText(
  315. text: TextSpan(
  316. text: '预订须知',
  317. style: TextStyle(fontSize: zsp(28),color: Color(0xFF348AE1)),
  318. children: [
  319. TextSpan(
  320. text: ' >',
  321. style: TextStyle(color: Color(0xFF000000))
  322. ),
  323. ]
  324. ),
  325. ),
  326. padding: EdgeInsets.only(left: wsp(40),right: wsp(40)),
  327. margin: EdgeInsets.only(top: hsp(10),bottom: hsp(10)),
  328. height: hsp(80),
  329. width: MediaQuery.of(context).size.width,
  330. alignment: Alignment.centerLeft,
  331. color: Colors.white,
  332. ),
  333. Container(
  334. height: hsp(80),
  335. padding: EdgeInsets.only(left: wsp(40),right: wsp(40)),
  336. child: Text('说明',style: TextStyle(color: Color(0xFF333333),fontSize: zsp(30),fontWeight: FontWeight.bold),),
  337. margin: EdgeInsets.only(bottom: 0.5),
  338. alignment: Alignment.centerLeft,
  339. color: Colors.white,
  340. ),
  341. Container(
  342. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),top: hsp(20),bottom: hsp(20)),
  343. child: Text('信息提交后,将有我们的工作人员联系您讨论具体的救援方案,请保证手机畅通',style: TextStyle(color: Color(0xFF999999),fontSize: zsp(30)),),
  344. alignment: Alignment.centerLeft,
  345. color: Colors.white,
  346. )
  347. ],
  348. ),
  349. ),
  350. ),
  351. ],
  352. ),
  353. ),
  354. Container(
  355. height: hsp(120),
  356. width: MediaQuery.of(context).size.width,
  357. color: Colors.white,
  358. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  359. child: Row(
  360. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  361. children: [
  362. RichText(
  363. text: TextSpan(
  364. text: '参考价(¥) ',
  365. style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),
  366. children: [
  367. TextSpan(
  368. text: _priceStr==null?'0':_priceStr,
  369. style: TextStyle(fontSize: zsp(40),color: Color(0xFFFF6600)),
  370. ),
  371. TextSpan(
  372. text: '元'
  373. )
  374. ]
  375. ),
  376. ),
  377. // GestureDetector(
  378. // child: Row(
  379. // children: [
  380. // Text('明细',style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),),
  381. // Icon(Icons.keyboard_arrow_up,size: hsp(30),color: Color(0xFF007EFF),),
  382. // ],
  383. // ),
  384. // onTap: (){
  385. // setState(() {
  386. // _isDetail = !_isDetail;
  387. // });
  388. // },
  389. // ),
  390. GestureDetector(
  391. onTap: (){
  392. _postHelpPlaneOrderData();
  393. },
  394. child: Container(
  395. height: hsp(70),
  396. padding: EdgeInsets.only(left: wsp(50),right: wsp(50)),
  397. decoration: BoxDecoration(
  398. color: Color(0xFF007EFF),
  399. borderRadius: BorderRadius.all(Radius.circular(50))
  400. ),
  401. alignment: Alignment.center,
  402. child: Text('立即预约',style: TextStyle(fontSize: zsp(30),color: Colors.white,fontWeight: FontWeight.bold),),
  403. ),
  404. )
  405. ],
  406. ),
  407. )
  408. ],
  409. ),
  410. ),
  411. ),
  412. ),
  413. if(_isDetail==true)GestureDetector(
  414. onTap: (){
  415. setState(() {
  416. _isDetail = false;
  417. });
  418. },
  419. child: Container(
  420. height: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)-hsp(120),
  421. color: Colors.black45,
  422. child: Container(
  423. margin: EdgeInsets.only(top: (MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44)-hsp(120)-hsp(370)),
  424. height: hsp(370),
  425. decoration: BoxDecoration(
  426. color: Colors.white,
  427. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  428. ),
  429. child: GestureDetector(
  430. onTap: (){},
  431. behavior: HitTestBehavior.opaque,
  432. child: Column(
  433. children: [
  434. Container(
  435. height: hsp(100),
  436. padding: EdgeInsets.only(left: 15,right: 15),
  437. child: Row(
  438. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  439. children: [
  440. GestureDetector(
  441. child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  442. onTap: (){
  443. setState(() {
  444. _isDetail = false;
  445. });
  446. },
  447. ),
  448. Text('明细',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  449. Container(width: wsp(50),),
  450. ],
  451. ),
  452. ),
  453. Container(
  454. height: hsp(100),
  455. color: Color(0xFFF7F8F9),
  456. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(20),top: hsp(20)),
  457. child: Row(
  458. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  459. children: [
  460. Text('VIP尊享座位',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000),decoration: TextDecoration.none),),
  461. Text('¥ 780x 10人',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  462. ],
  463. ),
  464. ),
  465. Container(
  466. color: Color(0xFFF7F8F9),
  467. height: hsp(170),
  468. child: ListView.builder(
  469. padding: EdgeInsets.all(0),
  470. itemBuilder: (context,index){
  471. return Container(
  472. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(10)),
  473. child: Row(
  474. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  475. children: [
  476. Text('票价',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),),
  477. Text('¥ 770x 10人',style: TextStyle(fontSize: zsp(28),color: Color(0xFF9A9A9A)),),
  478. ],
  479. ),
  480. );
  481. },
  482. itemCount: 3,
  483. ),
  484. )
  485. ],
  486. ),
  487. ),
  488. ),
  489. ),
  490. )
  491. ],
  492. ),
  493. ),
  494. );
  495. }
  496. _getHelpPlaneData() async{
  497. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/get',parameter: {'type':2},isLoading: true,isToken: false);
  498. if(dict!=null){
  499. _msgDict = dict['data'];
  500. }
  501. }
  502. _postHelpPlaneOrderData() async{
  503. Map request = {};
  504. request['type'] = 2;
  505. request['travelersNumber'] = _numStr;
  506. request['phone'] = _phone.text;
  507. if(_des.text.isNotEmpty)request['des'] = _des.text;
  508. request['loactionSetout'] = _startStr;
  509. request['loactionArrive'] = _endStr;
  510. request['rescueTypeId'] = _typeDict['id'];
  511. request['price'] = _priceStr;
  512. Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/airplaneorder/createOrder',parameter: request,isLoading: true,isToken: true);
  513. if(dict!=null){
  514. Navigator.of(context).push(
  515. CupertinoPageRoute(
  516. builder: (context){
  517. return YSPay(orderDict: dict['data'],type: payType.help,);
  518. }
  519. )
  520. );
  521. }
  522. }
  523. _getPriceData() async{
  524. FocusScope.of(context).unfocus();
  525. _startStr = '34,108';
  526. _endStr = '34.1,108.1';
  527. if(_startStr==null){
  528. ysFlutterToast(context,'请选择出发位置');
  529. return;
  530. }
  531. if(_endStr==null){
  532. ysFlutterToast(context,'请选择到达位置');
  533. return;
  534. }
  535. if(_typeDict==null){
  536. ysFlutterToast(context,'请选择救援类型');
  537. return;
  538. }
  539. if(_numStr==null){
  540. ysFlutterToast(context,'请选择救援人数');
  541. return;
  542. }
  543. if(_phone.text.isEmpty){
  544. ysFlutterToast(context,'电话号码不能为空');
  545. return;
  546. }
  547. if(isChinaPhoneLegal(_phone.text)==false){
  548. ysFlutterToast(context,'电话号码格式不正确');
  549. return;
  550. }
  551. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/wallconfigure/calculation',parameter: {'loactionSetout':_startStr,'loactionArrive':_endStr},isLoading: true,isToken: false);
  552. if(dict!=null){
  553. _priceStr = '${dict['data']}';
  554. setState(() {
  555. _isOrder = true;
  556. });
  557. }
  558. }
  559. }