send_express_page.dart 39 KB

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