send_express_page.dart 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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. } else if (key == '代收') {
  449. goodsAgencyFund = double.parse(value);
  450. } else if (key == '保价') {
  451. goodsPriceProtection = double.parse(value);
  452. } else if (key == '重量') {
  453. goodsWeight = double.parse(value);
  454. }
  455. }
  456. },
  457. ),
  458. ),
  459. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  460. ],
  461. )
  462. )
  463. ],
  464. ),
  465. )
  466. ),
  467. Expanded(
  468. flex: 0,
  469. child: _underLine()
  470. )
  471. ],
  472. )
  473. );
  474. }
  475. Widget _cityWiget(String key, BuildContext context, String type) {
  476. return
  477. GestureDetector(
  478. child: Padding(
  479. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  480. child: Column(
  481. children: < Widget > [
  482. SizedBox(
  483. height: ScreenUtil.getInstance().setHeight(89),
  484. child: Center(
  485. child: Row(
  486. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  487. children: < Widget > [
  488. Expanded(
  489. flex: 0,
  490. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  491. ),
  492. Expanded(
  493. child: Row(
  494. mainAxisAlignment: MainAxisAlignment.end,
  495. children: < Widget > [
  496. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  497. SizedBox(
  498. width: ScreenUtil.getInstance().setWidth(500),
  499. child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
  500. ),
  501. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  502. ],
  503. )
  504. )
  505. ],
  506. ),
  507. )
  508. ),
  509. Expanded(
  510. flex: 0,
  511. child: _underLine()
  512. )
  513. ],
  514. )
  515. ),
  516. onTap: () {
  517. getCity(context).then((resp) {
  518. if (resp == null) {
  519. return;
  520. }
  521. print(resp.toString());
  522. setState(() {
  523. if (type == 'send') {
  524. sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  525. sendCompanyProvinceName = resp.provinceName;
  526. sendCompanyProvinceCode = resp.provinceId;
  527. sendCompanyCityName = resp.cityName;
  528. sendCompanyCityCode = resp.cityId;
  529. sendCompanyAreaName = resp.areaName;
  530. sendCompanyAreaCode = resp.areaId;
  531. } else {
  532. getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  533. receiptCompanyProvinceName = resp.provinceName;
  534. receiptCompanyProvinceCode = resp.provinceId;
  535. receiptCompanyCityName = resp.cityName;
  536. receiptCompanyCityCode = resp.cityId;
  537. receiptCompanyAreaName = resp.areaName;
  538. receiptCompanyAreaCode = resp.areaId;
  539. }
  540. });
  541. //print(value);
  542. });
  543. },
  544. );
  545. }
  546. Widget _lastContentWiget(String key, String type) {
  547. return Padding(
  548. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  549. child: SizedBox(
  550. height: ScreenUtil.getInstance().setHeight(89),
  551. child: Center(
  552. child: Row(
  553. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  554. children: < Widget > [
  555. Expanded(
  556. flex: 0,
  557. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  558. ),
  559. Expanded(
  560. child: Row(
  561. mainAxisAlignment: MainAxisAlignment.end,
  562. children: < Widget > [
  563. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  564. SizedBox(
  565. width: ScreenUtil.getInstance().setWidth(500),
  566. child: TextField(
  567. controller: type == 'send' ? sendCompanyAddreddController : receiptCompanyAddressController,
  568. textAlign: TextAlign.end,
  569. decoration: InputDecoration(
  570. border: InputBorder.none
  571. ),
  572. ),
  573. ),
  574. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  575. ],
  576. )
  577. )
  578. ],
  579. ),
  580. )
  581. )
  582. );
  583. }
  584. Widget _descWidget() {
  585. return
  586. Container(
  587. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  588. //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  589. child: TextField(
  590. maxLines: 3,
  591. decoration: InputDecoration(
  592. border: InputBorder.none,
  593. hintText: "请输入备注内容"
  594. ),
  595. onChanged: (value) {
  596. setState(() {
  597. memo = value;
  598. });
  599. },
  600. ),
  601. );
  602. }
  603. Widget _submitBtn() {
  604. return GestureDetector(
  605. child: Container(
  606. margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
  607. height: ScreenUtil.getInstance().setHeight(88),
  608. decoration: BoxDecoration(
  609. borderRadius: BorderRadius.all(Radius.circular(4)),
  610. color: Color.fromRGBO(37, 102, 242, 1),
  611. ),
  612. child: Center(
  613. child: Row(
  614. mainAxisAlignment: MainAxisAlignment.center,
  615. children: < Widget > [
  616. Offstage(
  617. offstage: submitStatus,
  618. child: SizedBox(
  619. width: ScreenUtil.getInstance().setWidth(45),
  620. height: ScreenUtil.getInstance().setHeight(45),
  621. child: Image.asset('lib/images/loading.gif'),
  622. ),
  623. ),
  624. Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
  625. ],
  626. )
  627. ),
  628. ),
  629. onTap: () {
  630. if (!submitStatus) {
  631. return;
  632. }
  633. String errStr = '';
  634. print('sendCompanyId---${sendCompanyId}');
  635. print('sendCompanyName---${sendCompanyName}');
  636. print('sendCompanyPhone---${sendCompanyPhone}');
  637. print('sendCompanyCode---${sendCompanyCode}');
  638. print('sendCompanyProvinceName---${sendCompanyProvinceName}');
  639. print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
  640. print('sendCompanyCityName---${sendCompanyCityName}');
  641. print('sendCompanyCityCode---${sendCompanyCityCode}');
  642. print('sendCompanyAreaName---${sendCompanyAreaName}');
  643. print('sendCompanyAreaCode---${sendCompanyAreaCode}');
  644. print('sendCompanyAddress---${sendCompanyAddress}');
  645. print('receiptCompanyId---${receiptCompanyId}');
  646. print('receiptCompanyPhone---${receiptCompanyPhone}');
  647. print('receiptCompanyName---${receiptCompanyName}');
  648. print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
  649. print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
  650. print('receiptCompanyCityName---${receiptCompanyCityName}');
  651. print('receiptCompanyCityCode---${receiptCompanyCityCode}');
  652. print('receiptCompanyAreaName---${receiptCompanyAreaName}');
  653. print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
  654. print('receiptCompanyAddress---${receiptCompanyAddress}');
  655. print('goods---${goods}');
  656. print('goodsQuantity---${goodsQuantity}');
  657. print('goodsPackingId---${goodsPackingId}');
  658. print('goodsCategoryId---${goodsCategoryId}');
  659. print('goodsPaymentMethod---${goodsPaymentMethod}');
  660. print('goodsWeight---${goodsWeight}');
  661. print('goodsPriceProtection---${goodsPriceProtection}');
  662. print('goodsAgencyFund---${goodsAgencyFund}');
  663. print('goodsFreight---${goodsFreight}');
  664. print('memo---${memo}');
  665. // if (!isChinaPhoneLegal(sendCompanyPhone)) {
  666. // }
  667. if (sendCompanyPhone == '') {
  668. errStr = '请填写发件电话';
  669. }
  670. if (sendCompanyName == '') {
  671. errStr = '请填写发件企业名称';
  672. }
  673. if (sendCompanyProvinceName == '') {
  674. errStr = '请填写发件城市/区域';
  675. }
  676. if (sendCompanyAddress == '') {
  677. errStr = '请填写发件详细地址';
  678. }
  679. if (receiptCompanyPhone == '') {
  680. errStr = '请填写收件电话';
  681. }
  682. if (receiptCompanyName == '') {
  683. errStr = '请填写收件企业名称';
  684. }
  685. if (receiptCompanyProvinceName == '') {
  686. errStr = '请填写收件城市/区域';
  687. }
  688. if (receiptCompanyAddress == '') {
  689. errStr = '请填写收件详细地址';
  690. }
  691. if (goods == '') {
  692. errStr = '请填写货物名称';
  693. }
  694. if (goodsQuantity == 0) {
  695. errStr = '请填写货物数量';
  696. }
  697. if(int.tryParse(goodsQuantity.toString())==null){
  698. errStr='货物数量格式错误';
  699. }
  700. if (goodsFreight == 0.0) {
  701. errStr = '请填写运费';
  702. }
  703. if(int.tryParse(sendCompanyPhone)==null || int.tryParse(receiptCompanyPhone)==null || sendCompanyPhone.length!=11 || receiptCompanyPhone.length!=11){
  704. errStr='请输入正确的电话';
  705. }
  706. if (errStr != '') {
  707. showError(errStr);
  708. return;
  709. }
  710. return;
  711. setState(() {
  712. submitStatus = false;
  713. });
  714. createOrder(
  715. sendCompanyId, //寄件公司Id
  716. sendCompanyName, //寄件公司名称 不能为空
  717. sendCompanyPhone, //寄件公司电话 不能为空
  718. sendCompanyCode ?? '', //寄件公司编码
  719. sendCompanyProvinceName, //寄件公司省名称 不能为空
  720. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  721. sendCompanyCityName, //寄件公司市名称 不能为空
  722. sendCompanyCityCode, //寄件公司市编码 不能为空
  723. sendCompanyAreaName, //寄件公司区名称 不能为空
  724. sendCompanyAreaCode, //寄件公司区编码 不能为空
  725. sendCompanyAddress, //寄件公司详细地址,不能为空
  726. receiptCompanyId, //收件公司id
  727. receiptCompanyPhone, //收件公司电话 不能为空
  728. receiptCompanyName, //收件公司名称 不能为空
  729. receiptCompanyProvinceName, //收件公司省名称 不能为空
  730. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  731. receiptCompanyCityName, //收件公司市名称 不能为空
  732. receiptCompanyCityCode, //收件公市编码 不能为空
  733. receiptCompanyAreaName, //收件公区名称 不能为空
  734. receiptCompanyAreaCode, //收件公司区编码 不能为空
  735. receiptCompanyAddress, //收件公司地址详情 不能为空
  736. goods, //商品名称 不能为空
  737. goodsQuantity, //商品数量 不能为空
  738. goodsPackingId, //商品包装ID
  739. goodsCategoryId, //商品类别ID
  740. goodsPaymentMethod, //付款方式 1,现付 2 到付
  741. goodsWeight, //商品重量
  742. goodsPriceProtection * 100, //商品保价,已分为单位
  743. goodsAgencyFund * 100, //商品代收款,已分为单位
  744. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  745. memo, //备注
  746. ).then((resp) {
  747. if (isNotError(context, resp)) {
  748. setState(() {
  749. submitStatus = true;
  750. });
  751. CreateOrder orderObj = CreateOrder.fromJson(resp.data);
  752. showDialog < Null > (
  753. context: context, //BuildContext对象
  754. barrierDismissible: false,
  755. builder: (BuildContext context) {
  756. return SendDialog( //调用对话框
  757. orderNo: orderObj.orderNo,
  758. childCallback: (val) {
  759. if (!val) {
  760. //跳转
  761. Navigator.push(context, MaterialPageRoute(builder: (context) {
  762. return OrderDetail(orderId: orderObj.orderNo, );
  763. }));
  764. }
  765. },
  766. );
  767. });
  768. } else {
  769. setState(() {
  770. submitStatus = true;
  771. });
  772. }
  773. });
  774. },
  775. );
  776. }
  777. showError(String str) {
  778. showDialog < Null > (
  779. context: context, //BuildContext对象
  780. barrierDismissible: false,
  781. builder: (BuildContext context) {
  782. return MyAlertDialog( //调用对话框
  783. text: str, childCallback: (val) {},
  784. );
  785. });
  786. }
  787. Future getCity(context) async {
  788. Result result = await CityPickers.showCityPicker(
  789. context: context,
  790. );
  791. return result;
  792. }
  793. Widget _tipItem(LikePhoneList obj) {
  794. return Container(
  795. child: Column(
  796. children: < Widget > [
  797. InkWell(
  798. child: Container(
  799. height: ScreenUtil.getInstance().setHeight(89),
  800. child: Center(
  801. child: Row(
  802. mainAxisAlignment: MainAxisAlignment.start,
  803. children: < Widget > [
  804. Padding(
  805. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  806. child: Text(obj.uzerPhone, style: TextStyle(
  807. fontSize: ScreenUtil.getInstance().setSp(28),
  808. color: Color.fromRGBO(74, 74, 74, 1)
  809. ), )
  810. ),
  811. SizedBox(
  812. width: ScreenUtil.getInstance().setWidth(185),
  813. child: Text(obj.areaCode,
  814. textAlign: TextAlign.left,
  815. style: TextStyle(
  816. fontSize: ScreenUtil.getInstance().setSp(28),
  817. color: Color.fromRGBO(155, 155, 155, 1)
  818. ), ),
  819. ),
  820. Text(obj.companyName,
  821. textAlign: TextAlign.left,
  822. overflow: TextOverflow.ellipsis,
  823. style: TextStyle(
  824. fontSize: ScreenUtil.getInstance().setSp(28),
  825. color: Color.fromRGBO(155, 155, 155, 1)
  826. ),
  827. )
  828. ],
  829. ),
  830. ),
  831. ),
  832. onTap: () {
  833. if (sendPhoneOrGetPhoneTab) {
  834. sendCompanyPhone = obj.uzerPhone;
  835. sendCompanyCode = obj.companyCode;
  836. sendCompanyName = obj.companyName;
  837. sendCompanyId = obj.id.toString();
  838. sendCompanyPhoneController.text = obj.uzerPhone;
  839. sendCompanyCodeController.text = obj.companyCode;
  840. sendCompanyNameController.text = obj.companyName;
  841. } else {
  842. receiptCompanyPhone = obj.uzerPhone;
  843. receiptCompanyName = obj.companyName;
  844. receiptCompanyPhoneController.text = obj.uzerPhone;
  845. receiptCompanyNameController.text = obj.companyName;
  846. receiptCompanyId = obj.id.toString();
  847. }
  848. setState(() {
  849. FocusScope.of(context).requestFocus(FocusNode());
  850. tipStatus = true;
  851. });
  852. },
  853. ),
  854. _underLine()
  855. ],
  856. ),
  857. );
  858. }
  859. Widget _packageType(String key) {
  860. return Padding(
  861. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  862. child: Column(
  863. children: < Widget > [
  864. InkWell(
  865. child: SizedBox(
  866. height: ScreenUtil.getInstance().setHeight(89),
  867. child: Center(
  868. child: Row(
  869. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  870. children: < Widget > [
  871. Expanded(
  872. flex: 0,
  873. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  874. ),
  875. Expanded(
  876. child: Row(
  877. mainAxisAlignment: MainAxisAlignment.end,
  878. children: < Widget > [
  879. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  880. SizedBox(
  881. width: ScreenUtil.getInstance().setWidth(500),
  882. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '商品类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  883. ),
  884. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  885. ],
  886. )
  887. )
  888. ],
  889. ),
  890. )
  891. ),
  892. onTap: () {
  893. showPickerModal(context, key);
  894. },
  895. ),
  896. Expanded(
  897. flex: 0,
  898. child: _underLine()
  899. )
  900. ],
  901. )
  902. );
  903. }
  904. showPickerModal(BuildContext context, String type) {
  905. List < dynamic > data = [];
  906. if (type == '包装类型') {
  907. for (int i = 0; i < goodsPackageList.length; i++) {
  908. data.add(goodsPackageList[i].name);
  909. }
  910. } else if (type == '商品类型') {
  911. for (int i = 0; i < goodsCateGoryList.length; i++) {
  912. data.add(goodsCateGoryList[i].name);
  913. }
  914. } else if (type == '付款方式') {
  915. data = ['现付', '到付'];
  916. }
  917. new Picker(
  918. adapter: PickerDataAdapter < String > (pickerdata: data),
  919. height: ScreenUtil.getInstance().setHeight(450),
  920. confirmText: '确定',
  921. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  922. cancelText: '取消',
  923. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  924. headercolor: Color.fromRGBO(245, 245, 245, 1),
  925. itemExtent: ScreenUtil.getInstance().setHeight(80),
  926. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  927. changeToFirst: true,
  928. hideHeader: false,
  929. onConfirm: (Picker picker, List value) {
  930. if (type == '包装类型') {
  931. setState(() {
  932. showTextGoodsPackage = goodsPackageList[value[0]].name;
  933. goodsPackingId = goodsPackageList[value[0]].id;
  934. });
  935. } else if (type == '商品类型') {
  936. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  937. goodsCategoryId = goodsCateGoryList[value[0]].id;
  938. } else if (type == '付款方式') {
  939. showTextPaymentMehod = data[value[0]];
  940. if (showTextPaymentMehod == '现付') {
  941. goodsPaymentMethod = 1;
  942. } else {
  943. goodsPaymentMethod = 2;
  944. }
  945. }
  946. }
  947. ).showModal(this.context); //_scaffoldKey.currentState);
  948. }
  949. }