send_express_page.dart 37 KB

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