send_express_page.dart 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:city_pickers/city_pickers.dart';
  4. import 'package:flutter_picker/flutter_picker.dart';
  5. import 'dart:async';
  6. import 'send_express_page/order_detail_page.dart';
  7. import '../util/util.dart';
  8. import '../util/api.dart';
  9. import '../util/models.dart';
  10. import '../showAlert.dart';
  11. import '../send_Dialog.dart';
  12. class SendExpressPage extends StatefulWidget {
  13. final Widget child;
  14. SendExpressPage({
  15. Key key,
  16. this.child
  17. }): super(key: key);
  18. _SendExpressPageState createState() => _SendExpressPageState();
  19. }
  20. class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
  21. ScrollController _scrollController = ScrollController();
  22. //组件自用字段-----------------------------
  23. GlobalKey _sendPhoneKey = GlobalKey();
  24. GlobalKey _getPhoneKey = GlobalKey();
  25. double tipWidth = 0;
  26. double tipHeight = 0;
  27. double tipPosX = 0;
  28. double tipPosY = 0;
  29. bool tipStatus = true;
  30. bool submitStatus = true;
  31. List < LikePhoneList > likePhoneList = [];
  32. var timer;
  33. bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
  34. TextEditingController sendCompanyPhoneController = TextEditingController();
  35. TextEditingController sendCompanyCodeController = TextEditingController();
  36. TextEditingController sendCompanyNameController = TextEditingController();
  37. TextEditingController receiptCompanyPhoneController = TextEditingController();
  38. TextEditingController receiptCompanyNameController = TextEditingController();
  39. TextEditingController sendCompanyAddreddController = TextEditingController();
  40. TextEditingController receiptCompanyAddressController = TextEditingController();
  41. List < dynamic > goodsCateGoryList = [];
  42. List < dynamic > goodsPackageList = [];
  43. //请求字段-------------------------
  44. int sendCompanyId; //寄件公司Id
  45. String sendCompanyName = ''; //寄件公司名称 不能为空
  46. String sendCompanyPhone = ''; //寄件公司电话 不能为空
  47. String sendCompanyCode = ''; //寄件公司编码
  48. String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
  49. String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
  50. String sendCompanyCityName = ''; //寄件公司市名称 不能为空
  51. String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
  52. String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
  53. String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
  54. String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
  55. int receiptCompanyId; //收件公司id
  56. String receiptCompanyPhone = ''; //收件公司电话 不能为空
  57. String receiptCompanyName = ''; //收件公司名称 不能为空
  58. String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
  59. String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
  60. String receiptCompanyCityName = ''; //收件公司市名称 不能为空
  61. String receiptCompanyCityCode = ''; //收件公市编码 不能为空
  62. String receiptCompanyAreaName = ''; //收件公区名称 不能为空
  63. String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
  64. String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
  65. String goods = ''; //商品名称 不能为空
  66. int goodsQuantity = 1; //商品数量 不能为空
  67. int goodsPackingId; //商品包装ID
  68. int goodsCategoryId; //商品类别ID
  69. int goodsPaymentMethod = 1; //付款方式 1,现付 2 到付
  70. double goodsWeight = 0.0; //商品重量
  71. double goodsPriceProtection = 0.0; //商品保价
  72. double goodsAgencyFund = 0.0; //商品代收款
  73. double goodsFreight = 0.0; //商品运费 不能为空
  74. String memo = ''; //备注
  75. String sendPCA = ' '; //Text组件内容必须有空格,否则报null
  76. String getPCA = ' ';
  77. String showTextGoodsCategory = ' ';
  78. String showTextGoodsPackage = ' ';
  79. String showTextPaymentMehod = '现付';
  80. @override
  81. void initState() {
  82. super.initState();
  83. goodsCategory().then((resp) {
  84. if (isNotError(context, resp)) {
  85. GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
  86. setState(() {
  87. goodsCateGoryList = goodsCategoryObj.data;
  88. showTextGoodsCategory = goodsCateGoryList[0].name;
  89. goodsCategoryId = goodsCateGoryList[0].id;
  90. });
  91. }
  92. });
  93. goodsPackage().then((resp) {
  94. if (isNotError(context, resp)) {
  95. GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
  96. setState(() {
  97. goodsPackageList = goodsPackageObj.data;
  98. showTextGoodsPackage = goodsPackageList[0].name;
  99. goodsPackingId = goodsPackageList[0].id;
  100. });
  101. }
  102. });
  103. _scrollController.addListener(() {
  104. if (!tipStatus) {
  105. setState(() {
  106. tipStatus = true;
  107. });
  108. }
  109. //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
  110. });
  111. sendCompanyPhoneController.addListener(() {
  112. setState(() {
  113. sendCompanyPhone = sendCompanyPhoneController.text;
  114. });
  115. if (timer != null) {
  116. timer.cancel();
  117. }
  118. if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length >= 11) {
  119. setState(() {
  120. tipStatus = true;
  121. });
  122. }
  123. timer = Timer(Duration(milliseconds: 500), () {
  124. if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length < 11) {
  125. likePhone(sendCompanyPhoneController.text).then((resp) {
  126. if (isNotError(context, resp)) {
  127. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  128. likePhoneList = likePhoneObj.data;
  129. }
  130. if (likePhoneList.length > 0) {
  131. sendPhoneOrGetPhoneTab = true;
  132. RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
  133. setState(() {
  134. tipWidth = sendPhoneObj.paintBounds.size.width;
  135. tipHeight = sendPhoneObj.paintBounds.size.height;
  136. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  137. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  138. tipStatus = false;
  139. });
  140. } else {
  141. setState(() {
  142. tipStatus = true;
  143. });
  144. }
  145. });
  146. }
  147. });
  148. });
  149. receiptCompanyPhoneController.addListener(() {
  150. setState(() {
  151. receiptCompanyPhone = receiptCompanyPhoneController.text;
  152. });
  153. if (timer != null) {
  154. timer.cancel();
  155. }
  156. if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length >= 11) {
  157. setState(() {
  158. tipStatus = true;
  159. });
  160. }
  161. timer = Timer(Duration(milliseconds: 500), () {
  162. if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length < 11) {
  163. likePhone(receiptCompanyPhoneController.text).then((resp) {
  164. if (isNotError(context, resp)) {
  165. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  166. likePhoneList = likePhoneObj.data;
  167. }
  168. if (likePhoneList.length > 0) {
  169. sendPhoneOrGetPhoneTab = false;
  170. RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
  171. setState(() {
  172. tipWidth = getPhoneKey.paintBounds.size.width;
  173. tipHeight = getPhoneKey.paintBounds.size.height;
  174. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  175. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  176. tipStatus = false;
  177. });
  178. } else {
  179. setState(() {
  180. tipStatus = true;
  181. });
  182. }
  183. });
  184. }
  185. });
  186. });
  187. sendCompanyAddreddController.addListener(() {
  188. setState(() {
  189. sendCompanyAddress = sendCompanyAddreddController.text;
  190. });
  191. });
  192. receiptCompanyAddressController.addListener(() {
  193. setState(() {
  194. receiptCompanyAddress = receiptCompanyAddressController.text;
  195. });
  196. });
  197. }
  198. @override
  199. bool get wantKeepAlive => true;
  200. @override
  201. Widget build(BuildContext context) {
  202. return Container(
  203. child: Scaffold(
  204. appBar: AppBar(
  205. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  206. centerTitle: true,
  207. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  208. ),
  209. body:
  210. Stack(
  211. children: < Widget > [
  212. Container(
  213. color: Color.fromRGBO(246, 246, 254, 1),
  214. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  215. child: ListView(
  216. controller: _scrollController,
  217. children: < Widget > [
  218. _sendInfo(context),
  219. _getInfo(context),
  220. _itemInfoWidget(),
  221. _submitBtn()
  222. ],
  223. ),
  224. ),
  225. Positioned(
  226. top: tipPosY,
  227. left: tipPosX,
  228. child: Offstage(
  229. offstage: tipStatus,
  230. child: Container(
  231. width: tipWidth,
  232. height: ScreenUtil.getInstance().setHeight(450),
  233. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  234. decoration: BoxDecoration(
  235. color: Color.fromRGBO(244, 248, 251, 1),
  236. ),
  237. child: ListView.builder(
  238. itemCount: likePhoneList.length,
  239. itemBuilder: (BuildContext context, int index) {
  240. return _tipItem(likePhoneList[index]);
  241. },
  242. )
  243. ),
  244. )
  245. )
  246. ],
  247. ),
  248. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  249. ),
  250. );
  251. }
  252. Widget _sendInfo(BuildContext context) {
  253. return Container(
  254. color: Colors.white,
  255. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  256. child: Column(
  257. children: < Widget > [
  258. _titleWidget('lib/images/icon_send.png', '发件信息'),
  259. _underLine(),
  260. _inputWiget('电话', 'sendPhone'),
  261. _contentWiget('企业编码', 'send', true),
  262. _contentWiget('企业名称', 'send', true),
  263. _cityWiget('城市/区域', context, 'send'),
  264. _lastContentWiget('详细地址', 'send')
  265. ],
  266. )
  267. );
  268. }
  269. Widget _getInfo(BuildContext context) {
  270. return Container(
  271. color: Colors.white,
  272. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  273. child: Column(
  274. children: < Widget > [
  275. _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  276. _underLine(),
  277. _inputWiget('电话', 'getPhone'),
  278. //_contentWiget('企业编码', 'get', true),
  279. _contentWiget('企业名称', 'get', true),
  280. _cityWiget('城市/区域', context, 'get'),
  281. _lastContentWiget('详细地址', 'get')
  282. ],
  283. )
  284. );
  285. }
  286. Widget _itemInfoWidget() {
  287. return Container(
  288. child: Container(
  289. color: Colors.white,
  290. child: Column(
  291. crossAxisAlignment: CrossAxisAlignment.start,
  292. children: < Widget > [
  293. _titleWidget('lib/images/icon_huowu.png', "货物信息"),
  294. _underLine(),
  295. _contentWiget("货物名称", 'goods', true),
  296. _contentWiget("数量", 'goods'),
  297. _contentWiget("运费", 'goods'),
  298. _contentWiget("代收", 'goods'),
  299. _contentWiget("保价", 'goods'),
  300. _contentWiget("重量", 'goods'),
  301. _packageType('包装类型'),
  302. _packageType('商品类型'),
  303. _packageType('付款方式'),
  304. _descWidget()
  305. ],
  306. ),
  307. )
  308. );
  309. }
  310. Widget _titleWidget(String iconUrl, String str) {
  311. return Container(
  312. height: ScreenUtil.getInstance().setHeight(90),
  313. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  314. child: Center(
  315. child: Row(
  316. mainAxisAlignment: MainAxisAlignment.start,
  317. children: < Widget > [
  318. Padding(
  319. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  320. child: Image.asset(
  321. iconUrl,
  322. width: ScreenUtil.getInstance().setWidth(40),
  323. height: ScreenUtil.getInstance().setHeight(40),
  324. )
  325. ),
  326. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  327. ],
  328. ),
  329. ),
  330. );
  331. }
  332. Widget _underLine() {
  333. return Container(
  334. color: Color.fromRGBO(223, 223, 223, 1),
  335. height: ScreenUtil.getInstance().setHeight(1),
  336. );
  337. }
  338. Widget _inputWiget(String key, String tab) {
  339. return Padding(
  340. key: tab == 'sendPhone' ? _sendPhoneKey : _getPhoneKey,
  341. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  342. child: Column(
  343. children: < Widget > [
  344. SizedBox(
  345. height: ScreenUtil.getInstance().setHeight(89),
  346. child: Center(
  347. child: Row(
  348. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  349. children: < Widget > [
  350. Expanded(
  351. flex: 0,
  352. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  353. ),
  354. Expanded(
  355. child: Row(
  356. mainAxisAlignment: MainAxisAlignment.end,
  357. children: < Widget > [
  358. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  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.0) {
  695. errStr = '请填写货物数量';
  696. }
  697. if (goodsFreight == 0.0) {
  698. errStr = '请填写运费';
  699. }
  700. if (errStr != '') {
  701. showError(errStr);
  702. return;
  703. }
  704. setState(() {
  705. submitStatus = false;
  706. });
  707. createOrder(
  708. sendCompanyId ?? "", //寄件公司Id
  709. sendCompanyName, //寄件公司名称 不能为空
  710. sendCompanyPhone, //寄件公司电话 不能为空
  711. sendCompanyCode ?? '', //寄件公司编码
  712. sendCompanyProvinceName, //寄件公司省名称 不能为空
  713. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  714. sendCompanyCityName, //寄件公司市名称 不能为空
  715. sendCompanyCityCode, //寄件公司市编码 不能为空
  716. sendCompanyAreaName, //寄件公司区名称 不能为空
  717. sendCompanyAreaCode, //寄件公司区编码 不能为空
  718. sendCompanyAddress, //寄件公司详细地址,不能为空
  719. receiptCompanyId, //收件公司id
  720. receiptCompanyPhone, //收件公司电话 不能为空
  721. receiptCompanyName, //收件公司名称 不能为空
  722. receiptCompanyProvinceName, //收件公司省名称 不能为空
  723. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  724. receiptCompanyCityName, //收件公司市名称 不能为空
  725. receiptCompanyCityCode, //收件公市编码 不能为空
  726. receiptCompanyAreaName, //收件公区名称 不能为空
  727. receiptCompanyAreaCode, //收件公司区编码 不能为空
  728. receiptCompanyAddress, //收件公司地址详情 不能为空
  729. goods, //商品名称 不能为空
  730. goodsQuantity, //商品数量 不能为空
  731. goodsPackingId, //商品包装ID
  732. goodsCategoryId, //商品类别ID
  733. goodsPaymentMethod, //付款方式 1,现付 2 到付
  734. goodsWeight, //商品重量
  735. goodsPriceProtection * 100, //商品保价,已分为单位
  736. goodsAgencyFund * 100, //商品代收款,已分为单位
  737. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  738. memo, //备注
  739. ).then((resp) {
  740. if (isNotError(context, resp)) {
  741. setState(() {
  742. submitStatus = true;
  743. });
  744. CreateOrder orderObj = CreateOrder.fromJson(resp.data);
  745. showDialog < Null > (
  746. context: context, //BuildContext对象
  747. barrierDismissible: false,
  748. builder: (BuildContext context) {
  749. return SendDialog( //调用对话框
  750. orderNo: orderObj.orderNo,
  751. childCallback: (val) {
  752. if (!val) {
  753. //跳转
  754. Navigator.push(context, MaterialPageRoute(builder: (context) {
  755. return OrderDetail(orderId: orderObj.orderNo, );
  756. }));
  757. }
  758. },
  759. );
  760. });
  761. } else {
  762. setState(() {
  763. submitStatus = false;
  764. });
  765. }
  766. });
  767. },
  768. );
  769. }
  770. showError(String str) {
  771. showDialog < Null > (
  772. context: context, //BuildContext对象
  773. barrierDismissible: false,
  774. builder: (BuildContext context) {
  775. return MyAlertDialog( //调用对话框
  776. text: str, childCallback: (val) {},
  777. );
  778. });
  779. }
  780. Future getCity(context) async {
  781. Result result = await CityPickers.showCityPicker(
  782. context: context,
  783. );
  784. return result;
  785. }
  786. Widget _tipItem(LikePhoneList obj) {
  787. return Container(
  788. child: Column(
  789. children: < Widget > [
  790. InkWell(
  791. child: Container(
  792. height: ScreenUtil.getInstance().setHeight(89),
  793. child: Center(
  794. child: Row(
  795. mainAxisAlignment: MainAxisAlignment.start,
  796. children: < Widget > [
  797. Padding(
  798. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  799. child: Text(obj.uzerPhone, style: TextStyle(
  800. fontSize: ScreenUtil.getInstance().setSp(28),
  801. color: Color.fromRGBO(74, 74, 74, 1)
  802. ), )
  803. ),
  804. SizedBox(
  805. width: ScreenUtil.getInstance().setWidth(185),
  806. child: Text(obj.areaCode,
  807. textAlign: TextAlign.left,
  808. style: TextStyle(
  809. fontSize: ScreenUtil.getInstance().setSp(28),
  810. color: Color.fromRGBO(155, 155, 155, 1)
  811. ), ),
  812. ),
  813. Text(obj.companyName,
  814. textAlign: TextAlign.left,
  815. overflow: TextOverflow.ellipsis,
  816. style: TextStyle(
  817. fontSize: ScreenUtil.getInstance().setSp(28),
  818. color: Color.fromRGBO(155, 155, 155, 1)
  819. ),
  820. )
  821. ],
  822. ),
  823. ),
  824. ),
  825. onTap: () {
  826. if (sendPhoneOrGetPhoneTab) {
  827. sendCompanyPhone = obj.uzerPhone;
  828. sendCompanyCode = obj.companyCode;
  829. sendCompanyName = obj.companyName;
  830. sendCompanyId = obj.id;
  831. sendCompanyPhoneController.text = obj.uzerPhone;
  832. sendCompanyCodeController.text = obj.companyCode;
  833. sendCompanyNameController.text = obj.companyName;
  834. } else {
  835. receiptCompanyPhone = obj.uzerPhone;
  836. receiptCompanyName = obj.companyName;
  837. receiptCompanyPhoneController.text = obj.uzerPhone;
  838. receiptCompanyNameController.text = obj.companyName;
  839. receiptCompanyId = obj.id;
  840. }
  841. setState(() {
  842. FocusScope.of(context).requestFocus(FocusNode());
  843. tipStatus = true;
  844. });
  845. },
  846. ),
  847. _underLine()
  848. ],
  849. ),
  850. );
  851. }
  852. Widget _packageType(String key) {
  853. return Padding(
  854. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  855. child: Column(
  856. children: < Widget > [
  857. InkWell(
  858. child: SizedBox(
  859. height: ScreenUtil.getInstance().setHeight(89),
  860. child: Center(
  861. child: Row(
  862. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  863. children: < Widget > [
  864. Expanded(
  865. flex: 0,
  866. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  867. ),
  868. Expanded(
  869. child: Row(
  870. mainAxisAlignment: MainAxisAlignment.end,
  871. children: < Widget > [
  872. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  873. SizedBox(
  874. width: ScreenUtil.getInstance().setWidth(500),
  875. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '商品类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  876. ),
  877. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  878. ],
  879. )
  880. )
  881. ],
  882. ),
  883. )
  884. ),
  885. onTap: () {
  886. showPickerModal(context, key);
  887. },
  888. ),
  889. Expanded(
  890. flex: 0,
  891. child: _underLine()
  892. )
  893. ],
  894. )
  895. );
  896. }
  897. showPickerModal(BuildContext context, String type) {
  898. List < dynamic > data = [];
  899. if (type == '包装类型') {
  900. for (int i = 0; i < goodsPackageList.length; i++) {
  901. data.add(goodsPackageList[i].name);
  902. }
  903. } else if (type == '商品类型') {
  904. for (int i = 0; i < goodsCateGoryList.length; i++) {
  905. data.add(goodsCateGoryList[i].name);
  906. }
  907. } else if (type == '付款方式') {
  908. data = ['现付', '到付'];
  909. }
  910. new Picker(
  911. adapter: PickerDataAdapter < String > (pickerdata: data),
  912. height: ScreenUtil.getInstance().setHeight(450),
  913. confirmText: '确定',
  914. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  915. cancelText: '取消',
  916. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  917. headercolor: Color.fromRGBO(245, 245, 245, 1),
  918. itemExtent: ScreenUtil.getInstance().setHeight(80),
  919. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  920. changeToFirst: true,
  921. hideHeader: false,
  922. onConfirm: (Picker picker, List value) {
  923. if (type == '包装类型') {
  924. setState(() {
  925. showTextGoodsPackage = goodsPackageList[value[0]].name;
  926. goodsPackingId = goodsPackageList[value[0]].id;
  927. });
  928. } else if (type == '商品类型') {
  929. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  930. goodsCategoryId = goodsCateGoryList[value[0]].id;
  931. } else if (type == '付款方式') {
  932. showTextPaymentMehod = data[value[0]];
  933. if (showTextPaymentMehod == '现付') {
  934. goodsPaymentMethod = 1;
  935. } else {
  936. goodsPaymentMethod = 2;
  937. }
  938. }
  939. }
  940. ).showModal(this.context); //_scaffoldKey.currentState);
  941. }
  942. }