search_index.dart 31 KB

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