order_taking_page.dart 24 KB

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