order_page.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. // import 'package:liftmanager/internal/wode/model/order_model.dart';
  5. import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
  6. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  7. import 'package:liftmanager/internal/wode/order_const.dart';
  8. import 'package:liftmanager/internal/wode/presenter/order_master_list_presenter.dart';
  9. import 'package:liftmanager/internal/wode/wode_router.dart';
  10. import 'package:liftmanager/mvp/base_page_state.dart';
  11. import 'package:liftmanager/res/colors.dart';
  12. import 'package:liftmanager/routers/fluro_navigator.dart';
  13. import 'package:liftmanager/utils/time_format.dart';
  14. import 'package:liftmanager/widgets/app_bar.dart';
  15. import 'package:liftmanager/widgets/load_image.dart';
  16. import 'package:liftmanager/widgets/my_refresh_list.dart';
  17. import 'package:liftmanager/widgets/state_layout.dart';
  18. import 'package:provider/provider.dart';
  19. class OrderPageMaster extends StatefulWidget {
  20. OrderPageMaster(this.checkType);
  21. String checkType;
  22. int tabCheckIndex = 0;
  23. @override
  24. // State<StatefulWidget> createState() {
  25. // return OrderPageMasterState();
  26. // }
  27. OrderPageMasterState createState() => OrderPageMasterState();
  28. }
  29. class OrderPageMasterState
  30. extends BasePageState<OrderPageMaster, OrderListPresenterSeconds> {
  31. BaseListProvider<LiftCasesDetailModel> provider =
  32. BaseListProvider<LiftCasesDetailModel>();
  33. int _page = 1;
  34. ScrollController _scrollController = new ScrollController();
  35. @override
  36. void dispose() {
  37. _scrollController.dispose();
  38. super.dispose();
  39. }
  40. @override
  41. void initState() {
  42. if (widget.checkType.isNotEmpty && widget.checkType != null) {
  43. widget.tabCheckIndex = int.parse(widget.checkType);
  44. }
  45. provider.setStateTypeNotNotify(StateType.loading);
  46. super.initState();
  47. _onRefresh();
  48. }
  49. @override
  50. Widget build(BuildContext context) {
  51. double width = MediaQuery.of(context).size.width;
  52. return WillPopScope(
  53. // ignore: missing_return
  54. onWillPop: () {
  55. Navigator.popUntil(context, ModalRoute.withName('/home'));
  56. },
  57. child: ChangeNotifierProvider<BaseListProvider<LiftCasesDetailModel>>(
  58. create: (_) => provider,
  59. child: Scaffold(
  60. appBar: MyAppBar(
  61. centerTitle: "专家订单",
  62. isFun: true,
  63. fun: () {
  64. Navigator.popUntil(context, ModalRoute.withName('/home'));
  65. },
  66. actions: <Widget>[],
  67. ),
  68. body: Container(
  69. child: Stack(
  70. children: <Widget>[
  71. Container(
  72. padding: EdgeInsets.only(top: ScreenUtil().setWidth(44)),
  73. child: Column(
  74. children: <Widget>[
  75. Expanded(
  76. flex: 1,
  77. child:
  78. Consumer<BaseListProvider<LiftCasesDetailModel>>(
  79. builder: (_, provider, __) {
  80. return MyListView(
  81. key: Key('order_list'),
  82. itemCount: provider.list.length,
  83. stateType: provider.stateType,
  84. onRefresh: _onRefresh,
  85. loadMore: _loadMore,
  86. hasMore: provider.hasMore,
  87. itemBuilder: (_, index) {
  88. return OrderListItemWidget(
  89. data: provider.list[index],
  90. );
  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.expertOrderType.asMap().keys.map((i) {
  114. return TabThis(
  115. item: OrderConstant.expertOrderType[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. }).toList(),
  126. ),
  127. ),
  128. ),
  129. ],
  130. ),
  131. ),
  132. ),
  133. ));
  134. }
  135. Future _onRefresh() async {
  136. _page = 1;
  137. await presenter.getOrderList(
  138. _page, OrderConstant.expertOrderType[widget.tabCheckIndex]['value']);
  139. }
  140. Future _loadMore() async {
  141. _page++;
  142. await presenter.getOrderList(
  143. _page, OrderConstant.expertOrderType[widget.tabCheckIndex]['value']);
  144. }
  145. @override
  146. OrderListPresenterSeconds createPresenter() {
  147. // TODO: implement createPresenter
  148. // throw UnimplementedError();
  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}) : super(key: key);
  203. LiftCasesDetailModel data;
  204. @override
  205. Widget build(BuildContext context) {
  206. double width = MediaQuery.of(context).size.width;
  207. return IntrinsicWidth(
  208. child: Container(
  209. padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  210. width: width,
  211. // height: 100,
  212. child: GestureDetector(
  213. onTap: () {
  214. NavigatorUtils.push(
  215. context, "${WodeRouter.orderDetailMaster}?id=${data.id}");
  216. },
  217. child: Row(
  218. crossAxisAlignment: CrossAxisAlignment.start,
  219. // mainAxisSize: MainAxisSize.min,
  220. children: <Widget>[
  221. Container(
  222. margin: EdgeInsets.only(
  223. left: ScreenUtil().setWidth(10),
  224. right: ScreenUtil().setWidth(10),
  225. top: ScreenUtil().setWidth(5),
  226. ),
  227. decoration: BoxDecoration(
  228. borderRadius: BorderRadius.circular(
  229. ScreenUtil().setWidth(22),
  230. ),
  231. ),
  232. child: LoadNetworkImage(
  233. data.avatarUrl,
  234. width: ScreenUtil().setWidth(43),
  235. height: ScreenUtil().setWidth(43),
  236. // alignment: Alignment.centerLeft,
  237. ),
  238. ),
  239. Expanded(
  240. child: Container(
  241. padding: EdgeInsets.only(
  242. right: ScreenUtil().setWidth(15),
  243. ),
  244. child: Column(
  245. children: <Widget>[
  246. Container(
  247. child: Row(
  248. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  249. children: <Widget>[
  250. Row(
  251. crossAxisAlignment: CrossAxisAlignment.center,
  252. children: <Widget>[
  253. Text(
  254. data.name ?? '',
  255. style: TextStyle(
  256. fontSize: ScreenUtil().setSp(17),
  257. ),
  258. textAlign: TextAlign.start,
  259. ),
  260. Container(
  261. decoration: BoxDecoration(
  262. //背景
  263. color: data.dataTable == 1
  264. ? Colours.blue_app_main
  265. : Color(0xffFDAF2C),
  266. //设置四周圆角 角度
  267. borderRadius:
  268. BorderRadius.all(Radius.circular(4.0)),
  269. ),
  270. padding: EdgeInsets.only(
  271. left: 5, right: 5, top: 0, bottom: 0),
  272. child: Text(
  273. data.dataTable == 1 ? '问诊服务' : '出诊服务',
  274. style: TextStyle(
  275. color: Colors.white,
  276. fontSize: ScreenUtil().setSp(14),
  277. ),
  278. textAlign: TextAlign.start,
  279. ),
  280. )
  281. ],
  282. ),
  283. Container(
  284. child: Text(
  285. OrderConstant.getStatusName(
  286. data.statuz, data.dataTable,
  287. arrivedFlag: data.arrivedFlag,
  288. examineFlag: data.examineFlag != null
  289. ? int.parse(data.examineFlag)
  290. : null,
  291. userType: 'EXPERT'),
  292. style: TextStyle(
  293. color: data.dataTable != 1
  294. ? Color(0xffF84203)
  295. : Color(0xff0288FF),
  296. fontSize: ScreenUtil().setSp(14),
  297. ),
  298. textAlign: TextAlign.end,
  299. ),
  300. )
  301. ]),
  302. ),
  303. Container(
  304. child: Row(
  305. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  306. children: <Widget>[
  307. Row(
  308. crossAxisAlignment: CrossAxisAlignment.center,
  309. children: <Widget>[
  310. Text(
  311. data.createTime != null
  312. ? DateUtils.instance.getFormartData(
  313. timeSamp: data.createTime,
  314. format: "MM-dd")
  315. : '',
  316. style: TextStyle(
  317. color: Color(0xff999999),
  318. fontSize: ScreenUtil().setSp(13),
  319. ),
  320. textAlign: TextAlign.start,
  321. ),
  322. Container(
  323. padding: EdgeInsets.only(left: 5),
  324. child: Text(
  325. data.brandName ?? '',
  326. style: TextStyle(
  327. color: Color(0xff999999),
  328. fontSize: ScreenUtil().setSp(13),
  329. ),
  330. textAlign: TextAlign.start,
  331. ),
  332. )
  333. ],
  334. ),
  335. ]),
  336. ),
  337. data.dataTable == 1
  338. ? Container(
  339. child: Row(
  340. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  341. children: <Widget>[
  342. Row(
  343. crossAxisAlignment: CrossAxisAlignment.center,
  344. children: <Widget>[
  345. Text(
  346. '问题描述:',
  347. style: TextStyle(
  348. color: Color(0xff666666),
  349. fontSize: ScreenUtil().setSp(14),
  350. ),
  351. textAlign: TextAlign.start,
  352. ),
  353. Container(
  354. width: 200,
  355. padding: EdgeInsets.only(left: 5),
  356. child: Text(
  357. data.expression ?? '',
  358. style: TextStyle(
  359. color: Color(0xff666666),
  360. fontSize: ScreenUtil().setSp(14),
  361. ),
  362. textAlign: TextAlign.start,
  363. maxLines: 1,
  364. overflow: TextOverflow.ellipsis,
  365. ),
  366. )
  367. ],
  368. ),
  369. ],
  370. ),
  371. )
  372. : Container(
  373. child: Row(
  374. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  375. children: <Widget>[
  376. Row(
  377. crossAxisAlignment: CrossAxisAlignment.center,
  378. children: <Widget>[
  379. Text(
  380. '出诊时间:',
  381. style: TextStyle(
  382. color: Color(0xff666666),
  383. fontSize: ScreenUtil().setSp(14),
  384. ),
  385. textAlign: TextAlign.start,
  386. ),
  387. Container(
  388. padding: EdgeInsets.only(left: 5),
  389. child: Text(
  390. data.arrivedTime != null
  391. ? DateUtils.instance.getFormartData(
  392. timeSamp: data.arrivedTime,
  393. format: "MM-dd HH:mm")
  394. : '',
  395. style: TextStyle(
  396. color: Color(0xff666666),
  397. fontSize: ScreenUtil().setSp(14),
  398. ),
  399. textAlign: TextAlign.start,
  400. ),
  401. )
  402. ],
  403. ),
  404. ],
  405. ),
  406. ),
  407. data.dataTable == 1
  408. ? Container(
  409. child: Row(
  410. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  411. children: <Widget>[
  412. Row(
  413. crossAxisAlignment: CrossAxisAlignment.center,
  414. children: <Widget>[
  415. Text(
  416. '已尝试方法:',
  417. style: TextStyle(
  418. color: Color(0xff666666),
  419. fontSize: ScreenUtil().setSp(14),
  420. ),
  421. textAlign: TextAlign.start,
  422. ),
  423. Container(
  424. width: 200,
  425. padding: EdgeInsets.only(left: 5),
  426. child: Text(
  427. data.usedMethods ?? '',
  428. style: TextStyle(
  429. color: Color(0xff666666),
  430. fontSize: ScreenUtil().setSp(14),
  431. ),
  432. textAlign: TextAlign.start,
  433. maxLines: 1,
  434. overflow: TextOverflow.ellipsis,
  435. ),
  436. )
  437. ],
  438. ),
  439. ],
  440. ),
  441. )
  442. : Container(
  443. child: Row(
  444. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  445. children: <Widget>[
  446. Row(
  447. crossAxisAlignment: CrossAxisAlignment.center,
  448. children: <Widget>[
  449. Text(
  450. '出诊地点:',
  451. style: TextStyle(
  452. color: Color(0xff666666),
  453. fontSize: ScreenUtil().setSp(14),
  454. ),
  455. textAlign: TextAlign.start,
  456. ),
  457. Container(
  458. width: 200,
  459. padding: EdgeInsets.only(left: 5),
  460. child: Text(
  461. data.address ?? '',
  462. style: TextStyle(
  463. color: Color(0xff666666),
  464. fontSize: ScreenUtil().setSp(14),
  465. ),
  466. textAlign: TextAlign.start,
  467. maxLines: 1,
  468. overflow: TextOverflow.ellipsis,
  469. ),
  470. )
  471. ],
  472. ),
  473. ],
  474. ),
  475. ),
  476. data.dataTable == 2
  477. ? Container(
  478. child: Row(
  479. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  480. children: <Widget>[
  481. Row(
  482. crossAxisAlignment: CrossAxisAlignment.center,
  483. children: <Widget>[
  484. Text(
  485. '问题描述:',
  486. style: TextStyle(
  487. color: Color(0xff666666),
  488. fontSize: ScreenUtil().setSp(14),
  489. ),
  490. textAlign: TextAlign.start,
  491. ),
  492. Container(
  493. width: 200,
  494. padding: EdgeInsets.only(left: 5),
  495. child: Text(
  496. data.expression ?? '',
  497. style: TextStyle(
  498. color: Color(0xff666666),
  499. fontSize: ScreenUtil().setSp(14),
  500. ),
  501. textAlign: TextAlign.start,
  502. maxLines: 1,
  503. overflow: TextOverflow.ellipsis,
  504. ),
  505. )
  506. ],
  507. ),
  508. ],
  509. ),
  510. )
  511. : Container(),
  512. Container(
  513. margin: EdgeInsets.only(top: 6),
  514. child: Row(
  515. children: <Widget>[
  516. Container(
  517. padding: EdgeInsets.only(right: 5),
  518. child: Text(
  519. data.totalCost != null
  520. ? "¥${data.totalCost.toString()}"
  521. : '',
  522. style: TextStyle(
  523. color: Color(0xffFD0808),
  524. fontSize: ScreenUtil().setSp(15),
  525. ),
  526. textAlign: TextAlign.start,
  527. ),
  528. ),
  529. ],
  530. ),
  531. )
  532. ],
  533. ),
  534. ),
  535. ),
  536. ],
  537. ),
  538. ),
  539. ));
  540. }
  541. }