send_express_page.dart 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  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. String sendCompanyId = '0'; //寄件公司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. String receiptCompanyId='0'; //收件公司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. if(int.tryParse(sendCompanyPhoneController.text)==null){
  113. sendCompanyPhoneController.text = sendCompanyPhone;
  114. }
  115. if(sendCompanyPhoneController.text.length>11){
  116. sendCompanyPhoneController.text = sendCompanyPhone;
  117. }
  118. print(sendCompanyAddreddController);
  119. print(sendCompanyPhoneController.text);
  120. setState(() {
  121. sendCompanyPhone = sendCompanyPhoneController.text;
  122. });
  123. if (timer != null) {
  124. timer.cancel();
  125. }
  126. if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length >= 11) {
  127. setState(() {
  128. tipStatus = true;
  129. });
  130. }
  131. timer = Timer(Duration(milliseconds: 500), () {
  132. if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length < 11) {
  133. likePhone(sendCompanyPhoneController.text).then((resp) {
  134. if (isNotError(context, resp)) {
  135. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  136. likePhoneList = likePhoneObj.data;
  137. }
  138. if (likePhoneList.length > 0) {
  139. sendPhoneOrGetPhoneTab = true;
  140. RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
  141. setState(() {
  142. tipWidth = sendPhoneObj.paintBounds.size.width;
  143. tipHeight = sendPhoneObj.paintBounds.size.height;
  144. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  145. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  146. tipStatus = false;
  147. });
  148. } else {
  149. setState(() {
  150. tipStatus = true;
  151. });
  152. }
  153. });
  154. }
  155. });
  156. });
  157. receiptCompanyPhoneController.addListener(() {
  158. setState(() {
  159. receiptCompanyPhone = receiptCompanyPhoneController.text;
  160. });
  161. if (timer != null) {
  162. timer.cancel();
  163. }
  164. if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length >= 11) {
  165. setState(() {
  166. tipStatus = true;
  167. });
  168. }
  169. timer = Timer(Duration(milliseconds: 500), () {
  170. if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length < 11) {
  171. likePhone(receiptCompanyPhoneController.text).then((resp) {
  172. if (isNotError(context, resp)) {
  173. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  174. likePhoneList = likePhoneObj.data;
  175. }
  176. if (likePhoneList.length > 0) {
  177. sendPhoneOrGetPhoneTab = false;
  178. RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
  179. setState(() {
  180. tipWidth = getPhoneKey.paintBounds.size.width;
  181. tipHeight = getPhoneKey.paintBounds.size.height;
  182. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  183. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  184. tipStatus = false;
  185. });
  186. } else {
  187. setState(() {
  188. tipStatus = true;
  189. });
  190. }
  191. });
  192. }
  193. });
  194. });
  195. sendCompanyAddreddController.addListener(() {
  196. setState(() {
  197. sendCompanyAddress = sendCompanyAddreddController.text;
  198. });
  199. });
  200. receiptCompanyAddressController.addListener(() {
  201. setState(() {
  202. receiptCompanyAddress = receiptCompanyAddressController.text;
  203. });
  204. });
  205. }
  206. @override
  207. bool get wantKeepAlive => true;
  208. @override
  209. Widget build(BuildContext context) {
  210. return Container(
  211. child: Scaffold(
  212. appBar: AppBar(
  213. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  214. centerTitle: true,
  215. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  216. ),
  217. body:
  218. Stack(
  219. children: < Widget > [
  220. Container(
  221. color: Color.fromRGBO(246, 246, 254, 1),
  222. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  223. child: ListView(
  224. controller: _scrollController,
  225. children: < Widget > [
  226. _sendInfo(context),
  227. _getInfo(context),
  228. _itemInfoWidget(),
  229. _submitBtn()
  230. ],
  231. ),
  232. ),
  233. Positioned(
  234. top: tipPosY,
  235. left: tipPosX,
  236. child: Offstage(
  237. offstage: tipStatus,
  238. child: Container(
  239. width: tipWidth,
  240. height: ScreenUtil.getInstance().setHeight(450),
  241. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  242. decoration: BoxDecoration(
  243. color: Color.fromRGBO(244, 248, 251, 1),
  244. ),
  245. child: ListView.builder(
  246. itemCount: likePhoneList.length,
  247. itemBuilder: (BuildContext context, int index) {
  248. return _tipItem(likePhoneList[index]);
  249. },
  250. )
  251. ),
  252. )
  253. )
  254. ],
  255. ),
  256. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  257. ),
  258. );
  259. }
  260. Widget _sendInfo(BuildContext context) {
  261. return Container(
  262. color: Colors.white,
  263. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  264. child: Column(
  265. children: < Widget > [
  266. _titleWidget('lib/images/icon_send.png', '发件信息'),
  267. _underLine(),
  268. _inputWiget('电话', 'sendPhone'),
  269. _contentWiget('企业编码', 'send', true),
  270. _contentWiget('企业名称', 'send', true),
  271. _cityWiget('城市/区域', context, 'send'),
  272. _lastContentWiget('详细地址', 'send')
  273. ],
  274. )
  275. );
  276. }
  277. Widget _getInfo(BuildContext context) {
  278. return Container(
  279. color: Colors.white,
  280. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  281. child: Column(
  282. children: < Widget > [
  283. _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  284. _underLine(),
  285. _inputWiget('电话', 'getPhone'),
  286. //_contentWiget('企业编码', 'get', true),
  287. _contentWiget('企业名称', 'get', true),
  288. _cityWiget('城市/区域', context, 'get'),
  289. _lastContentWiget('详细地址', 'get')
  290. ],
  291. )
  292. );
  293. }
  294. Widget _itemInfoWidget() {
  295. return Container(
  296. child: Container(
  297. color: Colors.white,
  298. child: Column(
  299. crossAxisAlignment: CrossAxisAlignment.start,
  300. children: < Widget > [
  301. _titleWidget('lib/images/icon_huowu.png', "货物信息"),
  302. _underLine(),
  303. _contentWiget("货物名称", 'goods', true),
  304. _contentWiget("数量", 'goods'),
  305. _contentWiget("运费", 'goods'),
  306. _contentWiget("代收", 'goods'),
  307. _contentWiget("保价", 'goods'),
  308. _contentWiget("重量", 'goods'),
  309. _packageType('包装类型'),
  310. _packageType('商品类型'),
  311. _packageType('付款方式'),
  312. _descWidget()
  313. ],
  314. ),
  315. )
  316. );
  317. }
  318. Widget _titleWidget(String iconUrl, String str) {
  319. return Container(
  320. height: ScreenUtil.getInstance().setHeight(90),
  321. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  322. child: Center(
  323. child: Row(
  324. mainAxisAlignment: MainAxisAlignment.start,
  325. children: < Widget > [
  326. Padding(
  327. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  328. child: Image.asset(
  329. iconUrl,
  330. width: ScreenUtil.getInstance().setWidth(40),
  331. height: ScreenUtil.getInstance().setHeight(40),
  332. )
  333. ),
  334. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  335. ],
  336. ),
  337. ),
  338. );
  339. }
  340. Widget _underLine() {
  341. return Container(
  342. color: Color.fromRGBO(223, 223, 223, 1),
  343. height: ScreenUtil.getInstance().setHeight(1),
  344. );
  345. }
  346. Widget _inputWiget(String key, String tab) {
  347. return Padding(
  348. key: tab == 'sendPhone' ? _sendPhoneKey : _getPhoneKey,
  349. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  350. child: Column(
  351. children: < Widget > [
  352. SizedBox(
  353. height: ScreenUtil.getInstance().setHeight(89),
  354. child: Center(
  355. child: Row(
  356. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  357. children: < Widget > [
  358. Expanded(
  359. flex: 0,
  360. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  361. ),
  362. Expanded(
  363. child: Row(
  364. mainAxisAlignment: MainAxisAlignment.end,
  365. children: < Widget > [
  366. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  367. SizedBox(
  368. width: ScreenUtil.getInstance().setWidth(500),
  369. child: TextField(
  370. controller: tab == 'sendPhone' ? sendCompanyPhoneController : receiptCompanyPhoneController,
  371. keyboardType: TextInputType.number,
  372. textAlign: TextAlign.end,
  373. decoration: InputDecoration(
  374. border: InputBorder.none
  375. ),
  376. onEditingComplete: () {
  377. setState(() {
  378. FocusScope.of(context).requestFocus(FocusNode());
  379. tipStatus = true;
  380. });
  381. },
  382. ),
  383. ),
  384. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  385. ],
  386. )
  387. )
  388. ],
  389. ),
  390. )
  391. ),
  392. Expanded(
  393. flex: 0,
  394. child: _underLine()
  395. )
  396. ],
  397. )
  398. );
  399. }
  400. Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  401. return Padding(
  402. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  403. child: Column(
  404. children: < Widget > [
  405. SizedBox(
  406. height: ScreenUtil.getInstance().setHeight(89),
  407. child: Center(
  408. child: Row(
  409. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  410. children: < Widget > [
  411. Expanded(
  412. flex: 0,
  413. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  414. ),
  415. Expanded(
  416. child: Row(
  417. mainAxisAlignment: MainAxisAlignment.end,
  418. children: < Widget > [
  419. SizedBox(
  420. width: ScreenUtil.getInstance().setWidth(500),
  421. child: TextField(
  422. controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
  423. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  424. textAlign: TextAlign.end,
  425. decoration: InputDecoration(
  426. border: InputBorder.none
  427. ),
  428. onChanged: (value) {
  429. if (type == 'send') {
  430. if (key == '企业编码') {
  431. setState(() {
  432. sendCompanyCode = value;
  433. });
  434. } else if (key == '企业名称') {
  435. setState(() {
  436. sendCompanyName = value;
  437. });
  438. }
  439. } else if (type == 'get') {
  440. if (key == '企业编码') {
  441. setState(() {
  442. sendCompanyCode = value;
  443. });
  444. } else if (key == '企业名称') {
  445. setState(() {
  446. receiptCompanyName = value;
  447. });
  448. }
  449. } else {
  450. if (key == '货物名称') {
  451. goods = value;
  452. } else if (key == '数量') {
  453. goodsQuantity = int.parse(value);
  454. } else if (key == '运费') {
  455. goodsFreight = double.parse(value);
  456. } else if (key == '代收') {
  457. goodsAgencyFund = double.parse(value);
  458. } else if (key == '保价') {
  459. goodsPriceProtection = double.parse(value);
  460. } else if (key == '重量') {
  461. goodsWeight = double.parse(value);
  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.0) {
  703. errStr = '请填写货物数量';
  704. }
  705. if (goodsFreight == 0.0) {
  706. errStr = '请填写运费';
  707. }
  708. if (errStr != '') {
  709. showError(errStr);
  710. return;
  711. }
  712. setState(() {
  713. submitStatus = false;
  714. });
  715. createOrder(
  716. sendCompanyId, //寄件公司Id
  717. sendCompanyName, //寄件公司名称 不能为空
  718. sendCompanyPhone, //寄件公司电话 不能为空
  719. sendCompanyCode ?? '', //寄件公司编码
  720. sendCompanyProvinceName, //寄件公司省名称 不能为空
  721. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  722. sendCompanyCityName, //寄件公司市名称 不能为空
  723. sendCompanyCityCode, //寄件公司市编码 不能为空
  724. sendCompanyAreaName, //寄件公司区名称 不能为空
  725. sendCompanyAreaCode, //寄件公司区编码 不能为空
  726. sendCompanyAddress, //寄件公司详细地址,不能为空
  727. receiptCompanyId, //收件公司id
  728. receiptCompanyPhone, //收件公司电话 不能为空
  729. receiptCompanyName, //收件公司名称 不能为空
  730. receiptCompanyProvinceName, //收件公司省名称 不能为空
  731. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  732. receiptCompanyCityName, //收件公司市名称 不能为空
  733. receiptCompanyCityCode, //收件公市编码 不能为空
  734. receiptCompanyAreaName, //收件公区名称 不能为空
  735. receiptCompanyAreaCode, //收件公司区编码 不能为空
  736. receiptCompanyAddress, //收件公司地址详情 不能为空
  737. goods, //商品名称 不能为空
  738. goodsQuantity, //商品数量 不能为空
  739. goodsPackingId, //商品包装ID
  740. goodsCategoryId, //商品类别ID
  741. goodsPaymentMethod, //付款方式 1,现付 2 到付
  742. goodsWeight, //商品重量
  743. goodsPriceProtection * 100, //商品保价,已分为单位
  744. goodsAgencyFund * 100, //商品代收款,已分为单位
  745. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  746. memo, //备注
  747. ).then((resp) {
  748. if (isNotError(context, resp)) {
  749. setState(() {
  750. submitStatus = true;
  751. });
  752. CreateOrder orderObj = CreateOrder.fromJson(resp.data);
  753. showDialog < Null > (
  754. context: context, //BuildContext对象
  755. barrierDismissible: false,
  756. builder: (BuildContext context) {
  757. return SendDialog( //调用对话框
  758. orderNo: orderObj.orderNo,
  759. childCallback: (val) {
  760. if (!val) {
  761. //跳转
  762. Navigator.push(context, MaterialPageRoute(builder: (context) {
  763. return OrderDetail(orderId: orderObj.orderNo, );
  764. }));
  765. }
  766. },
  767. );
  768. });
  769. } else {
  770. setState(() {
  771. submitStatus = true;
  772. });
  773. }
  774. });
  775. },
  776. );
  777. }
  778. showError(String str) {
  779. showDialog < Null > (
  780. context: context, //BuildContext对象
  781. barrierDismissible: false,
  782. builder: (BuildContext context) {
  783. return MyAlertDialog( //调用对话框
  784. text: str, childCallback: (val) {},
  785. );
  786. });
  787. }
  788. Future getCity(context) async {
  789. Result result = await CityPickers.showCityPicker(
  790. context: context,
  791. );
  792. return result;
  793. }
  794. Widget _tipItem(LikePhoneList obj) {
  795. return Container(
  796. child: Column(
  797. children: < Widget > [
  798. InkWell(
  799. child: Container(
  800. height: ScreenUtil.getInstance().setHeight(89),
  801. child: Center(
  802. child: Row(
  803. mainAxisAlignment: MainAxisAlignment.start,
  804. children: < Widget > [
  805. Padding(
  806. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  807. child: Text(obj.uzerPhone, style: TextStyle(
  808. fontSize: ScreenUtil.getInstance().setSp(28),
  809. color: Color.fromRGBO(74, 74, 74, 1)
  810. ), )
  811. ),
  812. SizedBox(
  813. width: ScreenUtil.getInstance().setWidth(185),
  814. child: Text(obj.areaCode,
  815. textAlign: TextAlign.left,
  816. style: TextStyle(
  817. fontSize: ScreenUtil.getInstance().setSp(28),
  818. color: Color.fromRGBO(155, 155, 155, 1)
  819. ), ),
  820. ),
  821. Text(obj.companyName,
  822. textAlign: TextAlign.left,
  823. overflow: TextOverflow.ellipsis,
  824. style: TextStyle(
  825. fontSize: ScreenUtil.getInstance().setSp(28),
  826. color: Color.fromRGBO(155, 155, 155, 1)
  827. ),
  828. )
  829. ],
  830. ),
  831. ),
  832. ),
  833. onTap: () {
  834. if (sendPhoneOrGetPhoneTab) {
  835. sendCompanyPhone = obj.uzerPhone;
  836. sendCompanyCode = obj.companyCode;
  837. sendCompanyName = obj.companyName;
  838. sendCompanyId = obj.id.toString();
  839. sendCompanyPhoneController.text = obj.uzerPhone;
  840. sendCompanyCodeController.text = obj.companyCode;
  841. sendCompanyNameController.text = obj.companyName;
  842. } else {
  843. receiptCompanyPhone = obj.uzerPhone;
  844. receiptCompanyName = obj.companyName;
  845. receiptCompanyPhoneController.text = obj.uzerPhone;
  846. receiptCompanyNameController.text = obj.companyName;
  847. receiptCompanyId = obj.id.toString();
  848. }
  849. setState(() {
  850. FocusScope.of(context).requestFocus(FocusNode());
  851. tipStatus = true;
  852. });
  853. },
  854. ),
  855. _underLine()
  856. ],
  857. ),
  858. );
  859. }
  860. Widget _packageType(String key) {
  861. return Padding(
  862. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  863. child: Column(
  864. children: < Widget > [
  865. InkWell(
  866. child: SizedBox(
  867. height: ScreenUtil.getInstance().setHeight(89),
  868. child: Center(
  869. child: Row(
  870. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  871. children: < Widget > [
  872. Expanded(
  873. flex: 0,
  874. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  875. ),
  876. Expanded(
  877. child: Row(
  878. mainAxisAlignment: MainAxisAlignment.end,
  879. children: < Widget > [
  880. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  881. SizedBox(
  882. width: ScreenUtil.getInstance().setWidth(500),
  883. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '商品类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  884. ),
  885. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  886. ],
  887. )
  888. )
  889. ],
  890. ),
  891. )
  892. ),
  893. onTap: () {
  894. showPickerModal(context, key);
  895. },
  896. ),
  897. Expanded(
  898. flex: 0,
  899. child: _underLine()
  900. )
  901. ],
  902. )
  903. );
  904. }
  905. showPickerModal(BuildContext context, String type) {
  906. List < dynamic > data = [];
  907. if (type == '包装类型') {
  908. for (int i = 0; i < goodsPackageList.length; i++) {
  909. data.add(goodsPackageList[i].name);
  910. }
  911. } else if (type == '商品类型') {
  912. for (int i = 0; i < goodsCateGoryList.length; i++) {
  913. data.add(goodsCateGoryList[i].name);
  914. }
  915. } else if (type == '付款方式') {
  916. data = ['现付', '到付'];
  917. }
  918. new Picker(
  919. adapter: PickerDataAdapter < String > (pickerdata: data),
  920. height: ScreenUtil.getInstance().setHeight(450),
  921. confirmText: '确定',
  922. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  923. cancelText: '取消',
  924. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  925. headercolor: Color.fromRGBO(245, 245, 245, 1),
  926. itemExtent: ScreenUtil.getInstance().setHeight(80),
  927. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  928. changeToFirst: true,
  929. hideHeader: false,
  930. onConfirm: (Picker picker, List value) {
  931. if (type == '包装类型') {
  932. setState(() {
  933. showTextGoodsPackage = goodsPackageList[value[0]].name;
  934. goodsPackingId = goodsPackageList[value[0]].id;
  935. });
  936. } else if (type == '商品类型') {
  937. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  938. goodsCategoryId = goodsCateGoryList[value[0]].id;
  939. } else if (type == '付款方式') {
  940. showTextPaymentMehod = data[value[0]];
  941. if (showTextPaymentMehod == '现付') {
  942. goodsPaymentMethod = 1;
  943. } else {
  944. goodsPaymentMethod = 2;
  945. }
  946. }
  947. }
  948. ).showModal(this.context); //_scaffoldKey.currentState);
  949. }
  950. }