gang_page.dart 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  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. decoration: BoxDecoration(
  459. border: Border.all(color: MyColors.cE7E7E7),
  460. borderRadius: BorderRadius.circular(4)
  461. ),
  462. ),
  463. Expanded(
  464. child: Container(
  465. height: 45,
  466. child: Column(
  467. children: [
  468. Row(
  469. children: [
  470. Expanded(
  471. child: Text(
  472. data.shopName,
  473. style: TextStyle(
  474. color: MyColors.c333333, fontSize: 15),
  475. )),
  476. Visibility(
  477. child: Container(
  478. decoration: BoxDecoration(
  479. color: MyColors.cFFCD00,
  480. borderRadius: BorderRadius.only(
  481. topLeft: Radius.circular(6),
  482. bottomRight: Radius.circular(6))),
  483. height: 18,
  484. width: 30,
  485. child: Text(
  486. '自建',
  487. style: TextStyle(
  488. color: Colors.white, fontSize: 10),
  489. ),
  490. alignment: Alignment.center,
  491. padding: EdgeInsets.only(bottom: 2),
  492. ),
  493. visible: data.ownerUid == MyCookie().getUID(),
  494. ),
  495. ],
  496. ),
  497. Row(
  498. children: [
  499. Visibility(
  500. visible: !data.privateShop,
  501. child: Container(
  502. decoration: BoxDecoration(
  503. border: Border.all(
  504. color: MyColors.cFF4233, width: 1),
  505. borderRadius: BorderRadius.circular(8),
  506. ),
  507. height: 16,
  508. width: 28,
  509. child: Text(
  510. '公开',
  511. style: TextStyle(
  512. color: MyColors.cFF4233,
  513. fontSize: 10),
  514. ),
  515. alignment: Alignment.center,
  516. margin: EdgeInsets.only(right: 5),
  517. ),
  518. ),
  519. Expanded(
  520. child: Text(
  521. 'ID:${data.shopUid}',
  522. style: TextStyle(
  523. color: MyColors.c888888, fontSize: 12),
  524. ),
  525. ),
  526. Visibility(
  527. child: Container(
  528. decoration: BoxDecoration(
  529. color: MyColors.cFF4233,
  530. borderRadius: BorderRadius.only(
  531. topLeft: Radius.circular(6),
  532. bottomRight: Radius.circular(6))),
  533. height: 18,
  534. width: 30,
  535. child: Text(
  536. '欠费',
  537. style: TextStyle(
  538. color: Colors.white, fontSize: 10),
  539. ),
  540. alignment: Alignment.center,
  541. padding: EdgeInsets.only(bottom: 2),
  542. ),
  543. visible: data.shopState == shopStateArrearage,
  544. ),
  545. ],
  546. )
  547. ],
  548. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  549. ),
  550. ),
  551. )
  552. ],
  553. ),
  554. ),
  555. Container(
  556. margin: EdgeInsets.only(left: 73),
  557. height: 0.5,
  558. color: MyColors.cE7E7E7,
  559. )
  560. ],
  561. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  562. ),
  563. ),
  564. );
  565. }
  566. }
  567. dismissTheBulletFrame(MyShopBeanDataData data) {
  568. TextEditingController controller = TextEditingController();
  569. showDialog(
  570. context: context,
  571. builder: (BuildContext context) {
  572. return Material(
  573. color: Colors.black12,
  574. child: Center(
  575. child: Container(
  576. decoration: BoxDecoration(
  577. borderRadius: BorderRadius.circular(16),
  578. color: Colors.white,
  579. ),
  580. height: 180,
  581. margin: EdgeInsets.symmetric(horizontal: 18),
  582. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  583. child: Column(
  584. children: [
  585. Expanded(
  586. child: Center(
  587. child: Column(
  588. children: [
  589. Container(
  590. child: MyViews().myText(
  591. '确认解散${data.shopName}(${data.shopUid})?',
  592. MyColors.c333333,
  593. 14),
  594. margin: EdgeInsets.symmetric(horizontal: 20),
  595. ),
  596. TextField(
  597. controller: controller,
  598. decoration: InputDecoration(
  599. border: InputBorder.none,
  600. disabledBorder: InputBorder.none,
  601. enabledBorder: InputBorder.none,
  602. focusedBorder: InputBorder.none,
  603. hintText: '输入“解散货帮”确认解散',
  604. hintStyle: TextStyle(
  605. color: MyColors.c999999, fontSize: 16),
  606. isDense: true,
  607. contentPadding:
  608. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5)),
  609. textAlign: TextAlign.center,
  610. )
  611. ],
  612. mainAxisAlignment: MainAxisAlignment.spaceAround,
  613. ),
  614. ),
  615. ),
  616. Container(
  617. height: 0.5,
  618. color: MyColors.cE7E7E7,
  619. margin: EdgeInsets.only(bottom: 12),
  620. ),
  621. Container(
  622. margin: EdgeInsets.symmetric(horizontal: 10),
  623. child: Row(
  624. children: [
  625. Expanded(
  626. child: GestureDetector(
  627. onTap: () {
  628. Navigator.pop(context);
  629. },
  630. behavior: HitTestBehavior.translucent,
  631. child: Container(
  632. decoration: BoxDecoration(
  633. borderRadius: BorderRadius.only(
  634. topLeft: Radius.circular(20),
  635. bottomLeft: Radius.circular(20),
  636. ),
  637. border: Border.all(
  638. color: MyColors.cFF4233, width: 1.1),
  639. color: Colors.white),
  640. child:
  641. MyViews().myText('取消', MyColors.cFF4233, 14),
  642. height: 40,
  643. alignment: Alignment.center,
  644. ),
  645. ),
  646. ),
  647. Expanded(
  648. child: GestureDetector(
  649. behavior: HitTestBehavior.translucent,
  650. onTap: () {
  651. if (controller.text.toString() == '解散货帮') {
  652. Navigator.pop(context);
  653. EasyLoading.instance
  654. ..contentPadding = EdgeInsets.symmetric(
  655. horizontal: 20, vertical: 12)
  656. ..alignment = Alignment.center
  657. ..loadingStyle = EasyLoadingStyle.light
  658. ..contentMargin = EdgeInsets.all(20);
  659. EasyLoading.show();
  660. delShop(data);
  661. } else {
  662. showToast('请输入“解散货帮”');
  663. }
  664. },
  665. child: Container(
  666. decoration: BoxDecoration(
  667. borderRadius: BorderRadius.only(
  668. topRight: Radius.circular(20),
  669. bottomRight: Radius.circular(20),
  670. ),
  671. color: MyColors.cFF4233),
  672. height: 40,
  673. child: MyViews().myText('确认', Colors.white, 14),
  674. alignment: Alignment.center,
  675. ),
  676. ),
  677. )
  678. ],
  679. ),
  680. )
  681. ],
  682. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  683. ),
  684. ),
  685. ),
  686. );
  687. },
  688. );
  689. }
  690. @override
  691. // TODO: implement wantKeepAlive
  692. bool get wantKeepAlive => true;
  693. queryGang() {
  694. var dJson;
  695. var conditions1 = [
  696. "role!=$shopUserOwner",
  697. "user_uid==${MyCookie().getUID()}",
  698. "review_state==1"
  699. ];
  700. var conditions2 = [
  701. "role==$shopUserOwner",
  702. "user_uid==${MyCookie().getUID()}"
  703. ];
  704. if (sIndex == 0) {
  705. conditions1.add('private_shop==true');
  706. dJson = {
  707. "key": "shop_user",
  708. "filters": {
  709. "or": true,
  710. "conditions": conditions1,
  711. "filters": [
  712. {"conditions": conditions2}
  713. ]
  714. },
  715. "dims": shopUserDims,
  716. "paging": [page, 5000],
  717. "order_by": ["shop_name,DESC"]
  718. };
  719. } else {
  720. conditions1.add('private_shop==false');
  721. dJson = {
  722. "key": "shop_user",
  723. "filters": {"conditions": conditions1},
  724. "dims": shopUserDims,
  725. "paging": [page, 5000],
  726. "order_by": ["shop_name,DESC"]
  727. };
  728. }
  729. // if (sIndex == 1) {
  730. // conditions1.add('collected == true');
  731. // conditions2.add('collected == true');
  732. // }
  733. MyDio().query(dJson, (response, hasError) {
  734. if (!hasError) {
  735. MyShopBeanEntity entity =
  736. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  737. if (page == 1) {
  738. data.clear();
  739. }
  740. data.addAll(entity.data.data);
  741. // data.sort((a, b) {
  742. // String aT = PinyinHelper.getShortPinyin(a.shopName);
  743. // String bT = PinyinHelper.getShortPinyin(b.shopName);
  744. // return aT.compareTo(bT);
  745. // });
  746. data.forEach((element) {
  747. element.tagIndex =
  748. PinyinHelper.getPinyinE(element.shopName).toLowerCase();
  749. });
  750. data.sort((left, right) => left.tagIndex.compareTo(right.tagIndex));
  751. if (applications.isNotEmpty && page == 1 && sIndex == 0) {
  752. MyShopBeanDataData shopB = MyShopBeanDataData();
  753. shopB.shopName = '0';
  754. // add hotCityList.
  755. data.insert(0, shopB);
  756. }
  757. // _handleList(data);
  758. setState(() {
  759. endRe(controller);
  760. });
  761. }
  762. }, (error) {});
  763. }
  764. /*void _handleList(List<MyShopBeanDataData> list) {
  765. List<MyShopBeanDataData> selfBuilt = [];
  766. list.forEach((element) {
  767. if (element.ownerUid == MyCookie().getUID()) {
  768. selfBuilt.add(element);
  769. }
  770. });
  771. selfBuilt.forEach((element) {
  772. list.removeWhere((data) => data.id == element.id);
  773. });
  774. if (list.isEmpty && selfBuilt.isEmpty) return;
  775. for (int i = 0, length = list.length; i < length; i++) {
  776. String pinyin = PinyinHelper.getPinyinE(list[i].shopName);
  777. String tag = pinyin.substring(0, 1).toUpperCase();
  778. if (RegExp('[A-Z]').hasMatch(tag)) {
  779. list[i].tagIndex = tag;
  780. } else {
  781. list[i].tagIndex = '#';
  782. }
  783. }
  784. // A-Z sort.
  785. SuspensionUtil.sortListBySuspensionTag(list);
  786. data.insertAll(0, selfBuilt);
  787. if (applications.isNotEmpty) {
  788. MyShopBeanDataData shopB = MyShopBeanDataData();
  789. shopB.shopName = '★';
  790. // add hotCityList.
  791. data.insert(0, shopB);
  792. }
  793. // show sus tag.
  794. SuspensionUtil.setShowSuspensionStatus(data);
  795. setState(() {});
  796. }*/
  797. enquiryApplication() {
  798. MyDio().query({
  799. "key": "shop_user",
  800. "filters": {
  801. "conditions": ["owner_uid==${MyCookie().getUID()}", "review_state==0"]
  802. },
  803. "dims": shopUserDims,
  804. "paging": [1, 2000]
  805. }, (response, hasError) {
  806. if (!hasError) {
  807. MyShopBeanEntity entity =
  808. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  809. applications.clear();
  810. applications.addAll(entity.data.data);
  811. }
  812. setState(() {
  813. endRe(controller);
  814. });
  815. }, (error) {});
  816. }
  817. void onRefresh() {
  818. page = 1;
  819. queryGang();
  820. enquiryApplication();
  821. }
  822. void onLoading() {
  823. page++;
  824. queryGang();
  825. enquiryApplication();
  826. }
  827. void delShop(MyShopBeanDataData data) {
  828. MyDio().query({
  829. "key": "shop",
  830. "filters": {
  831. "conditions": ["uid == ${data.shopUid}"]
  832. },
  833. "dims": shopDims,
  834. "paging": [1, 5]
  835. }, (response, hasError) {
  836. if (!hasError) {
  837. StoreBeanEntity entity =
  838. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  839. MyDio().del({
  840. 'key': 'shop',
  841. 'ids': [entity.data.data[0].id]
  842. }, (response, hasError) {
  843. if (!hasError) {
  844. showToast('删除成功');
  845. onRefresh();
  846. }
  847. }, (error) {});
  848. }
  849. }, (error) {});
  850. }
  851. }