order_taking_page.dart 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:url_launcher/url_launcher.dart';
  4. import '../util/api.dart';
  5. import '../util/models.dart';
  6. import '../showDialog.dart';
  7. import '../util/session.dart';
  8. import '../util/util.dart';
  9. import '../showAlert.dart';
  10. import 'package:barcode_scan/barcode_scan.dart';
  11. import 'package:flutter/services.dart';
  12. import 'order_management_page/order_detail_page.dart';
  13. class OrderTakingPage extends StatefulWidget {
  14. OrderTakingPage({Key key}) : super(key: key);
  15. _OrderTakingPageState createState() => _OrderTakingPageState();
  16. }
  17. class _OrderTakingPageState extends State<OrderTakingPage>
  18. with AutomaticKeepAliveClientMixin {
  19. ScrollController _scrollController = ScrollController(); //初始化滚动轴监控对象
  20. List<OrderList> orderList = []; //订单列表
  21. bool hasNextPage = true;
  22. List lineList = []; //线路列表
  23. String stationId;
  24. List<bool> checkStatusList = [];
  25. bool showLineStatus = true;
  26. String lineIdStr = '';
  27. String oldLineIdStr = '';
  28. int page = 1;
  29. bool loadMoreOrder = true;
  30. String barcode = ""; //扫描的订单号
  31. @override
  32. void initState() {
  33. super.initState();
  34. getKey('stationId').then((value) {
  35. stationId = value;
  36. getLine().then((childValue) {
  37. getKey('lineIdStr').then((value) {
  38. if (value != null) {
  39. getOrderList(stationId, value, page).then((resp) {
  40. if (isNotError(context, resp) && this.mounted) {
  41. setState(() {
  42. orderList = OrderListObj.fromJson(resp.data).data.items;
  43. hasNextPage =
  44. OrderListObj.fromJson(resp.data).data.hasNextPage;
  45. });
  46. lineIdStr = value;
  47. }
  48. });
  49. } else {
  50. getOrderList(stationId, lineIdStr, page).then((resp) {
  51. if (isNotError(context, resp) && this.mounted) {
  52. setState(() {
  53. orderList = OrderListObj.fromJson(resp.data).data.items;
  54. hasNextPage =
  55. OrderListObj.fromJson(resp.data).data.hasNextPage;
  56. });
  57. }
  58. });
  59. }
  60. });
  61. });
  62. });
  63. _scrollController.addListener(() {
  64. if (!showLineStatus) {
  65. setState(() {
  66. showLineStatus = true;
  67. });
  68. switchLine(context);
  69. }
  70. if (_scrollController.position.pixels ==
  71. _scrollController.position.maxScrollExtent) {
  72. if (hasNextPage && loadMoreOrder) {
  73. loadMoreOrder = false;
  74. page = ++page;
  75. getOrderList(stationId, lineIdStr, page).then((resp) {
  76. if (isNotError(context, resp) && this.mounted) {
  77. OrderListObj tempObj = OrderListObj.fromJson(resp.data);
  78. setState(() {
  79. orderList.addAll(tempObj.data.items);
  80. hasNextPage = tempObj.data.hasNextPage;
  81. });
  82. loadMoreOrder = true;
  83. } else {
  84. loadMoreOrder = true;
  85. }
  86. });
  87. }
  88. }
  89. });
  90. }
  91. Future getLine() async {
  92. setState(() {
  93. lineList.clear();
  94. });
  95. await getAllLine().then((resp) {
  96. if (isNotError(context, resp) && this.mounted) {
  97. setState(() {
  98. checkStatusList = [];
  99. lineList = StationLine.fromJson(resp.data).data;
  100. LineObj tempLine =
  101. LineObj(code: 'xxxx', id: -1, name: '未知线路'); //创建未知线路
  102. lineList.add(tempLine); //添加未知线路
  103. getKey('lineIdStr').then((value) {
  104. if (value != null) {
  105. for (int i = 0; i < lineList.length; i++) {
  106. if (value.indexOf(lineList[i].id.toString()) != -1) {
  107. checkStatusList.add(true);
  108. } else {
  109. checkStatusList.add(false);
  110. }
  111. if (i < lineList.length - 1) {
  112. lineIdStr += lineList[i].id.toString() + ',';
  113. } else {
  114. lineIdStr += lineList[i].id.toString();
  115. }
  116. }
  117. } else {
  118. for (int i = 0; i < lineList.length; i++) {
  119. checkStatusList.add(true);
  120. if (i < lineList.length - 1) {
  121. lineIdStr += lineList[i].id.toString() + ',';
  122. } else {
  123. lineIdStr += lineList[i].id.toString();
  124. }
  125. }
  126. }
  127. });
  128. });
  129. return lineIdStr;
  130. }
  131. });
  132. }
  133. @override
  134. bool get wantKeepAlive => true;
  135. @override
  136. Widget build(BuildContext context) {
  137. return Container(
  138. child: Scaffold(
  139. appBar: AppBar(
  140. title: Text(
  141. '接单',
  142. style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)),
  143. ),
  144. centerTitle: true,
  145. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  146. actions: <Widget>[
  147. IconButton(
  148. icon: Icon(Icons.add_circle_outline),
  149. onPressed: () {
  150. setState(() {
  151. showLineStatus = !showLineStatus;
  152. });
  153. if (!showLineStatus) {
  154. getLine();
  155. } else {
  156. switchLine(context);
  157. }
  158. },
  159. )
  160. ]),
  161. body: Stack(
  162. children: <Widget>[
  163. RefreshIndicator(
  164. onRefresh: _onRefresh, //回调方法
  165. child: InkWell(
  166. child: Container(
  167. padding: EdgeInsets.fromLTRB(
  168. ScreenUtil.getInstance().setWidth(20),
  169. ScreenUtil.getInstance().setWidth(20),
  170. ScreenUtil.getInstance().setWidth(20),
  171. 0),
  172. decoration: BoxDecoration(
  173. color: Color.fromRGBO(246, 246, 254, 1)),
  174. child: ListView.builder(
  175. controller: _scrollController,
  176. physics: AlwaysScrollableScrollPhysics(),
  177. itemCount: orderList.length + 1,
  178. itemBuilder: (BuildContext context, int index) {
  179. //itemBuilder实际上就是一个map的循环
  180. if (index < orderList.length) {
  181. return OrderCardContainer(
  182. order: orderList[index],
  183. index: index,
  184. callback: (val) => deleteOrder(val));
  185. }
  186. if (hasNextPage) {
  187. return _getMoreWidget();
  188. } else {
  189. return _noMoreWidegt();
  190. }
  191. },
  192. )),
  193. onTap: () {
  194. setState(() {
  195. showLineStatus = true;
  196. });
  197. switchLine(context);
  198. },
  199. ),
  200. ),
  201. Positioned(
  202. top: 0,
  203. right: 0,
  204. child: Offstage(
  205. offstage: showLineStatus,
  206. child: Container(
  207. width: ScreenUtil.getInstance().setWidth(350),
  208. height: ScreenUtil.getInstance().setHeight(500),
  209. margin: EdgeInsets.fromLTRB(0, 2, 8, 0),
  210. padding: EdgeInsets.fromLTRB(15, 0, 0, 0),
  211. decoration: BoxDecoration(
  212. color: Color.fromRGBO(76, 76, 76, 1),
  213. borderRadius: BorderRadius.all(Radius.circular(4.0)),
  214. boxShadow: [
  215. //阴影
  216. BoxShadow(
  217. color: Colors.black54,
  218. offset: Offset(2.0, 2.0),
  219. blurRadius: 4.0)
  220. ]),
  221. child: lineList.length == 0
  222. ? Center(
  223. child: Container(
  224. width: ScreenUtil.getInstance().setWidth(50),
  225. height:
  226. ScreenUtil.getInstance().setHeight(50),
  227. child: CircularProgressIndicator()),
  228. )
  229. : ListView.builder(
  230. itemCount: lineList.length,
  231. itemBuilder: (BuildContext context, int index) {
  232. //itemBuilder实际上就是一个map的循环
  233. if (index < lineList.length) {
  234. return _lineWidget(lineList[index], index,
  235. checkStatusList[index]);
  236. }
  237. },
  238. ),
  239. ),
  240. )),
  241. Positioned(
  242. right: 20,
  243. bottom: 20,
  244. child: Container(
  245. width: ScreenUtil.getInstance().setWidth(80),
  246. height: ScreenUtil.getInstance().setHeight(80),
  247. decoration: BoxDecoration(
  248. color: Colors.white,
  249. borderRadius: BorderRadius.all(Radius.circular(50)),
  250. boxShadow: [
  251. //阴影
  252. BoxShadow(
  253. color: Colors.black54,
  254. offset: Offset(2.0, 2.0),
  255. blurRadius: 4.0)
  256. ]),
  257. child: IconButton(
  258. icon: Image.asset(
  259. 'lib/images/icon_saoyisao.png',
  260. width: ScreenUtil.getInstance().setWidth(50),
  261. height: ScreenUtil.getInstance().setHeight(48),
  262. ),
  263. onPressed: () {
  264. scan();
  265. },
  266. )),
  267. )
  268. ],
  269. )),
  270. );
  271. }
  272. Widget _lineWidget(LineObj lineObj, int index, bool checked) {
  273. return InkWell(
  274. child: Container(
  275. height: ScreenUtil.getInstance().setHeight(80),
  276. decoration: BoxDecoration(
  277. border: BorderDirectional(
  278. bottom: BorderSide(color: Colors.white, width: 0.1))),
  279. child: Row(
  280. children: <Widget>[
  281. Padding(
  282. padding: EdgeInsets.fromLTRB(0, 0, 15, 0),
  283. child: checked
  284. ? Image.asset(
  285. 'lib/images/icon_checked.png',
  286. width: ScreenUtil.getInstance().setWidth(30),
  287. height: ScreenUtil.getInstance().setWidth(30),
  288. )
  289. : Icon(Icons.check,
  290. color: Color.fromRGBO(
  291. 255,
  292. 255,
  293. 255,
  294. 0.0,
  295. )),
  296. ),
  297. Expanded(
  298. flex: 1,
  299. child: Container(
  300. padding: EdgeInsets.only(right: 15),
  301. child: Row(
  302. mainAxisAlignment: MainAxisAlignment.end,
  303. children: <Widget>[
  304. Text(lineObj.name,
  305. overflow: TextOverflow.ellipsis,
  306. style: TextStyle(
  307. color: Colors.white,
  308. fontSize: ScreenUtil.getInstance().setSp(30)))
  309. ],
  310. ),
  311. ))
  312. ],
  313. ),
  314. ),
  315. onTap: () {
  316. setState(() {
  317. checkStatusList[index] = !checked;
  318. });
  319. },
  320. );
  321. }
  322. Widget _getMoreWidget() {
  323. return Center(
  324. child: Padding(
  325. padding: EdgeInsets.all(10.0),
  326. child: Row(
  327. mainAxisAlignment: MainAxisAlignment.center,
  328. crossAxisAlignment: CrossAxisAlignment.center,
  329. children: <Widget>[
  330. Text(
  331. '加载中...',
  332. style: TextStyle(fontSize: 16.0),
  333. ),
  334. Container(
  335. width: ScreenUtil.getInstance().setWidth(50),
  336. height: ScreenUtil.getInstance().setHeight(50),
  337. child: CircularProgressIndicator())
  338. ],
  339. ),
  340. ),
  341. );
  342. }
  343. Widget _noMoreWidegt() {
  344. return Center(
  345. child: Padding(
  346. padding: EdgeInsets.all(10.0),
  347. child: Text(
  348. '没有更多数据了...',
  349. style: TextStyle(fontSize: 16.0),
  350. ),
  351. ),
  352. );
  353. }
  354. Future _onRefresh() async {
  355. page = 1;
  356. print(lineIdStr);
  357. await getOrderList(stationId, lineIdStr, page).then((resp) {
  358. if (isNotError(context, resp) && this.mounted) {
  359. setState(() {
  360. orderList = OrderListObj.fromJson(resp.data).data.items;
  361. });
  362. }
  363. });
  364. }
  365. Future scan() async {
  366. try {
  367. String barcode = await BarcodeScanner.scan();
  368. int index = barcode.indexOf('&');
  369. if (index != -1) {
  370. barcode = barcode.substring(index + 1);
  371. }
  372. Navigator.push(context,
  373. MaterialPageRoute(builder: (BuildContext context) {
  374. return OrderDetailPage(
  375. orderNo: barcode,
  376. status: '寄件',
  377. );
  378. }));
  379. } on PlatformException catch (e) {
  380. if (e.code == BarcodeScanner.CameraAccessDenied) {
  381. setState(() {
  382. return this.barcode = 'The user did not grant the camera permission!';
  383. });
  384. } else {
  385. setState(() {
  386. return this.barcode = 'Unknown error: $e';
  387. });
  388. }
  389. } on FormatException {
  390. setState(() => this.barcode =
  391. 'null (User returned using the "back"-button before scanning anything. Result)');
  392. } catch (e) {
  393. setState(() => this.barcode = 'Unknown error: $e');
  394. }
  395. }
  396. void deleteOrder(val) {
  397. //确认接单后的操作
  398. setState(() {
  399. orderList.removeAt(val);
  400. if (orderList.length < 4) {
  401. if (hasNextPage) {
  402. setState(() {
  403. page = ++page;
  404. });
  405. getOrderList(stationId, lineIdStr, page).then((resp) {
  406. if (resp.success && resp.code == 1) {
  407. setState(() {
  408. orderList.addAll(resp.data.items);
  409. hasNextPage = resp.data.hasNextPage;
  410. });
  411. }
  412. });
  413. }
  414. }
  415. });
  416. }
  417. void switchLine(BuildContext context) {
  418. //切换线路
  419. lineIdStr = '';
  420. for (int i = 0; i < checkStatusList.length; i++) {
  421. if (checkStatusList[i]) {
  422. lineIdStr += lineList[i].id.toString() + ',';
  423. }
  424. }
  425. if (lineIdStr == '') {
  426. setState(() {
  427. orderList = [];
  428. hasNextPage = false;
  429. });
  430. return;
  431. }
  432. lineIdStr = lineIdStr.substring(0, lineIdStr.length - 1);
  433. getKey('oldLineIdStr').then((oldLineIdStr) {
  434. if (oldLineIdStr == lineIdStr) return;
  435. setKey('oldLineIdStr', lineIdStr);
  436. setState(() {
  437. orderList = [];
  438. hasNextPage = true;
  439. });
  440. getOrderList(stationId, lineIdStr, page).then((resp) {
  441. if (isNotError(context, resp) && this.mounted) {
  442. OrderListObj tempObj = OrderListObj.fromJson(resp.data);
  443. setState(() {
  444. orderList = tempObj.data.items;
  445. hasNextPage = tempObj.data.hasNextPage;
  446. });
  447. oldLineIdStr = lineIdStr;
  448. setKey('lineIdStr', lineIdStr);
  449. }
  450. });
  451. });
  452. }
  453. }
  454. class OrderCardContainer extends StatefulWidget {
  455. final OrderList order;
  456. final int index;
  457. final callback;
  458. OrderCardContainer(
  459. {Key key,
  460. @required this.order,
  461. @required this.index,
  462. @required this.callback})
  463. : super(key: key);
  464. _OrderCardContainerState createState() => _OrderCardContainerState();
  465. }
  466. class _OrderCardContainerState extends State<OrderCardContainer>
  467. with SingleTickerProviderStateMixin {
  468. Animation<dynamic> animation;
  469. AnimationController controller;
  470. String str = "联系方式";
  471. bool animationStatus = true;
  472. @override
  473. initState() {
  474. super.initState();
  475. controller = new AnimationController(
  476. duration: const Duration(milliseconds: 200), vsync: this);
  477. animation = Tween(begin: 0, end: 230).animate(controller);
  478. animation.addStatusListener((status) {
  479. if (status == AnimationStatus.completed) {
  480. //动画执行结束时反向执行动画
  481. setState(() {
  482. animationStatus = false;
  483. str = "收起";
  484. });
  485. } else if (status == AnimationStatus.dismissed) {
  486. //动画恢复到初始状态时执行动画(正向)
  487. setState(() {
  488. animationStatus = true;
  489. str = "联系方式";
  490. });
  491. }
  492. });
  493. }
  494. @override
  495. Widget build(BuildContext context) {
  496. return Container(
  497. margin: EdgeInsets.all(4),
  498. decoration: BoxDecoration(
  499. color: Colors.white,
  500. borderRadius: BorderRadius.all(Radius.circular(8)),
  501. boxShadow: [
  502. BoxShadow(
  503. color: Color.fromRGBO(217, 226, 233, 0.5),
  504. offset: Offset(0, 2),
  505. blurRadius: 3.0),
  506. ]),
  507. child: Container(
  508. padding: EdgeInsets.fromLTRB(
  509. ScreenUtil.getInstance().setWidth(30),
  510. ScreenUtil.getInstance().setWidth(30),
  511. ScreenUtil.getInstance().setWidth(30),
  512. 0),
  513. child: Column(
  514. children: <Widget>[
  515. orderNoRow(widget.order.orderNo, widget.order.createTime),
  516. orderAddress(widget.order.sendCompanyName,
  517. widget.order.receiptCompanyName),
  518. orderItem('货物名称', widget.order.goods, 15),
  519. orderItem('货物件数', '${widget.order.goodsQuantity}件', 30),
  520. orderCutLine(),
  521. orderBtn(context, animationStatus, controller, str,
  522. widget.order.orderNo),
  523. AnimatedOpen(
  524. animation: animation,
  525. openInfo: widget.order,
  526. )
  527. ],
  528. ),
  529. ));
  530. }
  531. dispose() {
  532. //路由销毁时需要释放动画资源
  533. controller.dispose();
  534. super.dispose();
  535. }
  536. Widget orderBtn(BuildContext context, bool animationStatus,
  537. AnimationController controller, String str, String orderNo) {
  538. return Container(
  539. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  540. child: Row(
  541. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  542. children: <Widget>[
  543. InkWell(
  544. child: Container(
  545. width: ScreenUtil.getInstance().setWidth(100),
  546. height: ScreenUtil.getInstance().setHeight(48),
  547. color: Colors.white,
  548. child: Center(
  549. child: Text(
  550. str,
  551. style: TextStyle(
  552. fontSize: ScreenUtil.getInstance().setSp(24),
  553. color: Color.fromRGBO(64, 98, 254, 1)),
  554. ),
  555. )),
  556. onTap: () {
  557. if (animationStatus) {
  558. //动画恢复到初始状态时执行动画(正向)
  559. controller.forward();
  560. } else {
  561. //动画执行结束时反向执行动画
  562. controller.reverse();
  563. }
  564. },
  565. ),
  566. InkWell(
  567. child: Container(
  568. width: ScreenUtil.getInstance().setWidth(94),
  569. height: ScreenUtil.getInstance().setWidth(48),
  570. decoration: BoxDecoration(
  571. color: Color.fromRGBO(252, 97, 128, 1),
  572. borderRadius: BorderRadius.all(Radius.circular(4.0))),
  573. child: Center(
  574. child: Text(
  575. "接单",
  576. style: TextStyle(
  577. fontSize: ScreenUtil.getInstance().setSp(24),
  578. color: Colors.white),
  579. ),
  580. ),
  581. ),
  582. onTap: () {
  583. showDialog<Null>(
  584. context: context, //BuildContext对象
  585. barrierDismissible: false,
  586. builder: (BuildContext context) {
  587. return new LoadingDialog(
  588. //调用对话框
  589. text: '是否确认接单',
  590. childCallback: (val) {
  591. if (val) {
  592. orderReception(orderNo).then((resp) {
  593. if (isNotError(context, resp) && this.mounted) {
  594. OrderReception obj =
  595. OrderReception.fromJson(resp.data);
  596. if (obj.success) {
  597. widget.callback(widget.index);
  598. } else {
  599. showError(obj.msg);
  600. }
  601. }
  602. });
  603. } else {
  604. return;
  605. }
  606. },
  607. );
  608. });
  609. },
  610. )
  611. ],
  612. ));
  613. }
  614. showError(String str) {
  615. showDialog<Null>(
  616. context: context, //BuildContext对象
  617. barrierDismissible: false,
  618. builder: (BuildContext context) {
  619. return MyAlertDialog(
  620. //调用对话框
  621. text: str, childCallback: (val) {},
  622. );
  623. });
  624. }
  625. }
  626. class AnimatedOpen extends AnimatedWidget {
  627. final OrderList openInfo;
  628. AnimatedOpen({Key key, Animation<dynamic> animation, @required this.openInfo})
  629. : super(key: key, listenable: animation);
  630. Widget build(BuildContext context) {
  631. final Animation<dynamic> animation = listenable;
  632. return Container(
  633. height: ScreenUtil.getInstance().setHeight(animation.value),
  634. child: orderDetailInfo(openInfo),
  635. );
  636. }
  637. }
  638. Widget orderNoRow(String orderNo, int createTime) {
  639. //订单号及时间
  640. String date = fromatDate(createTime);
  641. return Container(
  642. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
  643. child: Row(
  644. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  645. children: <Widget>[
  646. Text(
  647. "订单号:${orderNo}",
  648. style: TextStyle(
  649. color: Color.fromRGBO(153, 153, 153, 1),
  650. fontSize: ScreenUtil.getInstance().setSp(24)),
  651. ),
  652. Text(
  653. '${date}',
  654. style: TextStyle(
  655. color: Color.fromRGBO(153, 153, 153, 1),
  656. fontSize: ScreenUtil.getInstance().setSp(24)),
  657. ),
  658. ],
  659. ),
  660. );
  661. }
  662. Widget orderAddress(String startAddress, String endAddress) {
  663. //运送路线
  664. return Container(
  665. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  666. child: Row(
  667. children: <Widget>[
  668. Text(
  669. '${startAddress} ---> ${endAddress}',
  670. overflow: TextOverflow.ellipsis,
  671. style: TextStyle(
  672. color: Colors.black,
  673. fontSize: ScreenUtil.getInstance().setSp(30)),
  674. ),
  675. ],
  676. ));
  677. }
  678. Widget orderCutLine() {
  679. //分割线
  680. return Container(
  681. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  682. height: ScreenUtil.getInstance().setHeight(1),
  683. color: Color.fromRGBO(223, 223, 223, 1),
  684. );
  685. }
  686. Widget orderDetailInfo(OrderList obj) {
  687. //卡片展开信息
  688. String sendAddress = obj.sendCompanyProvinceName +
  689. ' ' +
  690. (obj.sendCompanyCityName == '市辖区' ? '' : obj.sendCompanyCityName) +
  691. ' ' +
  692. obj.sendCompanyAreaName +
  693. ' ' +
  694. obj.sendCompanyAddress;
  695. String receiptAddress = obj.receiptCompanyProvinceName +
  696. ' ' +
  697. (obj.receiptCompanyCityName == '市辖区' ? '' : obj.receiptCompanyCityName) +
  698. ' ' +
  699. obj.receiptCompanyAreaName +
  700. ' ' +
  701. obj.receiptCompanyAddress;
  702. return Container(
  703. child: Wrap(
  704. children: <Widget>[
  705. orderCutLine(),
  706. orderPhone('发件电话', obj.sendCompanyPhone, 15),
  707. orderItem('发件地址', sendAddress, 30),
  708. orderPhone('收件电话', obj.receiptCompanyPhone, 15),
  709. orderItem('收件地址', receiptAddress, 30),
  710. ],
  711. ));
  712. }
  713. Widget orderItem(String key, String value, int marginBottom) {
  714. //货物名称,件数
  715. return Container(
  716. margin: EdgeInsets.only(
  717. bottom: ScreenUtil.getInstance().setHeight( marginBottom)),
  718. child: Row(
  719. children: <Widget>[
  720. Text(
  721. '${key}:${value}',
  722. overflow: TextOverflow.ellipsis,
  723. style: TextStyle(
  724. color: Color.fromRGBO(153, 153, 153, 1),
  725. fontSize: ScreenUtil.getInstance().setSp(24)),
  726. ),
  727. ],
  728. ));
  729. }
  730. Widget orderPhone(String key, String value, int marginBottom) {
  731. return InkWell(
  732. child: Container(
  733. margin: EdgeInsets.only(
  734. bottom: ScreenUtil.getInstance().setHeight(marginBottom)),
  735. child: Row(
  736. children: <Widget>[
  737. Text(
  738. '${key}:',
  739. style: TextStyle(
  740. color: Color.fromRGBO(153, 153, 153, 1),
  741. fontSize: ScreenUtil.getInstance().setSp(24)),
  742. ),
  743. Text(
  744. '${value}',
  745. style: TextStyle(
  746. color: Color.fromRGBO(64, 98, 254, 1),
  747. fontSize: ScreenUtil.getInstance().setSp(24)),
  748. ),
  749. ],
  750. )),
  751. onTap: () async {
  752. String phone = 'tel:${value}';
  753. print(phone);
  754. if (await canLaunch(phone)) {
  755. await (launch(phone));
  756. } else {
  757. throw 'Could not launch $value';
  758. }
  759. },
  760. );
  761. }