OrderListCard.dart 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import '../models/entities/OrderListAll.dart';
  5. import '../pages/OrderConfirmation/index.dart';
  6. import '../pages/orderInfo/index.dart';
  7. import 'package:intl/intl.dart';
  8. import 'LinearGradientText.dart';
  9. class OrderListCard extends StatefulWidget {
  10. final OrderListAll item;
  11. const OrderListCard({Key? key, required this.item}) : super(key: key);
  12. @override
  13. _OrderListCardPages createState() => _OrderListCardPages(item);
  14. }
  15. class StyleObj {
  16. String title;
  17. Color styleColor;
  18. StyleObj({required this.title, required this.styleColor});
  19. }
  20. class _OrderListCardPages extends State<OrderListCard> {
  21. final OrderListAll item;
  22. _OrderListCardPages(this.item);
  23. StyleObj orderStates() {
  24. if (item.payStatus == 0) {
  25. return StyleObj(title: '待付款', styleColor: Color(0xFF51D4FF));
  26. } else if (item.payStatus == 1 &&
  27. item.workStatus == 0 &&
  28. item.dispatchStatus == 0) {
  29. return StyleObj(title: '已付款', styleColor: Color(0xFFFF703B));
  30. } else if (item.payStatus == 1 &&
  31. item.dispatchStatus == 1 &&
  32. item.workStatus == 0) {
  33. return StyleObj(title: '待作业', styleColor: Color(0xFFFF703B));
  34. } else if (item.payStatus == 1 &&
  35. (item.workStatus == 1 || item.workStatus == 2)) {
  36. return StyleObj(title: '进行中', styleColor: Color(0xFF44F68B));
  37. } else if (item.workStatus == 3 && item.isEvaluated == 0) {
  38. return StyleObj(title: '待评价', styleColor: Color(0xFF51D4FF));
  39. }
  40. if (item.workStatus == 3 &&
  41. item.isEvaluated == 1 &&
  42. item.dispatchStatus == 1) {
  43. return StyleObj(title: '已完成', styleColor: Color(0xFFFF703B));
  44. } else if (item.payStatus == -1 &&
  45. item.workStatus == 0 &&
  46. item.isRefund == 1) {
  47. return StyleObj(title: '已退单', styleColor: Color(0xFFFF703B));
  48. } else if (item.payStatus == 3 &&
  49. (item.dispatchStatus == 1 || item.dispatchStatus == 0)) {
  50. return StyleObj(title: '退单申请中', styleColor: Color(0xFFFF703B));
  51. } else {
  52. return StyleObj(title: '异常', styleColor: Color(0xFFFF0000));
  53. }
  54. }
  55. @override
  56. Widget build(BuildContext context) {
  57. return Container(
  58. width: 375.w,
  59. height: 345.h,
  60. margin: EdgeInsets.fromLTRB(0, 0, 0, 20),
  61. decoration: const BoxDecoration(color: Colors.white, boxShadow: [
  62. BoxShadow(
  63. color: Colors.black12,
  64. offset: Offset(0.0, 15.0), //阴影xy轴偏移量
  65. blurRadius: 15.0, //阴影模糊程度
  66. spreadRadius: 1.0 //阴影扩散程度
  67. )
  68. ]),
  69. child: Row(
  70. crossAxisAlignment: CrossAxisAlignment.start,
  71. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  72. children: [
  73. Container(
  74. margin: EdgeInsets.fromLTRB(15, 20, 15, 0),
  75. width: 18.0,
  76. height: 275.h,
  77. child: Image(
  78. image: AssetImage('images/ordersLeft.png'),
  79. ),
  80. ),
  81. Expanded(
  82. child: Column(
  83. crossAxisAlignment: CrossAxisAlignment.start,
  84. children: [
  85. Container(
  86. width: 320.w,
  87. margin: EdgeInsets.fromLTRB(0, 10, 0, 15),
  88. padding: EdgeInsets.fromLTRB(0, 0, 0, 20),
  89. decoration: const BoxDecoration(
  90. border: Border(
  91. bottom:
  92. BorderSide(width: 0.5, color: Color(0x20000000)
  93. // 0x17000000
  94. ))),
  95. child: Row(
  96. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  97. children: [
  98. Container(
  99. child: RichText(
  100. text: TextSpan(children: <InlineSpan>[
  101. TextSpan(
  102. text: '订单编号:',
  103. style: TextStyle(
  104. color: Color(0xff666666),
  105. fontSize: 16,
  106. fontWeight: FontWeight.bold)),
  107. TextSpan(
  108. text: item.orderNo,
  109. style: TextStyle(
  110. color: Color(0xff222222),
  111. fontSize: 16,
  112. fontWeight: FontWeight.bold)),
  113. ]),
  114. ),
  115. ),
  116. GestureDetector(
  117. child: const Text('详情 >>',
  118. style: TextStyle(
  119. color: Color(0xff222222),
  120. fontSize: 16,
  121. fontWeight: FontWeight.bold,
  122. )),
  123. onTap: () {
  124. print('进入详情');
  125. Get.toNamed('/orderPageInfo', arguments: {
  126. 'id': item.orderId,
  127. 'title': orderStates().title,
  128. 'styleColor': orderStates().styleColor
  129. });
  130. },
  131. )
  132. ],
  133. ),
  134. ),
  135. Expanded(
  136. child: Column(
  137. crossAxisAlignment: CrossAxisAlignment.start,
  138. children: [
  139. Padding(
  140. padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
  141. child: RichText(
  142. text: TextSpan(children: <InlineSpan>[
  143. TextSpan(
  144. text: '农机名称:',
  145. style: TextStyle(
  146. color: Color(0xff666666),
  147. fontSize: 16,
  148. fontWeight: FontWeight.bold)),
  149. TextSpan(
  150. text: item.machineryName,
  151. style: TextStyle(
  152. color: Color(0xff222222),
  153. fontSize: 16,
  154. fontWeight: FontWeight.bold)),
  155. ]),
  156. ),
  157. ),
  158. Padding(
  159. padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
  160. child: RichText(
  161. text: TextSpan(children: <InlineSpan>[
  162. TextSpan(
  163. text: '作业面积:',
  164. style: TextStyle(
  165. color: Color(0xff666666),
  166. fontSize: 16,
  167. fontWeight: FontWeight.bold)),
  168. TextSpan(
  169. text: item.amount.toString(),
  170. style: TextStyle(
  171. color: Color(0xff222222),
  172. fontSize: 16,
  173. fontWeight: FontWeight.bold)),
  174. ]),
  175. ),
  176. ),
  177. Padding(
  178. padding: EdgeInsets.fromLTRB(0, 0, 0, 15),
  179. child: RichText(
  180. text: TextSpan(children: <InlineSpan>[
  181. TextSpan(
  182. text: '需求时间:',
  183. style: TextStyle(
  184. color: Color(0xff666666),
  185. fontSize: 16,
  186. fontWeight: FontWeight.bold)),
  187. TextSpan(
  188. text: DateFormat("yyyy-MM-dd").format(
  189. DateTime.parse(
  190. item.appointmentDate.toString())),
  191. style: TextStyle(
  192. color: Color(0xff222222),
  193. fontSize: 16,
  194. fontWeight: FontWeight.bold)),
  195. ]),
  196. ),
  197. ),
  198. Padding(
  199. padding: EdgeInsets.fromLTRB(0, 0, 0, 4),
  200. child: RichText(
  201. text: TextSpan(children: <InlineSpan>[
  202. TextSpan(
  203. text: '下单时间:',
  204. style: TextStyle(
  205. color: Color(0xff666666),
  206. fontSize: 16,
  207. fontWeight: FontWeight.bold)),
  208. TextSpan(
  209. text: DateFormat("yyyy-MM-dd").format(
  210. DateTime.parse(item.createDate.toString())),
  211. style: TextStyle(
  212. color: Color(0xff222222),
  213. fontSize: 16,
  214. fontWeight: FontWeight.bold)),
  215. ]),
  216. ),
  217. ),
  218. ],
  219. )),
  220. Container(
  221. margin: EdgeInsets.fromLTRB(0, 0, 0, 30),
  222. padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
  223. decoration: const BoxDecoration(
  224. border: Border(
  225. top: BorderSide(
  226. width: 0.5, color: Color(0x20000000)))),
  227. width: 320.w,
  228. child: Row(
  229. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  230. children: [
  231. RichText(
  232. text: TextSpan(children: <InlineSpan>[
  233. TextSpan(
  234. text: '订单状态:',
  235. style: TextStyle(
  236. color: Color(0xff666666),
  237. fontSize: 16,
  238. fontWeight: FontWeight.bold)),
  239. TextSpan(
  240. text: orderStates().title,
  241. style: TextStyle(
  242. color: orderStates().styleColor,
  243. fontSize: 16,
  244. fontWeight: FontWeight.bold)),
  245. ]),
  246. ),
  247. Container(
  248. child: Row(
  249. children: [
  250. const Text('费用:',
  251. style: TextStyle(
  252. color: Color(0xff666666),
  253. fontSize: 16,
  254. fontWeight: FontWeight.bold)),
  255. LinearGradientText(
  256. colors: const <Color>[
  257. Color(0xFFFA7878),
  258. Color(0xFFB61515),
  259. ],
  260. child: RichText(
  261. text: TextSpan(children: <InlineSpan>[
  262. TextSpan(
  263. text: ((item.charges ?? 0) / 100)
  264. .toString(),
  265. style: TextStyle(
  266. fontSize: 16,
  267. fontWeight: FontWeight.bold,
  268. )),
  269. TextSpan(
  270. text: "元",
  271. style: TextStyle(
  272. fontSize: 16,
  273. fontWeight: FontWeight.bold,
  274. )),
  275. ]),
  276. ),
  277. ),
  278. ],
  279. ),
  280. ),
  281. ],
  282. ),
  283. ),
  284. ],
  285. ),
  286. ),
  287. ],
  288. ),
  289. );
  290. }
  291. }