order_detail.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import '../../util/api.dart';
  4. import '../../util/models.dart';
  5. import '../../util/util.dart';
  6. import '../../showAlert.dart';
  7. import '../../showLineModal.dart';
  8. class OrderDetailsPage extends StatefulWidget {
  9. final String orderNo;
  10. OrderDetailsPage({
  11. Key key,
  12. @required this.orderNo
  13. }): super(key: key);
  14. _OrderDetailsPageState createState() => _OrderDetailsPageState();
  15. }
  16. class _OrderDetailsPageState extends State < OrderDetailsPage > {
  17. OrderDetailData orderDetailObj;
  18. @override
  19. void initState() {
  20. super.initState();
  21. getOrderDetail(widget.orderNo).then((resp){
  22. if(isNotError(context, resp) && this.mounted){
  23. OrderDetailObj tempObj = OrderDetailObj.fromJson(resp.data);
  24. setState(() {
  25. orderDetailObj =tempObj.data;
  26. });
  27. }
  28. });
  29. }
  30. @override
  31. Widget build(BuildContext context) {
  32. return Scaffold(
  33. appBar: AppBar(
  34. title: Text("订单详情", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
  35. centerTitle: true,
  36. backgroundColor: Color.fromRGBO(64, 98, 254, 1),
  37. ),
  38. body: Container(
  39. padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
  40. color: Color.fromRGBO(246, 246, 254, 1),
  41. child:orderDetailObj==null?Center(
  42. child:_getMoreWidget(),
  43. ): ListView(
  44. children: < Widget > [
  45. _sendInfo(),
  46. _getInfo(),
  47. ItemInfoWidget(obj:orderDetailObj),
  48. ],
  49. )
  50. ),
  51. //resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
  52. );
  53. }
  54. Widget _sendInfo() {
  55. return Container(
  56. color: Colors.white,
  57. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  58. child: Column(
  59. children: < Widget > [
  60. titleWidget('lib/images/icon_send.png', '发件信息'),
  61. underLine(),
  62. contentWiget('电话', orderDetailObj.senderPhone!=null?orderDetailObj.senderPhone:orderDetailObj.sendCompanyPhone),
  63. contentWiget('企业编码', orderDetailObj.sendCompanyCode),
  64. contentWiget('企业名称', orderDetailObj.sendCompanyName),
  65. contentWiget('城市/区域', '${orderDetailObj.sendCompanyProvinceName}'+' '+'${orderDetailObj.sendCompanyCityName}'+' '+ '${orderDetailObj.sendCompanyAreaName}'),
  66. lastContentWiget('详细地址', orderDetailObj.sendCompanyAddress)
  67. ],
  68. )
  69. );
  70. }
  71. Widget _getInfo() {
  72. return Container(
  73. color: Colors.white,
  74. margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
  75. child: Column(
  76. children: < Widget > [
  77. titleWidget('lib/images/icon_shoujian.png', '收件信息'),
  78. underLine(),
  79. contentWiget('企业名称', orderDetailObj.receiptCompanyName),
  80. contentWiget('电话', orderDetailObj.receiptCompanyPhone),
  81. contentWiget('城市/区域', '${orderDetailObj.receiptCompanyProvinceName}'+' '+ '${orderDetailObj.receiptCompanyCityName}'+' '+ '${orderDetailObj.receiptCompanyAreaName}'),
  82. lastContentWiget('详细地址', orderDetailObj.sendCompanyAddress)
  83. ],
  84. )
  85. );
  86. }
  87. }
  88. class ItemInfoWidget extends StatefulWidget {
  89. final OrderDetailData obj;
  90. ItemInfoWidget({
  91. Key key,
  92. @required this.obj
  93. }): super(key: key);
  94. _ItemInfoWidgetState createState() => _ItemInfoWidgetState();
  95. }
  96. class _ItemInfoWidgetState extends State < ItemInfoWidget > {
  97. double afterTransportFee=0.0;//运费
  98. int afterGoodsNumber=0;//数量
  99. double afterCollectingFee=0.0;//代收
  100. bool submitStatus = true;
  101. String lineId = '-1';
  102. List<CompanyOfLineList> lineList = [];
  103. @override
  104. void initState() {
  105. super.initState();
  106. setState(() {
  107. afterTransportFee = widget.obj.goodsFreight/100;
  108. afterGoodsNumber =widget.obj.goodsQuantity;
  109. afterCollectingFee =widget.obj.goodsAgencyFund/100;
  110. });
  111. getLineOfCompanyId(widget.obj.sendCompanyId.toString()).then((resp){
  112. if(isNotError(context, resp) && this.mounted){
  113. CompanyOfLine obj = CompanyOfLine.fromJson(resp.data);
  114. setState(() {
  115. lineList = obj.data;
  116. });
  117. }
  118. });
  119. }
  120. @override
  121. Widget build(BuildContext context) {
  122. return Container(
  123. child: Container(
  124. color: Colors.white,
  125. child: Column(
  126. crossAxisAlignment: CrossAxisAlignment.start,
  127. children: < Widget > [
  128. titleWidget('lib/images/icon_huowu.png', "货物信息"),
  129. underLine(),
  130. contentWiget("货物名称",widget.obj.goods),
  131. contentWiget("数量", (widget.obj.goodsQuantity).toString()),
  132. contentWiget("运费", (widget.obj.goodsFreight/100).toString()),
  133. contentWiget("代收", (widget.obj.goodsAgencyFund/100).toString()),
  134. contentWiget("保价",(widget.obj.goodsPriceProtection/100).toString()),
  135. contentWiget("重量", widget.obj.goodsWeight.toStringAsFixed(1)),
  136. contentWiget("包装类型", (widget.obj.goodsPackingName)),
  137. contentWiget("货物类型", (widget.obj.goodsCategoryName)),
  138. contentWiget("付款方式", (widget.obj.goodsPaymentMethod==1?'现付':'到付')),
  139. _descWidget(widget.obj.memo),
  140. ],
  141. ),
  142. )
  143. );
  144. }
  145. Widget _inputWidget(String key, num value) {
  146. return Padding(
  147. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  148. child: Column(
  149. children: < Widget > [
  150. SizedBox(
  151. height: ScreenUtil.getInstance().setHeight(89),
  152. child: Center(
  153. child: Row(
  154. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  155. children: < Widget > [
  156. Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  157. Container(
  158. width: ScreenUtil.getInstance().setWidth(300),
  159. child: Row(
  160. mainAxisAlignment: MainAxisAlignment.end,
  161. children: < Widget > [
  162. Expanded(
  163. //padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(20)),
  164. //child: Text(value,style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  165. child: Center(
  166. child: TextField(
  167. keyboardType: TextInputType.number,
  168. textAlign: TextAlign.end,
  169. style: TextStyle(
  170. fontSize: ScreenUtil.getInstance().setSp(30),
  171. color: Color.fromRGBO(136, 136, 136, 1)
  172. ),
  173. decoration: InputDecoration(
  174. border: InputBorder.none,
  175. hintText: value.toString(),
  176. hintStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)),
  177. contentPadding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(20), 0, 0, 0),
  178. ),
  179. onChanged: (value){
  180. if(key=='数量'){
  181. afterGoodsNumber =int.parse(value);
  182. }else if(key=='运费'){
  183. afterTransportFee =double.parse(value);
  184. String temp = afterTransportFee.toStringAsFixed(1);
  185. afterTransportFee = double.parse(temp);
  186. }else if(key=='代收'){
  187. afterCollectingFee =double.parse(value);
  188. String temp = afterCollectingFee.toStringAsFixed(1);
  189. afterCollectingFee = double.parse(temp);
  190. }
  191. },
  192. ),
  193. )
  194. ),
  195. Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
  196. ],
  197. )
  198. )
  199. ],
  200. ),
  201. )
  202. ),
  203. Expanded(
  204. flex: 0,
  205. child: underLine()
  206. )
  207. ],
  208. )
  209. );
  210. }
  211. Widget _descWidget(String str) {
  212. return
  213. Container(
  214. padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
  215. child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  216. );
  217. }
  218. }
  219. Widget titleWidget(String iconUrl, String str) {
  220. return Container(
  221. height: ScreenUtil.getInstance().setHeight(90),
  222. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  223. child: Center(
  224. child: Row(
  225. mainAxisAlignment: MainAxisAlignment.start,
  226. children: < Widget > [
  227. Padding(
  228. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
  229. child: Image.asset(
  230. iconUrl,
  231. width: ScreenUtil.getInstance().setWidth(40),
  232. height: ScreenUtil.getInstance().setHeight(40),
  233. )
  234. ),
  235. Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
  236. ],
  237. ),
  238. ),
  239. );
  240. }
  241. Widget underLine() {
  242. return Container(
  243. color: Color.fromRGBO(223, 223, 223, 1),
  244. height: ScreenUtil.getInstance().setHeight(1),
  245. );
  246. }
  247. Widget contentWiget(String key, String value) {
  248. return Padding(
  249. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  250. child: Column(
  251. children: < Widget > [
  252. Padding(
  253. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  254. child: SizedBox(
  255. height: ScreenUtil.getInstance().setHeight(89),
  256. child: Center(
  257. child: Row(
  258. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  259. children: < Widget > [
  260. Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  261. Text(value, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  262. ],
  263. ),
  264. )
  265. )
  266. ),
  267. Expanded(
  268. flex: 0,
  269. child: underLine()
  270. )
  271. ],
  272. )
  273. );
  274. }
  275. Widget lastContentWiget(String key, String value) {
  276. return Padding(
  277. padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
  278. child:
  279. Padding(
  280. padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(30)),
  281. child: SizedBox(
  282. height: ScreenUtil.getInstance().setHeight(89),
  283. child: Center(
  284. child: Row(
  285. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  286. children: < Widget > [
  287. Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
  288. Text(value, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
  289. ],
  290. ),
  291. )
  292. )
  293. ),
  294. );
  295. }
  296. Widget _getMoreWidget() {
  297. return Center(
  298. child: Padding(
  299. padding: EdgeInsets.all(10.0),
  300. child: Row(
  301. mainAxisAlignment: MainAxisAlignment.center,
  302. crossAxisAlignment: CrossAxisAlignment.center,
  303. children: < Widget > [
  304. Text(
  305. '加载中...',
  306. style: TextStyle(fontSize: 16.0),
  307. ),
  308. Container(
  309. width: ScreenUtil.getInstance().setWidth(50),
  310. height: ScreenUtil.getInstance().setHeight(50),
  311. child: CircularProgressIndicator()
  312. )
  313. ],
  314. ),
  315. ),
  316. );
  317. }