order_page.dart 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
  5. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  6. import 'package:liftmanager/internal/wode/order_const.dart';
  7. import 'package:liftmanager/internal/wode/presenter/order_list_presenter.dart';
  8. import 'package:liftmanager/internal/wode/wode_router.dart';
  9. import 'package:liftmanager/mvp/base_page_state.dart';
  10. import 'package:liftmanager/res/colors.dart';
  11. import 'package:liftmanager/routers/fluro_navigator.dart';
  12. import 'package:liftmanager/utils/time_format.dart';
  13. import 'package:liftmanager/widgets/app_bar.dart';
  14. import 'package:liftmanager/widgets/load_image.dart';
  15. import 'package:liftmanager/widgets/my_refresh_list.dart';
  16. import 'package:liftmanager/widgets/state_layout.dart';
  17. import 'package:provider/provider.dart';
  18. class OrderPage extends StatefulWidget {
  19. OrderPage(this.checkType);
  20. String checkType;
  21. int tabCheckIndex = 0;
  22. @override
  23. OrderPageState createState() => OrderPageState();
  24. }
  25. class OrderPageState
  26. extends BasePageState<OrderPage, OrderListPresenterSeconds> {
  27. BaseListProvider<LiftCasesDetailModel> provider =
  28. BaseListProvider<LiftCasesDetailModel>();
  29. int _page = 1;
  30. ScrollController _scrollController = new ScrollController();
  31. @override
  32. void dispose() {
  33. _scrollController.dispose();
  34. super.dispose();
  35. }
  36. @override
  37. void initState() {
  38. if (widget.checkType.isNotEmpty && widget.checkType != null) {
  39. widget.tabCheckIndex = int.parse(widget.checkType);
  40. }
  41. provider.setStateTypeNotNotify(StateType.loading);
  42. super.initState();
  43. _onRefresh();
  44. }
  45. @override
  46. Widget build(BuildContext context) {
  47. double width = MediaQuery.of(context).size.width;
  48. return WillPopScope(
  49. // ignore: missing_return
  50. onWillPop: () {
  51. Navigator.popUntil(context, ModalRoute.withName('/home'));
  52. },
  53. child: ChangeNotifierProvider<BaseListProvider<LiftCasesDetailModel>>(
  54. create: (_) => provider,
  55. child: Scaffold(
  56. appBar: MyAppBar(
  57. centerTitle: "我的订单",
  58. isFun: true,
  59. fun: () {
  60. Navigator.popUntil(context, ModalRoute.withName('/home'));
  61. },
  62. actions: <Widget>[],
  63. ),
  64. body: Container(
  65. child: Stack(
  66. children: <Widget>[
  67. Container(
  68. padding: EdgeInsets.only(top: ScreenUtil().setWidth(44)),
  69. child: Column(
  70. children: <Widget>[
  71. Expanded(
  72. flex: 1,
  73. child: Consumer<BaseListProvider<LiftCasesDetailModel>>(
  74. builder: (_, provider, __) {
  75. return MyListView(
  76. key: Key('order_list'),
  77. itemCount: provider.list.length,
  78. stateType: provider.stateType,
  79. onRefresh: _onRefresh,
  80. loadMore: _loadMore,
  81. hasMore: provider.hasMore,
  82. itemBuilder: (_, index) {
  83. return OrderListItemWidget(
  84. data: provider.list[index],
  85. typeValue: OrderConstant
  86. .userOrderType[widget.tabCheckIndex]
  87. ['value']);
  88. },
  89. );
  90. },
  91. ),
  92. )
  93. ],
  94. ),
  95. ),
  96. Positioned(
  97. child: Container(
  98. padding: EdgeInsets.only(bottom: 5),
  99. // color:Color(0xffFAF7FA),
  100. decoration: BoxDecoration(
  101. border: Border(
  102. bottom:
  103. BorderSide(width: 0.5, color: Color(0xffeeeeee)),
  104. ),
  105. // color: Color(0xff9FD1FE),
  106. ),
  107. child: Row(
  108. mainAxisAlignment: MainAxisAlignment.spaceAround,
  109. children:
  110. OrderConstant.userOrderType.asMap().keys.map((i) {
  111. return TabThis(
  112. item: OrderConstant.userOrderType[i]['name'],
  113. tabIndex: i,
  114. checkIndex: widget.tabCheckIndex,
  115. fun: (index) {
  116. setState(() {
  117. widget.tabCheckIndex = index;
  118. provider.list.clear();
  119. _onRefresh();
  120. });
  121. },
  122. );
  123. }).toList(),
  124. ),
  125. ),
  126. ),
  127. ],
  128. ),
  129. ),
  130. ),
  131. ),
  132. );
  133. }
  134. Future _onRefresh() async {
  135. _page = 1;
  136. await presenter.getOrderList(
  137. _page, OrderConstant.userOrderType[widget.tabCheckIndex]['value']);
  138. }
  139. Future _loadMore() async {
  140. _page++;
  141. await presenter.getOrderList(
  142. _page, OrderConstant.userOrderType[widget.tabCheckIndex]['value']);
  143. }
  144. @override
  145. OrderListPresenterSeconds createPresenter() {
  146. return OrderListPresenterSeconds();
  147. }
  148. }
  149. class TabThis extends StatelessWidget {
  150. TabThis({Key key, this.item, this.tabIndex, this.fun, this.checkIndex})
  151. : super(key: key);
  152. String item;
  153. int tabIndex;
  154. int checkIndex;
  155. Function fun;
  156. @override
  157. Widget build(BuildContext context) {
  158. return Container(
  159. padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  160. child: Container(
  161. child: Row(
  162. mainAxisAlignment: MainAxisAlignment.center,
  163. children: <Widget>[
  164. GestureDetector(
  165. onTap: () {
  166. fun(tabIndex);
  167. },
  168. child: Container(
  169. padding: EdgeInsets.only(bottom: 6),
  170. decoration: BoxDecoration(
  171. border: Border(
  172. bottom: BorderSide(
  173. width: 2,
  174. color: checkIndex == tabIndex
  175. ? Color(0xff02A0FD)
  176. : Colors.transparent),
  177. ),
  178. // color: Color(0xff9FD1FE),
  179. ),
  180. child: Text(
  181. item,
  182. style: TextStyle(
  183. color: checkIndex == tabIndex
  184. ? Color(0xff02A0FD)
  185. : Color(0xff666666),
  186. fontSize: ScreenUtil().setSp(14),
  187. ),
  188. textAlign: TextAlign.center,
  189. ),
  190. ),
  191. )
  192. ],
  193. ),
  194. ),
  195. );
  196. }
  197. }
  198. class OrderListItemWidget extends StatelessWidget {
  199. OrderListItemWidget({Key key, this.data, this.typeValue}) : super(key: key);
  200. LiftCasesDetailModel data;
  201. String typeValue;
  202. getTypeValue(liftCaseAppealStatus) {
  203. String str;
  204. if (liftCaseAppealStatus == 1) {
  205. str = "申诉中";
  206. } else if (liftCaseAppealStatus == 2) {
  207. str = "申诉驳回";
  208. } else if (liftCaseAppealStatus == 3) {
  209. str = "申诉已结束";
  210. } else if (liftCaseAppealStatus == 4) {
  211. str = "申诉已退款";
  212. }
  213. return str;
  214. }
  215. @override
  216. Widget build(BuildContext context) {
  217. double width = MediaQuery.of(context).size.width;
  218. return Container(
  219. padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  220. width: width,
  221. // height: 100,
  222. child: GestureDetector(
  223. onTap: () {
  224. NavigatorUtils.push(
  225. context, "${WodeRouter.orderDetail}?id=${data.id}");
  226. },
  227. child: Row(
  228. crossAxisAlignment: CrossAxisAlignment.start,
  229. // mainAxisSize: MainAxisSize.min,
  230. children: <Widget>[
  231. ClipRRect(
  232. borderRadius: BorderRadius.circular(20),
  233. child: Container(
  234. margin: EdgeInsets.only(
  235. left: ScreenUtil().setWidth(10),
  236. right: ScreenUtil().setWidth(10),
  237. top: ScreenUtil().setWidth(0)),
  238. // decoration: BoxDecoration(
  239. // borderRadius: BorderRadius.circular(ScreenUtil().setWidth(22)),
  240. // ),
  241. child: LoadNetworkImage(
  242. data.avatarUrl,
  243. width: ScreenUtil().setWidth(43),
  244. height: ScreenUtil().setWidth(43),
  245. // alignment: Alignment.centerLeft,
  246. ),
  247. ),
  248. ),
  249. Expanded(
  250. // flex: 1,
  251. // fit: FlexFit.loose,
  252. child: Container(
  253. padding: EdgeInsets.only(right: ScreenUtil().setWidth(15)),
  254. child: Column(
  255. children: <Widget>[
  256. Container(
  257. child: Row(
  258. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  259. children: <Widget>[
  260. Row(
  261. crossAxisAlignment: CrossAxisAlignment.center,
  262. children: <Widget>[
  263. Text(
  264. data.name ?? "小小修理工",
  265. style: TextStyle(
  266. color: Color(0xff333333),
  267. fontSize: ScreenUtil().setSp(17)),
  268. textAlign: TextAlign.start,
  269. ),
  270. Container(
  271. decoration: BoxDecoration(
  272. //背景
  273. color: data.dataTable == 1
  274. ? Colours.blue_app_main
  275. : Color(0xffFDAF2C),
  276. //设置四周圆角 角度
  277. borderRadius:
  278. BorderRadius.all(Radius.circular(4.0)),
  279. ),
  280. margin: EdgeInsets.only(left: 5),
  281. padding: EdgeInsets.only(
  282. left: 5, right: 5, top: 0, bottom: 0),
  283. child: Text(
  284. data.dataTable == 1 ? '问诊服务' : '出诊服务',
  285. style: TextStyle(
  286. color: Colors.white,
  287. fontSize: ScreenUtil().setSp(14),
  288. ),
  289. textAlign: TextAlign.start,
  290. ),
  291. )
  292. ],
  293. ),
  294. typeValue != "TO_APPEAL"
  295. ? Container(
  296. child: Text(
  297. OrderConstant.getStatusName(
  298. data.statuz, data.dataTable,
  299. arrivedFlag: data.arrivedFlag,
  300. userType: 'USER'),
  301. style: TextStyle(
  302. color: data.dataTable != 1
  303. ? Color(0xffF84203)
  304. : Color(0xff0288FF),
  305. fontSize: ScreenUtil().setSp(14),
  306. ),
  307. textAlign: TextAlign.end,
  308. ),
  309. )
  310. : Container(
  311. child: Text(
  312. data.liftCaseAppealStatus != null
  313. ? getTypeValue(
  314. data.liftCaseAppealStatus)
  315. : "",
  316. style: TextStyle(
  317. color: Color(0xff0288FF),
  318. fontSize: ScreenUtil().setSp(14),
  319. ),
  320. textAlign: TextAlign.end,
  321. ),
  322. )
  323. ],
  324. ),
  325. ),
  326. Container(
  327. child: Row(
  328. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  329. children: <Widget>[
  330. Row(
  331. crossAxisAlignment: CrossAxisAlignment.center,
  332. children: <Widget>[
  333. Text(
  334. data.createTime != null
  335. ? DateUtils.instance.getFormartData(
  336. timeSamp: data.createTime,
  337. format: "MM月dd日")
  338. : '',
  339. style: TextStyle(
  340. color: Color(0xff999999),
  341. fontSize: ScreenUtil().setSp(13),
  342. ),
  343. textAlign: TextAlign.start,
  344. ),
  345. Container(
  346. padding: EdgeInsets.only(left: 5),
  347. child: Text(
  348. data.brandName ?? '',
  349. style: TextStyle(
  350. color: Colours.blue_app_main,
  351. fontSize: ScreenUtil().setSp(13),
  352. ),
  353. textAlign: TextAlign.start,
  354. ),
  355. )
  356. ],
  357. ),
  358. ],
  359. ),
  360. ),
  361. data.dataTable != 1
  362. ? Container(
  363. child: Row(
  364. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  365. children: <Widget>[
  366. Row(
  367. crossAxisAlignment: CrossAxisAlignment.start,
  368. children: <Widget>[
  369. Container(
  370. // padding: EdgeInsets.only(left: 5),
  371. child: Text(
  372. '出诊时间:',
  373. style: TextStyle(
  374. color: Color(0xff999999),
  375. fontSize: ScreenUtil().setSp(13),
  376. ),
  377. textAlign: TextAlign.start,
  378. ),
  379. ),
  380. Text(
  381. data.arrivedTime != null
  382. ? DateUtils.instance.getFormartData(
  383. timeSamp: data.arrivedTime,
  384. format: "MM月dd日 HH:mm")
  385. : '',
  386. style: TextStyle(
  387. color: Color(0xff666666),
  388. fontSize: ScreenUtil().setSp(13),
  389. ),
  390. textAlign: TextAlign.start,
  391. ),
  392. ],
  393. ),
  394. ],
  395. ),
  396. )
  397. : Container(),
  398. data.dataTable != 1
  399. ? Container(
  400. // margin: EdgeInsets.only(top: 6),
  401. child: Row(
  402. children: <Widget>[
  403. Container(
  404. // padding: EdgeInsets.only(left: 5),
  405. child: Text(
  406. '出诊地点:',
  407. style: TextStyle(
  408. color: Color(0xff999999),
  409. fontSize: ScreenUtil().setSp(13),
  410. ),
  411. textAlign: TextAlign.start,
  412. ),
  413. ),
  414. Container(
  415. width: ScreenUtil().setWidth(230),
  416. child: Text(
  417. '${data.address ?? ''}',
  418. style: TextStyle(
  419. color: Color(0xff666666),
  420. fontSize: ScreenUtil().setSp(13),
  421. // color: Color(0xff666666),
  422. // fontSize: ScreenUtil().setSp(15),
  423. ),
  424. textAlign: TextAlign.start,
  425. maxLines: 1,
  426. overflow: TextOverflow.ellipsis,
  427. ),
  428. ),
  429. ],
  430. ),
  431. )
  432. : Container(),
  433. Container(
  434. // margin: EdgeInsets.only(top: 6),
  435. child: Row(
  436. children: <Widget>[
  437. Container(
  438. // padding: EdgeInsets.only(left: 5),
  439. child: Text(
  440. '问题描述:',
  441. style: TextStyle(
  442. color: Color(0xff999999),
  443. fontSize: ScreenUtil().setSp(13),
  444. ),
  445. textAlign: TextAlign.start,
  446. ),
  447. ),
  448. Container(
  449. width: ScreenUtil().setWidth(230),
  450. child: Text(
  451. '${data.expression ?? ''}',
  452. style: TextStyle(
  453. color: Color(0xff666666),
  454. fontSize: ScreenUtil().setSp(13),
  455. // color: Color(0xff666666),
  456. // fontSize: ScreenUtil().setSp(15),
  457. ),
  458. textAlign: TextAlign.start,
  459. maxLines: 1,
  460. overflow: TextOverflow.ellipsis,
  461. ),
  462. ),
  463. ],
  464. ),
  465. ),
  466. Container(
  467. margin: EdgeInsets.only(top: 6),
  468. child: Row(
  469. children: <Widget>[
  470. Container(
  471. padding: EdgeInsets.only(right: 5),
  472. child: Text(
  473. data.totalCost != null
  474. ? "¥${data.totalCost.toString()}"
  475. : '',
  476. style: TextStyle(
  477. color: Color(0xffFD0808),
  478. fontSize: ScreenUtil().setSp(15),
  479. ),
  480. textAlign: TextAlign.left,
  481. ),
  482. ),
  483. ],
  484. ),
  485. )
  486. ],
  487. ),
  488. ),
  489. )
  490. ],
  491. ),
  492. ),
  493. );
  494. }
  495. }