gang_in_page.dart 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'dart:math';
  4. import 'package:azlistview/azlistview.dart';
  5. import 'package:bbyyy/beans/goods_bean_entity.dart';
  6. import 'package:bbyyy/beans/my_shop_bean_entity.dart';
  7. import 'package:bbyyy/beans/new_order_bean_entity.dart';
  8. import 'package:bbyyy/beans/smart_order_bean_entity.dart';
  9. import 'package:bbyyy/beans/store_bean_entity.dart';
  10. import 'package:bbyyy/beans/user_vp_bean_entity.dart';
  11. import 'package:bbyyy/https/MyDio.dart';
  12. import 'package:bbyyy/https/url.dart';
  13. import 'package:bbyyy/my_tools/const.dart';
  14. import 'package:bbyyy/my_tools/dims.dart';
  15. import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
  16. import 'package:bbyyy/my_tools/event_bus.dart';
  17. import 'package:bbyyy/my_tools/my_colors.dart';
  18. import 'package:bbyyy/my_tools/my_cookie.dart';
  19. import 'package:bbyyy/my_tools/my_tools.dart';
  20. import 'package:bbyyy/my_tools/my_views.dart';
  21. import 'package:bbyyy/my_tools/pop_up_queue.dart';
  22. import 'package:bbyyy/paegs/chat_page/chat_page.dart';
  23. import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_information_page/add_member_page/add_member_page.dart';
  24. import 'package:bbyyy/paegs/gang_page/gang_in_page/pay_to_the_helper_page/pay_to_the_helper_page.dart';
  25. import 'package:bbyyy/paegs/gang_page/gang_in_page/qr_pay_page/set_amount_page.dart';
  26. import 'package:bbyyy/paegs/mine_page/privacy_protection_props_page/privacy_protection_props_page.dart';
  27. import 'package:bbyyy/paegs/other_people_s_turnover_page/other_people_s_turnover_page.dart';
  28. import 'package:bbyyy/paegs/pay_page/order_information_page.dart';
  29. import 'package:bbyyy/paegs/release_goods_page/release_goods_page.dart';
  30. import 'package:flutter/cupertino.dart';
  31. import 'package:flutter/material.dart';
  32. import 'package:flutter_slidable/flutter_slidable.dart';
  33. import 'package:flutter_svg/svg.dart';
  34. import 'package:pull_to_refresh/pull_to_refresh.dart';
  35. import 'package:url_launcher/url_launcher.dart';
  36. import 'gang_information_page/gang_information_page.dart';
  37. import 'gang_information_page/member_list_page/member_details_page.dart';
  38. import 'initiate_collection_page/initiate_collection_page.dart';
  39. import 'scan_page/scan_page.dart';
  40. class GangInPage extends StatefulWidget {
  41. MyShopBeanDataData data;
  42. NewOrderBeanContent order;
  43. GangInPage(this.data, this.order);
  44. @override
  45. _GangInPageState createState() => _GangInPageState();
  46. }
  47. class _GangInPageState extends State<GangInPage> {
  48. int selectedIndex = 0;
  49. RefreshController controller = RefreshController(initialRefresh: true);
  50. int page = 1;
  51. bool collect = false;
  52. bool needRE = false;
  53. bool canSendGood = false;
  54. _GangInPageState();
  55. List<GoodsBeanDataData> goods = [];
  56. List<SmartOrderBeanDataData> orders = [];
  57. @override
  58. void initState() {
  59. // TODO: implement initState
  60. super.initState();
  61. EventBus().on('payAnOrder', (arg) {
  62. controller.requestRefresh();
  63. });
  64. EventBus().on('reNoPayOrder', (arg) {
  65. controller.requestRefresh();
  66. });
  67. EventBus().on('刷新未付订单', (arg) {
  68. controller.requestRefresh();
  69. });
  70. Future.delayed(Duration.zero, () {
  71. if (widget.order != null) {
  72. setState(() {
  73. selectedIndex = 2;
  74. payTheOrder();
  75. });
  76. }
  77. });
  78. if (widget.data.ownerUid == MyCookie().getUID()) {
  79. selectedIndex = 1;
  80. }
  81. queryWhetherToFollow();
  82. queryStoreInformation();
  83. }
  84. @override
  85. void dispose() {
  86. // TODO: implement dispose
  87. super.dispose();
  88. EventBus().off('payAnOrder');
  89. EventBus().off('reNoPayOrder');
  90. EventBus().off('刷新未付订单');
  91. }
  92. @override
  93. Widget build(BuildContext context) {
  94. return Scaffold(
  95. body: Column(
  96. children: [
  97. MyViews().myAppBar(widget.data.shopName, context, [
  98. Visibility(
  99. visible: false,
  100. child: IconButton(
  101. icon: Icon(Icons.qr_code_scanner),
  102. onPressed: () async {
  103. MyTools().toPage(context, ScanPage(), (then) {
  104. if (then is String) {
  105. if (then.isNotEmpty &&
  106. then != null &&
  107. then.length == 8) {
  108. Timer(Duration(milliseconds: 200), () {
  109. StoreBeanDataData store = StoreBeanDataData();
  110. store.ownerUid = widget.data.ownerUid;
  111. store.ownerName = widget.data.ownerName;
  112. store.uid = widget.data.shopUid;
  113. MyTools().toPage(
  114. context,
  115. AddMemberPage(
  116. store: store,
  117. qrUID: then,
  118. ),
  119. (then) {});
  120. MyTools().hideKeyboard(context);
  121. controller.requestRefresh();
  122. });
  123. }
  124. }
  125. });
  126. }),
  127. ),
  128. Visibility(
  129. visible: false,
  130. child: IconButton(
  131. icon: Icon(Icons.more_horiz),
  132. onPressed: () {
  133. MyTools().toPage(context, GangInformationPage(widget.data),
  134. (then) {
  135. if (then == '删除货帮') {
  136. Navigator.pop(context, '删除货帮');
  137. }
  138. });
  139. }),
  140. ),
  141. PopupMenuButton<String>(
  142. icon: Icon(Icons.more_horiz),
  143. onSelected: (v) {
  144. switch (v) {
  145. case '扫一扫':
  146. MyTools().toPage(context, ScanPage(), (then) {
  147. if (then is String) {
  148. if (then.isNotEmpty &&
  149. then != null &&
  150. then.length == 8) {
  151. Timer(Duration(milliseconds: 200), () {
  152. StoreBeanDataData store = StoreBeanDataData();
  153. store.ownerUid = widget.data.ownerUid;
  154. store.ownerName = widget.data.ownerName;
  155. store.uid = widget.data.shopUid;
  156. MyTools().toPage(
  157. context,
  158. AddMemberPage(
  159. store: store,
  160. qrUID: then,
  161. ),
  162. (then) {});
  163. MyTools().hideKeyboard(context);
  164. controller.requestRefresh();
  165. });
  166. }
  167. }
  168. });
  169. break;
  170. case '发布商品':
  171. MyTools().toPage(
  172. context, ReleaseGoodsPage(null, widget.data.shopName),
  173. (then) {
  174. controller.requestRefresh();
  175. });
  176. break;
  177. case '货帮详情':
  178. MyTools().toPage(context, GangInformationPage(widget.data),
  179. (then) {
  180. if (then == '删除货帮') {
  181. Navigator.pop(context, '删除货帮');
  182. }
  183. });
  184. break;
  185. default:
  186. break;
  187. }
  188. },
  189. itemBuilder: (context) {
  190. return <PopupMenuEntry<String>>[
  191. if(canSendGood)
  192. PopupMenuItem<String>(
  193. value: '发布商品',
  194. child: Row(
  195. children: [
  196. SvgPicture.asset(
  197. 'images/svg/发布商品_icon.svg',
  198. height: 22,
  199. width: 22,
  200. ),
  201. Container(
  202. child: Text(
  203. '发布商品',
  204. style: TextStyle(
  205. fontSize: 14, color: MyColors.c333333),
  206. ),
  207. margin: EdgeInsets.only(left: 5),
  208. ),
  209. ],
  210. ),
  211. ),
  212. PopupMenuItem<String>(
  213. value: '货帮详情',
  214. child: Row(
  215. children: [
  216. SvgPicture.asset(
  217. 'images/svg/货帮详情_icon.svg',
  218. height: 20,
  219. width: 20,
  220. ),
  221. Container(
  222. child: Text(
  223. '货帮详情',
  224. style: TextStyle(
  225. fontSize: 14, color: MyColors.c333333),
  226. ),
  227. margin: EdgeInsets.only(left: 5),
  228. ),
  229. ],
  230. ),
  231. ),
  232. if (MyCookie().getUID() == widget.data.ownerUid)
  233. PopupMenuItem<String>(
  234. value: '扫一扫',
  235. child: Row(
  236. children: [
  237. SvgPicture.asset(
  238. 'images/svg/扫一扫_icon.svg',
  239. height: 20,
  240. width: 20,
  241. ),
  242. Container(
  243. child: Text(
  244. '扫一扫',
  245. style: TextStyle(
  246. fontSize: 14, color: MyColors.c333333),
  247. ),
  248. margin: EdgeInsets.only(left: 5),
  249. ),
  250. ],
  251. ),
  252. ),
  253. ];
  254. },
  255. )
  256. ]),
  257. Container(
  258. color: MyColors.cF7F7F7,
  259. child: Container(
  260. decoration: BoxDecoration(
  261. borderRadius: BorderRadius.circular(4), color: Colors.white),
  262. margin: EdgeInsets.all(10),
  263. child: Column(
  264. children: [
  265. Row(
  266. children: [
  267. Container(
  268. margin: EdgeInsets.only(
  269. right: 10, top: 6, left: 6, bottom: 6),
  270. child: GestureDetector(
  271. onTap: () {
  272. shopInfo();
  273. },
  274. behavior: HitTestBehavior.translucent,
  275. child: ClipRRect(
  276. child: MyViews()
  277. .netImg(imgURL(widget.data.shopPic), 65, 65),
  278. borderRadius: BorderRadius.circular(4),
  279. ),
  280. ),
  281. ),
  282. Expanded(
  283. child: Container(
  284. height: 65,
  285. margin: EdgeInsets.only(right: 6),
  286. child: Column(
  287. children: [
  288. Row(
  289. children: [
  290. Text(
  291. widget.data.shopName,
  292. style: TextStyle(
  293. color: MyColors.c333333, fontSize: 13),
  294. maxLines: 1,
  295. overflow: TextOverflow.ellipsis,
  296. softWrap: true,
  297. ),
  298. ],
  299. mainAxisAlignment:
  300. MainAxisAlignment.spaceBetween,
  301. ),
  302. Row(
  303. children: [
  304. Expanded(
  305. child: Text(
  306. store != null &&
  307. store.introduction.isNotEmpty
  308. ? '货帮介绍:${store.introduction}'
  309. : '货帮介绍:暂无',
  310. style: TextStyle(
  311. color: MyColors.c666666,
  312. fontSize: 11),
  313. maxLines: 1,
  314. overflow: TextOverflow.ellipsis,
  315. softWrap: true,
  316. ),
  317. ),
  318. ],
  319. crossAxisAlignment: CrossAxisAlignment.center,
  320. ),
  321. Row(
  322. children: [
  323. SvgPicture.asset(
  324. 'images/svg/地址.svg',
  325. color: MyColors.c666666,
  326. height: 12,
  327. width: 12,
  328. ),
  329. Container(
  330. width: 5,
  331. ),
  332. Expanded(
  333. child: Text(
  334. store != null && store.address.isNotEmpty
  335. ? store.address
  336. : '暂无',
  337. style: TextStyle(
  338. color: MyColors.c666666,
  339. fontSize: 11),
  340. maxLines: 1,
  341. overflow: TextOverflow.ellipsis,
  342. softWrap: true,
  343. ),
  344. ),
  345. ],
  346. ),
  347. ],
  348. crossAxisAlignment: CrossAxisAlignment.start,
  349. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  350. ),
  351. ),
  352. ),
  353. Visibility(
  354. visible: !widget.data.privateShop,
  355. child: GestureDetector(
  356. child: Container(
  357. margin: EdgeInsets.all(12),
  358. child: SvgPicture.asset(
  359. collect
  360. ? 'images/svg/已收藏.svg'
  361. : 'images/svg/未收藏.svg',
  362. height: 20,
  363. width: 20,
  364. ),
  365. ),
  366. onTap: () {
  367. EasyLoading.show();
  368. collectionShop();
  369. },
  370. ),
  371. ),
  372. ],
  373. ),
  374. Container(
  375. height: 0.5,
  376. color: MyColors.cE7E7E7,
  377. ),
  378. Visibility(
  379. visible: store != null && store.mobile.isNotEmpty,
  380. child: Container(
  381. margin: EdgeInsets.all(6),
  382. child: Row(
  383. children: [
  384. Row(
  385. children: [
  386. SvgPicture.asset(
  387. 'images/svg/电话.svg',
  388. height: 18,
  389. width: 18,
  390. ),
  391. Container(
  392. width: 5,
  393. ),
  394. Text(
  395. store == null ? '暂无' : store.mobile,
  396. style: TextStyle(
  397. color: MyColors.cFF4233, fontSize: 12),
  398. ),
  399. ],
  400. ),
  401. GestureDetector(
  402. onTap: () {
  403. launch('tel:${store.mobile}');
  404. },
  405. behavior: HitTestBehavior.translucent,
  406. child: Container(
  407. decoration: BoxDecoration(
  408. color: MyColors.cFF4233,
  409. borderRadius: BorderRadius.circular(10),
  410. ),
  411. height: 20,
  412. width: 50,
  413. child: MyViews().myText('点击拨打', Colors.white, 9),
  414. alignment: Alignment.center,
  415. ),
  416. )
  417. ],
  418. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  419. ),
  420. ),
  421. )
  422. ],
  423. ),
  424. ),
  425. ),
  426. Visibility(
  427. visible: widget.data.privateShop ||
  428. widget.data.ownerUid == MyCookie().getUID(),
  429. child: Container(
  430. height: 40,
  431. color: Colors.white,
  432. child: Row(
  433. children: [
  434. Expanded(
  435. flex: 1,
  436. child: GestureDetector(
  437. onTap: () {
  438. setState(() {
  439. selectedIndex = 0;
  440. controller.requestRefresh();
  441. });
  442. },
  443. behavior: HitTestBehavior.translucent,
  444. child: Padding(
  445. padding: EdgeInsets.only(left: 10, right: 10),
  446. child: Column(
  447. children: [
  448. Text(
  449. '货帮商品',
  450. style: TextStyle(
  451. color: selectedIndex == 0
  452. ? MyColors.cFF4233
  453. : MyColors.c666666,
  454. fontSize: 15),
  455. ),
  456. Container(
  457. height: 10,
  458. child: Visibility(
  459. child: SvgPicture.asset('images/svg/tab.svg'),
  460. visible: selectedIndex == 0,
  461. ),
  462. )
  463. ],
  464. mainAxisAlignment: MainAxisAlignment.end,
  465. ),
  466. ),
  467. ),
  468. ),
  469. Expanded(
  470. flex: 1,
  471. child: GestureDetector(
  472. onTap: () {
  473. setState(() {
  474. selectedIndex = 1;
  475. controller.requestRefresh();
  476. });
  477. },
  478. behavior: HitTestBehavior.translucent,
  479. child: Padding(
  480. padding: EdgeInsets.only(left: 10, right: 10),
  481. child: Column(
  482. children: [
  483. Text(
  484. widget.data.ownerUid == MyCookie().getUID()
  485. ? '未付订单'
  486. : '未收订单',
  487. style: TextStyle(
  488. color: selectedIndex == 1
  489. ? MyColors.cFF4233
  490. : MyColors.c666666,
  491. fontSize: 15),
  492. ),
  493. Container(
  494. height: 10,
  495. child: Visibility(
  496. child: SvgPicture.asset('images/svg/tab.svg'),
  497. visible: selectedIndex == 1,
  498. ),
  499. )
  500. ],
  501. mainAxisAlignment: MainAxisAlignment.end,
  502. ),
  503. ),
  504. ),
  505. ),
  506. Expanded(
  507. flex: 1,
  508. child: GestureDetector(
  509. onTap: () {
  510. setState(() {
  511. selectedIndex = 2;
  512. controller.requestRefresh();
  513. });
  514. },
  515. behavior: HitTestBehavior.translucent,
  516. child: Padding(
  517. padding: EdgeInsets.only(left: 10, right: 10),
  518. child: Column(
  519. children: [
  520. Text(
  521. widget.data.ownerUid == MyCookie().getUID()
  522. ? '已付订单'
  523. : '未付订单',
  524. style: TextStyle(
  525. color: selectedIndex == 2
  526. ? MyColors.cFF4233
  527. : MyColors.c666666,
  528. fontSize: 15),
  529. ),
  530. Container(
  531. height: 10,
  532. child: Visibility(
  533. child: SvgPicture.asset('images/svg/tab.svg'),
  534. visible: selectedIndex == 2,
  535. ),
  536. )
  537. ],
  538. mainAxisAlignment: MainAxisAlignment.end,
  539. ),
  540. ),
  541. ),
  542. ),
  543. Expanded(
  544. flex: MyCookie().getUID() == widget.data.ownerUid ||
  545. !hideMember
  546. ? 1
  547. : 0,
  548. child: Visibility(
  549. visible: MyCookie().getUID() == widget.data.ownerUid ||
  550. !hideMember,
  551. child: GestureDetector(
  552. onTap: () {
  553. setState(() {
  554. selectedIndex = 3;
  555. controller.requestRefresh();
  556. });
  557. },
  558. behavior: HitTestBehavior.translucent,
  559. child: Padding(
  560. padding: EdgeInsets.only(left: 10, right: 10),
  561. child: Column(
  562. children: [
  563. Text(
  564. '货帮成员',
  565. style: TextStyle(
  566. color: selectedIndex == 3
  567. ? MyColors.cFF4233
  568. : MyColors.c666666,
  569. fontSize: 15),
  570. ),
  571. Container(
  572. height: 10,
  573. child: Visibility(
  574. child: SvgPicture.asset('images/svg/tab.svg'),
  575. visible: selectedIndex == 3,
  576. ),
  577. )
  578. ],
  579. mainAxisAlignment: MainAxisAlignment.end,
  580. ),
  581. ),
  582. ),
  583. ),
  584. )
  585. ],
  586. ),
  587. ),
  588. ),
  589. body(),
  590. Container(
  591. color: Colors.white,
  592. child: SafeArea(
  593. top: false,
  594. child: Container(
  595. padding: EdgeInsets.symmetric(horizontal: 37),
  596. color: Colors.white,
  597. width: double.infinity,
  598. height: 60,
  599. child: Row(
  600. children: [
  601. Expanded(
  602. child: GestureDetector(
  603. onTap: () {
  604. if(!widget.data.privateShop&&MyCookie().getUID()==widget.data.ownerUid){
  605. MyTools().toPage(context, SetAmountPage(widget.data), (then){});
  606. }else{
  607. queryShopMembers(true);
  608. }
  609. },
  610. behavior: HitTestBehavior.translucent,
  611. child: Container(
  612. decoration: BoxDecoration(
  613. borderRadius: BorderRadius.only(
  614. topLeft: Radius.circular(20),
  615. bottomLeft: Radius.circular(20),
  616. ),
  617. border: Border.all(
  618. color: MyColors.cFF4233, width: 1)),
  619. height: 40,
  620. child:
  621. MyViews().myText(!widget.data.privateShop&&MyCookie().getUID()==widget.data.ownerUid?'扫码收款':'联系帮主', MyColors.cFF4233, 14),
  622. alignment: Alignment.center),
  623. ),
  624. ),
  625. Expanded(
  626. child: GestureDetector(
  627. onTap: () {
  628. if (MyCookie().getUID() == widget.data.ownerUid) {
  629. MyTools().toPage(
  630. context, InitiateCollectionPage(widget.data),
  631. (then) {
  632. if (then is String && then == '发起收款') {
  633. controller.requestRefresh();
  634. }
  635. });
  636. } else {
  637. MyTools().toPage(context,
  638. PayToTheHelperPage(widget.data), (then) {});
  639. }
  640. },
  641. behavior: HitTestBehavior.translucent,
  642. child: Container(
  643. decoration: BoxDecoration(
  644. borderRadius: BorderRadius.only(
  645. topRight: Radius.circular(20),
  646. bottomRight: Radius.circular(20),
  647. ),
  648. color: MyColors.cFF4233),
  649. height: 40,
  650. child: MyViews().myText(
  651. MyCookie().getUID() == widget.data.ownerUid
  652. ? '发起收款'
  653. : '到店付款',
  654. Colors.white,
  655. 14),
  656. alignment: Alignment.center),
  657. ),
  658. )
  659. ],
  660. ),
  661. ),
  662. ),
  663. )
  664. ],
  665. ),
  666. );
  667. }
  668. body() {
  669. if (selectedIndex == 0) {
  670. return Expanded(
  671. child: SmartRefresher(
  672. controller: controller,
  673. onRefresh: onRefresh,
  674. onLoading: onLoading,
  675. enablePullDown: true,
  676. enablePullUp: true,
  677. child: goods.length == 0
  678. ? SingleChildScrollView(child: noData())
  679. : GridView.builder(
  680. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  681. crossAxisCount: 2, //每行三列
  682. childAspectRatio: 164 / 261, //显示区域宽高相等
  683. mainAxisSpacing: 8,
  684. crossAxisSpacing: 8),
  685. itemCount: goods.length,
  686. padding:
  687. EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
  688. itemBuilder: (context, index) {
  689. return MyViews().getGoodsItem(goods[index], context);
  690. }),
  691. ),
  692. );
  693. } else if (selectedIndex == 1) {
  694. return Expanded(
  695. child: SmartRefresher(
  696. controller: controller,
  697. onRefresh: onRefresh,
  698. onLoading: onLoading,
  699. enablePullDown: true,
  700. enablePullUp: true,
  701. child: orders.length == 0
  702. ? SingleChildScrollView(child: noData())
  703. : ListView.builder(
  704. itemBuilder: (c, index) {
  705. return Slidable(
  706. child: MyViews().getNoPayGoodsItem(
  707. orders[index], context, widget.data.ownerUid),
  708. actionPane: SlidableDrawerActionPane(),
  709. enabled: widget.data.ownerUid == MyCookie().getUID(),
  710. actionExtentRatio: 0.25,
  711. secondaryActions: <Widget>[
  712. SlideAction(
  713. child: Container(
  714. child: Container(
  715. decoration: BoxDecoration(
  716. borderRadius: BorderRadius.circular(30),
  717. color: MyColors.cFF4233,
  718. ),
  719. height: 60,
  720. width: 60,
  721. child: SvgPicture.asset(
  722. 'images/svg/del.svg',
  723. height: 40,
  724. width: 40,
  725. ),
  726. alignment: Alignment.center,
  727. ),
  728. ),
  729. onTap: () {
  730. showSimpleDialog(
  731. '将删除订单(${orders[index].uid})', context, () {
  732. Navigator.pop(context);
  733. deleteOrder(orders[index]);
  734. });
  735. },
  736. )
  737. ],
  738. );
  739. },
  740. itemCount: orders.length,
  741. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  742. ),
  743. ),
  744. );
  745. } else if (selectedIndex == 2) {
  746. return Expanded(
  747. child: SmartRefresher(
  748. controller: controller,
  749. onRefresh: onRefresh,
  750. onLoading: onLoading,
  751. enablePullDown: true,
  752. enablePullUp: true,
  753. child: orders.length == 0
  754. ? SingleChildScrollView(child: noData())
  755. : ListView.builder(
  756. itemBuilder: (c, index) {
  757. return Slidable(
  758. child: MyViews().getNoPayGoodsItem(
  759. orders[index], context, widget.data.ownerUid),
  760. actionPane: SlidableDrawerActionPane(),
  761. enabled: orders[index].type == orderTypeOfflineTransfer &&
  762. orders[index].buyerUid == MyCookie().getUID(),
  763. actionExtentRatio: 0.25,
  764. secondaryActions: <Widget>[
  765. SlideAction(
  766. child: Container(
  767. child: Container(
  768. decoration: BoxDecoration(
  769. borderRadius: BorderRadius.circular(30),
  770. color: MyColors.cFF4233,
  771. ),
  772. height: 60,
  773. width: 60,
  774. child: SvgPicture.asset(
  775. 'images/svg/del.svg',
  776. height: 40,
  777. width: 40,
  778. ),
  779. alignment: Alignment.center,
  780. ),
  781. ),
  782. onTap: () {
  783. showSimpleDialog(
  784. '将删除订单(${orders[index].uid})', context, () {
  785. Navigator.pop(context);
  786. deleteOrder(orders[index]);
  787. });
  788. },
  789. )
  790. ],
  791. );
  792. },
  793. itemCount: orders.length,
  794. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  795. ),
  796. ),
  797. );
  798. } else if (selectedIndex == 3) {
  799. return Expanded(
  800. child: SmartRefresher(
  801. controller: controller,
  802. onRefresh: onRefresh,
  803. onLoading: onLoading,
  804. enablePullDown: true,
  805. enablePullUp: true,
  806. child: member.length == 0
  807. ? SingleChildScrollView(child: noData())
  808. : Container(
  809. margin: EdgeInsets.only(top: 10),
  810. child: AzListView(
  811. itemBuilder: (c, index) {
  812. return GestureDetector(
  813. onTap: () {
  814. if (MyCookie().getUID() == store.ownerUid) {
  815. if (MyCookie().getUID() != member[index].userUid) {
  816. MyTools().toPage(
  817. context, MemberDetailsPage(member[index]),
  818. (then) {
  819. controller.requestRefresh();
  820. });
  821. }
  822. } else {
  823. return;
  824. }
  825. },
  826. behavior: HitTestBehavior.translucent,
  827. child: Container(
  828. padding: EdgeInsets.only(left: 15, right: 15),
  829. color: Colors.white,
  830. child: Column(
  831. children: [
  832. Container(
  833. margin: EdgeInsets.only(top: 8, bottom: 6),
  834. child: Row(
  835. children: [
  836. Row(
  837. children: [
  838. Container(
  839. margin: EdgeInsets.only(right: 6),
  840. child: ClipRRect(
  841. child: MyViews().netImg(
  842. imgURL(member[index].userPic),
  843. 42,
  844. 42),
  845. borderRadius:
  846. BorderRadius.circular(21),
  847. ),
  848. ),
  849. MyViews().myText(
  850. '${member[index].userName} ${store.ownerUid == MyCookie().getUID() ? '(${member[index].userUid})' : ''}',
  851. MyColors.c333333,
  852. 15),
  853. Visibility(
  854. visible: member[index].role !=
  855. shopUserMember,
  856. child: Container(
  857. decoration: BoxDecoration(
  858. color: member[index].role ==
  859. shopUserStaff
  860. ? MyColors.cFF4233
  861. : MyColors.cFFCD00,
  862. borderRadius:
  863. BorderRadius.circular(8)),
  864. height: 16,
  865. width: 30,
  866. child: MyViews().myText(
  867. member[index].role ==
  868. shopUserOwner
  869. ? "帮主"
  870. : "助手",
  871. Colors.white,
  872. 10),
  873. alignment: Alignment.center,
  874. margin: EdgeInsets.only(left: 5),
  875. ),
  876. )
  877. ],
  878. ),
  879. Visibility(
  880. visible:
  881. member[index].role != shopUserOwner &&
  882. member[index].userUid !=
  883. MyCookie().getUID(),
  884. child: GestureDetector(
  885. child: Container(
  886. margin: EdgeInsets.only(right: 10),
  887. child: SvgPicture.asset(
  888. 'images/svg/透视.svg',
  889. height: 25,
  890. width: 25,
  891. ),
  892. ),
  893. onTap: () {
  894. queryWhetherThereIsANumberOfPerspectives(
  895. member[index], store, context);
  896. },
  897. behavior: HitTestBehavior.translucent,
  898. ),
  899. ),
  900. ],
  901. mainAxisAlignment:
  902. MainAxisAlignment.spaceBetween,
  903. ),
  904. ),
  905. Container(
  906. height: 0.5,
  907. color: MyColors.cE7E7E7,
  908. )
  909. ],
  910. ),
  911. ),
  912. );
  913. },
  914. itemCount: member.length,
  915. data: member,
  916. ),
  917. ),
  918. ),
  919. );
  920. } else {
  921. return SingleChildScrollView(child: noData());
  922. }
  923. }
  924. void onRefresh() {
  925. page = 1;
  926. if (selectedIndex == 0) {
  927. queryProducts();
  928. } else if (selectedIndex == 1) {
  929. unreceivedOrder();
  930. } else if (selectedIndex == 3) {
  931. queryShopMembers(false);
  932. } else {
  933. unpaidOrder();
  934. }
  935. }
  936. void onLoading() {
  937. page++;
  938. if (selectedIndex == 0) {
  939. queryProducts();
  940. } else if (selectedIndex == 1) {
  941. unreceivedOrder();
  942. } else if (selectedIndex == 3) {
  943. queryShopMembers(false);
  944. } else {
  945. unpaidOrder();
  946. }
  947. }
  948. //查询商品
  949. void queryProducts() {
  950. MyDio().query({
  951. "key": "commodity",
  952. "filters": {
  953. "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"]
  954. },
  955. "dims": commodityDims,
  956. "order_by": ["id,desc", "no,desc"],
  957. "paging": [page, 20]
  958. }, (response, hasError) {
  959. if (!hasError) {
  960. GoodsBeanEntity entity =
  961. GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
  962. if (page == 1) {
  963. goods.clear();
  964. }
  965. goods.addAll(entity.data.data);
  966. }
  967. setState(() {
  968. endRe(controller);
  969. });
  970. }, (error) {
  971. setState(() {
  972. endRe(controller);
  973. });
  974. });
  975. }
  976. //查询未收订单
  977. void unreceivedOrder() {
  978. var conditions = [];
  979. if (widget.data.ownerUid == MyCookie().getUID()) {
  980. conditions.add('state == $orderStateUnpaid');
  981. conditions.add('shop_uid == ${widget.data.shopUid}');
  982. } else {
  983. conditions.add('state == $orderStateUnpaid');
  984. conditions.add('shop_uid == ${widget.data.shopUid}');
  985. conditions.add('seller_uid == ${MyCookie().getUID()}');
  986. }
  987. MyDio().query({
  988. "key": "order",
  989. "filters": {"conditions": conditions},
  990. "dims": orderDims,
  991. "paging": [page, 20],
  992. "order_by": ["create_time,DESC"]
  993. }, (response, hasError) {
  994. if (!hasError) {
  995. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  996. .fromJson(json.decode(response.data.toString()));
  997. if (page == 1) {
  998. orders.clear();
  999. }
  1000. orders.addAll(entity.data.data);
  1001. setState(() {});
  1002. }
  1003. endRe(controller);
  1004. }, (error) {});
  1005. }
  1006. //查询未付订单
  1007. void unpaidOrder() {
  1008. var conditions = [];
  1009. if (widget.data.ownerUid == MyCookie().getUID()) {
  1010. conditions.add('state == $orderStatePaid');
  1011. conditions.add('shop_uid == ${widget.data.shopUid}');
  1012. } else {
  1013. conditions.add('state == $orderStateUnpaid');
  1014. conditions.add('shop_uid == ${widget.data.shopUid}');
  1015. conditions.add('buyer_name LIKE ${MyCookie().getName()}');
  1016. }
  1017. MyDio().query({
  1018. "key": "order",
  1019. "filters": {"conditions": conditions},
  1020. "dims": orderDims,
  1021. "paging": [page, 20],
  1022. "order_by": ["create_time,DESC"]
  1023. }, (response, hasError) {
  1024. if (!hasError) {
  1025. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1026. .fromJson(json.decode(response.data.toString()));
  1027. if (page == 1) {
  1028. orders.clear();
  1029. }
  1030. orders.addAll(entity.data.data);
  1031. setState(() {});
  1032. }
  1033. endRe(controller);
  1034. }, (error) {});
  1035. }
  1036. payTheOrder() {
  1037. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  1038. data.sellerUid = widget.order.sellerUID;
  1039. data.sellerName = widget.order.sellerName;
  1040. data.sellerPic = widget.order.sellerPic;
  1041. data.buyerUid = 0;
  1042. data.buyerName = widget.order.buyerName;
  1043. data.buyerPic = '';
  1044. data.amount = widget.order.amount;
  1045. data.uid = widget.order.uID;
  1046. MyTools().toPage(
  1047. context,
  1048. OrderInformationPage(
  1049. false,
  1050. orderType: orderTypeThirdPlatform,
  1051. amount: widget.order.amount,
  1052. uid: widget.order.uID,
  1053. buyerUid: MyCookie().getUID(),
  1054. buyerName: widget.order.buyerName,
  1055. buyerPic: MyCookie().getPic(),
  1056. commodityCount: 1,
  1057. commodityTitle: '第三方订单',
  1058. commodityCover: '',
  1059. sellName: widget.order.sellerName,
  1060. sellPic: widget.order.sellerPic,
  1061. sellUid: widget.order.sellerUID,
  1062. ), (then) {
  1063. controller.requestRefresh();
  1064. PopUpQueue().onShow = false;
  1065. PopUpQueue().showNext();
  1066. });
  1067. // showPayDialog(data, context, () {
  1068. // Navigator.pop(context);
  1069. // // MyTools().toPage(context,
  1070. // // PayPage(widget.order.uID, false, widget.order.amount), (then) {});
  1071. //
  1072. // });
  1073. }
  1074. List<MyShopBeanDataData> member = [];
  1075. List<MyShopBeanDataData> helper = [];
  1076. queryShopMembers(bool toOwner) {
  1077. MyDio().query({
  1078. "key": "shop_user",
  1079. "filters": {
  1080. "conditions": ["shop_uid==${widget.data.shopUid}", "review_state==1"]
  1081. },
  1082. "dims": shopUserDims,
  1083. "paging": [1, 2000]
  1084. }, (response, hasError) {
  1085. if (!hasError) {
  1086. MyShopBeanEntity entity =
  1087. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1088. member = entity.data.data;
  1089. if (toOwner) {
  1090. helper.clear();
  1091. member.forEach((element) {
  1092. if (element.role == shopUserStaff) {
  1093. helper.add(element);
  1094. }
  1095. });
  1096. MyShopBeanDataData chatWith;
  1097. if (helper.length == 0) {
  1098. chatWith = member[
  1099. member.indexWhere((element) => element.role == shopUserOwner)];
  1100. } else {
  1101. chatWith = helper[Random().nextInt(helper.length)];
  1102. }
  1103. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1104. } else {
  1105. controller.refreshCompleted();
  1106. controller.loadComplete();
  1107. setState(() {});
  1108. }
  1109. }
  1110. }, (error) {});
  1111. }
  1112. void deleteOrder(SmartOrderBeanDataData order) {
  1113. MyDio().del({
  1114. 'key': 'order',
  1115. 'ids': [order.id]
  1116. }, (response, hasError) {
  1117. if (!hasError) {
  1118. orders.remove(order);
  1119. setState(() {});
  1120. }
  1121. }, (error) {});
  1122. }
  1123. StoreBeanDataData store;
  1124. bool hideMember = true;
  1125. queryStoreInformation() {
  1126. MyDio().query({
  1127. "key": "shop",
  1128. "filters": {
  1129. "conditions": ["uid == ${widget.data.shopUid}"]
  1130. },
  1131. "dims": shopDims,
  1132. "paging": [1, 5]
  1133. }, (response, hasError) {
  1134. if (!hasError) {
  1135. StoreBeanEntity entity =
  1136. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1137. store = entity.data.data[0];
  1138. hideMember = store.hideMembers;
  1139. //自己的公开店铺
  1140. if (!store.private &&
  1141. store.ownerUid == MyCookie().getUID()) {
  1142. canSendGood = true;
  1143. }
  1144. //自己在某个允许顾客间交易的私有店铺中
  1145. if (store.innerTrade) {
  1146. canSendGood = true;
  1147. }
  1148. setState(() {});
  1149. }
  1150. endRe(controller);
  1151. }, (error) {});
  1152. }
  1153. void queryWhetherThereIsANumberOfPerspectives(
  1154. MyShopBeanDataData data, StoreBeanDataData store, BuildContext context) {
  1155. MyDio().query({
  1156. "key": "user_vp",
  1157. "filters": {
  1158. "conditions": [
  1159. "user_uid == ${MyCookie().getUID()}",
  1160. "vp_key == $vpKeyXRay"
  1161. ]
  1162. },
  1163. "dims": userVpDims,
  1164. "paging": [1, 2000]
  1165. }, (response, hasError) {
  1166. UserVpBeanEntity entity =
  1167. UserVpBeanEntity().fromJson(json.decode(response.data.toString()));
  1168. if (entity.data.data.length != 0) {
  1169. MyTools().toPage(context, OtherPeopleSTurnoverPage(data), (then) {});
  1170. } else {
  1171. // showSimpleDialog('你还未获取透视道具或道具用完,请先购买次数再查看。', context, () {
  1172. // Navigator.pop(context);
  1173. // MyShopBeanDataData shop = MyShopBeanDataData();
  1174. // shop.shopUid = store.uid;
  1175. // shop.shopName = store.name;
  1176. // shop.shopPic = store.picture;
  1177. // MyTools().toPage(
  1178. // context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1179. // });
  1180. MyShopBeanDataData shop = MyShopBeanDataData();
  1181. shop.shopUid = store.uid;
  1182. shop.shopName = store.name;
  1183. shop.shopPic = store.picture;
  1184. MyTools().toPage(
  1185. context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1186. }
  1187. }, (error) {});
  1188. }
  1189. void shopInfo() {
  1190. showDialog(
  1191. context: context,
  1192. builder: (BuildContext context) {
  1193. return GestureDetector(
  1194. onTap: (){
  1195. Navigator.pop(context);
  1196. },
  1197. child: Material(
  1198. color: Colors.black12,
  1199. child: Center(
  1200. child: GestureDetector(
  1201. onTap: (){},
  1202. child: Container(
  1203. decoration: BoxDecoration(
  1204. borderRadius: BorderRadius.circular(16),
  1205. color: Colors.white,
  1206. ),
  1207. height: 510,
  1208. margin: EdgeInsets.symmetric(horizontal: 28),
  1209. padding: EdgeInsets.symmetric(horizontal: 14, vertical: 15),
  1210. child: Column(
  1211. children: [
  1212. Container(
  1213. height: MediaQuery.of(context).size.width - 71,
  1214. width: MediaQuery.of(context).size.width - 56,
  1215. child: ClipRRect(
  1216. child: MyViews().netImg(
  1217. imgURL(widget.data.shopPic),
  1218. MediaQuery.of(context).size.width - 84,
  1219. MediaQuery.of(context).size.width - 84),
  1220. borderRadius: BorderRadius.circular(4),
  1221. ),
  1222. ),
  1223. Row(
  1224. children: [
  1225. SvgPicture.asset(
  1226. 'images/svg/店铺.svg',
  1227. height: 21,
  1228. width: 21,
  1229. ),
  1230. Container(
  1231. width: 6,
  1232. ),
  1233. Expanded(
  1234. child: Text(
  1235. widget.data.shopName,
  1236. style: TextStyle(
  1237. color: MyColors.c333333, fontSize: 16),
  1238. ))
  1239. ],
  1240. ),
  1241. Container(
  1242. height: 10,
  1243. ),
  1244. Text(
  1245. store != null && store.introduction.isNotEmpty
  1246. ? '货帮介绍:${store.introduction}'
  1247. : '货帮介绍:暂无',
  1248. style: TextStyle(
  1249. color: MyColors.c333333,
  1250. fontSize: 12,
  1251. ),
  1252. maxLines: 3,
  1253. overflow: TextOverflow.ellipsis,
  1254. softWrap: true,
  1255. ),
  1256. Container(
  1257. height: 10,
  1258. ),
  1259. Row(
  1260. children: [
  1261. SvgPicture.asset(
  1262. 'images/svg/地址.svg',
  1263. color: MyColors.c666666,
  1264. height: 12,
  1265. width: 12,
  1266. ),
  1267. Container(
  1268. width: 5,
  1269. ),
  1270. Expanded(
  1271. child: Text(
  1272. store != null && store.address.isNotEmpty
  1273. ? store.address
  1274. : '暂无',
  1275. style: TextStyle(
  1276. color: MyColors.c666666, fontSize: 11),
  1277. maxLines: 1,
  1278. overflow: TextOverflow.ellipsis,
  1279. softWrap: true,
  1280. ),
  1281. ),
  1282. ],
  1283. ),
  1284. Container(
  1285. height: 10,
  1286. ),
  1287. Visibility(
  1288. visible: store != null && store.mobile.isNotEmpty,
  1289. child: GestureDetector(
  1290. onTap: () {
  1291. launch('tel:${store.mobile}');
  1292. },
  1293. behavior: HitTestBehavior.translucent,
  1294. child: Container(
  1295. decoration: BoxDecoration(
  1296. color: MyColors.cFF4233,
  1297. borderRadius: BorderRadius.circular(20),
  1298. ),
  1299. height: 40,
  1300. child: Row(
  1301. children: [
  1302. SvgPicture.asset(
  1303. 'images/svg/电话.svg',
  1304. color: Colors.white,
  1305. height: 24,
  1306. width: 24,
  1307. ),
  1308. Container(
  1309. width: 4,
  1310. ),
  1311. Text(
  1312. store == null ? '' : store.mobile,
  1313. style: TextStyle(
  1314. color: Colors.white, fontSize: 15),
  1315. ),
  1316. ],
  1317. mainAxisAlignment: MainAxisAlignment.center,
  1318. ),
  1319. alignment: Alignment.center,
  1320. ),
  1321. ),
  1322. )
  1323. ],
  1324. mainAxisAlignment: MainAxisAlignment.spaceAround,
  1325. crossAxisAlignment: CrossAxisAlignment.start,
  1326. ),
  1327. ),
  1328. ),
  1329. ),
  1330. ),
  1331. );
  1332. },
  1333. );
  1334. }
  1335. void collectionShop() {
  1336. if(MyCookie().getUID()==widget.data.ownerUid){
  1337. return;
  1338. }
  1339. if (!collect) {
  1340. MyDio().save({
  1341. 'key': 'shop_user',
  1342. 'object': {
  1343. 'review_state': 1,
  1344. 'user_uid': MyCookie().getUID(),
  1345. 'shop_uid': widget.data.shopUid,
  1346. 'role': shopUserMember
  1347. }
  1348. }, (response, hasError) {
  1349. if (!hasError) {
  1350. needRE = !needRE;
  1351. EventBus().emit('needRE', needRE);
  1352. showToast('收藏成功');
  1353. queryWhetherToFollow();
  1354. }
  1355. }, (error) {});
  1356. } else {
  1357. MyDio().del({
  1358. 'key': 'shop_user',
  1359. 'ids': [shopUserID]
  1360. }, (response, hasError) {
  1361. if (!hasError) {
  1362. needRE = !needRE;
  1363. EventBus().emit('needRE', needRE);
  1364. showToast('取消收藏');
  1365. collect = false;
  1366. shopUserID = null;
  1367. setState(() {});
  1368. }
  1369. }, (error) {});
  1370. }
  1371. }
  1372. int shopUserID;
  1373. void queryWhetherToFollow() {
  1374. MyDio().query({
  1375. "key": "shop_user",
  1376. "filters": {
  1377. "conditions": [
  1378. "shop_uid==${widget.data.shopUid}",
  1379. "user_uid==${MyCookie().getUID()}"
  1380. ]
  1381. },
  1382. "dims": shopUserDims,
  1383. "paging": [1, 1]
  1384. }, (response, hasError) {
  1385. if (!hasError) {
  1386. MyShopBeanEntity entity =
  1387. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1388. collect = entity.data.data.length != 0;
  1389. if (entity.data.data.isNotEmpty) {
  1390. shopUserID = entity.data.data[0].id;
  1391. }
  1392. setState(() {});
  1393. }
  1394. }, (error) {});
  1395. }
  1396. }