send_express_page.dart 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  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. class SendExpressPage extends StatefulWidget {
  16. final Widget child;
  17. SendExpressPage({
  18. Key key,
  19. this.child
  20. }): super(key: key);
  21. _SendExpressPageState createState() => _SendExpressPageState();
  22. }
  23. class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
  24. ScrollController _scrollController = ScrollController();
  25. //组件自用字段-----------------------------
  26. GlobalKey _sendPhoneKey = GlobalKey();
  27. GlobalKey _getPhoneKey = GlobalKey();
  28. double tipWidth = 0;
  29. double tipHeight = 0;
  30. double tipPosX = 0;
  31. double tipPosY = 0;
  32. bool tipStatus = true;
  33. bool lineModalStatus = false;
  34. bool submitStatus = true;
  35. List < LikePhoneList > likePhoneList = [];
  36. var timer;
  37. bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
  38. TextEditingController sendCompanyPhoneController = TextEditingController();
  39. TextEditingController sendCompanyCodeController = TextEditingController();
  40. TextEditingController sendCompanyNameController = TextEditingController();
  41. TextEditingController receiptCompanyPhoneController = TextEditingController();
  42. TextEditingController receiptCompanyNameController = TextEditingController();
  43. TextEditingController sendCompanyAddressController = TextEditingController();
  44. TextEditingController receiptCompanyAddressController = TextEditingController();
  45. List < dynamic > goodsCateGoryList = [];
  46. List < dynamic > goodsPackageList = [];
  47. //请求字段-------------------------
  48. String lineId = '-1';//收件公司匹配的线路id
  49. String sendCompanyId = '0'; //寄件公司Id
  50. String sendCompanyName = ''; //寄件公司名称 不能为空
  51. String sendCompanyPhone = ''; //寄件公司电话 不能为空
  52. String sendCompanyCode = ''; //寄件公司编码
  53. String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
  54. String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
  55. String sendCompanyCityName = ''; //寄件公司市名称 不能为空
  56. String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
  57. String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
  58. String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
  59. String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
  60. String receiptCompanyId = '0'; //收件公司id
  61. String receiptCompanyPhone = ''; //收件公司电话 不能为空
  62. String receiptCompanyName = ''; //收件公司名称 不能为空
  63. String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
  64. String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
  65. String receiptCompanyCityName = ''; //收件公司市名称 不能为空
  66. String receiptCompanyCityCode = ''; //收件公市编码 不能为空
  67. String receiptCompanyAreaName = ''; //收件公区名称 不能为空
  68. String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
  69. String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
  70. String goods = ''; //商品名称 不能为空
  71. int goodsQuantity = 1; //商品数量 不能为空
  72. int goodsPackingId; //商品包装ID
  73. int goodsCategoryId; //商品类别ID
  74. int goodsPaymentMethod = 1; //付款方式 1,现付 2 到付
  75. double goodsWeight = 0.0; //商品重量
  76. double goodsPriceProtection = 0.0; //商品保价
  77. double goodsAgencyFund = 0.0; //商品代收款
  78. double goodsFreight = 0.0; //商品运费 不能为空
  79. String memo = ''; //备注
  80. List<CompanyOfLineList> lineList = [];
  81. String sendPCA = ' '; //Text组件内容必须有空格,否则报null
  82. String getPCA = ' ';
  83. String showTextGoodsCategory = ' ';
  84. String showTextGoodsPackage = ' ';
  85. String showTextPaymentMehod = '现付';
  86. @override
  87. void initState() {
  88. super.initState();
  89. goodsCategory().then((resp) {
  90. if (isNotError(context, resp) && this.mounted) {
  91. GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
  92. setState(() {
  93. goodsCateGoryList = goodsCategoryObj.data;
  94. showTextGoodsCategory = goodsCateGoryList[0].name;
  95. goodsCategoryId = goodsCateGoryList[0].id;
  96. });
  97. }
  98. });
  99. goodsPackage().then((resp) {
  100. if (isNotError(context, resp) && this.mounted) {
  101. GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
  102. setState(() {
  103. goodsPackageList = goodsPackageObj.data;
  104. showTextGoodsPackage = goodsPackageList[0].name;
  105. goodsPackingId = goodsPackageList[0].id;
  106. });
  107. }
  108. });
  109. _scrollController.addListener(() {
  110. if (!tipStatus) {
  111. setState(() {
  112. tipStatus = true;
  113. });
  114. }
  115. //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
  116. });
  117. sendCompanyPhoneController.addListener(() {
  118. setState(() {
  119. sendCompanyPhone = sendCompanyPhoneController.text;
  120. });
  121. if (timer != null) {
  122. timer.cancel();
  123. }
  124. if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
  125. setState(() {
  126. tipStatus = true;
  127. });
  128. }
  129. timer = Timer(Duration(milliseconds: 500), () {
  130. if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length < 11) {
  131. likePhone(sendCompanyPhoneController.text).then((resp) {
  132. if (isNotError(context, resp) && this.mounted) {
  133. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  134. likePhoneList = likePhoneObj.data;
  135. }
  136. if (likePhoneList.length > 0) {
  137. sendPhoneOrGetPhoneTab = true;
  138. RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
  139. setState(() {
  140. tipWidth = sendPhoneObj.paintBounds.size.width;
  141. tipHeight = sendPhoneObj.paintBounds.size.height;
  142. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  143. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  144. tipStatus = false;
  145. });
  146. } else {
  147. setState(() {
  148. tipStatus = true;
  149. });
  150. }
  151. });
  152. }
  153. });
  154. });
  155. receiptCompanyPhoneController.addListener(() {
  156. setState(() {
  157. receiptCompanyPhone = receiptCompanyPhoneController.text;
  158. });
  159. if (timer != null) {
  160. timer.cancel();
  161. }
  162. if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
  163. setState(() {
  164. tipStatus = true;
  165. });
  166. }
  167. timer = Timer(Duration(milliseconds: 500), () {
  168. if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length < 11) {
  169. likePhone(receiptCompanyPhoneController.text).then((resp) {
  170. if (isNotError(context, resp) && this.mounted) {
  171. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  172. likePhoneList = likePhoneObj.data;
  173. }
  174. if (likePhoneList.length > 0) {
  175. sendPhoneOrGetPhoneTab = false;
  176. RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
  177. setState(() {
  178. tipWidth = getPhoneKey.paintBounds.size.width;
  179. tipHeight = getPhoneKey.paintBounds.size.height;
  180. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  181. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  182. tipStatus = false;
  183. });
  184. } else {
  185. setState(() {
  186. tipStatus = true;
  187. });
  188. }
  189. });
  190. }
  191. });
  192. });
  193. sendCompanyAddressController.addListener(() {
  194. setState(() {
  195. sendCompanyAddress = sendCompanyAddressController.text;
  196. });
  197. });
  198. receiptCompanyAddressController.addListener(() {
  199. setState(() {
  200. receiptCompanyAddress = receiptCompanyAddressController.text;
  201. });
  202. });
  203. }
  204. @override
  205. bool get wantKeepAlive => true;
  206. @override
  207. Widget build(BuildContext context) {
  208. return Container(
  209. child: Scaffold(
  210. appBar: AppBar(
  211. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  212. centerTitle: true,
  213. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  214. ),
  215. body:
  216. Stack(
  217. children: < Widget > [
  218. Container(
  219. color: Color.fromRGBO(246, 246, 254, 1),
  220. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  221. child: ListView(
  222. controller: _scrollController,
  223. children: < Widget > [
  224. _sendInfo(context),
  225. _getInfo(context),
  226. _itemInfoWidget(),
  227. _submitBtn()
  228. ],
  229. ),
  230. ),
  231. Positioned(
  232. top: tipPosY,
  233. left: tipPosX,
  234. child: Offstage(
  235. offstage: tipStatus,
  236. child: Container(
  237. width: tipWidth,
  238. height: ScreenUtil.getInstance().setHeight(450),
  239. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  240. decoration: BoxDecoration(
  241. color: Color.fromRGBO(244, 248, 251, 1),
  242. ),
  243. child: ListView.builder(
  244. itemCount: likePhoneList.length,
  245. itemBuilder: (BuildContext context, int index) {
  246. return _tipItem(likePhoneList[index]);
  247. },
  248. )
  249. ),
  250. )
  251. )
  252. ],
  253. ),
  254. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  255. ),
  256. );
  257. }
  258. Widget _sendInfo(BuildContext context) {
  259. return Container(
  260. color: Colors.white,
  261. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  262. child: Column(
  263. children: < Widget > [
  264. _titleWidget('lib/images/icon_send.png', '发件信息'),
  265. _underLine(),
  266. _inputWiget('电话', 'sendPhone'),
  267. _contentWiget('企业编码', 'send', true),
  268. _contentWiget('企业名称', 'send', true),
  269. _cityWiget('城市/区域', context, 'send'),
  270. _lastContentWiget('详细地址', 'send')
  271. ],
  272. )
  273. );
  274. }
  275. Widget _getInfo(BuildContext context) {
  276. return Container(
  277. color: Colors.white,
  278. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  279. child: Column(
  280. children: < Widget > [
  281. _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  282. _underLine(),
  283. _inputWiget('电话', 'getPhone'),
  284. //_contentWiget('企业编码', 'get', true),
  285. _contentWiget('企业名称', 'get', true),
  286. _cityWiget('城市/区域', context, 'get'),
  287. _lastContentWiget('详细地址', 'get')
  288. ],
  289. )
  290. );
  291. }
  292. Widget _itemInfoWidget() {
  293. return Container(
  294. child: Container(
  295. color: Colors.white,
  296. child: Column(
  297. crossAxisAlignment: CrossAxisAlignment.start,
  298. children: < Widget > [
  299. _titleWidget('lib/images/icon_huowu.png', "货物信息"),
  300. _underLine(),
  301. _contentWiget("货物名称", 'goods', true),
  302. _contentWiget("数量", 'goods'),
  303. _contentWiget("运费", 'goods'),
  304. _contentWiget("代收", 'goods'),
  305. _contentWiget("保价", 'goods'),
  306. _contentWiget("重量", 'goods'),
  307. _packageType('包装类型'),
  308. _packageType('货物类型'),
  309. _packageType('付款方式'),
  310. _descWidget()
  311. ],
  312. ),
  313. )
  314. );
  315. }
  316. Widget _titleWidget(String iconUrl, String str) {
  317. return Container(
  318. height: ScreenUtil.getInstance().setHeight(90),
  319. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  320. child: Center(
  321. child: Row(
  322. mainAxisAlignment: MainAxisAlignment.start,
  323. children: < Widget > [
  324. Padding(
  325. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  326. child: Image.asset(
  327. iconUrl,
  328. width: ScreenUtil.getInstance().setWidth(40),
  329. height: ScreenUtil.getInstance().setHeight(40),
  330. )
  331. ),
  332. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  333. ],
  334. ),
  335. ),
  336. );
  337. }
  338. Widget _underLine() {
  339. return Container(
  340. color: Color.fromRGBO(223, 223, 223, 1),
  341. height: ScreenUtil.getInstance().setHeight(1),
  342. );
  343. }
  344. Widget _inputWiget(String key, String tab) {
  345. return Padding(
  346. key: tab == 'sendPhone' ? _sendPhoneKey : _getPhoneKey,
  347. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  348. child: Column(
  349. children: < Widget > [
  350. SizedBox(
  351. height: ScreenUtil.getInstance().setHeight(89),
  352. child: Center(
  353. child: Row(
  354. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  355. children: < Widget > [
  356. Expanded(
  357. flex: 0,
  358. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  359. ),
  360. Expanded(
  361. child: Row(
  362. mainAxisAlignment: MainAxisAlignment.end,
  363. children: < Widget > [
  364. SizedBox(
  365. width: ScreenUtil.getInstance().setWidth(500),
  366. child: TextField(
  367. controller: tab == 'sendPhone' ? sendCompanyPhoneController : receiptCompanyPhoneController,
  368. keyboardType: TextInputType.number,
  369. textAlign: TextAlign.end,
  370. decoration: InputDecoration(
  371. border: InputBorder.none
  372. ),
  373. onEditingComplete: () {
  374. setState(() {
  375. FocusScope.of(context).requestFocus(FocusNode());
  376. tipStatus = true;
  377. });
  378. },
  379. ),
  380. ),
  381. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  382. ],
  383. )
  384. )
  385. ],
  386. ),
  387. )
  388. ),
  389. Expanded(
  390. flex: 0,
  391. child: _underLine()
  392. )
  393. ],
  394. )
  395. );
  396. }
  397. Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  398. return Padding(
  399. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  400. child: Column(
  401. children: < Widget > [
  402. SizedBox(
  403. height: ScreenUtil.getInstance().setHeight(89),
  404. child: Center(
  405. child: Row(
  406. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  407. children: < Widget > [
  408. Expanded(
  409. flex: 0,
  410. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  411. ),
  412. Expanded(
  413. child: Row(
  414. mainAxisAlignment: MainAxisAlignment.end,
  415. children: < Widget > [
  416. SizedBox(
  417. width: ScreenUtil.getInstance().setWidth(500),
  418. child: TextField(
  419. controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
  420. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  421. textAlign: TextAlign.end,
  422. decoration: InputDecoration(
  423. border: InputBorder.none
  424. ),
  425. onChanged: (value) {
  426. if (type == 'send') {
  427. if (key == '企业编码') {
  428. setState(() {
  429. sendCompanyCode = value;
  430. });
  431. } else if (key == '企业名称') {
  432. setState(() {
  433. sendCompanyName = value;
  434. });
  435. }
  436. } else if (type == 'get') {
  437. if (key == '企业编码') {
  438. setState(() {
  439. sendCompanyCode = value;
  440. });
  441. } else if (key == '企业名称') {
  442. setState(() {
  443. receiptCompanyName = value;
  444. });
  445. }
  446. } else {
  447. if (key == '货物名称') {
  448. goods = value;
  449. } else if (key == '数量') {
  450. goodsQuantity = int.parse(value);
  451. } else if (key == '运费') {
  452. goodsFreight = double.parse(value);
  453. String temp = goodsFreight.toStringAsFixed(1);
  454. goodsFreight = double.parse(temp);
  455. } else if (key == '代收') {
  456. goodsAgencyFund = double.parse(value);
  457. String temp = goodsAgencyFund.toStringAsFixed(1);
  458. goodsAgencyFund = double.parse(temp);
  459. } else if (key == '保价') {
  460. goodsPriceProtection = double.parse(value);
  461. String temp = goodsPriceProtection.toStringAsFixed(1);
  462. goodsPriceProtection = double.parse(temp);
  463. } else if (key == '重量') {
  464. goodsWeight = double.parse(value);
  465. String temp = goodsWeight.toStringAsFixed(1);
  466. goodsWeight = double.parse(temp);
  467. }
  468. }
  469. },
  470. ),
  471. ),
  472. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  473. ],
  474. )
  475. )
  476. ],
  477. ),
  478. )
  479. ),
  480. Expanded(
  481. flex: 0,
  482. child: _underLine()
  483. )
  484. ],
  485. )
  486. );
  487. }
  488. Widget _cityWiget(String key, BuildContext context, String type) {
  489. return
  490. GestureDetector(
  491. child: Padding(
  492. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  493. child: Column(
  494. children: < Widget > [
  495. SizedBox(
  496. height: ScreenUtil.getInstance().setHeight(89),
  497. child: Center(
  498. child: Row(
  499. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  500. children: < Widget > [
  501. Expanded(
  502. flex: 0,
  503. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  504. ),
  505. Expanded(
  506. child: Row(
  507. mainAxisAlignment: MainAxisAlignment.end,
  508. children: < Widget > [
  509. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  510. SizedBox(
  511. width: ScreenUtil.getInstance().setWidth(500),
  512. child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
  513. ),
  514. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  515. ],
  516. )
  517. )
  518. ],
  519. ),
  520. )
  521. ),
  522. Expanded(
  523. flex: 0,
  524. child: _underLine()
  525. )
  526. ],
  527. )
  528. ),
  529. onTap: () {
  530. getCity(context).then((resp) {
  531. if (resp == null) {
  532. return;
  533. }
  534. print(resp.toString());
  535. setState(() {
  536. if (type == 'send') {
  537. sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  538. sendCompanyProvinceName = resp.provinceName;
  539. sendCompanyProvinceCode = resp.provinceId;
  540. sendCompanyCityName = resp.cityName;
  541. sendCompanyCityCode = resp.cityId;
  542. sendCompanyAreaName = resp.areaName;
  543. sendCompanyAreaCode = resp.areaId;
  544. } else {
  545. getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  546. receiptCompanyProvinceName = resp.provinceName;
  547. receiptCompanyProvinceCode = resp.provinceId;
  548. receiptCompanyCityName = resp.cityName;
  549. receiptCompanyCityCode = resp.cityId;
  550. receiptCompanyAreaName = resp.areaName;
  551. receiptCompanyAreaCode = resp.areaId;
  552. }
  553. });
  554. //print(value);
  555. });
  556. },
  557. );
  558. }
  559. Widget _lastContentWiget(String key, String type) {
  560. return Padding(
  561. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  562. child: SizedBox(
  563. height: ScreenUtil.getInstance().setHeight(89),
  564. child: Center(
  565. child: Row(
  566. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  567. children: < Widget > [
  568. Expanded(
  569. flex: 0,
  570. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  571. ),
  572. Expanded(
  573. child: Row(
  574. mainAxisAlignment: MainAxisAlignment.end,
  575. children: < Widget > [
  576. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  577. SizedBox(
  578. width: ScreenUtil.getInstance().setWidth(500),
  579. child: TextField(
  580. controller: type == 'send' ? sendCompanyAddressController : receiptCompanyAddressController,
  581. textAlign: TextAlign.end,
  582. decoration: InputDecoration(
  583. border: InputBorder.none
  584. ),
  585. ),
  586. ),
  587. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  588. ],
  589. )
  590. )
  591. ],
  592. ),
  593. )
  594. )
  595. );
  596. }
  597. Widget _descWidget() {
  598. return
  599. Container(
  600. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  601. //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  602. child: TextField(
  603. maxLines: 3,
  604. decoration: InputDecoration(
  605. border: InputBorder.none,
  606. hintText: "请输入备注内容"
  607. ),
  608. onChanged: (value) {
  609. setState(() {
  610. memo = value;
  611. });
  612. },
  613. ),
  614. );
  615. }
  616. Widget _submitBtn() {
  617. return GestureDetector(
  618. child: Container(
  619. margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
  620. height: ScreenUtil.getInstance().setHeight(88),
  621. decoration: BoxDecoration(
  622. borderRadius: BorderRadius.all(Radius.circular(4)),
  623. color: Color.fromRGBO(37, 102, 242, 1),
  624. ),
  625. child: Center(
  626. child: Row(
  627. mainAxisAlignment: MainAxisAlignment.center,
  628. children: < Widget > [
  629. Offstage(
  630. offstage: submitStatus,
  631. child: SizedBox(
  632. width: ScreenUtil.getInstance().setWidth(45),
  633. height: ScreenUtil.getInstance().setHeight(45),
  634. child: Image.asset('lib/images/loading.gif'),
  635. ),
  636. ),
  637. Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
  638. ],
  639. )
  640. ),
  641. ),
  642. onTap: () {
  643. if (!submitStatus) {
  644. return;
  645. }
  646. String errStr = '';
  647. print('sendCompanyId---${sendCompanyId}');
  648. print('sendCompanyName---${sendCompanyName}');
  649. print('sendCompanyPhone---${sendCompanyPhone}');
  650. print('sendCompanyCode---${sendCompanyCode}');
  651. print('sendCompanyProvinceName---${sendCompanyProvinceName}');
  652. print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
  653. print('sendCompanyCityName---${sendCompanyCityName}');
  654. print('sendCompanyCityCode---${sendCompanyCityCode}');
  655. print('sendCompanyAreaName---${sendCompanyAreaName}');
  656. print('sendCompanyAreaCode---${sendCompanyAreaCode}');
  657. print('sendCompanyAddress---${sendCompanyAddress}');
  658. print('receiptCompanyId---${receiptCompanyId}');
  659. print('receiptCompanyPhone---${receiptCompanyPhone}');
  660. print('receiptCompanyName---${receiptCompanyName}');
  661. print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
  662. print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
  663. print('receiptCompanyCityName---${receiptCompanyCityName}');
  664. print('receiptCompanyCityCode---${receiptCompanyCityCode}');
  665. print('receiptCompanyAreaName---${receiptCompanyAreaName}');
  666. print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
  667. print('receiptCompanyAddress---${receiptCompanyAddress}');
  668. print('goods---${goods}');
  669. print('goodsQuantity---${goodsQuantity}');
  670. print('goodsPackingId---${goodsPackingId}');
  671. print('goodsCategoryId---${goodsCategoryId}');
  672. print('goodsPaymentMethod---${goodsPaymentMethod}');
  673. print('goodsWeight---${goodsWeight}');
  674. print('goodsPriceProtection---${goodsPriceProtection}');
  675. print('goodsAgencyFund---${goodsAgencyFund}');
  676. print('goodsFreight---${goodsFreight}');
  677. print('memo---${memo}');
  678. if (sendCompanyPhone == '') {
  679. errStr = '请填写发件电话';
  680. }
  681. if (sendCompanyName == '') {
  682. errStr = '请填写发件企业名称';
  683. }
  684. if (sendCompanyProvinceName == '') {
  685. errStr = '请填写发件城市/区域';
  686. }
  687. if (sendCompanyAddress == '') {
  688. errStr = '请填写发件详细地址';
  689. }
  690. if (receiptCompanyPhone == '') {
  691. errStr = '请填写收件电话';
  692. }
  693. if (receiptCompanyName == '') {
  694. errStr = '请填写收件企业名称';
  695. }
  696. if (receiptCompanyProvinceName == '') {
  697. errStr = '请填写收件城市/区域';
  698. }
  699. if (receiptCompanyAddress == '') {
  700. errStr = '请填写收件详细地址';
  701. }
  702. if (goods == '') {
  703. errStr = '请填写货物名称';
  704. }
  705. if (goodsQuantity == 0) {
  706. errStr = '请填写货物数量';
  707. }
  708. if (int.tryParse(goodsQuantity.toString()) == null) {
  709. errStr = '货物数量格式错误';
  710. }
  711. if (goodsFreight == 0.0) {
  712. errStr = '请填写运费';
  713. }
  714. if (int.tryParse(sendCompanyPhone) == null || int.tryParse(receiptCompanyPhone) == null || sendCompanyPhone.length != 11 || receiptCompanyPhone.length != 11) {
  715. errStr = '请输入正确的电话';
  716. }
  717. if (errStr != '') {
  718. showError(errStr);
  719. return;
  720. }
  721. if(lineList.length==1){
  722. lineId = lineList[0].lineId.toString();
  723. }else if(lineList.length>1){
  724. showLineModal(lineList);
  725. return;
  726. }
  727. submitOrder();
  728. },
  729. );
  730. }
  731. submitOrder(){
  732. setState(() {
  733. submitStatus = false;
  734. });
  735. getKey('stationId').then((value) {
  736. createOrder(
  737. lineId,
  738. value,
  739. sendCompanyId, //寄件公司Id
  740. sendCompanyName, //寄件公司名称 不能为空
  741. sendCompanyPhone, //寄件公司电话 不能为空
  742. sendCompanyCode ?? '', //寄件公司编码
  743. sendCompanyProvinceName, //寄件公司省名称 不能为空
  744. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  745. sendCompanyCityName, //寄件公司市名称 不能为空
  746. sendCompanyCityCode, //寄件公司市编码 不能为空
  747. sendCompanyAreaName, //寄件公司区名称 不能为空
  748. sendCompanyAreaCode, //寄件公司区编码 不能为空
  749. sendCompanyAddress, //寄件公司详细地址,不能为空
  750. receiptCompanyId, //收件公司id
  751. receiptCompanyPhone, //收件公司电话 不能为空
  752. receiptCompanyName, //收件公司名称 不能为空
  753. receiptCompanyProvinceName, //收件公司省名称 不能为空
  754. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  755. receiptCompanyCityName, //收件公司市名称 不能为空
  756. receiptCompanyCityCode, //收件公市编码 不能为空
  757. receiptCompanyAreaName, //收件公区名称 不能为空
  758. receiptCompanyAreaCode, //收件公司区编码 不能为空
  759. receiptCompanyAddress, //收件公司地址详情 不能为空
  760. goods, //商品名称 不能为空
  761. goodsQuantity, //商品数量 不能为空
  762. goodsPackingId, //商品包装ID
  763. goodsCategoryId, //商品类别ID
  764. goodsPaymentMethod, //付款方式 1,现付 2 到付
  765. goodsWeight, //商品重量
  766. goodsPriceProtection * 100, //商品保价,已分为单位
  767. goodsAgencyFund * 100, //商品代收款,已分为单位
  768. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  769. memo, //备注
  770. ).then((resp) {
  771. if (isNotError(context, resp) && this.mounted) {
  772. setState(() {
  773. submitStatus = true;
  774. });
  775. OrderDetailData orderObj = OrderDetailObj.fromJson(resp.data).data;
  776. showDialog < Null > (
  777. context: context, //BuildContext对象
  778. barrierDismissible: false,
  779. builder: (BuildContext context) {
  780. return SendDialog( //调用对话框
  781. orderNo: orderObj.orderNo,
  782. childCallback: (val) {
  783. if (!val) {
  784. //跳转
  785. Navigator.push(context, MaterialPageRoute(builder: (context) {
  786. return OrderDetail(orderId: orderObj.orderNo, );
  787. }));
  788. }
  789. },
  790. );
  791. });
  792. } else {
  793. setState(() {
  794. submitStatus = true;
  795. });
  796. }
  797. });
  798. });
  799. }
  800. showError(String str) {
  801. showDialog < Null > (
  802. context: context, //BuildContext对象
  803. barrierDismissible: false,
  804. builder: (BuildContext context) {
  805. return MyAlertDialog( //调用对话框
  806. text: str, childCallback: (val) {},
  807. );
  808. });
  809. }
  810. showLineModal(List<CompanyOfLineList> list){
  811. showDialog < Null > (
  812. context: context, //BuildContext对象
  813. barrierDismissible: false,
  814. builder: (BuildContext context) {
  815. return ShowLineModal(
  816. lineList: list, childCallback: (val) {
  817. lineId = val;
  818. submitOrder();
  819. },
  820. );
  821. });
  822. }
  823. Future getCity(context) async {
  824. Result result = await CityPickers.showCityPicker(
  825. context: context,
  826. );
  827. return result;
  828. }
  829. Widget _tipItem(LikePhoneList obj) {
  830. return Container(
  831. child: Column(
  832. children: < Widget > [
  833. InkWell(
  834. child: Container(
  835. height: ScreenUtil.getInstance().setHeight(89),
  836. child: Center(
  837. child: Row(
  838. mainAxisAlignment: MainAxisAlignment.start,
  839. children: < Widget > [
  840. Padding(
  841. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  842. child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
  843. fontSize: ScreenUtil.getInstance().setSp(28),
  844. color: Color.fromRGBO(74, 74, 74, 1)
  845. ), )
  846. ),
  847. SizedBox(
  848. width: ScreenUtil.getInstance().setWidth(185),
  849. child: Text(obj.areaCode,
  850. textAlign: TextAlign.left,
  851. style: TextStyle(
  852. fontSize: ScreenUtil.getInstance().setSp(28),
  853. color: Color.fromRGBO(155, 155, 155, 1)
  854. ), ),
  855. ),
  856. Text(obj.companyName,
  857. textAlign: TextAlign.left,
  858. overflow: TextOverflow.ellipsis,
  859. style: TextStyle(
  860. fontSize: ScreenUtil.getInstance().setSp(28),
  861. color: Color.fromRGBO(155, 155, 155, 1)
  862. ),
  863. )
  864. ],
  865. ),
  866. ),
  867. ),
  868. onTap: () {
  869. if (sendPhoneOrGetPhoneTab) {
  870. sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  871. sendCompanyCode = obj.companyCode;
  872. sendCompanyName = obj.companyName;
  873. sendCompanyId = obj.id.toString();
  874. sendCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  875. sendCompanyCodeController.text = obj.companyCode;
  876. sendCompanyNameController.text = obj.companyName;
  877. sendPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  878. sendCompanyProvinceName = obj.provinceName;
  879. sendCompanyProvinceCode = obj.provinceCode;
  880. sendCompanyCityName = obj.cityName;
  881. sendCompanyCityCode = obj.cityCode;
  882. sendCompanyAreaName = obj.areaName;
  883. sendCompanyAreaCode = obj.areaCode;
  884. sendCompanyAddressController.text = obj.address;
  885. } else {
  886. receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  887. receiptCompanyName = obj.companyName;
  888. receiptCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  889. receiptCompanyNameController.text = obj.companyName;
  890. receiptCompanyId = obj.id.toString();
  891. getLineOfCompanyId(receiptCompanyId).then((resp){
  892. if(isNotError(context, resp) && this.mounted){
  893. CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
  894. setState(() {
  895. lineList = obj.data;
  896. });
  897. }
  898. });
  899. getPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  900. receiptCompanyProvinceName = obj.provinceName;
  901. receiptCompanyProvinceCode = obj.provinceCode;
  902. receiptCompanyCityName = obj.cityName;
  903. receiptCompanyCityCode = obj.cityCode;
  904. receiptCompanyAreaName = obj.areaName;
  905. receiptCompanyAreaCode = obj.areaCode;
  906. receiptCompanyAddressController.text = obj.address;
  907. }
  908. setState(() {
  909. FocusScope.of(context).requestFocus(FocusNode());
  910. tipStatus = true;
  911. });
  912. },
  913. ),
  914. _underLine()
  915. ],
  916. ),
  917. );
  918. }
  919. Widget _packageType(String key) {
  920. return Padding(
  921. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  922. child: Column(
  923. children: < Widget > [
  924. InkWell(
  925. child: SizedBox(
  926. height: ScreenUtil.getInstance().setHeight(89),
  927. child: Center(
  928. child: Row(
  929. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  930. children: < Widget > [
  931. Expanded(
  932. flex: 0,
  933. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  934. ),
  935. Expanded(
  936. child: Row(
  937. mainAxisAlignment: MainAxisAlignment.end,
  938. children: < Widget > [
  939. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  940. SizedBox(
  941. width: ScreenUtil.getInstance().setWidth(500),
  942. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '货物类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  943. ),
  944. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  945. ],
  946. )
  947. )
  948. ],
  949. ),
  950. )
  951. ),
  952. onTap: () {
  953. showPickerModal(context, key);
  954. },
  955. ),
  956. Expanded(
  957. flex: 0,
  958. child: _underLine()
  959. )
  960. ],
  961. )
  962. );
  963. }
  964. showPickerModal(BuildContext context, String type) {
  965. List < dynamic > data = [];
  966. if (type == '包装类型') {
  967. for (int i = 0; i < goodsPackageList.length; i++) {
  968. data.add(goodsPackageList[i].name);
  969. }
  970. } else if (type == '商品类型') {
  971. for (int i = 0; i < goodsCateGoryList.length; i++) {
  972. data.add(goodsCateGoryList[i].name);
  973. }
  974. } else if (type == '付款方式') {
  975. data = ['现付', '到付'];
  976. }
  977. new Picker(
  978. adapter: PickerDataAdapter < String > (pickerdata: data),
  979. height: ScreenUtil.getInstance().setHeight(450),
  980. confirmText: '确定',
  981. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  982. cancelText: '取消',
  983. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  984. headercolor: Color.fromRGBO(245, 245, 245, 1),
  985. itemExtent: ScreenUtil.getInstance().setHeight(80),
  986. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  987. changeToFirst: true,
  988. hideHeader: false,
  989. onConfirm: (Picker picker, List value) {
  990. if (type == '包装类型') {
  991. setState(() {
  992. showTextGoodsPackage = goodsPackageList[value[0]].name;
  993. goodsPackingId = goodsPackageList[value[0]].id;
  994. });
  995. } else if (type == '商品类型') {
  996. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  997. goodsCategoryId = goodsCateGoryList[value[0]].id;
  998. } else if (type == '付款方式') {
  999. showTextPaymentMehod = data[value[0]];
  1000. if (showTextPaymentMehod == '现付') {
  1001. goodsPaymentMethod = 1;
  1002. } else {
  1003. goodsPaymentMethod = 2;
  1004. }
  1005. }
  1006. }
  1007. ).showModal(this.context); //_scaffoldKey.currentState);
  1008. }
  1009. }