send_express_page.dart 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  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. import '../util/session.dart';
  14. import '../showLineModal.dart';
  15. import '../util/bluetooth_utils.dart';
  16. class SendExpressPage extends StatefulWidget {
  17. final Widget child;
  18. SendExpressPage({
  19. Key key,
  20. this.child
  21. }): super(key: key);
  22. _SendExpressPageState createState() => _SendExpressPageState();
  23. }
  24. class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
  25. ScrollController _scrollController = ScrollController();
  26. //组件自用字段-----------------------------
  27. GlobalKey _sendPhoneKey = GlobalKey();
  28. GlobalKey _getPhoneKey = GlobalKey();
  29. double tipWidth = 0;
  30. double tipHeight = 0;
  31. double tipPosX = 0;
  32. double tipPosY = 0;
  33. bool tipStatus = true;
  34. bool lineModalStatus = false;
  35. bool submitStatus = true;
  36. List < LikePhoneList > likePhoneList = [];
  37. var timer;
  38. bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
  39. TextEditingController sendCompanyPhoneController = TextEditingController();
  40. TextEditingController sendCompanyCodeController = TextEditingController();
  41. TextEditingController sendCompanyNameController = TextEditingController();
  42. TextEditingController receiptCompanyPhoneController = TextEditingController();
  43. TextEditingController receiptCompanyNameController = TextEditingController();
  44. TextEditingController sendCompanyAddressController = TextEditingController();
  45. TextEditingController receiptCompanyAddressController = TextEditingController();
  46. TextEditingController bankCardController = TextEditingController();
  47. TextEditingController bankNameController = TextEditingController();
  48. TextEditingController openBankNameController = TextEditingController();
  49. TextEditingController openBankPhoneController = TextEditingController();
  50. List < dynamic > goodsCateGoryList = [];
  51. List < dynamic > goodsPackageList = [];
  52. //请求字段-------------------------
  53. String lineId = '-1';//收件公司匹配的线路id
  54. String sendCompanyId = '0'; //寄件公司Id
  55. String sendCompanyName = ''; //寄件公司名称 不能为空
  56. String sendCompanyPhone = ''; //寄件公司电话 不能为空
  57. String sendCompanyCode = ''; //寄件公司编码
  58. String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
  59. String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
  60. String sendCompanyCityName = ''; //寄件公司市名称 不能为空
  61. String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
  62. String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
  63. String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
  64. String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
  65. String receiptCompanyId = '0'; //收件公司id
  66. String receiptCompanyPhone = ''; //收件公司电话 不能为空
  67. String receiptCompanyName = ''; //收件公司名称 不能为空
  68. String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
  69. String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
  70. String receiptCompanyCityName = ''; //收件公司市名称 不能为空
  71. String receiptCompanyCityCode = ''; //收件公市编码 不能为空
  72. String receiptCompanyAreaName = ''; //收件公区名称 不能为空
  73. String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
  74. String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
  75. String goods = ''; //商品名称 不能为空
  76. int goodsQuantity = 1; //商品数量 不能为空
  77. int goodsPackingId; //商品包装ID
  78. int goodsCategoryId; //商品类别ID
  79. int goodsPaymentMethod = 2; //付款方式 1,现付 2 到付
  80. double goodsWeight = 0.0; //商品重量
  81. double goodsPriceProtection = 0.0; //商品保价
  82. double goodsAgencyFund = 0.0; //商品代收款
  83. double goodsFreight = 0.0; //商品运费 不能为空
  84. String memo = ''; //备注
  85. String bankCard = '';//银行卡号
  86. String bankName = '';//所属银行
  87. String openBankName = '';//开户人
  88. String openBankPhone = '';//开户电话
  89. List<CompanyOfLineList> lineList = [];
  90. String sendPCA = ' '; //Text组件内容必须有空格,否则报null
  91. String getPCA = ' ';
  92. String showTextGoodsCategory = ' ';
  93. String showTextGoodsPackage = ' ';
  94. String showTextPaymentMehod = '到付';
  95. BluetoothUtils bluetooth = BluetoothUtils();
  96. bool checkedCompanyInfo = false;//选择公司信息向sendCompanyPhoneController填充时不去模糊匹配
  97. @override
  98. void initState() {
  99. super.initState();
  100. goodsCategory().then((resp) {
  101. if (isNotError(context, resp) && this.mounted) {
  102. GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
  103. setState(() {
  104. goodsCateGoryList = goodsCategoryObj.data;
  105. showTextGoodsCategory = goodsCateGoryList[0].name;
  106. goodsCategoryId = goodsCateGoryList[0].id;
  107. });
  108. }
  109. });
  110. goodsPackage().then((resp) {
  111. if (isNotError(context, resp) && this.mounted) {
  112. GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
  113. setState(() {
  114. goodsPackageList = goodsPackageObj.data;
  115. showTextGoodsPackage = goodsPackageList[0].name;
  116. goodsPackingId = goodsPackageList[0].id;
  117. });
  118. }
  119. });
  120. _scrollController.addListener(() {
  121. if (!tipStatus) {
  122. setState(() {
  123. tipStatus = true;
  124. });
  125. }
  126. //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
  127. });
  128. sendCompanyPhoneController.addListener(() {
  129. if(checkedCompanyInfo){
  130. return;
  131. }
  132. setState(() {
  133. sendCompanyPhone = sendCompanyPhoneController.text;
  134. });
  135. if (timer != null) {
  136. timer.cancel();
  137. }
  138. if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
  139. setState(() {
  140. tipStatus = true;
  141. });
  142. }
  143. timer = Timer(Duration(milliseconds: 250), () {
  144. if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length <= 11) {
  145. likePhone(sendCompanyPhoneController.text).then((resp) {
  146. if (isNotError(context, resp) && this.mounted) {
  147. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  148. likePhoneList = likePhoneObj.data;
  149. }
  150. if (likePhoneList.length > 0) {
  151. sendPhoneOrGetPhoneTab = true;
  152. RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
  153. setState(() {
  154. tipWidth = sendPhoneObj.paintBounds.size.width;
  155. tipHeight = sendPhoneObj.paintBounds.size.height;
  156. tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
  157. tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  158. tipStatus = false;
  159. });
  160. } else {
  161. setState(() {
  162. tipStatus = true;
  163. });
  164. }
  165. });
  166. }
  167. });
  168. });
  169. receiptCompanyPhoneController.addListener(() {
  170. if(checkedCompanyInfo){
  171. return;
  172. }
  173. setState(() {
  174. receiptCompanyPhone = receiptCompanyPhoneController.text;
  175. });
  176. if (timer != null) {
  177. timer.cancel();
  178. }
  179. if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
  180. setState(() {
  181. tipStatus = true;
  182. });
  183. }
  184. timer = Timer(Duration(milliseconds: 250), () {
  185. if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length <= 11) {
  186. likePhone(receiptCompanyPhoneController.text).then((resp) {
  187. if (isNotError(context, resp) && this.mounted) {
  188. LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
  189. likePhoneList = likePhoneObj.data;
  190. }
  191. if (likePhoneList.length > 0) {
  192. sendPhoneOrGetPhoneTab = false;
  193. RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
  194. setState(() {
  195. tipWidth = getPhoneKey.paintBounds.size.width;
  196. tipHeight = getPhoneKey.paintBounds.size.height;
  197. tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
  198. tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
  199. tipStatus = false;
  200. });
  201. } else {
  202. setState(() {
  203. tipStatus = true;
  204. });
  205. }
  206. });
  207. }
  208. });
  209. });
  210. sendCompanyAddressController.addListener(() {
  211. setState(() {
  212. sendCompanyAddress = sendCompanyAddressController.text;
  213. });
  214. });
  215. receiptCompanyAddressController.addListener(() {
  216. setState(() {
  217. receiptCompanyAddress = receiptCompanyAddressController.text;
  218. });
  219. });
  220. }
  221. @override
  222. bool get wantKeepAlive => true;
  223. @override
  224. Widget build(BuildContext context) {
  225. return Container(
  226. child: Scaffold(
  227. appBar: AppBar(
  228. title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  229. centerTitle: true,
  230. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  231. ),
  232. body:
  233. Stack(
  234. children: < Widget > [
  235. Container(
  236. color: Color.fromRGBO(246, 246, 254, 1),
  237. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  238. child: ListView(
  239. controller: _scrollController,
  240. children: < Widget > [
  241. _sendInfo(context),
  242. _getInfo(context),
  243. _itemInfoWidget(),
  244. _bankInfo(context),
  245. _submitBtn()
  246. ],
  247. ),
  248. ),
  249. Positioned(
  250. top: tipPosY,
  251. left: tipPosX,
  252. child: Offstage(
  253. offstage: tipStatus,
  254. child: Container(
  255. width: tipWidth,
  256. height: ScreenUtil.getInstance().setHeight(450),
  257. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  258. decoration: BoxDecoration(
  259. color: Color.fromRGBO(244, 248, 251, 1),
  260. ),
  261. child: ListView.builder(
  262. itemCount: likePhoneList.length,
  263. itemBuilder: (BuildContext context, int index) {
  264. return _tipItem(likePhoneList[index]);
  265. },
  266. )
  267. ),
  268. )
  269. )
  270. ],
  271. ),
  272. resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  273. ),
  274. );
  275. }
  276. Widget _sendInfo(BuildContext context) {
  277. return Container(
  278. color: Colors.white,
  279. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  280. child: Column(
  281. children: < Widget > [
  282. _titleWidget('lib/images/icon_send.png', '发件信息'),
  283. _underLine(),
  284. _inputWiget('电话', 'sendPhone'),
  285. _contentWiget('企业编码', 'send', true),
  286. _contentWiget('企业名称', 'send', true),
  287. _cityWiget('城市/区域', context, 'send'),
  288. _lastContentWiget('详细地址', 'send')
  289. ],
  290. )
  291. );
  292. }
  293. Widget _getInfo(BuildContext context) {
  294. return Container(
  295. color: Colors.white,
  296. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  297. child: Column(
  298. children: < Widget > [
  299. _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  300. _underLine(),
  301. _inputWiget('电话', 'getPhone'),
  302. _contentWiget('企业名称', 'get', true),
  303. _cityWiget('城市/区域', context, 'get'),
  304. _lastContentWiget('详细地址', 'get')
  305. ],
  306. )
  307. );
  308. }
  309. Widget _itemInfoWidget() {
  310. return Container(
  311. child: Container(
  312. color: Colors.white,
  313. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  314. child: Column(
  315. crossAxisAlignment: CrossAxisAlignment.start,
  316. children: < Widget > [
  317. _titleWidget('lib/images/icon_huowu.png', "货物信息"),
  318. _underLine(),
  319. _contentWiget("货物名称", 'goods', true),
  320. _contentWiget("数量", 'goods'),
  321. _contentWiget("运费", 'goods'),
  322. _contentWiget("代收", 'goods'),
  323. _contentWiget("保价", 'goods'),
  324. _contentWiget("重量", 'goods'),
  325. _packageType('包装类型'),
  326. _packageType('货物类型'),
  327. _packageType('付款方式'),
  328. _descWidget()
  329. ],
  330. ),
  331. )
  332. );
  333. }
  334. Widget _bankInfo(BuildContext context) {
  335. return Container(
  336. color: Colors.white,
  337. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  338. child: Column(
  339. children: < Widget > [
  340. _titleWidget('lib/images/icon_bank.png', '银行信息'),
  341. _underLine(),
  342. _contentBankWiget('银行卡号', 'bank'),
  343. _contentBankWiget('银行名称', 'bank',true),
  344. _contentBankWiget('开户人', 'bank',true),
  345. _lastBankContentWiget('开户电话', 'bank'),
  346. ],
  347. )
  348. );
  349. }
  350. Widget _titleWidget(String iconUrl, String str) {
  351. return Container(
  352. height: ScreenUtil.getInstance().setHeight(90),
  353. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  354. child: Center(
  355. child: Row(
  356. mainAxisAlignment: MainAxisAlignment.start,
  357. children: < Widget > [
  358. Padding(
  359. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  360. child: Image.asset(
  361. iconUrl,
  362. width: ScreenUtil.getInstance().setWidth(40),
  363. height: ScreenUtil.getInstance().setHeight(40),
  364. )
  365. ),
  366. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  367. ],
  368. ),
  369. ),
  370. );
  371. }
  372. Widget _underLine() {
  373. return Container(
  374. color: Color.fromRGBO(223, 223, 223, 1),
  375. height: ScreenUtil.getInstance().setHeight(1),
  376. );
  377. }
  378. Widget _inputWiget(String key, String tab) {
  379. return Padding(
  380. key: tab == 'sendPhone' ? _sendPhoneKey : _getPhoneKey,
  381. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  382. child: Column(
  383. children: < Widget > [
  384. SizedBox(
  385. height: ScreenUtil.getInstance().setHeight(89),
  386. child: Center(
  387. child: Row(
  388. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  389. children: < Widget > [
  390. Expanded(
  391. flex: 0,
  392. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  393. ),
  394. Expanded(
  395. child: Row(
  396. mainAxisAlignment: MainAxisAlignment.end,
  397. children: < Widget > [
  398. SizedBox(
  399. width: ScreenUtil.getInstance().setWidth(500),
  400. child: TextField(
  401. controller: tab == 'sendPhone' ? sendCompanyPhoneController : receiptCompanyPhoneController,
  402. keyboardType: TextInputType.number,
  403. textAlign: TextAlign.end,
  404. decoration: InputDecoration(
  405. border: InputBorder.none
  406. ),
  407. onEditingComplete: () {
  408. setState(() {
  409. FocusScope.of(context).requestFocus(FocusNode());
  410. tipStatus = true;
  411. });
  412. },
  413. onChanged: (value){
  414. checkedCompanyInfo = false;
  415. if(tab=='sendPhone'){
  416. sendCompanyCode = '';
  417. sendCompanyName = '';
  418. sendCompanyId ='0';
  419. sendCompanyCodeController.text = '';
  420. sendCompanyNameController.text = '';
  421. sendPCA = '';
  422. sendCompanyProvinceName = '';
  423. sendCompanyProvinceCode = '';
  424. sendCompanyCityName = '';
  425. sendCompanyCityCode = '';
  426. sendCompanyAreaName = '';
  427. sendCompanyAreaCode = '';
  428. bankCardController.text = '';
  429. bankNameController.text = '';
  430. openBankNameController.text = '';
  431. openBankPhoneController.text = '';
  432. sendCompanyAddressController.text = '';
  433. }else if(tab=='getPhone'){
  434. receiptCompanyName = '';
  435. receiptCompanyNameController.text = '';
  436. receiptCompanyId = null;
  437. getPCA = '';
  438. receiptCompanyProvinceName = '';
  439. receiptCompanyProvinceCode = '';
  440. receiptCompanyCityName = '';
  441. receiptCompanyCityCode = '';
  442. receiptCompanyAreaName = '';
  443. receiptCompanyAreaCode = '';
  444. receiptCompanyAddressController.text = '';
  445. }
  446. },
  447. ),
  448. ),
  449. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  450. ],
  451. )
  452. )
  453. ],
  454. ),
  455. )
  456. ),
  457. Expanded(
  458. flex: 0,
  459. child: _underLine()
  460. )
  461. ],
  462. )
  463. );
  464. }
  465. Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  466. return Padding(
  467. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  468. child: Column(
  469. children: < Widget > [
  470. SizedBox(
  471. height: ScreenUtil.getInstance().setHeight(89),
  472. child: Center(
  473. child: Row(
  474. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  475. children: < Widget > [
  476. Expanded(
  477. flex: 0,
  478. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  479. ),
  480. Expanded(
  481. child: Row(
  482. mainAxisAlignment: MainAxisAlignment.end,
  483. children: < Widget > [
  484. SizedBox(
  485. width: ScreenUtil.getInstance().setWidth(500),
  486. child: TextField(
  487. controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
  488. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  489. textAlign: TextAlign.end,
  490. decoration: InputDecoration(
  491. border: InputBorder.none
  492. ),
  493. onChanged: (value) {
  494. if (type == 'send') {
  495. if (key == '企业编码') {
  496. setState(() {
  497. sendCompanyCode = value;
  498. });
  499. } else if (key == '企业名称') {
  500. setState(() {
  501. sendCompanyName = value;
  502. });
  503. }
  504. } else if (type == 'get') {
  505. if (key == '企业编码') {
  506. setState(() {
  507. sendCompanyCode = value;
  508. });
  509. } else if (key == '企业名称') {
  510. setState(() {
  511. receiptCompanyName = value;
  512. });
  513. }
  514. } else if(type=='goods') {
  515. if (key == '货物名称') {
  516. goods = value;
  517. } else if (key == '数量') {
  518. goodsQuantity = int.parse(value);
  519. } else if (key == '运费') {
  520. goodsFreight = double.parse(value);
  521. String temp = goodsFreight.toStringAsFixed(1);
  522. goodsFreight = double.parse(temp);
  523. } else if (key == '代收') {
  524. goodsAgencyFund = double.parse(value);
  525. String temp = goodsAgencyFund.toStringAsFixed(1);
  526. goodsAgencyFund = double.parse(temp);
  527. } else if (key == '保价') {
  528. goodsPriceProtection = double.parse(value);
  529. String temp = goodsPriceProtection.toStringAsFixed(1);
  530. goodsPriceProtection = double.parse(temp);
  531. } else if (key == '重量') {
  532. goodsWeight = double.parse(value);
  533. String temp = goodsWeight.toStringAsFixed(1);
  534. goodsWeight = double.parse(temp);
  535. }
  536. }else if(type=='bank'){
  537. if(key == '银行卡号'){
  538. bankCard = value;
  539. }else if(key=='银行名称'){
  540. bankName = value;
  541. }else if(key == '开户人'){
  542. openBankName = value;
  543. }else if(key == '开户电话'){
  544. openBankPhone = value;
  545. }
  546. }
  547. },
  548. ),
  549. ),
  550. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  551. ],
  552. )
  553. )
  554. ],
  555. ),
  556. )
  557. ),
  558. Expanded(
  559. flex: 0,
  560. child: _underLine()
  561. )
  562. ],
  563. )
  564. );
  565. }
  566. Widget _contentBankWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
  567. return Padding(
  568. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  569. child: Column(
  570. children: < Widget > [
  571. SizedBox(
  572. height: ScreenUtil.getInstance().setHeight(89),
  573. child: Center(
  574. child: Row(
  575. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  576. children: < Widget > [
  577. Expanded(
  578. flex: 0,
  579. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  580. ),
  581. Expanded(
  582. child: Row(
  583. mainAxisAlignment: MainAxisAlignment.end,
  584. children: < Widget > [
  585. SizedBox(
  586. width: ScreenUtil.getInstance().setWidth(500),
  587. child: TextField(
  588. controller: key == '银行卡号'?bankCardController:key=='银行名称'?bankNameController:openBankNameController,
  589. keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
  590. textAlign: TextAlign.end,
  591. decoration: InputDecoration(
  592. border: InputBorder.none
  593. ),
  594. ),
  595. ),
  596. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  597. ],
  598. )
  599. )
  600. ],
  601. ),
  602. )
  603. ),
  604. Expanded(
  605. flex: 0,
  606. child: _underLine()
  607. )
  608. ],
  609. )
  610. );
  611. }
  612. Widget _cityWiget(String key, BuildContext context, String type) {
  613. return
  614. GestureDetector(
  615. child: Padding(
  616. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  617. child: Column(
  618. children: < Widget > [
  619. SizedBox(
  620. height: ScreenUtil.getInstance().setHeight(89),
  621. child: Center(
  622. child: Row(
  623. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  624. children: < Widget > [
  625. Expanded(
  626. flex: 0,
  627. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  628. ),
  629. Expanded(
  630. child: Row(
  631. mainAxisAlignment: MainAxisAlignment.end,
  632. children: < Widget > [
  633. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  634. SizedBox(
  635. width: ScreenUtil.getInstance().setWidth(500),
  636. child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
  637. ),
  638. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  639. ],
  640. )
  641. )
  642. ],
  643. ),
  644. )
  645. ),
  646. Expanded(
  647. flex: 0,
  648. child: _underLine()
  649. )
  650. ],
  651. )
  652. ),
  653. onTap: () {
  654. getCity(context).then((resp) {
  655. if (resp == null) {
  656. return;
  657. }
  658. print(resp.toString());
  659. setState(() {
  660. if (type == 'send') {
  661. sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  662. sendCompanyProvinceName = resp.provinceName;
  663. sendCompanyProvinceCode = resp.provinceId;
  664. sendCompanyCityName = resp.cityName;
  665. sendCompanyCityCode = resp.cityId;
  666. sendCompanyAreaName = resp.areaName;
  667. sendCompanyAreaCode = resp.areaId;
  668. } else {
  669. getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
  670. receiptCompanyProvinceName = resp.provinceName;
  671. receiptCompanyProvinceCode = resp.provinceId;
  672. receiptCompanyCityName = resp.cityName;
  673. receiptCompanyCityCode = resp.cityId;
  674. receiptCompanyAreaName = resp.areaName;
  675. receiptCompanyAreaCode = resp.areaId;
  676. }
  677. });
  678. //print(value);
  679. });
  680. },
  681. );
  682. }
  683. Widget _lastContentWiget(String key, String type) {
  684. return Padding(
  685. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  686. child: SizedBox(
  687. height: ScreenUtil.getInstance().setHeight(89),
  688. child: Center(
  689. child: Row(
  690. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  691. children: < Widget > [
  692. Expanded(
  693. flex: 0,
  694. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  695. ),
  696. Expanded(
  697. child: Row(
  698. mainAxisAlignment: MainAxisAlignment.end,
  699. children: < Widget > [
  700. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  701. SizedBox(
  702. width: ScreenUtil.getInstance().setWidth(500),
  703. child: TextField(
  704. controller: type == 'send' ? sendCompanyAddressController : receiptCompanyAddressController,
  705. textAlign: TextAlign.end,
  706. decoration: InputDecoration(
  707. border: InputBorder.none
  708. ),
  709. ),
  710. ),
  711. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  712. ],
  713. )
  714. )
  715. ],
  716. ),
  717. )
  718. )
  719. );
  720. }
  721. Widget _lastBankContentWiget(String key, String type) {
  722. return Padding(
  723. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  724. child: SizedBox(
  725. height: ScreenUtil.getInstance().setHeight(89),
  726. child: Center(
  727. child: Row(
  728. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  729. children: < Widget > [
  730. Expanded(
  731. flex: 0,
  732. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  733. ),
  734. Expanded(
  735. child: Row(
  736. mainAxisAlignment: MainAxisAlignment.end,
  737. children: < Widget > [
  738. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  739. SizedBox(
  740. width: ScreenUtil.getInstance().setWidth(500),
  741. child: TextField(
  742. controller: openBankPhoneController,
  743. textAlign: TextAlign.end,
  744. decoration: InputDecoration(
  745. border: InputBorder.none
  746. ),
  747. ),
  748. ),
  749. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  750. ],
  751. )
  752. )
  753. ],
  754. ),
  755. )
  756. )
  757. );
  758. }
  759. Widget _descWidget() {
  760. return
  761. Container(
  762. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  763. //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  764. child: TextField(
  765. maxLines: 3,
  766. decoration: InputDecoration(
  767. border: InputBorder.none,
  768. hintText: "请输入备注内容"
  769. ),
  770. onChanged: (value) {
  771. setState(() {
  772. memo = value;
  773. });
  774. },
  775. ),
  776. );
  777. }
  778. Widget _submitBtn() {
  779. return GestureDetector(
  780. child: Container(
  781. margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
  782. height: ScreenUtil.getInstance().setHeight(88),
  783. decoration: BoxDecoration(
  784. borderRadius: BorderRadius.all(Radius.circular(4)),
  785. color: Color.fromRGBO(37, 102, 242, 1),
  786. ),
  787. child: Center(
  788. child: Row(
  789. mainAxisAlignment: MainAxisAlignment.center,
  790. children: < Widget > [
  791. Offstage(
  792. offstage: submitStatus,
  793. child: SizedBox(
  794. width: ScreenUtil.getInstance().setWidth(45),
  795. height: ScreenUtil.getInstance().setHeight(45),
  796. child: Image.asset('lib/images/loading.gif'),
  797. ),
  798. ),
  799. Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
  800. ],
  801. )
  802. ),
  803. ),
  804. onTap: () {
  805. if (!submitStatus) {
  806. return;
  807. }
  808. String errStr = '';
  809. print('sendCompanyId---${sendCompanyId}');
  810. print('sendCompanyName---${sendCompanyName}');
  811. print('sendCompanyPhone---${sendCompanyPhone}');
  812. print('sendCompanyCode---${sendCompanyCode}');
  813. print('sendCompanyProvinceName---${sendCompanyProvinceName}');
  814. print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
  815. print('sendCompanyCityName---${sendCompanyCityName}');
  816. print('sendCompanyCityCode---${sendCompanyCityCode}');
  817. print('sendCompanyAreaName---${sendCompanyAreaName}');
  818. print('sendCompanyAreaCode---${sendCompanyAreaCode}');
  819. print('sendCompanyAddress---${sendCompanyAddress}');
  820. print('receiptCompanyId---${receiptCompanyId}');
  821. print('receiptCompanyPhone---${receiptCompanyPhone}');
  822. print('receiptCompanyName---${receiptCompanyName}');
  823. print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
  824. print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
  825. print('receiptCompanyCityName---${receiptCompanyCityName}');
  826. print('receiptCompanyCityCode---${receiptCompanyCityCode}');
  827. print('receiptCompanyAreaName---${receiptCompanyAreaName}');
  828. print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
  829. print('receiptCompanyAddress---${receiptCompanyAddress}');
  830. print('goods---${goods}');
  831. print('goodsQuantity---${goodsQuantity}');
  832. print('goodsPackingId---${goodsPackingId}');
  833. print('goodsCategoryId---${goodsCategoryId}');
  834. print('goodsPaymentMethod---${goodsPaymentMethod}');
  835. print('goodsWeight---${goodsWeight}');
  836. print('goodsPriceProtection---${goodsPriceProtection}');
  837. print('goodsAgencyFund---${goodsAgencyFund}');
  838. print('goodsFreight---${goodsFreight}');
  839. print('memo---${memo}');
  840. if (sendCompanyPhone == '') {
  841. errStr = '请填写发件电话';
  842. }
  843. if (sendCompanyName == '') {
  844. errStr = '请填写发件企业名称';
  845. }
  846. if (sendCompanyProvinceName == '') {
  847. errStr = '请填写发件城市/区域';
  848. }
  849. if (sendCompanyAddress == '') {
  850. errStr = '请填写发件详细地址';
  851. }
  852. if (receiptCompanyPhone == '') {
  853. errStr = '请填写收件电话';
  854. }
  855. if (receiptCompanyName == '') {
  856. errStr = '请填写收件企业名称';
  857. }
  858. if (receiptCompanyProvinceName == '') {
  859. errStr = '请填写收件城市/区域';
  860. }
  861. if (receiptCompanyAddress == '') {
  862. errStr = '请填写收件详细地址';
  863. }
  864. if (goods == '') {
  865. errStr = '请填写货物名称';
  866. }
  867. if (goodsQuantity == 0) {
  868. errStr = '请填写货物数量';
  869. }
  870. if (int.tryParse(goodsQuantity.toString()) == null) {
  871. errStr = '货物数量格式错误';
  872. }
  873. if (goodsFreight == 0.0) {
  874. errStr = '请填写运费';
  875. }
  876. if (sendCompanyPhone == '' || receiptCompanyPhone == '' ) {
  877. errStr = '请输入正确的电话';
  878. }
  879. if (goodsAgencyFund>0 && sendCompanyId=='0') {//如果有代收,接没有拿到公司id
  880. if(bankNameController.text=='' || bankCardController.text=='' || openBankNameController.text=='' || openBankPhoneController.text==''){
  881. errStr = "请补全银行卡信息";
  882. }
  883. }
  884. if (errStr != '') {
  885. showError(errStr);
  886. return;
  887. }
  888. if(lineList.length>1){
  889. showLineModal(lineList);
  890. return;
  891. }
  892. submitOrder();
  893. },
  894. );
  895. }
  896. submitOrder(){
  897. setState(() {
  898. submitStatus = false;
  899. });
  900. getKey('stationId').then((value) {
  901. createOrder(
  902. lineId,//收件线路Id
  903. value,//当前用户选择的站点id
  904. sendCompanyId, //寄件公司Id
  905. sendCompanyName, //寄件公司名称 不能为空
  906. sendCompanyPhone, //寄件公司电话 不能为空
  907. sendCompanyCode ?? '', //寄件公司编码
  908. sendCompanyProvinceName, //寄件公司省名称 不能为空
  909. sendCompanyProvinceCode, //寄件公司省编码 不能为空
  910. sendCompanyCityName, //寄件公司市名称 不能为空
  911. sendCompanyCityCode, //寄件公司市编码 不能为空
  912. sendCompanyAreaName, //寄件公司区名称 不能为空
  913. sendCompanyAreaCode, //寄件公司区编码 不能为空
  914. sendCompanyAddress, //寄件公司详细地址,不能为空
  915. receiptCompanyId, //收件公司id
  916. receiptCompanyPhone, //收件公司电话 不能为空
  917. receiptCompanyName, //收件公司名称 不能为空
  918. receiptCompanyProvinceName, //收件公司省名称 不能为空
  919. receiptCompanyProvinceCode, //收件公司省编码 不能为空
  920. receiptCompanyCityName, //收件公司市名称 不能为空
  921. receiptCompanyCityCode, //收件公市编码 不能为空
  922. receiptCompanyAreaName, //收件公区名称 不能为空
  923. receiptCompanyAreaCode, //收件公司区编码 不能为空
  924. receiptCompanyAddress, //收件公司地址详情 不能为空
  925. goods, //商品名称 不能为空
  926. goodsQuantity, //商品数量 不能为空
  927. goodsPackingId, //商品包装ID
  928. goodsCategoryId, //商品类别ID
  929. goodsPaymentMethod, //付款方式 1,现付 2 到付
  930. goodsWeight, //商品重量
  931. goodsPriceProtection * 100, //商品保价,已分为单位
  932. goodsAgencyFund * 100, //商品代收款,已分为单位
  933. goodsFreight * 100, //商品运费 不能为空 ,已分为单位
  934. memo, //备注
  935. bankCardController.text,
  936. bankNameController.text,
  937. openBankNameController.text,
  938. openBankPhoneController.text
  939. ).then((resp) {
  940. if (isNotError(context, resp) && this.mounted) {
  941. setState(() {
  942. submitStatus = true;
  943. });
  944. OrderDetailData data = OrderDetailObj.fromJson(resp.data).data;
  945. showDialog < Null > (
  946. context: context, //BuildContext对象
  947. barrierDismissible: false,
  948. builder: (BuildContext context) {
  949. //打印
  950. getKey('printType').then((printType){
  951. getKey('stationName').then((stationName){
  952. getKey('nickName').then((nickName){
  953. getKey('companyName').then((companyName){
  954. getKey('companyCustomerPhone').then((companyCustomerPhone){
  955. double goodsYs = data.goodsPaymentMethod==2?(data.goodsFreight/100)+(data.goodsAgencyFund/100):data.goodsAgencyFund/100;
  956. String nowDate = fromatDate( DateTime.now().millisecondsSinceEpoch);//打印时间
  957. String createTime = fromatDate(data.createTime);
  958. double goodsAgencyFunds = data.goodsAgencyFund/100;
  959. double goodsDFreight = data.goodsPaymentMethod==2?data.goodsFreight/100:0;
  960. double goodsXFreight = data.goodsPaymentMethod==1?data.goodsFreight/100:0;
  961. String receiptAddress = data.receiptCompanyAddress.length>10?data.receiptCompanyAddress.substring(0,10):data.receiptCompanyAddress;
  962. Map<String, String> pum = {
  963. "[logisticsNo]": "${data.orderNo ?? ''}",
  964. "[createTime]": "$createTime",
  965. "[sendStationName]": "$stationName",
  966. "[dealerCode]": "${data.sendCompanyCode ?? ''}",
  967. "[dealerName]": "${data.sendCompanyName}",
  968. "[dealerTel]": "${data.sendCompanyPhone ?? ''}",
  969. "[repairName]": "${data.receiptCompanyName ?? ''}",
  970. "[repairTel]": "${data.receiptCompanyPhone ?? ''}",
  971. "[endStationName]": "${data.receiptStationName ?? ''}",
  972. "[goodsLineCode]": "${data.lineCode ?? ''}",
  973. "[goodsLine]": "${data.lineName ?? ''}",
  974. "[repairAddress]": "${receiptAddress?? ''}",
  975. "[goodsQuantity]": "${data.goodsQuantity ?? ''}",
  976. "[goodsInsurance]": "${data.goodsInsurance ?? ''}",
  977. "[goodsFlatCost]": "${data.goodsFlatCost ?? ''}",
  978. // 到付 现付 金额
  979. "[goodsDFreight]": "$goodsDFreight",
  980. "[goodsXFreight]": "$goodsXFreight",
  981. "[goodsAgencyFund]": "$goodsAgencyFunds",
  982. "[goodsYs]": "$goodsYs",
  983. "[dealerBankAccount]": "${data.sendCompanyBankCard ?? ''}",
  984. "[goodsRemark]": "${data.memo ?? ''}",
  985. "[realName]": "${nickName?? ''}",
  986. "[currentTime]": "$nowDate",
  987. "[currentGoodNumber]": "1/1",
  988. "[companyCustomerPhone]":"$companyCustomerPhone",
  989. "[companyName]":"$companyName"
  990. };
  991. bluetooth.printOrder(pum, int.parse(printType)).then((value){
  992. if(value==null){
  993. showDialog <Null> (
  994. context: context,
  995. barrierDismissible: false,
  996. builder: (BuildContext context) {
  997. return MyAlertDialog(text: '未连接打印机',childCallback:(val){});
  998. }
  999. );
  1000. }
  1001. });
  1002. });
  1003. });
  1004. });
  1005. });
  1006. });
  1007. return SendDialog( //调用对话框
  1008. orderNo: data.orderNo,
  1009. childCallback: (val) {
  1010. if (!val) {
  1011. //跳转
  1012. Navigator.push(context, MaterialPageRoute(builder: (context) {
  1013. return OrderDetail(orderNo: data.orderNo, );
  1014. }));
  1015. }
  1016. },
  1017. );
  1018. });
  1019. } else {
  1020. setState(() {
  1021. submitStatus = true;
  1022. });
  1023. }
  1024. });
  1025. });
  1026. }
  1027. showError(String str) {
  1028. showDialog < Null > (
  1029. context: context, //BuildContext对象
  1030. barrierDismissible: false,
  1031. builder: (BuildContext context) {
  1032. return MyAlertDialog( //调用对话框
  1033. text: str, childCallback: (val) {},
  1034. );
  1035. });
  1036. }
  1037. showLineModal(List<CompanyOfLineList> list){
  1038. showDialog < Null > (
  1039. context: context, //BuildContext对象
  1040. barrierDismissible: false,
  1041. builder: (BuildContext context) {
  1042. return ShowLineModal(
  1043. lineList: list, childCallback: (val) {
  1044. lineId = val;
  1045. submitOrder();
  1046. },
  1047. );
  1048. });
  1049. }
  1050. Future getCity(context) async {
  1051. Result result = await CityPickers.showCityPicker(
  1052. context: context,
  1053. );
  1054. return result;
  1055. }
  1056. Widget _tipItem(LikePhoneList obj) {
  1057. return Container(
  1058. child: Column(
  1059. children: < Widget > [
  1060. InkWell(
  1061. child: Container(
  1062. height: ScreenUtil.getInstance().setHeight(89),
  1063. child: Center(
  1064. child: Row(
  1065. mainAxisAlignment: MainAxisAlignment.start,
  1066. children: < Widget > [
  1067. Padding(
  1068. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
  1069. child: Text(obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone, style: TextStyle(
  1070. fontSize: ScreenUtil.getInstance().setSp(28),
  1071. color: Color.fromRGBO(74, 74, 74, 1)
  1072. ), )
  1073. ),
  1074. SizedBox(
  1075. width: ScreenUtil.getInstance().setWidth(185),
  1076. child: Text(obj.areaCode,
  1077. textAlign: TextAlign.left,
  1078. style: TextStyle(
  1079. fontSize: ScreenUtil.getInstance().setSp(28),
  1080. color: Color.fromRGBO(155, 155, 155, 1)
  1081. ), ),
  1082. ),
  1083. Text(obj.companyName,
  1084. textAlign: TextAlign.left,
  1085. overflow: TextOverflow.ellipsis,
  1086. style: TextStyle(
  1087. fontSize: ScreenUtil.getInstance().setSp(28),
  1088. color: Color.fromRGBO(155, 155, 155, 1)
  1089. ),
  1090. )
  1091. ],
  1092. ),
  1093. ),
  1094. ),
  1095. onTap: () {
  1096. checkedCompanyInfo = true;
  1097. if (sendPhoneOrGetPhoneTab) {
  1098. sendCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1099. sendCompanyCode = obj.companyCode;
  1100. sendCompanyName = obj.companyName;
  1101. sendCompanyId = obj.id.toString();
  1102. sendCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1103. sendCompanyCodeController.text = obj.companyCode;
  1104. sendCompanyNameController.text = obj.companyName;
  1105. sendPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  1106. sendCompanyProvinceName = obj.provinceName;
  1107. sendCompanyProvinceCode = obj.provinceCode;
  1108. sendCompanyCityName = obj.cityName;
  1109. sendCompanyCityCode = obj.cityCode;
  1110. sendCompanyAreaName = obj.areaName;
  1111. sendCompanyAreaCode = obj.areaCode;
  1112. sendCompanyAddressController.text = obj.address;
  1113. bankCardController.text = obj.bankCard;
  1114. bankNameController.text = obj.bankName;
  1115. openBankNameController.text = obj.openBankName;
  1116. openBankPhoneController.text = obj.openBankPhone;
  1117. } else {
  1118. receiptCompanyPhone = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1119. receiptCompanyName = obj.companyName;
  1120. receiptCompanyPhoneController.text = obj.uzerPhone!=null?obj.uzerPhone:obj.companyPhone;
  1121. receiptCompanyNameController.text = obj.companyName;
  1122. receiptCompanyId = obj.id.toString();
  1123. getLineOfCompanyId(receiptCompanyId).then((resp){
  1124. if(isNotError(context, resp) && this.mounted){
  1125. CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
  1126. setState(() {
  1127. lineList = obj.data;
  1128. });
  1129. }
  1130. });
  1131. getPCA = obj.provinceName + ' ' + obj.cityName + ' ' + ' ' + obj.areaName;
  1132. receiptCompanyProvinceName = obj.provinceName;
  1133. receiptCompanyProvinceCode = obj.provinceCode;
  1134. receiptCompanyCityName = obj.cityName;
  1135. receiptCompanyCityCode = obj.cityCode;
  1136. receiptCompanyAreaName = obj.areaName;
  1137. receiptCompanyAreaCode = obj.areaCode;
  1138. receiptCompanyAddressController.text = obj.address;
  1139. }
  1140. setState(() {
  1141. FocusScope.of(context).requestFocus(FocusNode());
  1142. tipStatus = true;
  1143. });
  1144. },
  1145. ),
  1146. _underLine()
  1147. ],
  1148. ),
  1149. );
  1150. }
  1151. Widget _packageType(String key) {
  1152. return Padding(
  1153. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  1154. child: Column(
  1155. children: < Widget > [
  1156. InkWell(
  1157. child: SizedBox(
  1158. height: ScreenUtil.getInstance().setHeight(89),
  1159. child: Center(
  1160. child: Row(
  1161. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1162. children: < Widget > [
  1163. Expanded(
  1164. flex: 0,
  1165. child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  1166. ),
  1167. Expanded(
  1168. child: Row(
  1169. mainAxisAlignment: MainAxisAlignment.end,
  1170. children: < Widget > [
  1171. //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  1172. SizedBox(
  1173. width: ScreenUtil.getInstance().setWidth(500),
  1174. child: Text(key == '包装类型' ? showTextGoodsPackage : key == '货物类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
  1175. ),
  1176. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  1177. ],
  1178. )
  1179. )
  1180. ],
  1181. ),
  1182. )
  1183. ),
  1184. onTap: () {
  1185. showPickerModal(context, key);
  1186. },
  1187. ),
  1188. Expanded(
  1189. flex: 0,
  1190. child: _underLine()
  1191. )
  1192. ],
  1193. )
  1194. );
  1195. }
  1196. showPickerModal(BuildContext context, String type) {
  1197. List < dynamic > data = [];
  1198. if (type == '包装类型') {
  1199. for (int i = 0; i < goodsPackageList.length; i++) {
  1200. data.add(goodsPackageList[i].name);
  1201. }
  1202. } else if (type == '货物类型') {
  1203. for (int i = 0; i < goodsCateGoryList.length; i++) {
  1204. data.add(goodsCateGoryList[i].name);
  1205. }
  1206. } else if (type == '付款方式') {
  1207. data = ['现付', '到付'];
  1208. }
  1209. new Picker(
  1210. adapter: PickerDataAdapter < String > (pickerdata: data),
  1211. height: ScreenUtil.getInstance().setHeight(450),
  1212. confirmText: '确定',
  1213. confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
  1214. cancelText: '取消',
  1215. cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
  1216. headercolor: Color.fromRGBO(245, 245, 245, 1),
  1217. itemExtent: ScreenUtil.getInstance().setHeight(80),
  1218. textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
  1219. changeToFirst: true,
  1220. hideHeader: false,
  1221. onConfirm: (Picker picker, List value) {
  1222. if (type == '包装类型') {
  1223. setState(() {
  1224. showTextGoodsPackage = goodsPackageList[value[0]].name;
  1225. goodsPackingId = goodsPackageList[value[0]].id;
  1226. });
  1227. } else if (type == '货物类型') {
  1228. setState(() {
  1229. showTextGoodsCategory = goodsCateGoryList[value[0]].name;
  1230. goodsCategoryId = goodsCateGoryList[value[0]].id;
  1231. });
  1232. } else if (type == '付款方式') {
  1233. setState(() {
  1234. showTextPaymentMehod = data[value[0]];
  1235. });
  1236. if (showTextPaymentMehod == '现付') {
  1237. goodsPaymentMethod = 1;
  1238. } else {
  1239. goodsPaymentMethod = 2;
  1240. }
  1241. }
  1242. }
  1243. ).showModal(this.context); //_scaffoldKey.currentState);
  1244. }
  1245. }