order_page.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/net/api_service.dart';
  3. import 'package:liftmanager/utils/toast.dart';
  4. import 'package:liftmanager/widgets/app_bar.dart';
  5. import 'package:liftmanager/routers/fluro_navigator.dart';
  6. import 'package:liftmanager/widgets/load_image.dart';
  7. import 'package:liftmanager/mvp/base_page_state.dart';
  8. import 'dart:async';
  9. import 'package:liftmanager/internal/wode/wode_router.dart';
  10. import 'package:flutter_screenutil/flutter_screenutil.dart';
  11. import 'package:provider/provider.dart';
  12. import 'package:liftmanager/internal/bbs/model/liftcase_model.dart';
  13. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  14. import 'package:liftmanager/internal/wode/presenter/order_list_presenter.dart';
  15. import 'package:liftmanager/widgets/state_layout.dart';
  16. import 'package:liftmanager/mvp/base_page_state.dart';
  17. import 'package:liftmanager/widgets/my_refresh_list.dart';
  18. import 'package:liftmanager/utils/time_format.dart';
  19. import 'package:liftmanager/internal/wode/order_const.dart';
  20. class OrderPage extends StatefulWidget {
  21. OrderPage(this.checkType);
  22. String checkType;
  23. int tabCheckIndex = 0;
  24. @override
  25. OrderPageState createState() => OrderPageState();
  26. }
  27. class OrderPageState
  28. extends BasePageState<OrderPage, OrderListPresenterSeconds> {
  29. BaseListProvider<LiftCasesDetailModel> provider =
  30. BaseListProvider<LiftCasesDetailModel>();
  31. int _page = 1;
  32. ScrollController _scrollController = new ScrollController();
  33. @override
  34. void dispose() {
  35. _scrollController.dispose();
  36. super.dispose();
  37. }
  38. @override
  39. void initState() {
  40. if (widget.checkType.isNotEmpty && widget.checkType != null) {
  41. widget.tabCheckIndex = int.parse(widget.checkType);
  42. }
  43. provider.setStateTypeNotNotify(StateType.loading);
  44. super.initState();
  45. _onRefresh();
  46. }
  47. @override
  48. Widget build(BuildContext context) {
  49. double width = MediaQuery.of(context).size.width;
  50. return WillPopScope(
  51. // ignore: missing_return
  52. onWillPop:(){
  53. Navigator.popUntil(context, ModalRoute.withName('/home'));
  54. },
  55. child: ChangeNotifierProvider<BaseListProvider<LiftCasesDetailModel>>(
  56. create: (_) => provider,
  57. child: Scaffold(
  58. appBar: MyAppBar(
  59. centerTitle: "我的订单",
  60. isFun: true,
  61. fun: () {
  62. Navigator.popUntil(context, ModalRoute.withName('/home'));
  63. },
  64. actions: <Widget>[],
  65. ),
  66. body: Container(
  67. child: Stack(
  68. children: <Widget>[
  69. Container(
  70. padding: EdgeInsets.only(top: ScreenUtil().setWidth(44)),
  71. child: Column(
  72. children: <Widget>[
  73. Expanded(
  74. flex: 1,
  75. child: Consumer<BaseListProvider<LiftCasesDetailModel>>(
  76. builder: (_, provider, __) {
  77. return MyListView(
  78. key: Key('order_list'),
  79. itemCount: provider.list.length,
  80. stateType: provider.stateType,
  81. onRefresh: _onRefresh,
  82. loadMore: _loadMore,
  83. hasMore: provider.hasMore,
  84. itemBuilder: (_, index) {
  85. return OrderListItemWidget(
  86. data: provider.list[index],
  87. typeValue:OrderConstant.userOrderType[widget.tabCheckIndex]['value']
  88. );
  89. },
  90. );
  91. },
  92. ),
  93. )
  94. ],
  95. ),
  96. ),
  97. Positioned(
  98. child: Container(
  99. padding: EdgeInsets.only(bottom: 5),
  100. // color:Color(0xffFAF7FA),
  101. decoration: BoxDecoration(
  102. border: Border(
  103. bottom: BorderSide(width: 0.5, color: Color(0xffeeeeee)),
  104. ),
  105. // color: Color(0xff9FD1FE),
  106. ),
  107. child: Row(
  108. mainAxisAlignment: MainAxisAlignment.spaceAround,
  109. children: OrderConstant.userOrderType.asMap().keys.map((i) {
  110. return TabThis(
  111. item: OrderConstant.userOrderType[i]['name'],
  112. tabIndex: i,
  113. checkIndex: widget.tabCheckIndex,
  114. fun: (index) {
  115. setState(() {
  116. widget.tabCheckIndex = index;
  117. provider.list.clear();
  118. _onRefresh();
  119. });
  120. },
  121. );
  122. }).toList(),
  123. ),
  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. }
  211. else if (liftCaseAppealStatus == 4){
  212. str = "申诉已退款";
  213. }
  214. return str;
  215. }
  216. @override
  217. Widget build(BuildContext context) {
  218. double width = MediaQuery.of(context).size.width;
  219. return Container(
  220. padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  221. width: width,
  222. // height: 100,
  223. child: GestureDetector(
  224. onTap: () {
  225. NavigatorUtils.push(
  226. context, "${WodeRouter.orderDetail}?id=${data.id}");
  227. },
  228. child: Row(
  229. crossAxisAlignment: CrossAxisAlignment.start,
  230. // mainAxisSize: MainAxisSize.min,
  231. children: <Widget>[
  232. Container(
  233. margin: EdgeInsets.only(
  234. left: ScreenUtil().setWidth(10),
  235. right: ScreenUtil().setWidth(10),
  236. top: ScreenUtil().setWidth(5)),
  237. decoration: BoxDecoration(
  238. borderRadius: BorderRadius.circular(ScreenUtil().setWidth(22)),
  239. ),
  240. child: LoadNetworkImage(
  241. data.avatarUrl,
  242. width: ScreenUtil().setWidth(43),
  243. height: ScreenUtil().setWidth(43),
  244. // alignment: Alignment.centerLeft,
  245. ),
  246. ),
  247. Expanded(
  248. // flex: 1,
  249. // fit: FlexFit.loose,
  250. child: Container(
  251. padding: EdgeInsets.only(right: ScreenUtil().setWidth(15)),
  252. child: Column(
  253. children: <Widget>[
  254. Container(
  255. child: Row(
  256. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  257. children: <Widget>[
  258. Row(
  259. crossAxisAlignment: CrossAxisAlignment.center,
  260. children: <Widget>[
  261. Text(
  262. data.name??"",
  263. style: TextStyle(
  264. color: Color(0xff333333),
  265. fontSize: ScreenUtil().setSp(17)),
  266. textAlign: TextAlign.start,
  267. ),
  268. Container(
  269. padding: EdgeInsets.only(left: 5),
  270. child: Text(
  271. data.dataTable == 1 ? '问诊服务' : '出诊服务',
  272. style: TextStyle(
  273. color: Color(0xff0288FF),
  274. fontSize: ScreenUtil().setSp(14),
  275. ),
  276. textAlign: TextAlign.start,
  277. ),
  278. )
  279. ],
  280. ),
  281. typeValue != "TO_APPEAL" ?Container(
  282. child: Text(
  283. OrderConstant.getStatusName(data.statuz, data.dataTable, arrivedFlag: data.arrivedFlag, userType: 'USER'),
  284. style: TextStyle(
  285. color: [].indexOf(data.statuz) == -1
  286. ? Color(0xff0288FF)
  287. : Color(0xffF84203),
  288. fontSize: ScreenUtil().setSp(14),
  289. ),
  290. textAlign: TextAlign.end,
  291. ),
  292. ):Container(
  293. child: Text(
  294. data.liftCaseAppealStatus!=null? getTypeValue(data.liftCaseAppealStatus):"",
  295. style: TextStyle(
  296. color: Color(0xff0288FF),
  297. fontSize: ScreenUtil().setSp(14),
  298. ),
  299. textAlign: TextAlign.end,
  300. ),
  301. )
  302. ],
  303. ),
  304. ),
  305. Container(
  306. child: Row(
  307. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  308. children: <Widget>[
  309. Row(
  310. crossAxisAlignment: CrossAxisAlignment.center,
  311. children: <Widget>[
  312. Text(
  313. data.createTime != null
  314. ? DateUtils.instance.getFormartData(
  315. timeSamp: data.createTime,
  316. format: "yyyy-MM-dd")
  317. : '',
  318. style: TextStyle(
  319. color: Color(0xff999999),
  320. fontSize: ScreenUtil().setSp(13),
  321. ),
  322. textAlign: TextAlign.start,
  323. ),
  324. Container(
  325. padding: EdgeInsets.only(left: 5),
  326. child: Text(
  327. data.brandName ?? '',
  328. style: TextStyle(
  329. color: Color(0xff999999),
  330. fontSize: ScreenUtil().setSp(13),
  331. ),
  332. textAlign: TextAlign.start,
  333. ),
  334. )
  335. ],
  336. ),
  337. ],
  338. ),
  339. ),
  340. Container(
  341. // margin: EdgeInsets.only(top: 6),
  342. child: Row(
  343. children: <Widget>[
  344. Container(
  345. width: 260,
  346. child: Text(
  347. data.expression ?? '',
  348. style: TextStyle(
  349. color: Color(0xff666666),
  350. fontSize: ScreenUtil().setSp(15),
  351. ),
  352. textAlign: TextAlign.start,
  353. maxLines: 1,
  354. overflow: TextOverflow.ellipsis,
  355. ),
  356. ),
  357. ],
  358. ),
  359. ),
  360. Container(
  361. margin: EdgeInsets.only(top: 6),
  362. child: Row(
  363. children: <Widget>[
  364. Container(
  365. padding: EdgeInsets.only(right: 5),
  366. child: Text(
  367. data.totalCost != null
  368. ? "¥${data.totalCost.toString()}"
  369. : '',
  370. style: TextStyle(
  371. color: Color(0xffFD0808),
  372. fontSize: ScreenUtil().setSp(15),
  373. ),
  374. textAlign: TextAlign.left,
  375. ),
  376. ),
  377. ],
  378. ),
  379. )
  380. ],
  381. ),
  382. ),
  383. )
  384. ],
  385. ),
  386. ),
  387. );
  388. }
  389. }