gang_in_page.dart 54 KB

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