order_page.dart 21 KB

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