redbao_page.dart 18 KB

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