send_express_page.dart 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:city_pickers/city_pickers.dart';
  5. import 'package:flutter_picker/flutter_picker.dart';
  6. import 'dart:async';
  7. import 'send_express_page/order_detail_page.dart';
  8. import '../util/util.dart';
  9. import '../util/api.dart';
  10. import '../util/models.dart';
  11. import '../showAlert.dart';
  12. import '../send_Dialog.dart';
  13. import '../util/session.dart';
  14. import '../showLineModal.dart';
  15. import '../util/bluetooth_utils.dart';
  16. class SendExpressPage extends StatefulWidget {
  17. final Widget child;
  18. SendExpressPage({
  19. Key key,
  20. this.child
  21. }): super(key: key);
  22. _SendExpressPageState createState() => _SendExpressPageState();
  23. }
  24. class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
  25. ScrollController _scrollController = ScrollController();
  26. //组件自用字段-----------------------------
  27. GlobalKey _sendPhoneKey = GlobalKey();
  28. GlobalKey _getPhoneKey = GlobalKey();
  29. GlobalKey _sendCompanyCodeKey = GlobalKey();
  30. GlobalKey _sendCompanyNameKey = GlobalKey();
  31. GlobalKey _getCompanyNameKey = GlobalKey();
  32. double tipWidth = 0;
  33. double tipHeight = 0;
  34. double tipPosX = 0;
  35. double tipPosY = 0;
  36. bool tipStatus = true;
  37. bool lineModalStatus = false;
  38. bool submitStatus = true;
  39. List < LikePhoneList > likePhoneList = [];
  40. var timer;
  41. bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
  42. TextEditingController sendCompanyPhoneController = TextEditingController();
  43. TextEditingController sendCompanyCodeController = TextEditingController();
  44. TextEditingController sendCompanyNameController = TextEditingController();
  45. TextEditingController receiptCompanyPhoneController = TextEditingController();
  46. TextEditingController receiptCompanyNameController = TextEditingController();
  47. TextEditingController sendCompanyAddressController = TextEditingController();
  48. TextEditingController receiptCompanyAddressController = TextEditingController();
  49. TextEditingController bankCardController = TextEditingController();
  50. TextEditingController bankNameController = TextEditingController();
  51. TextEditingController openBankNameController = TextEditingController();
  52. TextEditingController openBankPhoneController = TextEditingController();
  53. TextEditingController goodsController = TextEditingController();
  54. TextEditingController goodsQuantityController = TextEditingController();
  55. TextEditingController goodsFreightController = TextEditingController();
  56. TextEditingController goodsAgencyFundController = TextEditingController();
  57. TextEditingController goodsPriceProtectionController = TextEditingController();
  58. TextEditingController goodsWeightController = TextEditingController();
  59. TextEditingController memoController = TextEditingController();
  60. FocusNode bankCardFocusNode = FocusNode();
  61. List < dynamic > goodsCateGoryList = [];
  62. List < dynamic > goodsPackageList = [];
  63. //请求字段-------------------------
  64. String lineId = '-1';//收件公司匹配的线路id
  65. String sendCompanyId = '0'; //寄件公司Id
  66. String sendCompanyName = ''; //寄件公司名称 不能为空
  67. String sendCompanyPhone = ''; //寄件公司电话 不能为空
  68. String sendCompanyCode = ''; //寄件公司编码
  69. String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
  70. String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
  71. String sendCompanyCityName = ''; //寄件公司市名称 不能为空
  72. String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
  73. String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
  74. String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
  75. String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
  76. String receiptCompanyId = '0'; //收件公司id
  77. String receiptCompanyPhone = ''; //收件公司电话 不能为空
  78. String receiptCompanyName = ''; //收件公司名称 不能为空
  79. String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
  80. String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
  81. String receiptCompanyCityName = ''; //收件公司市名称 不能为空
  82. String receiptCompanyCityCode = ''; //收件公市编码 不能为空
  83. String receiptCompanyAreaName = ''; //收件公区名称 不能为空
  84. String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
  85. String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
  86. String goods = ''; //商品名称 不能为空
  87. int goodsQuantity = 1; //商品数量 不能为空
  88. int goodsPackingId; //商品包装ID
  89. int goodsCategoryId; //商品类别ID
  90. int goodsPaymentMethod = 2; //付款方式 1,现付 2 到付
  91. double goodsWeight = 0.0; //商品重量
  92. double goodsPriceProtection = 0.0; //商品保价
  93. double goodsAgencyFund = 0.0; //商品代收款
  94. double goodsFreight = 0.0; //商品运费 不能为空
  95. String memo = ''; //备注
  96. String bankCard = '';//银行卡号
  97. String bankName = '';//所属银行
  98. String openBankName = '';//开户人
  99. String openBankPhone = '';//开户电话
  100. List<CompanyOfLineList> lineList = [];
  101. String sendPCA = ' '; //Text组件内容必须有空格,否则报null
  102. String getPCA = ' ';
  103. String showTextGoodsCategory = ' ';
  104. String showTextGoodsPackage = ' ';
  105. String showTextPaymentMehod = '到付';
  106. BluetoothUtils bluetooth = BluetoothUtils();
  107. bool checkedCompanyInfo = false;//选择公司信息向sendCompanyPhoneController填充时不去模糊匹配
  108. @override
  109. void initState() {
  110. super.initState();
  111. goodsCategory().then((resp) {
  112. if (isNotError(context, resp) && this.mounted) {
  113. GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
  114. setState(() {
  115. goodsCateGoryList = goodsCategoryObj.data;
  116. showTextGoodsCategory = goodsCateGoryList[0].name;
  117. goodsCategoryId = goodsCateGoryList[0].id;
  118. });
  119. }
  120. });
  121. goodsPackage().then((resp) {
  122. if (isNotError(context, resp) && this.mounted) {
  123. GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
  124. setState(() {
  125. goodsPackageList = goodsPackageObj.data;
  126. showTextGoodsPackage = goodsPackageList[0].name;
  127. goodsPackingId = goodsPackageList[0].id;
  128. });
  129. }
  130. });
  131. _scrollController.addListener(() {
  132. if (!tipStatus) {
  133. setState(() {
  134. tipStatus = true;
  135. });
  136. }
  137. //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
  138. });
  139. //发件公司电话监听
  140. sendCompanyPhoneController.addListener(() {
  141. if(checkedCompanyInfo){
  142. return;
  143. }
  144. setState(() {
  145. sendCompanyPhone = sendCompanyPhoneController.text;
  146. });
  147. if (timer != null) {
  148. timer.cancel();
  149. }
  150. if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
  151. setState(() {
  152. tipStatus = true;
  153. });
  154. }
  155. timer = Timer(Duration(milliseconds: 250), () {
  156. if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length <= 11) {
  157. likePhone(sendCompanyPhoneController.text).then((resp) {
  158. if (isNotError(context, resp) && this.mounted) {
  159. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  160. likePhoneList = likePhoneObj.data;
  161. }
  162. if (likePhoneList.length > 0) {
  163. sendPhoneOrGetPhoneTab = true;
  164. RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
  165. setState(() {
  166. tipWidth = sendPhoneObj.paintBounds.size.width;
  167. tipHeight = sendPhoneObj.paintBounds.size.height;
  168. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  169. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  170. tipStatus = false;
  171. });
  172. } else {
  173. setState(() {
  174. tipStatus = true;
  175. });
  176. }
  177. });
  178. }
  179. });
  180. });
  181. //发件公司编码监听
  182. sendCompanyCodeController.addListener(() {
  183. if(checkedCompanyInfo){
  184. return;
  185. }
  186. setState(() {
  187. sendCompanyCode = sendCompanyCodeController.text;
  188. });
  189. if (timer != null) {
  190. timer.cancel();
  191. }
  192. if (sendCompanyCodeController.text.length < 2 || sendCompanyCodeController.text.length > 6) {
  193. setState(() {
  194. tipStatus = true;
  195. });
  196. }
  197. timer = Timer(Duration(milliseconds: 250), () {
  198. if (sendCompanyCodeController.text.length >= 2 && sendCompanyCodeController.text.length <= 6) {
  199. likeCompanyCode(sendCompanyCodeController.text).then((resp) {
  200. if (isNotError(context, resp) && this.mounted) {
  201. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  202. likePhoneList = likePhoneObj.data;
  203. }
  204. if (likePhoneList.length > 0) {
  205. sendPhoneOrGetPhoneTab = true;
  206. RenderObject sendPhoneObj = _sendCompanyCodeKey.currentContext.findRenderObject();
  207. setState(() {
  208. tipWidth = sendPhoneObj.paintBounds.size.width;
  209. tipHeight = sendPhoneObj.paintBounds.size.height;
  210. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  211. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  212. tipStatus = false;
  213. });
  214. } else {
  215. setState(() {
  216. tipStatus = true;
  217. });
  218. }
  219. });
  220. }
  221. });
  222. });
  223. //发件公司名字监听
  224. sendCompanyNameController.addListener(() {
  225. if(checkedCompanyInfo){
  226. return;
  227. }
  228. setState(() {
  229. sendCompanyName = sendCompanyNameController.text;
  230. });
  231. if (timer != null) {
  232. timer.cancel();
  233. }
  234. if (sendCompanyNameController.text.length < 2 || sendCompanyNameController.text.length > 11) {
  235. setState(() {
  236. tipStatus = true;
  237. });
  238. }
  239. timer = Timer(Duration(milliseconds: 250), () {
  240. if (sendCompanyNameController.text.length >= 2 && sendCompanyNameController.text.length <= 11) {
  241. likeCompanyName(sendCompanyNameController.text).then((resp) {
  242. if (isNotError(context, resp) && this.mounted) {
  243. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  244. likePhoneList = likePhoneObj.data;
  245. }
  246. if (likePhoneList.length > 0) {
  247. sendPhoneOrGetPhoneTab = true;
  248. RenderObject sendPhoneObj = _sendCompanyNameKey.currentContext.findRenderObject();
  249. setState(() {
  250. tipWidth = sendPhoneObj.paintBounds.size.width;
  251. tipHeight = sendPhoneObj.paintBounds.size.height;
  252. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  253. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  254. tipStatus = false;
  255. });
  256. } else {
  257. setState(() {
  258. tipStatus = true;
  259. });
  260. }
  261. });
  262. }
  263. });
  264. });
  265. //收件公司电话监听
  266. receiptCompanyPhoneController.addListener(() {
  267. if(checkedCompanyInfo){
  268. return;
  269. }
  270. setState(() {
  271. receiptCompanyPhone = receiptCompanyPhoneController.text;
  272. });
  273. if (timer != null) {
  274. timer.cancel();
  275. }
  276. if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
  277. setState(() {
  278. tipStatus = true;
  279. });
  280. }
  281. timer = Timer(Duration(milliseconds: 250), () {
  282. if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length <= 11) {
  283. likePhone(receiptCompanyPhoneController.text).then((resp) {
  284. if (isNotError(context, resp) && this.mounted) {
  285. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  286. likePhoneList = likePhoneObj.data;
  287. }
  288. if (likePhoneList.length > 0) {
  289. sendPhoneOrGetPhoneTab = false;
  290. RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
  291. setState(() {
  292. tipWidth = getPhoneKey.paintBounds.size.width;
  293. tipHeight = getPhoneKey.paintBounds.size.height;
  294. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  295. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  296. tipStatus = false;
  297. });
  298. } else {
  299. setState(() {
  300. tipStatus = true;
  301. });
  302. }
  303. });
  304. }
  305. });
  306. });
  307. //收件公司名称监听
  308. receiptCompanyNameController.addListener(() {
  309. if(checkedCompanyInfo){
  310. return;
  311. }
  312. setState(() {
  313. receiptCompanyName = receiptCompanyNameController.text;
  314. });
  315. if (timer != null) {
  316. timer.cancel();
  317. }
  318. if (receiptCompanyNameController.text.length < 2 || receiptCompanyNameController.text.length > 11) {
  319. setState(() {
  320. tipStatus = true;
  321. });
  322. }
  323. timer = Timer(Duration(milliseconds: 250), () {
  324. if (receiptCompanyNameController.text.length >= 2 && receiptCompanyNameController.text.length <= 11) {
  325. likeCompanyName(receiptCompanyNameController.text).then((resp) {
  326. if (isNotError(context, resp) && this.mounted) {
  327. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  328. likePhoneList = likePhoneObj.data;
  329. }
  330. if (likePhoneList.length > 0) {
  331. sendPhoneOrGetPhoneTab = false;
  332. RenderObject getPhoneKey = _getCompanyNameKey.currentContext.findRenderObject();
  333. setState(() {
  334. tipWidth = getPhoneKey.paintBounds.size.width;
  335. tipHeight = getPhoneKey.paintBounds.size.height;
  336. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  337. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  338. tipStatus = false;
  339. });
  340. } else {
  341. setState(() {
  342. tipStatus = true;
  343. });
  344. }
  345. });
  346. }
  347. });
  348. });
  349. sendCompanyAddressController.addListener(() {
  350. setState(() {
  351. sendCompanyAddress = sendCompanyAddressController.text;
  352. });
  353. });
  354. receiptCompanyAddressController.addListener(() {
  355. setState(() {
  356. receiptCompanyAddress = receiptCompanyAddressController.text;
  357. });
  358. });
  359. bankCardFocusNode.addListener((){
  360. if(!bankCardFocusNode.hasFocus){
  361. if(bankCardController.text!=''){
  362. getBankName(bankCardController.text).then((resp){
  363. if(isNotError(context, resp) && this.mounted){
  364. BankNameObj obj = BankNameObj.fromJson(resp.data);
  365. setState(() {
  366. bankNameController.text = obj.data;
  367. });
  368. }
  369. });
  370. }
  371. }
  372. });
  373. }
  374. @override
  375. bool get wantKeepAlive => true;
  376. @override
  377. Widget build(BuildContext context) {
  378. return Container(
  379. child: Scaffold(
  380. appBar: AppBar(
  381. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  382. centerTitle: true,
  383. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  384. ),
  385. body:
  386. Stack(
  387. children: < Widget > [
  388. Container(
  389. color: Color.fromRGBO(246, 246, 254, 1),
  390. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  391. child: ListView(
  392. controller: _scrollController,
  393. children: < Widget > [
  394. _sendInfo(context),
  395. _getInfo(context),
  396. _itemInfoWidget(),
  397. _bankInfo(context),
  398. _submitBtn()
  399. ],
  400. ),
  401. ),
  402. Positioned(
  403. top: tipPosY,
  404. left: tipPosX,
  405. child: Offstage(
  406. offstage: tipStatus,
  407. child: Container(
  408. width: tipWidth,
  409. height: ScreenUtil.getInstance().setHeight(450),
  410. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  411. decoration: BoxDecoration(
  412. color: Color.fromRGBO(244, 248, 251, 1),
  413. ),
  414. child: ListView.builder(
  415. itemCount: likePhoneList.length,
  416. itemBuilder: (BuildContext context, int index) {
  417. return _tipItem(likePhoneList[index]);
  418. },
  419. )
  420. ),
  421. )
  422. )
  423. ],
  424. ),
  425. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  426. ),
  427. );
  428. }
  429. Widget _sendInfo(BuildContext context) {
  430. return Container(
  431. color: Colors.white,
  432. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  433. child: Column(
  434. children: < Widget > [
  435. _titleWidget('lib/images/icon_send.png', '发件信息'),
  436. _underLine(),
  437. _inputWiget('send_phone','发件电话', _sendPhoneKey,sendCompanyPhoneController),
  438. _inputWiget('send_code','企业编码', _sendCompanyCodeKey, sendCompanyCodeController,true),
  439. _inputWiget('send_name','企业名称', _sendCompanyNameKey, sendCompanyNameController,true),
  440. _cityWiget('城市/区域', context, 'send'),
  441. _lastContentWiget('详细地址', 'send')
  442. ],
  443. )
  444. );
  445. }
  446. Widget _getInfo(BuildContext context) {
  447. return Container(
  448. color: Colors.white,
  449. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  450. child: Column(
  451. children: < Widget > [
  452. _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  453. _underLine(),
  454. _inputWiget('get_phone','收件电话', _getPhoneKey,receiptCompanyPhoneController),
  455. _inputWiget('get_name','企业名称', _getCompanyNameKey,receiptCompanyNameController ,true),
  456. _cityWiget('城市/区域', context, 'get'),
  457. _lastContentWiget('详细地址', 'get')
  458. ],
  459. )
  460. );
  461. }
  462. Widget _itemInfoWidget() {
  463. return Container(
  464. child: Container(
  465. color: Colors.white,
  466. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  467. child: Column(
  468. crossAxisAlignment: CrossAxisAlignment.start,
  469. children: < Widget > [
  470. _titleWidget('lib/images/icon_huowu.png', "货物信息"),
  471. _underLine(),
  472. _itemContentWiget("货物名称", goodsController, true),
  473. _itemContentWiget("数量", goodsQuantityController),
  474. _itemContentWiget("运费", goodsFreightController),
  475. _itemContentWiget("代收", goodsAgencyFundController),
  476. _itemContentWiget("保价", goodsPriceProtectionController),
  477. _itemContentWiget("重量", goodsWeightController),
  478. _packageType('包装类型'),
  479. _packageType('货物类型'),
  480. _packageType('付款方式'),
  481. _descWidget()
  482. ],
  483. ),
  484. )
  485. );
  486. }
  487. Widget _bankInfo(BuildContext context) {
  488. return Container(
  489. color: Colors.white,
  490. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  491. child: Column(
  492. children: < Widget > [
  493. _titleWidget('lib/images/icon_bank.png', '银行信息'),
  494. _underLine(),
  495. _contentBankWiget('银行卡号', 'bank'),
  496. _contentBankWiget('银行名称', 'bank',true),
  497. _contentBankWiget('开户人', 'bank',true),
  498. _lastBankContentWiget('开户电话', 'bank'),
  499. ],
  500. )
  501. );
  502. }
  503. Widget _titleWidget(String iconUrl, String str) {
  504. return Container(
  505. height: ScreenUtil.getInstance().setHeight(90),
  506. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  507. child: Center(
  508. child: Row(
  509. mainAxisAlignment: MainAxisAlignment.start,
  510. children: < Widget > [
  511. Padding(
  512. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  513. child: Image.asset(
  514. iconUrl,
  515. width: ScreenUtil.getInstance().setWidth(40),
  516. height: ScreenUtil.getInstance().setHeight(40),
  517. )
  518. ),
  519. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  520. ],
  521. ),
  522. ),
  523. );
  524. }
  525. Widget _underLine() {
  526. return Container(
  527. color: Color.fromRGBO(223, 223, 223, 1),
  528. height: ScreenUtil.getInstance().setHeight(1),
  529. );
  530. }
  531. Widget _inputWiget(String key,String title GlobalKey tab,TextEditingController tab1,[bool keyboardType = false]) {
  532. return Padding(
  533. key: tab,
  534. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  535. child: Column(
  536. children: < Widget > [
  537. SizedBox(
  538. height: ScreenUtil.getInstance().setHeight(89),
  539. child: Center(
  540. child: Row(
  541. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  542. children: < Widget > [
  543. Expanded(
  544. flex: 0,
  545. child: Text(title, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  546. ),
  547. Expanded(
  548. child: Row(
  549. mainAxisAlignment: MainAxisAlignment.end,
  550. children: < Widget > [
  551. SizedBox(
  552. width: ScreenUtil.getInstance().setWidth(500),
  553. child: Padding(
  554. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  555. child: TextField(
  556. controller: tab1,
  557. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  558. textAlign: TextAlign.end,
  559. decoration: InputDecoration(
  560. border: InputBorder.none
  561. ),
  562. onEditingComplete: () {
  563. setState(() {
  564. FocusScope.of(context).requestFocus(FocusNode());
  565. tipStatus = true;
  566. });
  567. },
  568. onChanged: (value){
  569. checkedCompanyInfo = false;
  570. if(key=='send_phone'){
  571. sendCompanyCode = '';
  572. sendCompanyName = '';
  573. sendCompanyId ='0';
  574. sendCompanyCodeController.text = '';
  575. sendCompanyNameController.text = '';
  576. sendPCA = '';
  577. sendCompanyProvinceName = '';
  578. sendCompanyProvinceCode = '';
  579. sendCompanyCityName = '';
  580. sendCompanyCityCode = '';
  581. sendCompanyAreaName = '';
  582. sendCompanyAreaCode = '';
  583. bankCardController.text = '';
  584. bankNameController.text = '';
  585. openBankNameController.text = '';
  586. openBankPhoneController.text = '';
  587. sendCompanyAddressController.text = '';
  588. }else if(key=='get_phone'){
  589. receiptCompanyName = '';
  590. receiptCompanyNameController.text = '';
  591. receiptCompanyId = '0';
  592. getPCA = '';
  593. receiptCompanyProvinceName = '';
  594. receiptCompanyProvinceCode = '';
  595. receiptCompanyCityName = '';
  596. receiptCompanyCityCode = '';
  597. receiptCompanyAreaName = '';
  598. receiptCompanyAreaCode = '';
  599. receiptCompanyAddressController.text = '';
  600. }else if(key=='send_code'){
  601. sendCompanyPhone = '';
  602. sendCompanyName = '';
  603. sendCompanyId ='0';
  604. sendCompanyPhoneController.text = '';
  605. sendCompanyNameController.text = '';
  606. sendPCA = '';
  607. sendCompanyProvinceName = '';
  608. sendCompanyProvinceCode = '';
  609. sendCompanyCityName = '';
  610. sendCompanyCityCode = '';
  611. sendCompanyAreaName = '';
  612. sendCompanyAreaCode = '';
  613. bankCardController.text = '';
  614. bankNameController.text = '';
  615. openBankNameController.text = '';
  616. openBankPhoneController.text = '';
  617. sendCompanyAddressController.text = '';
  618. }else if(key=='send_name'){
  619. sendCompanyCode = '';
  620. sendCompanyPhone = '';
  621. sendCompanyId ='0';
  622. sendCompanyCodeController.text = '';
  623. sendCompanyPhoneController.text = '';
  624. sendPCA = '';
  625. sendCompanyProvinceName = '';
  626. sendCompanyProvinceCode = '';
  627. sendCompanyCityName = '';
  628. sendCompanyCityCode = '';
  629. sendCompanyAreaName = '';
  630. sendCompanyAreaCode = '';
  631. bankCardController.text = '';
  632. bankNameController.text = '';
  633. openBankNameController.text = '';
  634. openBankPhoneController.text = '';
  635. sendCompanyAddressController.text = '';
  636. }else if(key=='get_name'){
  637. receiptCompanyPhone = '';
  638. receiptCompanyPhoneController.text = '';
  639. receiptCompanyId = '0';
  640. getPCA = '';
  641. receiptCompanyProvinceName = '';
  642. receiptCompanyProvinceCode = '';
  643. receiptCompanyCityName = '';
  644. receiptCompanyCityCode = '';
  645. receiptCompanyAreaName = '';
  646. receiptCompanyAreaCode = '';
  647. receiptCompanyAddressController.text = '';
  648. }
  649. },
  650. ),
  651. )
  652. ),
  653. // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  654. ],
  655. )
  656. )
  657. ],
  658. ),
  659. )
  660. ),
  661. Expanded(
  662. flex: 0,
  663. child: _underLine()
  664. )
  665. ],
  666. )
  667. );
  668. }
  669. // Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  670. // return Padding(
  671. // padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  672. // child: Column(
  673. // children: < Widget > [
  674. // SizedBox(
  675. // height: ScreenUtil.getInstance().setHeight(89),
  676. // child: Center(
  677. // child: Row(
  678. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  679. // children: < Widget > [
  680. // Expanded(
  681. // flex: 0,
  682. // child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  683. // ),
  684. // Expanded(
  685. // child: Row(
  686. // mainAxisAlignment: MainAxisAlignment.end,
  687. // children: < Widget > [
  688. // SizedBox(
  689. // width: ScreenUtil.getInstance().setWidth(500),
  690. // child:Padding(
  691. // padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  692. // child:TextField(
  693. // controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
  694. // keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  695. // textAlign: TextAlign.end,
  696. // decoration: InputDecoration(
  697. // border: InputBorder.none
  698. // ),
  699. // onChanged: (value) {
  700. // if (key == '货物名称') {
  701. // goods = value;
  702. // } else if (key == '数量') {
  703. // goodsQuantity = int.parse(value);
  704. // } else if (key == '运费') {
  705. // goodsFreight = double.parse(value);
  706. // String temp = goodsFreight.toStringAsFixed(1);
  707. // goodsFreight = double.parse(temp);
  708. // } else if (key == '代收') {
  709. // goodsAgencyFund = double.parse(value);
  710. // String temp = goodsAgencyFund.toStringAsFixed(1);
  711. // goodsAgencyFund = double.parse(temp);
  712. // } else if (key == '保价') {
  713. // goodsPriceProtection = double.parse(value);
  714. // String temp = goodsPriceProtection.toStringAsFixed(1);
  715. // goodsPriceProtection = double.parse(temp);
  716. // } else if (key == '重量') {
  717. // goodsWeight = double.parse(value);
  718. // String temp = goodsWeight.toStringAsFixed(1);
  719. // goodsWeight = double.parse(temp);
  720. // }
  721. // },
  722. // ),
  723. // )
  724. // ),
  725. // // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  726. // ],
  727. // )
  728. // )
  729. // ],
  730. // ),
  731. // )
  732. // ),
  733. // Expanded(
  734. // flex: 0,
  735. // child: _underLine()
  736. // )
  737. // ],
  738. // )
  739. // );
  740. // }
  741. Widget _itemContentWiget(String key,TextEditingController controller, [bool keyboardType = false]) { //false是数字键盘
  742. return Padding(
  743. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  744. child: Column(
  745. children: < Widget > [
  746. SizedBox(
  747. height: ScreenUtil.getInstance().setHeight(89),
  748. child: Center(
  749. child: Row(
  750. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  751. children: < Widget > [
  752. Expanded(
  753. flex: 0,
  754. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  755. ),
  756. Expanded(
  757. child: Row(
  758. mainAxisAlignment: MainAxisAlignment.end,
  759. children: < Widget > [
  760. SizedBox(
  761. width: ScreenUtil.getInstance().setWidth(500),
  762. child: Padding(
  763. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  764. child:TextField(
  765. controller: controller,
  766. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  767. textAlign: TextAlign.end,
  768. decoration: InputDecoration(
  769. border: InputBorder.none
  770. ),
  771. onChanged: (value) {
  772. if (key == '货物名称') {
  773. goods = value;
  774. } else if (key == '数量') {
  775. goodsQuantity = int.parse(value);
  776. } else if (key == '运费') {
  777. goodsFreight = double.parse(value);
  778. String temp = goodsFreight.toStringAsFixed(1);
  779. goodsFreight = double.parse(temp);
  780. } else if (key == '代收') {
  781. goodsAgencyFund = double.parse(value);
  782. String temp = goodsAgencyFund.toStringAsFixed(1);
  783. goodsAgencyFund = double.parse(temp);
  784. } else if (key == '保价') {
  785. goodsPriceProtection = double.parse(value);
  786. String temp = goodsPriceProtection.toStringAsFixed(1);
  787. goodsPriceProtection = double.parse(temp);
  788. } else if (key == '重量') {
  789. goodsWeight = double.parse(value);
  790. String temp = goodsWeight.toStringAsFixed(1);
  791. goodsWeight = double.parse(temp);
  792. }
  793. },
  794. ),
  795. )
  796. ),
  797. // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  798. ],
  799. )
  800. )
  801. ],
  802. ),
  803. )
  804. ),
  805. Expanded(
  806. flex: 0,
  807. child: _underLine()
  808. )
  809. ],
  810. )
  811. );
  812. }
  813. Widget _contentBankWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  814. return Padding(
  815. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  816. child: Column(
  817. children: < Widget > [
  818. SizedBox(
  819. height: ScreenUtil.getInstance().setHeight(89),
  820. child: Center(
  821. child: Row(
  822. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  823. children: < Widget > [
  824. Expanded(
  825. flex: 0,
  826. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  827. ),
  828. Expanded(
  829. child: Row(
  830. mainAxisAlignment: MainAxisAlignment.end,
  831. children: < Widget > [
  832. SizedBox(
  833. width: ScreenUtil.getInstance().setWidth(500),
  834. child:
  835. Padding(
  836. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  837. child:TextField(
  838. focusNode: key == '银行卡号'?bankCardFocusNode:null,
  839. controller: key == '银行卡号'?bankCardController:key=='银行名称'?bankNameController:openBankNameController,
  840. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  841. textAlign: TextAlign.end,
  842. decoration: InputDecoration(
  843. border: InputBorder.none
  844. ),
  845. ),
  846. )
  847. ),
  848. // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  849. ],
  850. )
  851. )
  852. ],
  853. ),
  854. )
  855. ),
  856. Expanded(
  857. flex: 0,
  858. child: _underLine()
  859. )
  860. ],
  861. )
  862. );
  863. }
  864. Widget _cityWiget(String key, BuildContext context, String type) {
  865. return
  866. GestureDetector(
  867. child: Padding(
  868. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  869. child: Column(
  870. children: < Widget > [
  871. SizedBox(
  872. height: ScreenUtil.getInstance().setHeight(89),
  873. child: Center(
  874. child: Row(
  875. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  876. children: < Widget > [
  877. Expanded(
  878. flex: 0,
  879. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  880. ),
  881. Expanded(
  882. child: Row(
  883. mainAxisAlignment: MainAxisAlignment.end,
  884. children: < Widget > [
  885. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  886. SizedBox(
  887. width: ScreenUtil.getInstance().setWidth(500),
  888. child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
  889. ),
  890. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  891. ],
  892. )
  893. )
  894. ],
  895. ),
  896. )
  897. ),
  898. Expanded(
  899. flex: 0,
  900. child: _underLine()
  901. )
  902. ],
  903. )
  904. ),
  905. onTap: () {
  906. getCity(context).then((resp) {
  907. if (resp == null) {
  908. return;
  909. }
  910. print(resp.toString());
  911. setState(() {
  912. if (type == 'send') {
  913. sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  914. sendCompanyProvinceName = resp.provinceName;
  915. sendCompanyProvinceCode = resp.provinceId;
  916. sendCompanyCityName = resp.cityName;
  917. sendCompanyCityCode = resp.cityId;
  918. sendCompanyAreaName = resp.areaName;
  919. sendCompanyAreaCode = resp.areaId;
  920. } else {
  921. getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  922. receiptCompanyProvinceName = resp.provinceName;
  923. receiptCompanyProvinceCode = resp.provinceId;
  924. receiptCompanyCityName = resp.cityName;
  925. receiptCompanyCityCode = resp.cityId;
  926. receiptCompanyAreaName = resp.areaName;
  927. receiptCompanyAreaCode = resp.areaId;
  928. }
  929. });
  930. //print(value);
  931. });
  932. },
  933. );
  934. }
  935. Widget _lastContentWiget(String key, String type) {
  936. return Padding(
  937. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  938. child: SizedBox(
  939. height: ScreenUtil.getInstance().setHeight(89),
  940. child: Center(
  941. child: Row(
  942. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  943. children: < Widget > [
  944. Expanded(
  945. flex: 0,
  946. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  947. ),
  948. Expanded(
  949. child: Row(
  950. mainAxisAlignment: MainAxisAlignment.end,
  951. children: < Widget > [
  952. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  953. SizedBox(
  954. width: ScreenUtil.getInstance().setWidth(500),
  955. child: Padding(
  956. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  957. child: TextField(
  958. controller: type == 'send' ? sendCompanyAddressController : receiptCompanyAddressController,
  959. textAlign: TextAlign.end,
  960. decoration: InputDecoration(
  961. border: InputBorder.none
  962. ),
  963. ),
  964. )
  965. ),
  966. // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  967. ],
  968. )
  969. )
  970. ],
  971. ),
  972. )
  973. )
  974. );
  975. }
  976. Widget _lastBankContentWiget(String key, String type) {
  977. return Padding(
  978. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  979. child: SizedBox(
  980. height: ScreenUtil.getInstance().setHeight(89),
  981. child: Center(
  982. child: Row(
  983. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  984. children: < Widget > [
  985. Expanded(
  986. flex: 0,
  987. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  988. ),
  989. Expanded(
  990. child: Row(
  991. mainAxisAlignment: MainAxisAlignment.end,
  992. children: < Widget > [
  993. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  994. SizedBox(
  995. width: ScreenUtil.getInstance().setWidth(500),
  996. child: Padding(
  997. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  998. child: TextField(
  999. controller: openBankPhoneController,
  1000. textAlign: TextAlign.end,
  1001. keyboardType: TextInputType.number,
  1002. decoration: InputDecoration(
  1003. border: InputBorder.none
  1004. ),
  1005. ),
  1006. )
  1007. ),
  1008. // Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  1009. ],
  1010. )
  1011. )
  1012. ],
  1013. ),
  1014. )
  1015. )
  1016. );
  1017. }
  1018. Widget _descWidget() {
  1019. return
  1020. Container(
  1021. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  1022. //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  1023. child: TextField(
  1024. maxLines: 3,
  1025. controller: memoController,
  1026. decoration: InputDecoration(
  1027. border: InputBorder.none,
  1028. hintText: "请输入备注内容"
  1029. ),
  1030. onChanged: (value) {
  1031. setState(() {
  1032. memo = value;
  1033. });
  1034. },
  1035. ),
  1036. );
  1037. }
  1038. Widget _submitBtn() {
  1039. return GestureDetector(
  1040. child: Container(
  1041. margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
  1042. height: ScreenUtil.getInstance().setHeight(88),
  1043. decoration: BoxDecoration(
  1044. borderRadius: BorderRadius.all(Radius.circular(4)),
  1045. color: Color.fromRGBO(37, 102, 242, 1),
  1046. ),
  1047. child: Center(
  1048. child: Row(
  1049. mainAxisAlignment: MainAxisAlignment.center,
  1050. children: < Widget > [
  1051. Offstage(
  1052. offstage: submitStatus,
  1053. child: SizedBox(
  1054. width: ScreenUtil.getInstance().setWidth(45),
  1055. height: ScreenUtil.getInstance().setHeight(45),
  1056. child: Image.asset('lib/images/loading.gif'),
  1057. ),
  1058. ),
  1059. Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
  1060. ],
  1061. )
  1062. ),
  1063. ),
  1064. onTap: () {
  1065. if (!submitStatus) {
  1066. return;
  1067. }
  1068. String errStr = '';
  1069. print('sendCompanyId---${sendCompanyId}');
  1070. print('sendCompanyName---${sendCompanyName}');
  1071. print('sendCompanyPhone---${sendCompanyPhone}');
  1072. print('sendCompanyCode---${sendCompanyCode}');
  1073. print('sendCompanyProvinceName---${sendCompanyProvinceName}');
  1074. print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
  1075. print('sendCompanyCityName---${sendCompanyCityName}');
  1076. print('sendCompanyCityCode---${sendCompanyCityCode}');
  1077. print('sendCompanyAreaName---${sendCompanyAreaName}');
  1078. print('sendCompanyAreaCode---${sendCompanyAreaCode}');
  1079. print('sendCompanyAddress---${sendCompanyAddress}');
  1080. print('receiptCompanyId---${receiptCompanyId}');
  1081. print('receiptCompanyPhone---${receiptCompanyPhone}');
  1082. print('receiptCompanyName---${receiptCompanyName}');
  1083. print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
  1084. print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
  1085. print('receiptCompanyCityName---${receiptCompanyCityName}');
  1086. print('receiptCompanyCityCode---${receiptCompanyCityCode}');
  1087. print('receiptCompanyAreaName---${receiptCompanyAreaName}');
  1088. print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
  1089. print('receiptCompanyAddress---${receiptCompanyAddress}');
  1090. print('goods---${goods}');
  1091. print('goodsQuantity---${goodsQuantity}');
  1092. print('goodsPackingId---${goodsPackingId}');
  1093. print('goodsCategoryId---${goodsCategoryId}');
  1094. print('goodsPaymentMethod---${goodsPaymentMethod}');
  1095. print('goodsWeight---${goodsWeight}');
  1096. print('goodsPriceProtection---${goodsPriceProtection}');
  1097. print('goodsAgencyFund---${goodsAgencyFund}');
  1098. print('goodsFreight---${goodsFreight}');
  1099. print('memo---${memo}');
  1100. if (sendCompanyPhone == '') {
  1101. errStr = '请填写发件电话';
  1102. }
  1103. if (sendCompanyName == '') {
  1104. errStr = '请填写发件企业名称';
  1105. }
  1106. if (sendCompanyProvinceName == '') {
  1107. errStr = '请填写发件城市/区域';
  1108. }
  1109. if (sendCompanyAddress == '') {
  1110. errStr = '请填写发件详细地址';
  1111. }
  1112. if (receiptCompanyPhone == '') {
  1113. errStr = '请填写收件电话';
  1114. }
  1115. if (receiptCompanyName == '') {
  1116. errStr = '请填写收件企业名称';
  1117. }
  1118. if (receiptCompanyProvinceName == '') {
  1119. errStr = '请填写收件城市/区域';
  1120. }
  1121. if (receiptCompanyAddress == '') {
  1122. errStr = '请填写收件详细地址';
  1123. }
  1124. // if (goods == '') {
  1125. // errStr = '请填写货物名称';
  1126. // }
  1127. if (goodsQuantity == 0) {
  1128. errStr = '请填写货物数量';
  1129. }
  1130. if (int.tryParse(goodsQuantity.toString()) == null) {
  1131. errStr = '货物数量格式错误';
  1132. }
  1133. if (goodsFreight == 0.0) {
  1134. errStr = '请填写运费';
  1135. }
  1136. if (sendCompanyPhone == '' || receiptCompanyPhone == '' ) {
  1137. errStr = '请输入正确的电话';
  1138. }
  1139. if (goodsAgencyFund>0) {//如果有代收
  1140. if(bankNameController.text=='' || bankCardController.text=='' || openBankNameController.text=='' || openBankPhoneController.text==''){
  1141. errStr = "请补全银行卡信息";
  1142. }
  1143. }
  1144. if (errStr != '') {
  1145. showError(errStr);
  1146. return;
  1147. }
  1148. if(lineList.length>1){
  1149. showLineModal(lineList);
  1150. return;
  1151. }
  1152. submitOrder();
  1153. },
  1154. );
  1155. }
  1156. submitOrder(){
  1157. setState(() {
  1158. submitStatus = false;
  1159. });
  1160. getKey('stationId').then((value) {
  1161. createOrder(
  1162. lineId,//收件线路Id
  1163. value,//当前用户选择的站点id
  1164. sendCompanyId, //寄件公司Id
  1165. sendCompanyName, //寄件公司名称 不能为空
  1166. sendCompanyPhone, //寄件公司电话 不能为空
  1167. sendCompanyCode ?? '', //寄件公司编码
  1168. sendCompanyProvinceName, //寄件公司省名称 不能为空
  1169. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  1170. sendCompanyCityName, //寄件公司市名称 不能为空
  1171. sendCompanyCityCode, //寄件公司市编码 不能为空
  1172. sendCompanyAreaName, //寄件公司区名称 不能为空
  1173. sendCompanyAreaCode, //寄件公司区编码 不能为空
  1174. sendCompanyAddress, //寄件公司详细地址,不能为空
  1175. receiptCompanyId, //收件公司id
  1176. receiptCompanyPhone, //收件公司电话 不能为空
  1177. receiptCompanyName, //收件公司名称 不能为空
  1178. receiptCompanyProvinceName, //收件公司省名称 不能为空
  1179. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  1180. receiptCompanyCityName, //收件公司市名称 不能为空
  1181. receiptCompanyCityCode, //收件公市编码 不能为空
  1182. receiptCompanyAreaName, //收件公区名称 不能为空
  1183. receiptCompanyAreaCode, //收件公司区编码 不能为空
  1184. receiptCompanyAddress, //收件公司地址详情 不能为空
  1185. goods, //商品名称 不能为空
  1186. goodsQuantity, //商品数量 不能为空
  1187. goodsPackingId, //商品包装ID
  1188. goodsCategoryId, //商品类别ID
  1189. goodsPaymentMethod, //付款方式 1,现付 2 到付
  1190. goodsWeight, //商品重量
  1191. goodsPriceProtection * 100, //商品保价,已分为单位
  1192. goodsAgencyFund * 100, //商品代收款,已分为单位
  1193. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  1194. memo, //备注
  1195. bankCardController.text,
  1196. bankNameController.text,
  1197. openBankNameController.text,
  1198. openBankPhoneController.text
  1199. ).then((resp) {
  1200. if (isNotError(context, resp) && this.mounted) {
  1201. setState(() {
  1202. submitStatus = true;
  1203. });
  1204. OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
  1205. showDialog < Null > (
  1206. context: context, //BuildContext对象
  1207. barrierDismissible: false,
  1208. builder: (BuildContext context) {
  1209. //打印
  1210. getKey('printType').then((printType){
  1211. getKey('stationName').then((stationName){
  1212. getKey('nickName').then((nickName){
  1213. getKey('companyName').then((companyName){
  1214. getKey('companyCustomerPhone').then((companyCustomerPhone){
  1215. double goodsYs = data.goodsPaymentMethod==2?(data.goodsFreight/100)+(data.goodsAgencyFund/100):data.goodsAgencyFund/100;
  1216. String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
  1217. String createTime = fromatDate(data.createTime);
  1218. double goodsAgencyFunds = data.goodsAgencyFund/100;
  1219. double goodsDFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
  1220. double goodsXFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
  1221. String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
  1222. Map<String, String> pum = {
  1223. "[logisticsNo]": "${data.orderNo ?? ''}",
  1224. "[createTime]": "$createTime",
  1225. "[sendStationName]": "$stationName",
  1226. "[dealerCode]": "${data.sendCompanyCode ?? ''}",
  1227. "[dealerName]": "${data.sendCompanyName}",
  1228. "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
  1229. "[repairName]": "${data.receiptCompanyName ?? ''}",
  1230. "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
  1231. "[endStationName]": "${data.receiptStationName ?? ''}",
  1232. "[goodsLineCode]": "${data.lineCode ?? ''}",
  1233. "[goodsLine]": "${data.lineName ?? ''}",
  1234. "[repairAddress]": "${receiptAddress?? ''}",
  1235. "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
  1236. "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
  1237. "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
  1238. // 到付 现付 金额
  1239. "[goodsDFreight]": "$goodsDFreight",
  1240. "[goodsXFreight]": "$goodsXFreight",
  1241. "[goodsAgencyFund]": "$goodsAgencyFunds",
  1242. "[goodsYs]": "$goodsYs",
  1243. "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
  1244. "[goodsRemark]": "${data.memo ?? ''}",
  1245. "[realName]": "${nickName?? ''}",
  1246. "[currentTime]": "$nowDate",
  1247. "[currentGoodNumber]": "1/1",
  1248. "[companyCustomerPhone]":"$companyCustomerPhone",
  1249. "[companyName]":"$companyName"
  1250. };
  1251. bluetooth.printOrder(pum, int.parse(printType)).then((value){
  1252. if(value==null){
  1253. showDialog <Null> (
  1254. context: context,
  1255. barrierDismissible: false,
  1256. builder: (BuildContext context) {
  1257. return MyAlertDialog(text: '未连接打印机',childCallback:(val){});
  1258. }
  1259. );
  1260. }
  1261. });
  1262. });
  1263. });
  1264. });
  1265. });
  1266. });
  1267. return SendDialog( //调用对话框
  1268. orderNo: data.orderNo,
  1269. childCallback: (val) {
  1270. if (!val) {
  1271. //跳转
  1272. Navigator.push(context, MaterialPageRoute(builder: (context) {
  1273. return OrderDetail(orderNo: data.orderNo, );
  1274. }));
  1275. }else{
  1276. setState(() {
  1277. //----------------清除信息--------------------
  1278. lineId = '-1';
  1279. sendCompanyCode = '';
  1280. sendCompanyName = '';
  1281. sendCompanyId ='0';
  1282. sendCompanyPhoneController.text= '';
  1283. sendCompanyCodeController.text = '';
  1284. sendCompanyNameController.text = '';
  1285. sendPCA = '';
  1286. sendCompanyProvinceName = '';
  1287. sendCompanyProvinceCode = '';
  1288. sendCompanyCityName = '';
  1289. sendCompanyCityCode = '';
  1290. sendCompanyAreaName = '';
  1291. sendCompanyAreaCode = '';
  1292. bankCardController.text = '';
  1293. bankNameController.text = '';
  1294. openBankNameController.text = '';
  1295. openBankPhoneController.text = '';
  1296. sendCompanyAddressController.text = '';
  1297. receiptCompanyName = '';
  1298. receiptCompanyPhoneController.text= '';
  1299. receiptCompanyNameController.text = '';
  1300. receiptCompanyId = '0';
  1301. getPCA = '';
  1302. receiptCompanyProvinceName = '';
  1303. receiptCompanyProvinceCode = '';
  1304. receiptCompanyCityName = '';
  1305. receiptCompanyCityCode = '';
  1306. receiptCompanyAreaName = '';
  1307. receiptCompanyAreaCode = '';
  1308. receiptCompanyAddressController.text = '';
  1309. goods = ''; //商品名称 不能为空
  1310. goodsQuantity = 1; //商品数量 不能为空
  1311. goodsPaymentMethod = 2; //付款方式 1,现付 2 到付
  1312. goodsWeight = 0.0; //商品重量
  1313. goodsPriceProtection = 0.0; //商品保价
  1314. goodsAgencyFund = 0.0; //商品代收款
  1315. goodsFreight = 0.0; //商品运费 不能为空
  1316. memo = ''; //备注
  1317. goodsController.text = '';
  1318. goodsQuantityController.text = '';
  1319. goodsFreightController.text = '';
  1320. goodsAgencyFundController.text = '';
  1321. goodsPriceProtectionController.text = '';
  1322. goodsWeightController.text = '';
  1323. memoController.text = '';
  1324. //---------------------------------------------
  1325. });
  1326. }
  1327. },
  1328. );
  1329. });
  1330. } else {
  1331. setState(() {
  1332. submitStatus = true;
  1333. });
  1334. }
  1335. });
  1336. });
  1337. }
  1338. showError(String str) {
  1339. showDialog < Null > (
  1340. context: context, //BuildContext对象
  1341. barrierDismissible: false,
  1342. builder: (BuildContext context) {
  1343. return MyAlertDialog( //调用对话框
  1344. text: str, childCallback: (val) {},
  1345. );
  1346. });
  1347. }
  1348. showLineModal(List<CompanyOfLineList> list){
  1349. showDialog < Null > (
  1350. context: context, //BuildContext对象
  1351. barrierDismissible: false,
  1352. builder: (BuildContext context) {
  1353. return ShowLineModal(
  1354. lineList: list, childCallback: (val) {
  1355. lineId = val;
  1356. submitOrder();
  1357. },
  1358. );
  1359. });
  1360. }
  1361. Future getCity(context) async {
  1362. Result result = await CityPickers.showCityPicker(
  1363. context: context,
  1364. );
  1365. return result;
  1366. }
  1367. Widget _tipItem(LikePhoneList obj) {
  1368. return Container(
  1369. child: Column(
  1370. children: < Widget > [
  1371. InkWell(
  1372. child: Container(
  1373. height: ScreenUtil.getInstance().setHeight(89),
  1374. child: Center(
  1375. child: Row(
  1376. mainAxisAlignment: MainAxisAlignment.start,
  1377. children: < Widget > [
  1378. Padding(
  1379. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  1380. child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
  1381. fontSize: ScreenUtil.getInstance().setSp(28),
  1382. color: Color.fromRGBO(74, 74, 74, 1)
  1383. ), )
  1384. ),
  1385. SizedBox(
  1386. width: ScreenUtil.getInstance().setWidth(185),
  1387. child: Text(obj.areaCode,
  1388. textAlign: TextAlign.left,
  1389. style: TextStyle(
  1390. fontSize: ScreenUtil.getInstance().setSp(28),
  1391. color: Color.fromRGBO(155, 155, 155, 1)
  1392. ), ),
  1393. ),
  1394. Text(obj.companyName,
  1395. textAlign: TextAlign.left,
  1396. overflow: TextOverflow.ellipsis,
  1397. style: TextStyle(
  1398. fontSize: ScreenUtil.getInstance().setSp(28),
  1399. color: Color.fromRGBO(155, 155, 155, 1)
  1400. ),
  1401. )
  1402. ],
  1403. ),
  1404. ),
  1405. ),
  1406. onTap: () {
  1407. checkedCompanyInfo = true;
  1408. if (sendPhoneOrGetPhoneTab) {
  1409. sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1410. sendCompanyCode = obj.companyCode;
  1411. sendCompanyName = obj.companyName;
  1412. sendCompanyId = obj.id.toString();
  1413. sendCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1414. sendCompanyCodeController.text = obj.companyCode;
  1415. sendCompanyNameController.text = obj.companyName;
  1416. sendPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  1417. sendCompanyProvinceName = obj.provinceName;
  1418. sendCompanyProvinceCode = obj.provinceCode;
  1419. sendCompanyCityName = obj.cityName;
  1420. sendCompanyCityCode = obj.cityCode;
  1421. sendCompanyAreaName = obj.areaName;
  1422. sendCompanyAreaCode = obj.areaCode;
  1423. sendCompanyAddressController.text = obj.address;
  1424. bankCardController.text = obj.bankCard;
  1425. bankNameController.text = obj.bankName;
  1426. openBankNameController.text = obj.openBankName;
  1427. openBankPhoneController.text = obj.openBankPhone;
  1428. } else {
  1429. receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1430. receiptCompanyName = obj.companyName;
  1431. receiptCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1432. receiptCompanyNameController.text = obj.companyName;
  1433. receiptCompanyId = obj.id.toString();
  1434. getLineOfCompanyId(receiptCompanyId).then((resp){
  1435. if(isNotError(context, resp) && this.mounted){
  1436. CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
  1437. setState(() {
  1438. lineList = obj.data;
  1439. });
  1440. }
  1441. });
  1442. getPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  1443. receiptCompanyProvinceName = obj.provinceName;
  1444. receiptCompanyProvinceCode = obj.provinceCode;
  1445. receiptCompanyCityName = obj.cityName;
  1446. receiptCompanyCityCode = obj.cityCode;
  1447. receiptCompanyAreaName = obj.areaName;
  1448. receiptCompanyAreaCode = obj.areaCode;
  1449. receiptCompanyAddressController.text = obj.address;
  1450. }
  1451. setState(() {
  1452. FocusScope.of(context).requestFocus(FocusNode());
  1453. tipStatus = true;
  1454. });
  1455. },
  1456. ),
  1457. _underLine()
  1458. ],
  1459. ),
  1460. );
  1461. }
  1462. Widget _packageType(String key) {
  1463. return Padding(
  1464. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  1465. child: Column(
  1466. children: < Widget > [
  1467. InkWell(
  1468. child: SizedBox(
  1469. height: ScreenUtil.getInstance().setHeight(89),
  1470. child: Center(
  1471. child: Row(
  1472. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1473. children: < Widget > [
  1474. Expanded(
  1475. flex: 0,
  1476. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  1477. ),
  1478. Expanded(
  1479. child: Row(
  1480. mainAxisAlignment: MainAxisAlignment.end,
  1481. children: < Widget > [
  1482. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  1483. SizedBox(
  1484. width: ScreenUtil.getInstance().setWidth(500),
  1485. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '货物类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  1486. ),
  1487. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  1488. ],
  1489. )
  1490. )
  1491. ],
  1492. ),
  1493. )
  1494. ),
  1495. onTap: () {
  1496. showPickerModal(context, key);
  1497. },
  1498. ),
  1499. Expanded(
  1500. flex: 0,
  1501. child: _underLine()
  1502. )
  1503. ],
  1504. )
  1505. );
  1506. }
  1507. showPickerModal(BuildContext context, String type) {
  1508. List < dynamic > data = [];
  1509. if (type == '包装类型') {
  1510. for (int i = 0; i < goodsPackageList.length; i++) {
  1511. data.add(goodsPackageList[i].name);
  1512. }
  1513. } else if (type == '货物类型') {
  1514. for (int i = 0; i < goodsCateGoryList.length; i++) {
  1515. data.add(goodsCateGoryList[i].name);
  1516. }
  1517. } else if (type == '付款方式') {
  1518. data = ['现付', '到付'];
  1519. }
  1520. new Picker(
  1521. adapter: PickerDataAdapter < String > (pickerdata: data),
  1522. height: ScreenUtil.getInstance().setHeight(450),
  1523. confirmText: '确定',
  1524. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  1525. cancelText: '取消',
  1526. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  1527. headercolor: Color.fromRGBO(245, 245, 245, 1),
  1528. itemExtent: ScreenUtil.getInstance().setHeight(80),
  1529. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  1530. changeToFirst: true,
  1531. hideHeader: false,
  1532. onConfirm: (Picker picker, List value) {
  1533. if (type == '包装类型') {
  1534. setState(() {
  1535. showTextGoodsPackage = goodsPackageList[value[0]].name;
  1536. goodsPackingId = goodsPackageList[value[0]].id;
  1537. });
  1538. } else if (type == '货物类型') {
  1539. setState(() {
  1540. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  1541. goodsCategoryId = goodsCateGoryList[value[0]].id;
  1542. });
  1543. } else if (type == '付款方式') {
  1544. setState(() {
  1545. showTextPaymentMehod = data[value[0]];
  1546. });
  1547. if (showTextPaymentMehod == '现付') {
  1548. goodsPaymentMethod = 1;
  1549. } else {
  1550. goodsPaymentMethod = 2;
  1551. }
  1552. }
  1553. }
  1554. ).showModal(this.context); //_scaffoldKey.currentState);
  1555. }
  1556. }