gang_page.dart 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  1. import 'dart:convert';
  2. import 'package:bbyyy/beans/my_shop_bean_entity.dart';
  3. import 'package:bbyyy/beans/store_bean_entity.dart';
  4. import 'package:bbyyy/https/MyDio.dart';
  5. import 'package:bbyyy/https/url.dart';
  6. import 'package:bbyyy/my_tools/const.dart';
  7. import 'package:bbyyy/my_tools/dims.dart';
  8. import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
  9. import 'package:bbyyy/my_tools/event_bus.dart';
  10. import 'package:bbyyy/my_tools/my_colors.dart';
  11. import 'package:bbyyy/my_tools/my_cookie.dart';
  12. import 'package:bbyyy/my_tools/my_tools.dart';
  13. import 'package:bbyyy/my_tools/my_views.dart';
  14. import 'package:bbyyy/paegs/gang_page/create_a_gang_page/create_a_gang_page.dart';
  15. import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_in_page.dart';
  16. import 'package:bbyyy/paegs/gang_page/join_the_gang_page/join_the_gang_page.dart';
  17. import 'package:bbyyy/paegs/gang_page/query_gang_page/query_gang_page.dart';
  18. import 'package:bbyyy/paegs/mine_page/order_page/order_page.dart';
  19. import 'package:flutter/cupertino.dart';
  20. import 'package:flutter/material.dart';
  21. import 'package:flutter_svg/svg.dart';
  22. import 'package:lpinyin/lpinyin.dart';
  23. import 'package:pull_to_refresh/pull_to_refresh.dart';
  24. import 'application_page/application_page.dart';
  25. class GangPage extends StatefulWidget {
  26. @override
  27. _GangPageState createState() => _GangPageState();
  28. }
  29. class _GangPageState extends State<GangPage>
  30. with AutomaticKeepAliveClientMixin {
  31. List<PopupMenuItem> popItems = [];
  32. List<MyShopBeanDataData> data = [];
  33. List<MyShopBeanDataData> applications = [];
  34. int page = 1;
  35. RefreshController controller = RefreshController(initialRefresh: true);
  36. bool needRE = false;
  37. int sIndex = 0;
  38. @override
  39. void initState() {
  40. // TODO: implement initState
  41. super.initState();
  42. EventBus().on('needRE', (arg) {
  43. print(arg);
  44. needRE = arg;
  45. });
  46. if (!MyCookie().underReview)
  47. popItems.add(PopupMenuItem(
  48. child: Text(
  49. '创建货帮',
  50. style: TextStyle(color: MyColors.c666666, fontSize: 14),
  51. ),
  52. value: '创建货帮',
  53. ));
  54. popItems.add(PopupMenuItem(
  55. child: Text(
  56. '加入货帮',
  57. style: TextStyle(color: MyColors.c666666, fontSize: 14),
  58. ),
  59. value: '加入货帮',
  60. ));
  61. }
  62. @override
  63. void dispose() {
  64. // TODO: implement dispose
  65. super.dispose();
  66. EventBus().off('needRE');
  67. }
  68. @override
  69. Widget build(BuildContext context) {
  70. return Scaffold(
  71. body: Stack(
  72. children: [
  73. appBar(context),
  74. Container(
  75. margin:
  76. EdgeInsets.only(top: MediaQuery.of(context).padding.top + 50),
  77. decoration: BoxDecoration(
  78. color: Colors.white,
  79. borderRadius: BorderRadius.only(
  80. topLeft: Radius.circular(16),
  81. topRight: Radius.circular(16))),
  82. child: SmartRefresher(
  83. controller: controller,
  84. onRefresh: onRefresh,
  85. onLoading: onLoading,
  86. enablePullDown: true,
  87. enablePullUp: false,
  88. child: ListView.builder(
  89. padding: EdgeInsets.only(right: 20),
  90. itemBuilder: (c, index) {
  91. return getGangItem(data[index]);
  92. },
  93. itemCount: data.length,
  94. ),
  95. ),
  96. )
  97. ],
  98. ),
  99. );
  100. }
  101. Container appBar(BuildContext context) {
  102. return Container(
  103. decoration: BoxDecoration(
  104. gradient: LinearGradient(
  105. colors: MyColors.lg,
  106. ),
  107. ),
  108. height: 152,
  109. child: SafeArea(
  110. bottom: false,
  111. child: Stack(
  112. children: [
  113. Container(
  114. height: 50,
  115. child: Row(
  116. children: [
  117. GestureDetector(
  118. onTap: () {
  119. setState(() {
  120. sIndex = 0;
  121. controller.requestRefresh();
  122. });
  123. },
  124. child: Text(
  125. '货帮',
  126. style: TextStyle(
  127. color: Colors.white,
  128. fontSize: sIndex == 0 ? 16 : 15,
  129. fontWeight: sIndex == 0
  130. ? FontWeight.bold
  131. : FontWeight.normal),
  132. ),
  133. ),
  134. Container(
  135. width: 56,
  136. ),
  137. GestureDetector(
  138. onTap: () {
  139. setState(() {
  140. sIndex = 1;
  141. controller.requestRefresh();
  142. });
  143. },
  144. child: Text(
  145. '关注',
  146. style: TextStyle(
  147. color: Colors.white,
  148. fontSize: sIndex == 1 ? 16 : 15,
  149. fontWeight: sIndex == 1
  150. ? FontWeight.bold
  151. : FontWeight.normal),
  152. ),
  153. ),
  154. ],
  155. mainAxisAlignment: MainAxisAlignment.center,
  156. ),
  157. alignment: Alignment.center,
  158. ),
  159. Row(
  160. children: [
  161. GestureDetector(
  162. onTap: () {
  163. MyTools().toPage(context, QueryGangPage(), (then) {});
  164. },
  165. behavior: HitTestBehavior.translucent,
  166. child: Container(
  167. child: SvgPicture.asset(
  168. 'images/svg/搜索.svg',
  169. color: Colors.white,
  170. ),
  171. width: 50,
  172. height: 50,
  173. padding: EdgeInsets.all(15),
  174. ),
  175. ),
  176. Container(
  177. height: 50,
  178. child: PopupMenuButton(
  179. itemBuilder: (BuildContext context) {
  180. return popItems;
  181. },
  182. onSelected: (v) {
  183. if (v == '加入货帮') {
  184. MyTools().toPage(context, JoinTheGangPage(), (then) {
  185. controller.requestRefresh();
  186. });
  187. } else if (v == '创建货帮') {
  188. MyTools().toPage(context, CreateAGangPage(), (then) {
  189. controller.requestRefresh();
  190. });
  191. }
  192. },
  193. child: Container(
  194. padding: EdgeInsets.all(8),
  195. margin: EdgeInsets.only(right: 6),
  196. child: SvgPicture.asset('images/svg/添加.svg'),
  197. ),
  198. ),
  199. alignment: Alignment.centerRight,
  200. ),
  201. ],
  202. mainAxisAlignment: MainAxisAlignment.end,
  203. )
  204. ],
  205. alignment: Alignment.topCenter,
  206. ),
  207. ),
  208. alignment: Alignment.topCenter,
  209. );
  210. }
  211. Widget getGangItem(MyShopBeanDataData data) {
  212. if (data.shopPic == null) {
  213. return GestureDetector(
  214. onTap: () {
  215. MyTools().toPage(context, ApplicationPage(), (then) {
  216. controller.requestRefresh();
  217. });
  218. },
  219. behavior: HitTestBehavior.translucent,
  220. child: Container(
  221. height: 73,
  222. child: Column(
  223. children: [
  224. Expanded(
  225. child: Row(
  226. children: [
  227. Container(
  228. margin: EdgeInsets.only(left: 14, right: 14),
  229. child: SvgPicture.asset(
  230. 'images/svg/入帮申请.svg',
  231. height: 45,
  232. width: 45,
  233. ),
  234. ),
  235. Expanded(
  236. child: Container(
  237. height: 45,
  238. child: Column(
  239. children: [
  240. Row(
  241. children: [
  242. Expanded(
  243. child: Text(
  244. '入帮申请',
  245. style: TextStyle(
  246. color: MyColors.c333333, fontSize: 15),
  247. )),
  248. Text(
  249. '',
  250. style: TextStyle(
  251. color: MyColors.c888888, fontSize: 12),
  252. ),
  253. ],
  254. ),
  255. Row(
  256. children: [
  257. Expanded(
  258. child: Text(
  259. applications.length == 0
  260. ? '暂无申请'
  261. : '你有新的申请消息',
  262. style: TextStyle(
  263. color: MyColors.c888888, fontSize: 12),
  264. ),
  265. ),
  266. Visibility(
  267. visible: applications.length != 0,
  268. child: Container(
  269. decoration: BoxDecoration(
  270. color: MyColors.cFF4233,
  271. borderRadius: BorderRadius.all(
  272. Radius.circular(8))),
  273. constraints: BoxConstraints(minWidth: 16),
  274. height: 16,
  275. padding: EdgeInsets.only(left: 5, right: 5),
  276. child: Text(
  277. '${applications.length}',
  278. style: TextStyle(
  279. color: Colors.white, fontSize: 8),
  280. ),
  281. alignment: Alignment.center,
  282. ),
  283. )
  284. ],
  285. )
  286. ],
  287. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  288. ),
  289. ),
  290. )
  291. ],
  292. ),
  293. ),
  294. Container(
  295. margin: EdgeInsets.only(left: 73),
  296. height: 0.5,
  297. color: MyColors.cE7E7E7,
  298. )
  299. ],
  300. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  301. ),
  302. ),
  303. );
  304. } else {
  305. return GestureDetector(
  306. onTap: () {
  307. if (data.shopState == shopStateNormal) {
  308. MyTools().toPage(context, GangInPage(data, null), (then) {
  309. if (then == '删除货帮') {
  310. controller.requestRefresh();
  311. } else if (needRE) {
  312. needRE = false;
  313. controller.requestRefresh();
  314. }
  315. });
  316. } else {
  317. String s = '';
  318. if (data.shopState == shopStateArrearage) {
  319. s = '欠费';
  320. } else if (data.shopState == shopStateBanned) {
  321. s = '被禁';
  322. } else if (data.shopState == shopStateClosed) {
  323. s = '关闭';
  324. }
  325. showDialog(
  326. context: context,
  327. builder: (BuildContext context) {
  328. return Material(
  329. color: Colors.black12,
  330. child: Center(
  331. child: Container(
  332. decoration: BoxDecoration(
  333. borderRadius: BorderRadius.circular(16),
  334. color: Colors.white,
  335. ),
  336. height: 180,
  337. margin: EdgeInsets.symmetric(horizontal: 18),
  338. padding:
  339. EdgeInsets.symmetric(horizontal: 12, vertical: 12),
  340. child: Column(
  341. children: [
  342. Row(
  343. children: [
  344. GestureDetector(
  345. child: Icon(Icons.clear),
  346. onTap: () {
  347. Navigator.pop(context);
  348. },
  349. ),
  350. ],
  351. mainAxisAlignment: MainAxisAlignment.end,
  352. ),
  353. Expanded(
  354. child: Center(
  355. child: Container(
  356. child: MyViews().myText(
  357. '该店铺已$s,请尽快处理', MyColors.c333333, 14),
  358. margin: EdgeInsets.symmetric(horizontal: 20),
  359. ),
  360. ),
  361. ),
  362. Container(
  363. height: 0.5,
  364. color: MyColors.cE7E7E7,
  365. margin: EdgeInsets.only(bottom: 12),
  366. ),
  367. Container(
  368. margin: EdgeInsets.symmetric(horizontal: 10),
  369. child: Row(
  370. children: [
  371. Expanded(
  372. child: GestureDetector(
  373. onTap: () {
  374. Navigator.pop(context);
  375. dismissTheBulletFrame(data);
  376. },
  377. behavior: HitTestBehavior.translucent,
  378. child: Container(
  379. decoration: BoxDecoration(
  380. borderRadius: BorderRadius.only(
  381. topLeft: Radius.circular(20),
  382. bottomLeft: Radius.circular(20),
  383. ),
  384. border: Border.all(
  385. color: MyColors.cFF4233,
  386. width: 1.1),
  387. color: Colors.white),
  388. child: MyViews()
  389. .myText('解散货帮', MyColors.cFF4233, 14),
  390. height: 40,
  391. alignment: Alignment.center,
  392. ),
  393. ),
  394. ),
  395. Expanded(
  396. child: GestureDetector(
  397. behavior: HitTestBehavior.translucent,
  398. onTap: () {
  399. if (data.shopState ==
  400. shopStateArrearage) {
  401. MyTools().toPage(
  402. context,
  403. OrderPage(
  404. index: 2,
  405. ), (then) {
  406. onRefresh();
  407. });
  408. } else if (data.shopState ==
  409. shopStateBanned) {
  410. Navigator.pop(context);
  411. } else if (data.shopState ==
  412. shopStateClosed) {
  413. Navigator.pop(context);
  414. }
  415. },
  416. child: Container(
  417. decoration: BoxDecoration(
  418. borderRadius: BorderRadius.only(
  419. topRight: Radius.circular(20),
  420. bottomRight: Radius.circular(20),
  421. ),
  422. color: MyColors.cFF4233),
  423. height: 40,
  424. child: MyViews()
  425. .myText('去缴费', Colors.white, 14),
  426. alignment: Alignment.center,
  427. ),
  428. ),
  429. )
  430. ],
  431. ),
  432. )
  433. ],
  434. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  435. ),
  436. ),
  437. ),
  438. );
  439. },
  440. );
  441. }
  442. },
  443. behavior: HitTestBehavior.translucent,
  444. child: Container(
  445. height: 73,
  446. child: Column(
  447. children: [
  448. Expanded(
  449. child: Row(
  450. children: [
  451. Container(
  452. margin: EdgeInsets.only(left: 14, right: 14),
  453. child: ClipRRect(
  454. child: MyViews().netImg(imgURL(data.shopPic), 45, 45,
  455. placeholder: 'images/svg/占位图.svg'),
  456. borderRadius: BorderRadius.all(Radius.circular(4)),
  457. ),
  458. ),
  459. Expanded(
  460. child: Container(
  461. height: 45,
  462. child: Column(
  463. children: [
  464. Row(
  465. children: [
  466. Expanded(
  467. child: Text(
  468. data.shopName,
  469. style: TextStyle(
  470. color: MyColors.c333333, fontSize: 15),
  471. )),
  472. Visibility(
  473. child: Container(
  474. decoration: BoxDecoration(
  475. color: MyColors.cFFCD00,
  476. borderRadius: BorderRadius.only(
  477. topLeft: Radius.circular(6),
  478. bottomRight: Radius.circular(6))),
  479. height: 18,
  480. width: 30,
  481. child: Text(
  482. '自建',
  483. style: TextStyle(
  484. color: Colors.white, fontSize: 10),
  485. ),
  486. alignment: Alignment.center,
  487. padding: EdgeInsets.only(bottom: 2),
  488. ),
  489. visible: data.ownerUid == MyCookie().getUID(),
  490. ),
  491. ],
  492. ),
  493. Row(
  494. children: [
  495. Visibility(
  496. visible: !data.privateShop,
  497. child: Container(
  498. decoration: BoxDecoration(
  499. border: Border.all(
  500. color: MyColors.cFF4233, width: 1),
  501. borderRadius: BorderRadius.circular(8),
  502. ),
  503. height: 16,
  504. width: 28,
  505. child: Text(
  506. '公开',
  507. style: TextStyle(
  508. color: MyColors.cFF4233,
  509. fontSize: 10),
  510. ),
  511. alignment: Alignment.center,
  512. margin: EdgeInsets.only(right: 5),
  513. ),
  514. ),
  515. Expanded(
  516. child: Text(
  517. 'ID:${data.shopUid}',
  518. style: TextStyle(
  519. color: MyColors.c888888, fontSize: 12),
  520. ),
  521. ),
  522. Visibility(
  523. child: Container(
  524. decoration: BoxDecoration(
  525. color: MyColors.cFF4233,
  526. borderRadius: BorderRadius.only(
  527. topLeft: Radius.circular(6),
  528. bottomRight: Radius.circular(6))),
  529. height: 18,
  530. width: 30,
  531. child: Text(
  532. '欠费',
  533. style: TextStyle(
  534. color: Colors.white, fontSize: 10),
  535. ),
  536. alignment: Alignment.center,
  537. padding: EdgeInsets.only(bottom: 2),
  538. ),
  539. visible: data.shopState == shopStateArrearage,
  540. ),
  541. ],
  542. )
  543. ],
  544. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  545. ),
  546. ),
  547. )
  548. ],
  549. ),
  550. ),
  551. Container(
  552. margin: EdgeInsets.only(left: 73),
  553. height: 0.5,
  554. color: MyColors.cE7E7E7,
  555. )
  556. ],
  557. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  558. ),
  559. ),
  560. );
  561. }
  562. }
  563. dismissTheBulletFrame(MyShopBeanDataData data) {
  564. TextEditingController controller = TextEditingController();
  565. showDialog(
  566. context: context,
  567. builder: (BuildContext context) {
  568. return Material(
  569. color: Colors.black12,
  570. child: Center(
  571. child: Container(
  572. decoration: BoxDecoration(
  573. borderRadius: BorderRadius.circular(16),
  574. color: Colors.white,
  575. ),
  576. height: 180,
  577. margin: EdgeInsets.symmetric(horizontal: 18),
  578. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  579. child: Column(
  580. children: [
  581. Expanded(
  582. child: Center(
  583. child: Column(
  584. children: [
  585. Container(
  586. child: MyViews().myText(
  587. '确认解散${data.shopName}(${data.shopUid})?',
  588. MyColors.c333333,
  589. 14),
  590. margin: EdgeInsets.symmetric(horizontal: 20),
  591. ),
  592. TextField(
  593. controller: controller,
  594. decoration: InputDecoration(
  595. border: InputBorder.none,
  596. disabledBorder: InputBorder.none,
  597. enabledBorder: InputBorder.none,
  598. focusedBorder: InputBorder.none,
  599. hintText: '输入“解散货帮”确认解散',
  600. hintStyle: TextStyle(
  601. color: MyColors.c999999, fontSize: 16),
  602. isDense: true,
  603. contentPadding:
  604. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5)),
  605. textAlign: TextAlign.center,
  606. )
  607. ],
  608. mainAxisAlignment: MainAxisAlignment.spaceAround,
  609. ),
  610. ),
  611. ),
  612. Container(
  613. height: 0.5,
  614. color: MyColors.cE7E7E7,
  615. margin: EdgeInsets.only(bottom: 12),
  616. ),
  617. Container(
  618. margin: EdgeInsets.symmetric(horizontal: 10),
  619. child: Row(
  620. children: [
  621. Expanded(
  622. child: GestureDetector(
  623. onTap: () {
  624. Navigator.pop(context);
  625. },
  626. behavior: HitTestBehavior.translucent,
  627. child: Container(
  628. decoration: BoxDecoration(
  629. borderRadius: BorderRadius.only(
  630. topLeft: Radius.circular(20),
  631. bottomLeft: Radius.circular(20),
  632. ),
  633. border: Border.all(
  634. color: MyColors.cFF4233, width: 1.1),
  635. color: Colors.white),
  636. child:
  637. MyViews().myText('取消', MyColors.cFF4233, 14),
  638. height: 40,
  639. alignment: Alignment.center,
  640. ),
  641. ),
  642. ),
  643. Expanded(
  644. child: GestureDetector(
  645. behavior: HitTestBehavior.translucent,
  646. onTap: () {
  647. if (controller.text.toString() == '解散货帮') {
  648. Navigator.pop(context);
  649. EasyLoading.instance
  650. ..contentPadding = EdgeInsets.symmetric(
  651. horizontal: 20, vertical: 12)
  652. ..alignment = Alignment.center
  653. ..loadingStyle = EasyLoadingStyle.light
  654. ..contentMargin = EdgeInsets.all(20);
  655. EasyLoading.show();
  656. delShop(data);
  657. } else {
  658. showToast('请输入“解散货帮”');
  659. }
  660. },
  661. child: Container(
  662. decoration: BoxDecoration(
  663. borderRadius: BorderRadius.only(
  664. topRight: Radius.circular(20),
  665. bottomRight: Radius.circular(20),
  666. ),
  667. color: MyColors.cFF4233),
  668. height: 40,
  669. child: MyViews().myText('确认', Colors.white, 14),
  670. alignment: Alignment.center,
  671. ),
  672. ),
  673. )
  674. ],
  675. ),
  676. )
  677. ],
  678. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  679. ),
  680. ),
  681. ),
  682. );
  683. },
  684. );
  685. }
  686. @override
  687. // TODO: implement wantKeepAlive
  688. bool get wantKeepAlive => true;
  689. queryGang() {
  690. var dJson;
  691. var conditions1 = [
  692. "role!=$shopUserOwner",
  693. "user_uid==${MyCookie().getUID()}",
  694. "review_state==1"
  695. ];
  696. var conditions2 = [
  697. "role==$shopUserOwner",
  698. "user_uid==${MyCookie().getUID()}"
  699. ];
  700. if (sIndex == 0) {
  701. conditions1.add('private_shop==true');
  702. dJson = {
  703. "key": "shop_user",
  704. "filters": {
  705. "or": true,
  706. "conditions": conditions1,
  707. "filters": [
  708. {"conditions": conditions2}
  709. ]
  710. },
  711. "dims": shopUserDims,
  712. "paging": [page, 5000],
  713. "order_by": ["shop_name,DESC"]
  714. };
  715. } else {
  716. conditions1.add('private_shop==false');
  717. dJson = {
  718. "key": "shop_user",
  719. "filters": {"conditions": conditions1},
  720. "dims": shopUserDims,
  721. "paging": [page, 5000],
  722. "order_by": ["shop_name,DESC"]
  723. };
  724. }
  725. // if (sIndex == 1) {
  726. // conditions1.add('collected == true');
  727. // conditions2.add('collected == true');
  728. // }
  729. MyDio().query(dJson, (response, hasError) {
  730. if (!hasError) {
  731. MyShopBeanEntity entity =
  732. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  733. if (page == 1) {
  734. data.clear();
  735. }
  736. data.addAll(entity.data.data);
  737. // data.sort((a, b) {
  738. // String aT = PinyinHelper.getShortPinyin(a.shopName);
  739. // String bT = PinyinHelper.getShortPinyin(b.shopName);
  740. // return aT.compareTo(bT);
  741. // });
  742. data.forEach((element) {
  743. element.tagIndex =
  744. PinyinHelper.getPinyinE(element.shopName).toLowerCase();
  745. });
  746. data.sort((left, right) => left.tagIndex.compareTo(right.tagIndex));
  747. if (applications.isNotEmpty && page == 1 && sIndex == 0) {
  748. MyShopBeanDataData shopB = MyShopBeanDataData();
  749. shopB.shopName = '0';
  750. // add hotCityList.
  751. data.insert(0, shopB);
  752. }
  753. // _handleList(data);
  754. setState(() {
  755. endRe(controller);
  756. });
  757. }
  758. }, (error) {});
  759. }
  760. /*void _handleList(List<MyShopBeanDataData> list) {
  761. List<MyShopBeanDataData> selfBuilt = [];
  762. list.forEach((element) {
  763. if (element.ownerUid == MyCookie().getUID()) {
  764. selfBuilt.add(element);
  765. }
  766. });
  767. selfBuilt.forEach((element) {
  768. list.removeWhere((data) => data.id == element.id);
  769. });
  770. if (list.isEmpty && selfBuilt.isEmpty) return;
  771. for (int i = 0, length = list.length; i < length; i++) {
  772. String pinyin = PinyinHelper.getPinyinE(list[i].shopName);
  773. String tag = pinyin.substring(0, 1).toUpperCase();
  774. if (RegExp('[A-Z]').hasMatch(tag)) {
  775. list[i].tagIndex = tag;
  776. } else {
  777. list[i].tagIndex = '#';
  778. }
  779. }
  780. // A-Z sort.
  781. SuspensionUtil.sortListBySuspensionTag(list);
  782. data.insertAll(0, selfBuilt);
  783. if (applications.isNotEmpty) {
  784. MyShopBeanDataData shopB = MyShopBeanDataData();
  785. shopB.shopName = '★';
  786. // add hotCityList.
  787. data.insert(0, shopB);
  788. }
  789. // show sus tag.
  790. SuspensionUtil.setShowSuspensionStatus(data);
  791. setState(() {});
  792. }*/
  793. enquiryApplication() {
  794. MyDio().query({
  795. "key": "shop_user",
  796. "filters": {
  797. "conditions": ["owner_uid==${MyCookie().getUID()}", "review_state==0"]
  798. },
  799. "dims": shopUserDims,
  800. "paging": [1, 2000]
  801. }, (response, hasError) {
  802. if (!hasError) {
  803. MyShopBeanEntity entity =
  804. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  805. applications.clear();
  806. applications.addAll(entity.data.data);
  807. }
  808. setState(() {
  809. endRe(controller);
  810. });
  811. }, (error) {});
  812. }
  813. void onRefresh() {
  814. page = 1;
  815. queryGang();
  816. enquiryApplication();
  817. }
  818. void onLoading() {
  819. page++;
  820. queryGang();
  821. enquiryApplication();
  822. }
  823. void delShop(MyShopBeanDataData data) {
  824. MyDio().query({
  825. "key": "shop",
  826. "filters": {
  827. "conditions": ["uid == ${data.shopUid}"]
  828. },
  829. "dims": shopDims,
  830. "paging": [1, 5]
  831. }, (response, hasError) {
  832. if (!hasError) {
  833. StoreBeanEntity entity =
  834. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  835. MyDio().del({
  836. 'key': 'shop',
  837. 'ids': [entity.data.data[0].id]
  838. }, (response, hasError) {
  839. if (!hasError) {
  840. showToast('删除成功');
  841. onRefresh();
  842. }
  843. }, (error) {});
  844. }
  845. }, (error) {});
  846. }
  847. }