send_express_page.dart 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  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=1; //商品数量 不能为空
  66. int goodsPackingId; //商品包装ID
  67. int goodsCategoryId; //商品类别ID
  68. int goodsPaymentMethod = 1; //付款方式 1,现付 2 到付
  69. double goodsWeight=0.0; //商品重量
  70. double goodsPriceProtection=0.0; //商品保价
  71. double goodsAgencyFund=0.0; //商品代收款
  72. double goodsFreight=0.0; //商品运费 不能为空
  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. return;
  668. // if (!isChinaPhoneLegal(sendCompanyPhone)) {
  669. // }
  670. if(sendCompanyPhone==''){
  671. errStr ='请填写发件电话';
  672. }
  673. if(sendCompanyName==''){
  674. errStr = '请填写发件企业名称';
  675. }
  676. if(sendCompanyProvinceName==''){
  677. errStr ='请填写发件城市/区域';
  678. }
  679. if(sendCompanyAddress==''){
  680. errStr ='请填写发件详细地址';
  681. }
  682. if(receiptCompanyPhone==''){
  683. errStr='请填写收件电话';
  684. }
  685. if(receiptCompanyName==''){
  686. errStr='请填写收件企业名称';
  687. }
  688. if(receiptCompanyProvinceName==''){
  689. errStr ='请填写收件城市/区域';
  690. }
  691. if(receiptCompanyAddress==''){
  692. errStr ='请填写收件详细地址';
  693. }
  694. if(goods==''){
  695. errStr ='请填写货物名称';
  696. }
  697. if(goodsQuantity==0.0){
  698. errStr ='请填写货物数量';
  699. }
  700. if(goodsFreight==0.0){
  701. errStr = '请填写运费';
  702. }
  703. if(errStr!=''){
  704. showError(errStr);
  705. }
  706. createOrder(
  707. sendCompanyId??"",//寄件公司Id
  708. sendCompanyName,//寄件公司名称 不能为空
  709. sendCompanyPhone,//寄件公司电话 不能为空
  710. sendCompanyCode??'',//寄件公司编码
  711. sendCompanyProvinceName,//寄件公司省名称 不能为空
  712. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  713. sendCompanyCityName, //寄件公司市名称 不能为空
  714. sendCompanyCityCode, //寄件公司市编码 不能为空
  715. sendCompanyAreaName, //寄件公司区名称 不能为空
  716. sendCompanyAreaCode, //寄件公司区编码 不能为空
  717. sendCompanyAddress, //寄件公司详细地址,不能为空
  718. receiptCompanyId, //收件公司id
  719. receiptCompanyPhone,//收件公司电话 不能为空
  720. receiptCompanyName, //收件公司名称 不能为空
  721. receiptCompanyProvinceName,//收件公司省名称 不能为空
  722. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  723. receiptCompanyCityName, //收件公司市名称 不能为空
  724. receiptCompanyCityCode, //收件公市编码 不能为空
  725. receiptCompanyAreaName,//收件公区名称 不能为空
  726. receiptCompanyAreaCode, //收件公司区编码 不能为空
  727. receiptCompanyAddress, //收件公司地址详情 不能为空
  728. goods, //商品名称 不能为空
  729. goodsQuantity, //商品数量 不能为空
  730. goodsPackingId,//商品包装ID
  731. goodsCategoryId, //商品类别ID
  732. goodsPaymentMethod, //付款方式 1,现付 2 到付
  733. goodsWeight, //商品重量
  734. goodsPriceProtection*100, //商品保价,已分为单位
  735. goodsAgencyFund*100, //商品代收款,已分为单位
  736. goodsFreight*100,//商品运费 不能为空 ,已分为单位
  737. memo,//备注
  738. ).then((resp){
  739. if(isNotError(context, resp)){
  740. setState(() {
  741. submitStatus = true;
  742. });
  743. showDialog < Null > (
  744. context: context, //BuildContext对象
  745. barrierDismissible: false,
  746. builder: (BuildContext context) {
  747. return SendDialog( //调用对话框
  748. childCallback: (val) {
  749. if(!val){
  750. //跳转
  751. }
  752. },
  753. );
  754. });
  755. }
  756. });
  757. },
  758. );
  759. }
  760. showError(String str){
  761. showDialog < Null > (
  762. context: context, //BuildContext对象
  763. barrierDismissible: false,
  764. builder: (BuildContext context) {
  765. return MyAlertDialog( //调用对话框
  766. text: str, childCallback: (val) {},
  767. );
  768. });
  769. }
  770. Future getCity(context) async {
  771. Result result = await CityPickers.showCityPicker(
  772. context: context,
  773. );
  774. return result;
  775. }
  776. Widget _tipItem(LikePhoneList obj) {
  777. return Container(
  778. child: Column(
  779. children: < Widget > [
  780. InkWell(
  781. child: Container(
  782. height: ScreenUtil.getInstance().setHeight(89),
  783. child: Center(
  784. child: Row(
  785. mainAxisAlignment: MainAxisAlignment.start,
  786. children: < Widget > [
  787. Padding(
  788. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  789. child: Text(obj.uzerPhone, style: TextStyle(
  790. fontSize: ScreenUtil.getInstance().setSp(28),
  791. color: Color.fromRGBO(74, 74, 74, 1)
  792. ), )
  793. ),
  794. SizedBox(
  795. width: ScreenUtil.getInstance().setWidth(185),
  796. child: Text(obj.areaCode,
  797. textAlign: TextAlign.left,
  798. style: TextStyle(
  799. fontSize: ScreenUtil.getInstance().setSp(28),
  800. color: Color.fromRGBO(155, 155, 155, 1)
  801. ), ),
  802. ),
  803. Text(obj.companyName,
  804. textAlign: TextAlign.left,
  805. overflow: TextOverflow.ellipsis,
  806. style: TextStyle(
  807. fontSize: ScreenUtil.getInstance().setSp(28),
  808. color: Color.fromRGBO(155, 155, 155, 1)
  809. ),
  810. )
  811. ],
  812. ),
  813. ),
  814. ),
  815. onTap: () {
  816. if (sendPhoneOrGetPhoneTab) {
  817. sendCompanyPhone = obj.uzerPhone;
  818. sendCompanyCode = obj.companyCode;
  819. sendCompanyName = obj.companyName;
  820. sendCompanyId = obj.id;
  821. sendCompanyPhoneController.text = obj.uzerPhone;
  822. sendCompanyCodeController.text = obj.companyCode;
  823. sendCompanyNameController.text = obj.companyName;
  824. } else {
  825. receiptCompanyPhone = obj.uzerPhone;
  826. receiptCompanyName = obj.companyName;
  827. receiptCompanyPhoneController.text = obj.uzerPhone;
  828. receiptCompanyNameController.text = obj.companyName;
  829. receiptCompanyId = obj.id;
  830. }
  831. setState(() {
  832. FocusScope.of(context).requestFocus(FocusNode());
  833. tipStatus = true;
  834. });
  835. },
  836. ),
  837. _underLine()
  838. ],
  839. ),
  840. );
  841. }
  842. Widget _packageType(String key) {
  843. return Padding(
  844. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  845. child: Column(
  846. children: < Widget > [
  847. InkWell(
  848. child: SizedBox(
  849. height: ScreenUtil.getInstance().setHeight(89),
  850. child: Center(
  851. child: Row(
  852. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  853. children: < Widget > [
  854. Expanded(
  855. flex: 0,
  856. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  857. ),
  858. Expanded(
  859. child: Row(
  860. mainAxisAlignment: MainAxisAlignment.end,
  861. children: < Widget > [
  862. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  863. SizedBox(
  864. width: ScreenUtil.getInstance().setWidth(500),
  865. child: Text(key=='包装类型'?showTextGoodsPackage:key=='商品类型'?showTextGoodsCategory:showTextPaymentMehod, textAlign: TextAlign.end, )
  866. ),
  867. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  868. ],
  869. )
  870. )
  871. ],
  872. ),
  873. )
  874. ),
  875. onTap: () {
  876. showPickerModal(context, key);
  877. },
  878. ),
  879. Expanded(
  880. flex: 0,
  881. child: _underLine()
  882. )
  883. ],
  884. )
  885. );
  886. }
  887. showPickerModal(BuildContext context, String type) {
  888. List<dynamic> data = [];
  889. if(type=='包装类型'){
  890. for(int i=0;i<goodsPackageList.length;i++){
  891. data.add(goodsPackageList[i].name);
  892. }
  893. }else if(type=='商品类型'){
  894. for(int i=0;i<goodsCateGoryList.length;i++){
  895. data.add(goodsCateGoryList[i].name);
  896. }
  897. }else if(type=='付款方式'){
  898. data = ['现付','到付'];
  899. }
  900. new Picker(
  901. adapter: PickerDataAdapter < String > (pickerdata: data),
  902. height: ScreenUtil.getInstance().setHeight(450),
  903. confirmText: '确定',
  904. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  905. cancelText: '取消',
  906. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  907. headercolor: Color.fromRGBO(245, 245, 245, 1),
  908. itemExtent: ScreenUtil.getInstance().setHeight(80),
  909. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  910. changeToFirst: true,
  911. hideHeader: false,
  912. onConfirm: (Picker picker, List value) {
  913. if(type=='包装类型'){
  914. setState(() {
  915. showTextGoodsPackage =goodsPackageList[value[0]].name;
  916. goodsPackingId = goodsPackageList[value[0]].id;
  917. });
  918. }else if(type=='商品类型'){
  919. showTextGoodsCategory =goodsCateGoryList[value[0]].name;
  920. goodsCategoryId =goodsCateGoryList[value[0]].id;
  921. }else if(type=='付款方式'){
  922. showTextPaymentMehod = data[value[0]];
  923. if(showTextPaymentMehod=='现付'){
  924. goodsPaymentMethod = 1;
  925. }else{
  926. goodsPaymentMethod = 2;
  927. }
  928. }
  929. }
  930. ).showModal(this.context); //_scaffoldKey.currentState);
  931. }
  932. }