YSTicketChange.dart 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. import 'package:flutter/material.dart';
  2. import 'package:ysairplane2/base/YSBase.dart';
  3. import 'package:ysairplane2/tools/YSNetWorking.dart';
  4. import 'package:ysairplane2/tools/YSTools.dart';
  5. import 'YSPayTypeView.dart';
  6. class YSTicketChange extends StatefulWidget {
  7. final String title;
  8. final String dateStr;
  9. final String orderSn;
  10. const YSTicketChange({Key key, this.title = '', this.dateStr, this.orderSn}) : super(key: key);
  11. @override
  12. _YSTicketChangeState createState() => _YSTicketChangeState();
  13. }
  14. class _YSTicketChangeState extends State<YSTicketChange> {
  15. Map _msgDict = {};
  16. String _amount = '0.00';
  17. bool _isDetail = false;
  18. @override
  19. void initState() {
  20. Future.delayed(Duration(seconds: 0)).then((value){
  21. _getTicketData();
  22. });
  23. super.initState();
  24. }
  25. @override
  26. Widget build(BuildContext context) {
  27. return YSBase(
  28. ystitle: widget.title,
  29. yscolor: Color(0xFFF1F2F3),
  30. yschild: Container(
  31. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  32. decoration: BoxDecoration(
  33. gradient: LinearGradient(
  34. begin: Alignment.topCenter,
  35. end: Alignment.bottomCenter,
  36. colors: [
  37. Color(0xFF007CFF),
  38. Color(0xFFB8D8F8),
  39. Color(0xFFF1F2F3),
  40. Color(0xFFF1F2F3),
  41. ]
  42. )
  43. ),
  44. child: Stack(
  45. children: [
  46. Column(
  47. children: [
  48. Container(
  49. padding: EdgeInsets.only(top: hsp(20),left: hsp(20),right: hsp(20)),
  50. height: MediaQuery.of(context).size.height-hsp(220)-MediaQuery.of(context).padding.top-44,
  51. width: MediaQuery.of(context).size.width,
  52. child: SingleChildScrollView(
  53. child: Column(
  54. children: [
  55. ListView.separated(
  56. itemBuilder: (context,index){
  57. return Container(
  58. decoration: BoxDecoration(
  59. color: Colors.white,
  60. borderRadius: BorderRadius.all(Radius.circular(5))
  61. ),
  62. child: LayoutBuilder(
  63. builder: (context,listSize){
  64. return Column(
  65. crossAxisAlignment: CrossAxisAlignment.start,
  66. children: [
  67. Container(
  68. height: hsp(30),
  69. width: hsp(80),
  70. decoration: BoxDecoration(
  71. color: Color(index==0?0xFFFF9950:0xFFCACBCE),
  72. borderRadius: BorderRadius.only(topRight: Radius.circular(5),bottomLeft: Radius.circular(5))
  73. ),
  74. margin: EdgeInsets.only(left: listSize.maxWidth-hsp(80)),
  75. alignment: Alignment.center,
  76. child: Text(index==0?'新订单':'老订单',style: TextStyle(fontSize: zsp(16),color: Colors.white),),
  77. ),
  78. Container(
  79. child: RichText(
  80. text: TextSpan(
  81. // text: '9月30日 明天 预计',
  82. style: TextStyle(fontSize: zsp(24),color: Color(index==0?0xFF4A4A4A:0xFF9B9B9B)),
  83. children: [
  84. TextSpan(
  85. text: index==0?(_msgDict['newEndorseTime']??''):(_msgDict['time']??''),
  86. style: TextStyle(color: Color(index==0?0xFF0078FF:0xFF9B9B9B))
  87. ),
  88. TextSpan(
  89. text: ' 上机'
  90. )
  91. ]
  92. ),
  93. ),
  94. padding: EdgeInsets.only(left: hsp(30),right: hsp(30)),
  95. ),
  96. _msgDict['setout']!=null?Column(
  97. children: [
  98. Container(
  99. decoration: BoxDecoration(
  100. border: Border(bottom: BorderSide(color: Color(0xFFD8D8D8),width: hsp(1)))
  101. ),
  102. child: Row(
  103. crossAxisAlignment: CrossAxisAlignment.start,
  104. children: [
  105. Container(
  106. decoration: BoxDecoration(
  107. color: Colors.white,
  108. borderRadius: BorderRadius.all(Radius.circular(50)),
  109. border: Border.all(color: Color(0xFF00C390),width: hsp(10))
  110. ),
  111. height: hsp(30),
  112. width: hsp(30),
  113. ),
  114. Container(
  115. width: listSize.maxWidth-hsp(70),
  116. padding: EdgeInsets.only(left: hsp(20)),
  117. child: Text('${_msgDict['setoutCity']??''}· ${_msgDict['setout']??''}',style: TextStyle(fontSize: zsp(32),
  118. color: index==0?Colors.black:Color(0xFF9B9B9B),fontWeight: FontWeight.bold,height: 1),),
  119. )
  120. ],
  121. ),
  122. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(40),bottom: hsp(30)),
  123. ),
  124. Container(
  125. decoration: BoxDecoration(
  126. border: Border(bottom: BorderSide(color: Color(0xFFD8D8D8),width: hsp(1)))
  127. ),
  128. child: Row(
  129. crossAxisAlignment: CrossAxisAlignment.start,
  130. children: [
  131. Container(
  132. decoration: BoxDecoration(
  133. color: Colors.white,
  134. borderRadius: BorderRadius.all(Radius.circular(50)),
  135. border: Border.all(color: Color(0xFFFF8F46),width: hsp(10))
  136. ),
  137. height: hsp(30),
  138. width: hsp(30),
  139. ),
  140. Container(
  141. width: listSize.maxWidth-hsp(70),
  142. padding: EdgeInsets.only(left: hsp(20)),
  143. child: Text('${_msgDict['arriveCity']??''}· ${_msgDict['arrive']??''}',style: TextStyle(fontSize: zsp(32),
  144. color: index==0?Colors.black:Color(0xFF9B9B9B),fontWeight: FontWeight.bold,height: 1),),
  145. )
  146. ],
  147. ),
  148. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(40),bottom: hsp(30)),
  149. )
  150. ],
  151. ):Column(
  152. children: [
  153. Container(
  154. child: Text('${_msgDict['name']??''}',style: TextStyle(fontSize: zsp(32),
  155. color: index==0?Colors.black:Color(0xFF9B9B9B),fontWeight: FontWeight.bold,height: 1),),
  156. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(40)),
  157. ),
  158. Container(
  159. child: Text('${_msgDict['title']??''}',style: TextStyle(fontSize: zsp(28),
  160. color: index==0?Colors.black:Color(0xFF9B9B9B),fontWeight: FontWeight.normal,height: 1),),
  161. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(20)),
  162. )
  163. ],
  164. crossAxisAlignment: CrossAxisAlignment.start,
  165. ),
  166. Container(
  167. height: hsp(100),
  168. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  169. alignment: Alignment.centerRight,
  170. child: RichText(
  171. text: TextSpan(
  172. text: '订单金额:',
  173. style: TextStyle(fontSize: zsp(24),color: Color(0xFF4A4A4A)),
  174. children: [
  175. TextSpan(
  176. text: '¥${index==0?(_msgDict['newOrderPrice']??''):(_msgDict['orderPrice']??'')}',
  177. style: TextStyle(color: index==0?Color(0xFFFD2A2E):Color(0xFF9B9B9B),fontSize: zsp(36),fontWeight: FontWeight.bold)
  178. ),
  179. ]
  180. ),
  181. )
  182. )
  183. ],
  184. );
  185. },
  186. ),
  187. );
  188. },
  189. separatorBuilder: (context,index){return Container(height: hsp(20),);},
  190. itemCount: 2,
  191. padding: EdgeInsets.all(0),
  192. physics: NeverScrollableScrollPhysics(),
  193. shrinkWrap: true,
  194. ),
  195. if(_msgDict['personInfos']!=null)Container(
  196. margin: EdgeInsets.only(top: hsp(20)),
  197. padding: EdgeInsets.only(left: hsp(20),right: hsp(20),top: hsp(30)),
  198. decoration: BoxDecoration(
  199. color: Colors.white,
  200. borderRadius: BorderRadius.all(Radius.circular(5))
  201. ),
  202. child: Column(
  203. crossAxisAlignment: CrossAxisAlignment.start,
  204. children: [
  205. Text('乘车人',style: TextStyle(fontSize: zsp(28),color: Color(0xFF4A4A4A),fontWeight: FontWeight.bold),),
  206. ListView.separated(
  207. itemCount: _msgDict['personInfos'].length,
  208. separatorBuilder: (context,index){
  209. return Divider(height: hsp(1),thickness: hsp(1),color: Color(0xFFF1F2F3),);
  210. },
  211. itemBuilder: (context,index){
  212. Map item = _msgDict['personInfos'][index];
  213. return Container(
  214. padding: EdgeInsets.only(top: hsp(30),bottom: hsp(30)),
  215. child: Column(
  216. crossAxisAlignment: CrossAxisAlignment.start,
  217. children: [
  218. Text('姓名:${item['username']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF4A4A4A)),),
  219. Text('手机号码:${item['phone']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF4A4A4A),height: 2),),
  220. Text('身份证号码:${item['cardid']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF4A4A4A),height: 2),)
  221. ],
  222. ),
  223. );
  224. },
  225. shrinkWrap: true,
  226. physics: NeverScrollableScrollPhysics(),
  227. padding: EdgeInsets.all(0),
  228. )
  229. ],
  230. ),
  231. width: MediaQuery.of(context).size.width,
  232. )
  233. ],
  234. ),
  235. ),
  236. ),
  237. Container(
  238. height: hsp(100),
  239. color: Color(0xFFFFF6CC),
  240. alignment: Alignment.center,
  241. padding: EdgeInsets.only(left: hsp(20),right: hsp(20)),
  242. child: Text('改签订单金额高于原订单金额,需补足差价',style: TextStyle(fontSize: zsp(28),color: Color(0xFF93631B)),),
  243. ),
  244. Container(
  245. height: hsp(120),
  246. width: MediaQuery.of(context).size.width,
  247. color: Colors.white,
  248. padding: EdgeInsets.only(left: wsp(30),right: wsp(30)),
  249. child: Row(
  250. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  251. children: [
  252. RichText(
  253. text: TextSpan(
  254. text: '参考价(¥)',
  255. style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),
  256. children: [
  257. TextSpan(
  258. text: ' $_amount',
  259. style: TextStyle(fontSize: zsp(40),color: Color(0xFFFF6600)),
  260. )
  261. ]
  262. ),
  263. ),
  264. GestureDetector(
  265. child: Row(
  266. children: [
  267. Text('明细',style: TextStyle(fontSize: zsp(22),color: Color(0xFF181818)),),
  268. Icon(Icons.keyboard_arrow_up,size: hsp(30),color: Color(0xFF007EFF),),
  269. ],
  270. ),
  271. onTap: (){
  272. setState(() {
  273. _isDetail = !_isDetail;
  274. });
  275. },
  276. ),
  277. GestureDetector(
  278. onTap: (){
  279. showModalBottomSheet(
  280. context: context,
  281. backgroundColor: Colors.transparent,
  282. isScrollControlled: true,
  283. builder: (context){
  284. return YSPayTypeView(orderDict: {'orderSn':widget.orderSn,'price':_amount,'orderName':_msgDict['name']},postSuccess: (){
  285. Navigator.pop(context);
  286. Navigator.of(context).pop('');
  287. },);
  288. }
  289. );
  290. },
  291. child: Container(
  292. height: hsp(70),
  293. padding: EdgeInsets.only(left: wsp(50),right: wsp(50)),
  294. decoration: BoxDecoration(
  295. color: Color(0xFF007EFF),
  296. borderRadius: BorderRadius.all(Radius.circular(50))
  297. ),
  298. alignment: Alignment.center,
  299. child: Text('确定改签',style: TextStyle(fontSize: zsp(30),color: Colors.white,fontWeight: FontWeight.bold),),
  300. ),
  301. )
  302. ],
  303. ),
  304. )
  305. ],
  306. ),
  307. if(_isDetail==true)GestureDetector(
  308. onTap: (){
  309. setState(() {
  310. _isDetail = false;
  311. });
  312. },
  313. child: Container(
  314. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(120),
  315. color: Colors.black45,
  316. child: Container(
  317. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44-hsp(120)-hsp(370)),
  318. height: hsp(370),
  319. decoration: BoxDecoration(
  320. color: Colors.white,
  321. borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))
  322. ),
  323. child: GestureDetector(
  324. onTap: (){},
  325. behavior: HitTestBehavior.opaque,
  326. child: Column(
  327. children: [
  328. Container(
  329. height: hsp(100),
  330. padding: EdgeInsets.only(left: 15,right: 15),
  331. child: Row(
  332. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  333. children: [
  334. GestureDetector(
  335. child: Text('关闭',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  336. onTap: (){
  337. setState(() {
  338. _isDetail = false;
  339. });
  340. },
  341. ),
  342. Text('明细',style: TextStyle(fontSize: 15,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),),
  343. Container(width: wsp(50),),
  344. ],
  345. ),
  346. ),
  347. Container(
  348. height: hsp(270),
  349. color: Color(0xFFF7F8F9),
  350. padding: EdgeInsets.only(left: wsp(40),right: wsp(40),bottom: hsp(20),top: hsp(20)),
  351. child: Column(
  352. children: [
  353. Row(
  354. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  355. crossAxisAlignment: CrossAxisAlignment.start,
  356. children: [//x ${_customer.length==0?1:_customer.length}人
  357. Text('手续费',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000),decoration: TextDecoration.none),),
  358. Text('¥ ${_msgDict['newEndorsePrice']??0*_msgDict['personNum']??0}',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  359. ],
  360. ),
  361. if((_msgDict['newOrderPrice']??0)-(_msgDict['orderPrice']??0)>0)Container(
  362. margin: EdgeInsets.only(top: hsp(10)),
  363. child: Row(
  364. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  365. crossAxisAlignment: CrossAxisAlignment.start,
  366. children: [//x ${_customer.length==0?1:_customer.length}人
  367. Text('差价',style: TextStyle(fontSize: zsp(32),color: Color(0xFF000000),decoration: TextDecoration.none),),
  368. Text('¥ ${(_msgDict['newOrderPrice']??0)-(_msgDict['orderPrice']??0)}',style: TextStyle(fontSize: 15,color: Color(0xFF007EFF),decoration: TextDecoration.none),),
  369. ],
  370. ),
  371. )
  372. ],
  373. ),
  374. ),
  375. ],
  376. ),
  377. ),
  378. ),
  379. ),
  380. )
  381. ],
  382. ),
  383. ),
  384. );
  385. }
  386. _getTicketData() async{
  387. Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/createChanging',
  388. parameter: {'orderSn':widget.orderSn,'changeTime':widget.dateStr},isLoading: false,isToken: true);
  389. if(dict!=null){
  390. _msgDict = dict['data'];
  391. _amount = '${_msgDict['newEndorsePrice']*_msgDict['personNum']+(_msgDict['newOrderPrice']-_msgDict['orderPrice'])}';
  392. setState(() {});
  393. }
  394. }
  395. }