send_express_page.dart 37 KB

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