redbao_page.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:liftmanager/internal/bbs/model/coupon_model_page.dart';
  4. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  5. import 'package:liftmanager/internal/wode/presenter/red_list_presenter.dart';
  6. import 'package:liftmanager/mvp/base_page_state.dart';
  7. import 'package:liftmanager/widgets/app_bar.dart';
  8. import 'package:liftmanager/widgets/load_image.dart';
  9. import 'package:liftmanager/widgets/my_refresh_list.dart';
  10. import 'package:liftmanager/widgets/state_layout.dart';
  11. import 'package:provider/provider.dart';
  12. class RedbaoPage extends StatefulWidget {
  13. // QuestionList(this.index);
  14. // final String index;
  15. @override
  16. RedbaoPageState createState() => RedbaoPageState();
  17. }
  18. class RedbaoPageState extends BasePageState<RedbaoPage, RedtListPresenter>
  19. with AutomaticKeepAliveClientMixin {
  20. // NewsDetailItem item = NewsDetailItem();
  21. BaseListProvider<Records> provider = BaseListProvider<Records>();
  22. ScrollController _scrollController = new ScrollController();
  23. int _page = 1;
  24. @override
  25. void initState() {
  26. provider.setStateTypeNotNotify(StateType.loading);
  27. super.initState();
  28. _onRefresh();
  29. print(66666);
  30. }
  31. @override
  32. void dispose() {
  33. _scrollController.dispose();
  34. super.dispose();
  35. }
  36. getScenario(int type) {
  37. String str;
  38. if (type == 0) {
  39. str = "全场通用";
  40. } else if (type == 1) {
  41. str = "仅限出诊问诊服务";
  42. } else if (type == 2) {
  43. str = "仅限题库";
  44. } else if (type == 3) {
  45. str = "仅限视频";
  46. }
  47. return str;
  48. }
  49. @override
  50. Widget build(BuildContext context) {
  51. double width = MediaQuery.of(context).size.width;
  52. return ChangeNotifierProvider<BaseListProvider<Records>>(
  53. create: (_) => provider,
  54. child: Scaffold(
  55. resizeToAvoidBottomPadding: true,
  56. appBar: MyAppBar(centerTitle: "我的红包"),
  57. body: Container(
  58. // color: Color(0xFFF1F4FC),
  59. child: Column(
  60. crossAxisAlignment: CrossAxisAlignment.start,
  61. children: <Widget>[
  62. Expanded(
  63. flex: 1,
  64. child: Consumer<BaseListProvider<Records>>(
  65. builder: (_, provider, __) {
  66. return MyListView(
  67. key: Key('red_list'),
  68. itemCount: provider.list.length,
  69. stateType: provider.stateType,
  70. onRefresh: _onRefresh,
  71. loadMore: _loadMore,
  72. pageSize: 8,
  73. hasMore: provider.hasMore,
  74. itemBuilder: (_, index) {
  75. return Container(
  76. child: Column(
  77. children: <Widget>[
  78. Container(
  79. // padding: EdgeInsets.only(
  80. // left: ScreenUtil().setWidth(10),
  81. // right: ScreenUtil().setWidth(10),
  82. // top: ScreenUtil().setWidth(15)),
  83. child: InkWell(
  84. child: Container(
  85. // padding:
  86. // EdgeInsets.only(
  87. // left: ScreenUtil().setWidth(15),
  88. // right: ScreenUtil().setWidth(15),
  89. // top: ScreenUtil().setWidth(10),
  90. // bottom: ScreenUtil().setWidth(10)),
  91. child: Stack(
  92. children: [
  93. LoadAssetImage(
  94. // image: AssetImage(i['img']),
  95. 'img_hongbao_bg',
  96. width: width - 5,
  97. height: 140,
  98. fit: BoxFit.fill,
  99. // alignment: Alignment.centerLeft,
  100. ),
  101. Positioned(
  102. top: 20,
  103. left: 20,
  104. right: 20,
  105. child: Row(
  106. children: [
  107. LoadAssetImage(
  108. // image: AssetImage(i['img']),
  109. 'icon_hongbao',
  110. width: 30,
  111. height: 40,
  112. fit: BoxFit.cover,
  113. // ScreenUtil().setHeight(141),
  114. // // alignment: Alignment.centerLeft,
  115. ),
  116. SizedBox(
  117. width: 20,
  118. ),
  119. Column(
  120. crossAxisAlignment:
  121. CrossAxisAlignment.start,
  122. children: [
  123. Text(
  124. '会员专用红包',
  125. style: TextStyle(
  126. color:
  127. Color(0xff282828),
  128. fontWeight:
  129. FontWeight.bold,
  130. fontSize: 17),
  131. ),
  132. SizedBox(
  133. height: 6,
  134. ),
  135. Text('全场通用,支付立减',
  136. style: TextStyle(
  137. color:
  138. Color(0xff909090),
  139. fontSize: 13)),
  140. ],
  141. ),
  142. Expanded(child: Container()),
  143. RichText(
  144. text: TextSpan(
  145. text: '¥',
  146. style: TextStyle(
  147. color:
  148. Color(0xffF95046),
  149. fontSize: 18,
  150. fontWeight:
  151. FontWeight.bold),
  152. children: <TextSpan>[
  153. TextSpan(
  154. text: provider
  155. .list[index]
  156. .coupon
  157. .price
  158. .toString(),
  159. style: TextStyle(
  160. color: Color(
  161. 0xffF95046),
  162. fontSize: 40,
  163. fontWeight:
  164. FontWeight
  165. .bold)),
  166. ]))
  167. // Container(
  168. // alignment: Alignment.bottomLeft,
  169. // child: Row(
  170. // children: [
  171. // Container(
  172. // alignment: Alignment.bottomLeft,
  173. // height: 30,
  174. // child:
  175. // Text('¥',style: TextStyle(color: Color(0xffF95046)),),),
  176. // Text('10',style: TextStyle(color: Color(0xffF95046),fontSize: 40,fontWeight: FontWeight.bold)),
  177. // ],
  178. // ),
  179. // )
  180. ],
  181. )),
  182. // Positioned(
  183. // bottom: 25,
  184. // left: 30,
  185. // right: 30,
  186. // child: Row(
  187. // children: [
  188. // Text(
  189. // '4天后过期',
  190. // style: TextStyle(
  191. // color: Color(0xffF95046),
  192. // fontSize: 12),
  193. // ),
  194. // Expanded(child: Container()),
  195. // Text(
  196. // '有效时间:2020.10.30 11:59',
  197. // style: TextStyle(
  198. // color: Color(0xff909090),
  199. // fontSize: 12),
  200. // ),
  201. // ],
  202. // ))
  203. ],
  204. )
  205. // Row(
  206. // crossAxisAlignment:
  207. // CrossAxisAlignment.start,
  208. // children: <Widget>[
  209. // Container(
  210. // padding: EdgeInsets.only(
  211. // right:
  212. // ScreenUtil().setWidth(25),
  213. // left:
  214. // ScreenUtil().setWidth(10),
  215. // top: ScreenUtil()
  216. // .setWidth(15)),
  217. // child: Icon(
  218. // const IconData(0xe630,
  219. // fontFamily: "myfont"),
  220. // size: 60.0,
  221. // color: Color(0xffFE524C),
  222. // ),
  223. // ),
  224. // Column(
  225. // crossAxisAlignment:
  226. // CrossAxisAlignment.start,
  227. // children: <Widget>[
  228. // Text(
  229. // provider
  230. // .list[index].coupon.price
  231. // .toString(),
  232. // textAlign: TextAlign.left,
  233. // style: TextStyle(
  234. // fontSize:
  235. // ScreenUtil().setSp(26),
  236. // color: Color(0xff333333),
  237. // ),
  238. // ),
  239. // // Row(
  240. // // children: <Widget>[
  241. // // Text(
  242. // // DateUtils.instance
  243. // // .getFormartData(
  244. // // timeSamp: provider.list[index].coupon.createTime,
  245. // // format: "yyyy-MM-dd"),
  246. // // textAlign: TextAlign.left,
  247. // // style: TextStyle(
  248. // // fontSize:ScreenUtil().setSp(14),
  249. // // color:Color(0xff999999),
  250. // // ),
  251. // // ),
  252. // // Text(
  253. // // "至",
  254. // // textAlign: TextAlign.left,
  255. // // style: TextStyle(
  256. // // fontSize:ScreenUtil().setSp(14),
  257. // // color:Color(0xff999999),
  258. // // ),
  259. // // ),
  260. // // Text(
  261. // // DateUtils.instance
  262. // // .getFormartData(
  263. // // timeSamp: provider.list[index].coupon.updateTime,
  264. // // format: "yyyy-MM-dd"),
  265. // // textAlign: TextAlign.left,
  266. // // style: TextStyle(
  267. // // fontSize:ScreenUtil().setSp(14),
  268. // // color:Color(0xff999999),
  269. // // ),
  270. // // ),
  271. // // ],
  272. // // ),
  273. // SizedBox(height: 8),
  274. // Container(
  275. // width: ScreenUtil()
  276. // .setWidth(200),
  277. // height: 0.5,
  278. // color: Color(0xffeeeeee),
  279. // child: null,
  280. // ),
  281. // SizedBox(height: 5),
  282. // Text(
  283. // getScenario(provider
  284. // .list[index]
  285. // .coupon
  286. // .scenario),
  287. // textAlign: TextAlign.left,
  288. // style: TextStyle(
  289. // fontSize:
  290. // ScreenUtil().setSp(14),
  291. // color: Color(0xff999999),
  292. // ),
  293. // ),
  294. // ],
  295. // ),
  296. // ]),
  297. ),
  298. onTap: () {},
  299. )
  300. // MyCard(
  301. // child:
  302. // ),
  303. )
  304. ],
  305. ),
  306. );
  307. },
  308. );
  309. }))
  310. ],
  311. ),
  312. ),
  313. ));
  314. }
  315. Future _onRefresh() async {
  316. _page = 1;
  317. await presenter.getRedList(_page);
  318. }
  319. Future _loadMore() async {
  320. _page++;
  321. await presenter.getRedList(_page);
  322. }
  323. @override
  324. RedtListPresenter createPresenter() {
  325. return RedtListPresenter();
  326. }
  327. bool get wantKeepAlive => true;
  328. }