import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:ysairplane/code/YSIssue.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; import 'YSPay.dart'; import 'YSSearchResult.dart'; class YSShortGoods extends StatefulWidget { @override _YSShortGoodsState createState() => _YSShortGoodsState(); } class _YSShortGoodsState extends State { int _type = 1; bool _isDetail = false; bool _isOrder = false; int _index,_selected = 0; Map _msgDict,_kind; List chooses = ['货源','机源']; String choose = '货源'; int _page = 1; List _dataArray = []; List _priceList = []; List _kinds = []; TextEditingController _name = TextEditingController(); TextEditingController _volume = TextEditingController(); TextEditingController _weight = TextEditingController(); String _timeStr; @override void initState() { _timeStr = DateTime.now().year.toString()+'-'+DateTime.now().month.toString().padLeft(2,'0')+'-' +DateTime.now().day.toString().padLeft(2,'0')+' '+DateTime.now().hour.toString().padLeft(2,'0')+':'+DateTime.now().minute.toString().padLeft(2,'0'); Future.delayed(Duration(seconds: 0)).then((value){ _getBackImageData(); _refreshData(); }); super.initState(); } @override void dispose() { _name.dispose(); _volume.dispose(); _weight.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xFFF1F2F4), body: SingleChildScrollView( child: Stack( children: [ Container( height: MediaQuery.of(context).padding.top+hsp(370), width: MediaQuery.of(context).size.width, child: Image( image: _msgDict==null?AssetImage('lib/images/home3.png'):NetworkImage('${_msgDict['background']}'), fit: BoxFit.fill, ), ), if(_msgDict!=null)Container( margin: EdgeInsets.only(left: wsp(50),top: MediaQuery.of(context).padding.top+hsp(250)), child: RichText( text: TextSpan( text: '${_msgDict['name']} ', style: TextStyle(fontSize: zsp(50),color: Colors.white,fontWeight: FontWeight.bold), children: [ TextSpan( text: '${_msgDict['subtitle']}', style: TextStyle(fontWeight: FontWeight.normal,fontSize: zsp(28),color: Colors.white.withOpacity(0.5)) ) ] ), ), ), GestureDetector( onTap: (){ Navigator.pop(context); }, child: Container( margin: EdgeInsets.only(left: hsp(30),right: wsp(30),top: MediaQuery.of(context).padding.top+hsp(65)), child: Icon(Icons.arrow_back_ios,color: Colors.white,size: hsp(50),), ), ), GestureDetector( onTap: (){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSSearchResult(type: 3,); }) ); }, child: Container( margin: EdgeInsets.only(left: hsp(110),top: MediaQuery.of(context).padding.top+hsp(60)), width: MediaQuery.of(context).size.width-hsp(340), height: hsp(60), decoration: BoxDecoration( color: Colors.black.withOpacity(0.35), borderRadius: BorderRadius.all(Radius.circular(50)) ), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Row( children: [ DropdownButton( value: choose, items: [ for(int i=0;i _refreshData() async{ _page = 1; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: {'category':_type==1?3:33,'pageNo':_page,'pageSize':10},isLoading: false,isToken: false); if(dict!=null){ setState(() { _dataArray = dict['data']['resultList']; }); } } Future _loadMoreData() async{ _page++; Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/AirTour/list',parameter: {'category':_type==1?3:33,'pageNo':_page,'pageSize':10},isLoading: false,isToken: false); if(dict!=null){ setState(() { _dataArray.add(dict['data']['resultList']); }); } } _getPriceData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplaneorder/getDateAndTime', parameter: {'time':_timeStr,'type':3,'id':_dataArray[_index]['id']},isLoading: true,isToken: true); if(dict!=null){ _isOrder = true; _priceList = dict['data']; _getTypeData(); } } _getTypeData() async{ Map dict = await ysRequestHttp(context,type: requestType.get,api: '/app/applets/airplanegoods/type/get',parameter: {},isLoading: true,isToken: false); if(dict!=null){ setState(() { _kinds = dict['data']; _kind = _kinds[0]; }); } } _postOrderData() async{ if(_name.text.isEmpty){ ysFlutterToast(context, '货物名称不能为空'); return; } if(_volume.text.isEmpty){ ysFlutterToast(context, '货物体积不能为空'); return; } if(_weight.text.isEmpty){ ysFlutterToast(context, '货物重量不能为空'); return; } Map request = {}; request['flightTime'] = '2020-10-07 17:59:27'; request['type'] = 3; request['airplaneid'] = _dataArray[_index]['id']; request['airportidSetout'] = _dataArray[_index]['airportidSetout']; request['airportidArrive'] = _dataArray[_index]['airportidArrive']; request['airportidArrive'] = _dataArray[_index]['airportidArrive']; Map value = {}; value['goodsName'] = _name.text; value['goodsNatureId'] = _kind['id']; value['goodsVolume'] = _volume.text; value['goodsWeight'] = _weight.text; value['contactPerson'] = '111'; value['phone'] = '15829646496'; value['goodsPlace'] = '西安小寨A座国际商务酒店'; value['goodsLocation'] = '108.985463,34.30501'; value['goodsUnloadingPlace'] = '上海酒店'; value['goodsUnloadingLocation'] = '108.985463,34.30501'; request['dtAirplaneGoods'] = value; request['sourceType'] = _dataArray[_index]['type']; Map dict = await ysRequestHttp(context,type: requestType.post,api: '/app/applets/airplaneorder/createOrder',parameter: request,isLoading: true,isToken: true); if(dict!=null){ Navigator.of(context).push( CupertinoPageRoute( builder: (context){ return YSPay(orderDict: dict['data'],type: payType.goods,); } ) ); } } }