order_page.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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 ChangeNotifierProvider<BaseListProvider<LiftCasesDetailModel>>(
  51. create: (_) => provider,
  52. child: Scaffold(
  53. appBar: MyAppBar(
  54. centerTitle: "我的订单",
  55. isFun: true,
  56. fun: () {
  57. Navigator.popUntil(context, ModalRoute.withName('/home'));
  58. },
  59. actions: <Widget>[],
  60. ),
  61. body: Container(
  62. child: Stack(
  63. children: <Widget>[
  64. Container(
  65. padding: EdgeInsets.only(top: ScreenUtil().setWidth(44)),
  66. child: Column(
  67. children: <Widget>[
  68. Expanded(
  69. flex: 1,
  70. child: Consumer<BaseListProvider<LiftCasesDetailModel>>(
  71. builder: (_, provider, __) {
  72. return MyListView(
  73. key: Key('order_list'),
  74. itemCount: provider.list.length,
  75. stateType: provider.stateType,
  76. onRefresh: _onRefresh,
  77. loadMore: _loadMore,
  78. hasMore: provider.hasMore,
  79. itemBuilder: (_, index) {
  80. return OrderListItemWidget(
  81. data: provider.list[index],
  82. typeValue:OrderConstant.userOrderType[widget.tabCheckIndex]['value']
  83. );
  84. },
  85. );
  86. },
  87. ),
  88. )
  89. ],
  90. ),
  91. ),
  92. Positioned(
  93. child: Container(
  94. padding: EdgeInsets.only(bottom: 5),
  95. // color:Color(0xffFAF7FA),
  96. decoration: BoxDecoration(
  97. border: Border(
  98. bottom: BorderSide(width: 0.5, color: Color(0xffeeeeee)),
  99. ),
  100. // color: Color(0xff9FD1FE),
  101. ),
  102. child: Row(
  103. mainAxisAlignment: MainAxisAlignment.spaceAround,
  104. children: OrderConstant.userOrderType.asMap().keys.map((i) {
  105. return TabThis(
  106. item: OrderConstant.userOrderType[i]['name'],
  107. tabIndex: i,
  108. checkIndex: widget.tabCheckIndex,
  109. fun: (index) {
  110. setState(() {
  111. widget.tabCheckIndex = index;
  112. provider.list.clear();
  113. _onRefresh();
  114. });
  115. },
  116. );
  117. }).toList(),
  118. ),
  119. ),
  120. ),
  121. ],
  122. ),
  123. ),
  124. ),
  125. );
  126. }
  127. Future _onRefresh() async {
  128. _page = 1;
  129. await presenter.getOrderList(
  130. _page, OrderConstant.userOrderType[widget.tabCheckIndex]['value']);
  131. }
  132. Future _loadMore() async {
  133. _page++;
  134. await presenter.getOrderList(
  135. _page, OrderConstant.userOrderType[widget.tabCheckIndex]['value']);
  136. }
  137. @override
  138. OrderListPresenterSeconds createPresenter() {
  139. return OrderListPresenterSeconds();
  140. }
  141. }
  142. class TabThis extends StatelessWidget {
  143. TabThis({Key key, this.item, this.tabIndex, this.fun, this.checkIndex})
  144. : super(key: key);
  145. String item;
  146. int tabIndex;
  147. int checkIndex;
  148. Function fun;
  149. @override
  150. Widget build(BuildContext context) {
  151. return Container(
  152. padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  153. child: Container(
  154. child: Row(
  155. mainAxisAlignment: MainAxisAlignment.center,
  156. children: <Widget>[
  157. GestureDetector(
  158. onTap: () {
  159. fun(tabIndex);
  160. },
  161. child: Container(
  162. padding: EdgeInsets.only(bottom: 6),
  163. decoration: BoxDecoration(
  164. border: Border(
  165. bottom: BorderSide(
  166. width: 2,
  167. color: checkIndex == tabIndex
  168. ? Color(0xff02A0FD)
  169. : Colors.transparent),
  170. ),
  171. // color: Color(0xff9FD1FE),
  172. ),
  173. child: Text(
  174. item,
  175. style: TextStyle(
  176. color: checkIndex == tabIndex
  177. ? Color(0xff02A0FD)
  178. : Color(0xff666666),
  179. fontSize: ScreenUtil().setSp(14),
  180. ),
  181. textAlign: TextAlign.center,
  182. ),
  183. ),
  184. )
  185. ],
  186. ),
  187. ),
  188. );
  189. }
  190. }
  191. class OrderListItemWidget extends StatelessWidget {
  192. OrderListItemWidget({Key key, this.data,this.typeValue}) : super(key: key);
  193. LiftCasesDetailModel data;
  194. String typeValue;
  195. getTypeValue(liftCaseAppealStatus){
  196. String str;
  197. if(liftCaseAppealStatus == 1){
  198. str = "申诉中";
  199. }else if (liftCaseAppealStatus == 2){
  200. str = "申诉驳回";
  201. }else if (liftCaseAppealStatus == 3){
  202. str = "申诉已结束";
  203. }
  204. else if (liftCaseAppealStatus == 4){
  205. str = "申诉已退款";
  206. }
  207. return str;
  208. }
  209. @override
  210. Widget build(BuildContext context) {
  211. double width = MediaQuery.of(context).size.width;
  212. return Container(
  213. padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
  214. width: width,
  215. // height: 100,
  216. child: GestureDetector(
  217. onTap: () {
  218. NavigatorUtils.push(
  219. context, "${WodeRouter.orderDetail}?id=${data.id}");
  220. },
  221. child: Row(
  222. crossAxisAlignment: CrossAxisAlignment.start,
  223. // mainAxisSize: MainAxisSize.min,
  224. children: <Widget>[
  225. Container(
  226. margin: EdgeInsets.only(
  227. left: ScreenUtil().setWidth(10),
  228. right: ScreenUtil().setWidth(10),
  229. top: ScreenUtil().setWidth(5)),
  230. decoration: BoxDecoration(
  231. borderRadius: BorderRadius.circular(ScreenUtil().setWidth(22)),
  232. ),
  233. child: LoadNetworkImage(
  234. data.avatarUrl,
  235. width: ScreenUtil().setWidth(43),
  236. height: ScreenUtil().setWidth(43),
  237. // alignment: Alignment.centerLeft,
  238. ),
  239. ),
  240. Expanded(
  241. // flex: 1,
  242. // fit: FlexFit.loose,
  243. child: Container(
  244. padding: EdgeInsets.only(right: ScreenUtil().setWidth(15)),
  245. child: Column(
  246. children: <Widget>[
  247. Container(
  248. child: Row(
  249. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  250. children: <Widget>[
  251. Row(
  252. crossAxisAlignment: CrossAxisAlignment.center,
  253. children: <Widget>[
  254. Text(
  255. data.name??"",
  256. style: TextStyle(
  257. color: Color(0xff333333),
  258. fontSize: ScreenUtil().setSp(17)),
  259. textAlign: TextAlign.start,
  260. ),
  261. Container(
  262. padding: EdgeInsets.only(left: 5),
  263. child: Text(
  264. data.dataTable == 1 ? '问诊服务' : '出诊服务',
  265. style: TextStyle(
  266. color: Color(0xff0288FF),
  267. fontSize: ScreenUtil().setSp(14),
  268. ),
  269. textAlign: TextAlign.start,
  270. ),
  271. )
  272. ],
  273. ),
  274. typeValue != "TO_APPEAL" ?Container(
  275. child: Text(
  276. OrderConstant.getStatusName(data.statuz, data.dataTable, arrivedFlag: data.arrivedFlag, userType: 'USER'),
  277. style: TextStyle(
  278. color: [].indexOf(data.statuz) == -1
  279. ? Color(0xff0288FF)
  280. : Color(0xffF84203),
  281. fontSize: ScreenUtil().setSp(14),
  282. ),
  283. textAlign: TextAlign.end,
  284. ),
  285. ):Container(
  286. child: Text(
  287. data.liftCaseAppealStatus!=null? getTypeValue(data.liftCaseAppealStatus):"",
  288. style: TextStyle(
  289. color: Color(0xff0288FF),
  290. fontSize: ScreenUtil().setSp(14),
  291. ),
  292. textAlign: TextAlign.end,
  293. ),
  294. )
  295. ],
  296. ),
  297. ),
  298. Container(
  299. child: Row(
  300. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  301. children: <Widget>[
  302. Row(
  303. crossAxisAlignment: CrossAxisAlignment.center,
  304. children: <Widget>[
  305. Text(
  306. data.createTime != null
  307. ? DateUtils.instance.getFormartData(
  308. timeSamp: data.createTime,
  309. format: "yyyy-MM-dd")
  310. : '',
  311. style: TextStyle(
  312. color: Color(0xff999999),
  313. fontSize: ScreenUtil().setSp(13),
  314. ),
  315. textAlign: TextAlign.start,
  316. ),
  317. Container(
  318. padding: EdgeInsets.only(left: 5),
  319. child: Text(
  320. data.brandName ?? '',
  321. style: TextStyle(
  322. color: Color(0xff999999),
  323. fontSize: ScreenUtil().setSp(13),
  324. ),
  325. textAlign: TextAlign.start,
  326. ),
  327. )
  328. ],
  329. ),
  330. ],
  331. ),
  332. ),
  333. Container(
  334. // margin: EdgeInsets.only(top: 6),
  335. child: Row(
  336. children: <Widget>[
  337. Container(
  338. width: 260,
  339. child: Text(
  340. data.expression ?? '',
  341. style: TextStyle(
  342. color: Color(0xff666666),
  343. fontSize: ScreenUtil().setSp(15),
  344. ),
  345. textAlign: TextAlign.start,
  346. maxLines: 1,
  347. overflow: TextOverflow.ellipsis,
  348. ),
  349. ),
  350. ],
  351. ),
  352. ),
  353. Container(
  354. margin: EdgeInsets.only(top: 6),
  355. child: Row(
  356. children: <Widget>[
  357. Container(
  358. padding: EdgeInsets.only(right: 5),
  359. child: Text(
  360. data.totalCost != null
  361. ? "¥${data.totalCost.toString()}"
  362. : '',
  363. style: TextStyle(
  364. color: Color(0xffFD0808),
  365. fontSize: ScreenUtil().setSp(15),
  366. ),
  367. textAlign: TextAlign.left,
  368. ),
  369. ),
  370. ],
  371. ),
  372. )
  373. ],
  374. ),
  375. ),
  376. )
  377. ],
  378. ),
  379. ),
  380. );
  381. }
  382. }