search_index.dart 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  5. import 'package:liftmanager/internal/bbs/model/mix_model.dart';
  6. import 'package:liftmanager/internal/bbs/presenter/mix_search_list_presenter.dart';
  7. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  8. import 'package:liftmanager/internal/wode/wode_router.dart';
  9. import 'package:liftmanager/mvp/base_page_state.dart';
  10. import 'package:liftmanager/res/resources.dart';
  11. import 'package:liftmanager/routers/fluro_navigator.dart';
  12. import 'package:liftmanager/utils/time_format.dart';
  13. import 'package:liftmanager/widgets/app_bar.dart';
  14. import 'package:liftmanager/widgets/load_image.dart';
  15. import 'package:liftmanager/widgets/my_refresh_list.dart';
  16. import 'package:liftmanager/widgets/state_layout.dart';
  17. import 'package:provider/provider.dart';
  18. class SearchIndex extends StatefulWidget {
  19. SearchIndex(this.type,this.text);
  20. final String type;
  21. final String text;
  22. @override
  23. SearchIndexState createState() => SearchIndexState();
  24. }
  25. class SearchIndexState extends BasePageState<SearchIndex,MixListPresenter> {
  26. // NewsDetailItem item = NewsDetailItem();
  27. BaseListProvider<Records> provider = BaseListProvider<Records>();
  28. int _page = 1;
  29. @override
  30. void initState() {
  31. provider.setStateTypeNotNotify(StateType.loading);
  32. super.initState();
  33. _onRefresh();
  34. print(widget.text);
  35. print(66666);
  36. }
  37. @override
  38. Widget build(BuildContext context) {
  39. double width = MediaQuery.of(context).size.width;
  40. return Scaffold(
  41. appBar: MyAppBar(
  42. centerTitle: "搜索列表",
  43. ),
  44. body:Container(
  45. child: Stack(
  46. children: <Widget>[
  47. Container(
  48. child: ChangeNotifierProvider<BaseListProvider<Records>>(
  49. create: (_) => provider,
  50. child: Column(
  51. children: <Widget>[
  52. Expanded(
  53. flex: 1,
  54. child: Consumer<BaseListProvider<Records>>(
  55. builder: (_, provider, __) {
  56. return MyListView(
  57. key: Key('mix_search_list'),
  58. itemCount: provider.list.length,
  59. stateType: provider.stateType,
  60. onRefresh: _onRefresh,
  61. loadMore: _loadMore,
  62. hasMore: provider.hasMore,
  63. itemBuilder: (_, index) {
  64. return Column(
  65. children: <Widget>[
  66. widget.type == "1"?
  67. GestureDetector(
  68. child: provider.list[index]!=null?Container(
  69. padding: EdgeInsets.only(
  70. left: ScreenUtil().setWidth(15),
  71. right: ScreenUtil().setWidth(15),
  72. top: ScreenUtil().setHeight(10),
  73. bottom: ScreenUtil().setHeight(10)),
  74. decoration: BoxDecoration(
  75. border: Border(
  76. bottom: BorderSide(
  77. width: 0.5, color: Colours.line),
  78. ),
  79. ),
  80. child:
  81. Column(
  82. crossAxisAlignment: CrossAxisAlignment.start,
  83. children: <Widget>[
  84. Text(
  85. "[${provider.list[index].brandName}]${provider.list[index].title}",
  86. textAlign: TextAlign.left,
  87. style: TextStyle(
  88. fontSize: ScreenUtil().setSp(15)),
  89. ),
  90. Container(
  91. padding: EdgeInsets.only(
  92. top: ScreenUtil().setHeight(10),
  93. bottom: ScreenUtil().setHeight(10)),
  94. child: Row(
  95. children: <Widget>[
  96. ClipRRect(
  97. borderRadius:
  98. BorderRadius.circular(
  99. ScreenUtil()
  100. .setWidth(18)),
  101. child: Container(
  102. child: LoadNetworkImage(
  103. provider.list[index].avatarUrl,
  104. // fit: BoxFit.fitWidth,
  105. width:
  106. ScreenUtil().setWidth(34),
  107. height:
  108. ScreenUtil().setWidth(34),
  109. ),
  110. )),
  111. Container(
  112. padding: EdgeInsets.only(
  113. left:
  114. ScreenUtil().setWidth(10)),
  115. child: Column(
  116. crossAxisAlignment:
  117. CrossAxisAlignment.start,
  118. children: <Widget>[
  119. Text(
  120. provider.list[index].userName??"",
  121. style: TextStyle(
  122. fontSize: ScreenUtil()
  123. .setSp(14),
  124. color: Color(0xff333333)),
  125. ),
  126. Text(
  127. DateUtils.instance
  128. .getFormartData(
  129. timeSamp: provider
  130. .list[index]
  131. .createTime,
  132. format: "yyyy-MM-dd"),
  133. style: TextStyle(
  134. fontSize: ScreenUtil()
  135. .setSp(12),
  136. color: Color(0xffaaaaaa)),
  137. ),
  138. ],
  139. ),
  140. )
  141. ],
  142. ),
  143. ),
  144. Text(
  145. provider.list[index].expression??"",
  146. textAlign: TextAlign.left,
  147. style: TextStyle(
  148. color: Color(0xff666666),
  149. fontSize: ScreenUtil().setSp(14),
  150. ),
  151. maxLines: 2,
  152. overflow: TextOverflow.ellipsis,
  153. ),
  154. Container(
  155. padding: EdgeInsets.only(
  156. top: ScreenUtil().setHeight(5),
  157. bottom: ScreenUtil().setHeight(5)),
  158. child: Row(
  159. mainAxisAlignment:
  160. MainAxisAlignment.start,
  161. children: provider.list[index].imgs !=
  162. null &&
  163. provider.list[index].imgs
  164. .isNotEmpty
  165. ? List<Widget>.from(provider
  166. .list[index].imgs
  167. .split(",")
  168. .asMap().keys.map((subindex) {
  169. // print(item);
  170. return Container(
  171. padding:subindex<provider
  172. .list[index].imgs.split(",").length-1?EdgeInsets.only(right:6):EdgeInsets.only(right:0),
  173. // color:Colors.red,
  174. // decoration: BoxDecoration(
  175. // borderRadius: BorderRadius.circular(20.0),
  176. // ),
  177. child: ClipRRect(
  178. borderRadius:
  179. BorderRadius.circular(
  180. 10),
  181. child: LoadNetworkImage(
  182. provider
  183. .list[index].imgs.split(",")[subindex],
  184. // height: width/375*75,
  185. height: ScreenUtil()
  186. .setWidth(80),
  187. width: ScreenUtil()
  188. .setWidth(110),
  189. ),
  190. ),
  191. );
  192. }).toList())
  193. : <Widget>[]),
  194. ),
  195. Text(
  196. "${provider.list[index].likeNum.toString()}人赞",
  197. textAlign: TextAlign.right,
  198. style: TextStyle(
  199. color: Color(0xff999999),
  200. fontSize: ScreenUtil().setSp(14),
  201. ),
  202. )
  203. ]),
  204. ):Center(child: Text("加载中..."),),
  205. onTap: () {
  206. // print(item);
  207. NavigatorUtils.push(context,
  208. "${BbsRouter.questionDetail}?id=${provider.list[index].id.toString()}");
  209. },
  210. ):Container(child:null),
  211. widget.type == "2"?
  212. GestureDetector(
  213. child: provider.list[index]!=null?
  214. Container(
  215. padding: EdgeInsets.only(
  216. left: ScreenUtil().setWidth(15),
  217. // right: ScreenUtil().setWidth(15),
  218. top: ScreenUtil().setHeight(10),
  219. bottom: ScreenUtil().setHeight(10)),
  220. decoration: BoxDecoration(
  221. border: Border(
  222. bottom: BorderSide(
  223. width: 0.5, color: Colours.line),
  224. ),
  225. ),
  226. child:
  227. Row(
  228. crossAxisAlignment: CrossAxisAlignment.start,
  229. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  230. children: <Widget>[
  231. Container(
  232. height: width*0.24,
  233. child: Column(
  234. crossAxisAlignment: CrossAxisAlignment.start,
  235. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  236. children: <Widget>[
  237. Container(
  238. width:width*0.5,
  239. child: Text(
  240. "${provider.list[index].title??""}",
  241. style: TextStyle(
  242. fontWeight: FontWeight.w600,
  243. color: Color(0xff222222),
  244. fontSize: ScreenUtil().setSp(17)),
  245. textAlign: TextAlign.start,
  246. maxLines: 2,
  247. overflow: TextOverflow.ellipsis,
  248. ),
  249. ),
  250. Row(
  251. children: <Widget>[
  252. Container(
  253. width:width*0.18,
  254. child: Text(
  255. "${provider.list[index].brandName??""}",
  256. style: TextStyle(
  257. color: Color(0xff999999),
  258. fontSize: ScreenUtil().setSp(14)),
  259. textAlign: TextAlign.start,
  260. maxLines: 1,
  261. overflow: TextOverflow.ellipsis,
  262. ),
  263. ),
  264. SizedBox(
  265. width:5
  266. ),
  267. Text(
  268. "${provider.list[index].likeNum??"0"}人点赞",
  269. style: TextStyle(
  270. color: Color(0xff999999),
  271. fontSize: ScreenUtil().setSp(14)),
  272. textAlign: TextAlign.start,
  273. ),
  274. ],
  275. )
  276. ]),
  277. ),
  278. Container(
  279. padding: EdgeInsets.only(right:10),
  280. child: Stack(
  281. children: <Widget>[
  282. ClipRRect(
  283. borderRadius:
  284. BorderRadius.circular(1),
  285. child: Container(
  286. child: LoadNetworkImage(
  287. // imgFontUrl +
  288. // provider.list[index].cover,
  289. provider.list[index].cover,
  290. width: width*0.38,
  291. height: width*0.24,
  292. ),
  293. ),
  294. ),
  295. Positioned(
  296. left: width*0.17,
  297. top: width*0.08,
  298. child: Icon(
  299. IconData(0xe607,
  300. fontFamily: "myfont"),
  301. size: 26.0,
  302. color: Colors.white,
  303. ),
  304. )
  305. ],
  306. )),
  307. ],
  308. )
  309. )
  310. :Center(child:Text("加载中...")),
  311. onTap: () {
  312. NavigatorUtils.push(context,
  313. "${WodeRouter.videoDetail}?id=${provider.list[index].id.toString()}");
  314. },
  315. )
  316. :Container(child:null),
  317. widget.type == "4"?
  318. GestureDetector(
  319. child: provider.list[index]!=null?Container(
  320. padding: EdgeInsets.only(
  321. left: ScreenUtil().setWidth(15),
  322. right: ScreenUtil().setWidth(15),
  323. top: ScreenUtil().setHeight(10),
  324. bottom: ScreenUtil().setHeight(10)),
  325. decoration: BoxDecoration(
  326. border: Border(
  327. bottom: BorderSide(
  328. width: 0.5, color: Colours.line),
  329. ),
  330. ),
  331. child: Column(
  332. // crossAxisAlignment: CrossAxisAlignment.start,
  333. children: <Widget>[
  334. Container(
  335. padding: EdgeInsets.only(
  336. bottom: ScreenUtil().setHeight(5)),
  337. child: Row(
  338. mainAxisAlignment:
  339. MainAxisAlignment.spaceBetween,
  340. children: <Widget>[
  341. Text(
  342. provider.list[index].job ?? '',
  343. textAlign: TextAlign.left,
  344. style: TextStyle(
  345. fontSize:
  346. ScreenUtil().setSp(17),
  347. color: Color(0xff333333),
  348. ),
  349. ),
  350. Text(
  351. // 'jiage',
  352. "¥" +
  353. provider
  354. .list[index].lowerSalary
  355. .toString() +
  356. "-" +
  357. provider
  358. .list[index].upperSalary
  359. .toString(),
  360. textAlign: TextAlign.left,
  361. style: TextStyle(
  362. fontSize:
  363. ScreenUtil().setSp(17),
  364. color: Color(0xffff0000),
  365. ),
  366. ),
  367. ],
  368. ),
  369. ),
  370. Row(
  371. mainAxisAlignment:
  372. MainAxisAlignment.spaceBetween,
  373. children: <Widget>[
  374. Text(
  375. provider.list[index].company?.name ??
  376. '',
  377. textAlign: TextAlign.left,
  378. style: TextStyle(
  379. fontSize: ScreenUtil().setSp(14),
  380. color: Color(0xff999999),
  381. ),
  382. ),
  383. Text(
  384. provider.list[index].address ?? '',
  385. textAlign: TextAlign.left,
  386. style: TextStyle(
  387. fontSize: ScreenUtil().setSp(14),
  388. color: Color(0xff999999),
  389. ),
  390. ),
  391. ],
  392. ),
  393. Row(
  394. mainAxisAlignment:
  395. MainAxisAlignment.spaceBetween,
  396. children: <Widget>[
  397. Container(
  398. width: width * 0.65,
  399. child: Text(
  400. provider.list[index].info ?? '',
  401. textAlign: TextAlign.left,
  402. style: TextStyle(
  403. fontSize:
  404. ScreenUtil().setSp(14),
  405. color: Color(0xff999999),
  406. ),
  407. overflow: TextOverflow.ellipsis,
  408. ),
  409. ),
  410. Text(
  411. DateUtils.instance.getFormartData(
  412. timeSamp: provider
  413. .list[index].createTime,
  414. format: "yyyy-MM-dd"),
  415. textAlign: TextAlign.left,
  416. style: TextStyle(
  417. fontSize: ScreenUtil().setSp(14),
  418. color: Color(0xff999999),
  419. ),
  420. ),
  421. ],
  422. ),
  423. ]),
  424. ):Center(child: Text("加载中..."),),
  425. onTap: () {
  426. NavigatorUtils.push(context,
  427. "${BbsRouter.positionDetail}?id=${provider.list[index].id.toString()}");
  428. },
  429. )
  430. :Container(child:null),
  431. widget.type == "3"?
  432. InkWell(
  433. child: provider.list[index]!=null?Container(
  434. padding: EdgeInsets.only(
  435. left: ScreenUtil().setWidth(15),
  436. right: ScreenUtil().setWidth(15),
  437. top: ScreenUtil().setHeight(10),
  438. bottom: ScreenUtil().setHeight(10)),
  439. decoration: BoxDecoration(
  440. border: Border(
  441. bottom: BorderSide(
  442. width: 0.5, color: Colours.line),
  443. ),
  444. ),
  445. child: Row(
  446. crossAxisAlignment: CrossAxisAlignment.start,
  447. children: <Widget>[
  448. ClipRRect(
  449. borderRadius: BorderRadius.circular(5),
  450. child: Container(
  451. padding: EdgeInsets.only(
  452. right: ScreenUtil().setWidth(10)),
  453. child: LoadNetworkImage(
  454. provider.list[index].imgs,
  455. width: ScreenUtil().setWidth(90),
  456. height: ScreenUtil().setWidth(90),
  457. ),
  458. ),
  459. ),
  460. Column(
  461. crossAxisAlignment:
  462. CrossAxisAlignment.start,
  463. children: <Widget>[
  464. Text(
  465. provider.list[index].name??"",
  466. textAlign: TextAlign.left,
  467. style: TextStyle(
  468. fontSize: ScreenUtil().setSp(15),
  469. color: Color(0xff333333),
  470. ),
  471. ),
  472. Text(
  473. provider.list[index].brandId
  474. .toString(),
  475. textAlign: TextAlign.left,
  476. style: TextStyle(
  477. fontSize: ScreenUtil().setSp(14),
  478. color: Color(0xff666666),
  479. ),
  480. ),
  481. Text(
  482. "供应商:${provider.list[index].manufacturer}",
  483. textAlign: TextAlign.left,
  484. style: TextStyle(
  485. fontSize: ScreenUtil().setSp(14),
  486. color: Color(0xff666666),
  487. ),
  488. ),
  489. Text(
  490. "Tel:${provider.list[index].telephone}",
  491. textAlign: TextAlign.left,
  492. style: TextStyle(
  493. fontSize: ScreenUtil().setSp(14),
  494. color: Color(0xff666666),
  495. ),
  496. ),
  497. ],
  498. ),
  499. ]),
  500. ):Center(child: Text("加载中..."),),
  501. onTap: () {
  502. print(index);
  503. NavigatorUtils.push(context,
  504. "${BbsRouter.productDetail}?id=${provider.list[index].id.toString()}");
  505. },
  506. )
  507. :Container(child:null),
  508. ],
  509. );
  510. },
  511. );
  512. }))
  513. ],
  514. )
  515. ))
  516. ],
  517. )
  518. )
  519. );
  520. }
  521. Future _onRefresh() async {
  522. _page = 1;
  523. if(widget.type=="1"){
  524. await presenter.getQuestionList(_page,widget.text);
  525. }
  526. else if(widget.type=="2"){
  527. await presenter.getVideoList(_page,widget.text);
  528. }
  529. else if(widget.type=="3"){
  530. await presenter.getShopList(_page,widget.text);
  531. }
  532. else if(widget.type=="4"){
  533. await presenter.getPositionList(_page,widget.text);
  534. }
  535. }
  536. Future _loadMore() async {
  537. _page++;
  538. if(widget.type=="1"){
  539. await presenter.getQuestionList(_page,widget.text);
  540. }
  541. else if(widget.type=="2"){
  542. await presenter.getVideoList(_page,widget.text);
  543. }
  544. else if(widget.type=="3"){
  545. await presenter.getShopList(_page,widget.text);
  546. }
  547. else if(widget.type=="4"){
  548. await presenter.getPositionList(_page,widget.text);
  549. }
  550. }
  551. @override
  552. MixListPresenter createPresenter() {
  553. return MixListPresenter();
  554. }
  555. }