send_express_page.dart 40 KB

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