gang_in_page.dart 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'package:bbyyy/beans/apply_for_red_packet_bean_entity.dart';
  4. import 'package:bbyyy/beans/goods_bean_entity.dart';
  5. import 'package:bbyyy/beans/my_shop_bean_entity.dart';
  6. import 'package:bbyyy/beans/new_order_bean_entity.dart';
  7. import 'package:bbyyy/beans/red_envelope_wall_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/my_tools/role_permissions.dart';
  23. import 'package:bbyyy/paegs/chat_page/chat_page.dart';
  24. import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_information_page/add_member_page/add_member_page.dart';
  25. import 'package:bbyyy/paegs/gang_page/gang_in_page/pay_to_the_helper_page/pay_to_the_helper_page.dart';
  26. import 'package:bbyyy/paegs/gang_page/gang_in_page/qr_pay_page/set_amount_page.dart';
  27. import 'package:bbyyy/paegs/gang_page/gang_in_page/send_red_envelope_page/send_red_envelope_page.dart';
  28. import 'package:bbyyy/paegs/gang_page/gang_in_page/shop_flow_page/shop_flow_page.dart';
  29. import 'package:bbyyy/paegs/gang_page/qr_code_for_store_payment_page/qr_code_for_store_payment_page.dart';
  30. import 'package:bbyyy/paegs/mine_page/privacy_protection_props_page/privacy_protection_props_page.dart';
  31. import 'package:bbyyy/paegs/mine_page/referrer_page/referrer_page.dart';
  32. import 'package:bbyyy/paegs/other_people_s_turnover_page/other_people_s_turnover_page.dart';
  33. import 'package:bbyyy/paegs/pay_page/order_information_page.dart';
  34. import 'package:bbyyy/paegs/release_goods_page/release_goods_page.dart';
  35. import 'package:flutter/cupertino.dart';
  36. import 'package:flutter/material.dart';
  37. import 'package:flutter_slidable/flutter_slidable.dart';
  38. import 'package:flutter_svg/svg.dart';
  39. import 'package:pull_to_refresh/pull_to_refresh.dart';
  40. import 'package:url_launcher/url_launcher.dart';
  41. import 'gang_information_page/gang_information_page.dart';
  42. import 'gang_information_page/member_list_page/member_details_page.dart';
  43. import 'initiate_collection_page/initiate_collection_page.dart';
  44. import 'scan_page/scan_page.dart';
  45. class GangInPage extends StatefulWidget {
  46. MyShopBeanDataData data;
  47. NewOrderBeanContent order;
  48. GangInPage(this.data, this.order);
  49. @override
  50. _GangInPageState createState() => _GangInPageState();
  51. }
  52. class _GangInPageState extends State<GangInPage> {
  53. int selectedIndex = 0;
  54. RefreshController controller = RefreshController(initialRefresh: true);
  55. int page = 1;
  56. bool collect = false;
  57. bool needRE = false;
  58. bool canSendGood = false;
  59. bool hideOfflinePay = true;
  60. bool showMore = false;
  61. List<RedEnvelopeWallBeanDataData> redEnvelopes = [];
  62. _GangInPageState();
  63. List<GoodsBeanDataData> goods = [];
  64. List<SmartOrderBeanDataData> orders = [];
  65. double ppx;
  66. bool redWallShowMore = false;
  67. TextEditingController _textEditingController = TextEditingController();
  68. @override
  69. void initState() {
  70. // TODO: implement initState
  71. super.initState();
  72. EventBus().on('payAnOrder', (arg) {
  73. controller.requestRefresh();
  74. });
  75. EventBus().on('reNoPayOrder', (arg) {
  76. controller.requestRefresh();
  77. });
  78. EventBus().on('刷新未付订单', (arg) {
  79. controller.requestRefresh();
  80. });
  81. Future.delayed(Duration.zero, () {
  82. if (widget.order != null) {
  83. setState(() {
  84. selectedIndex = 2;
  85. payTheOrder();
  86. });
  87. }
  88. });
  89. if (paymentAuthority(widget.data.role)) {
  90. selectedIndex = 1;
  91. }
  92. Future.delayed(Duration.zero, () {
  93. queryRedEnvelope();
  94. queryWhetherToFollow();
  95. queryStoreInformation();
  96. });
  97. }
  98. @override
  99. void dispose() {
  100. // TODO: implement dispose
  101. super.dispose();
  102. EventBus().off('payAnOrder');
  103. EventBus().off('reNoPayOrder');
  104. EventBus().off('刷新未付订单');
  105. }
  106. @override
  107. Widget build(BuildContext context) {
  108. ppx = MediaQuery.of(context).size.width / 375;
  109. return GestureDetector(
  110. onTap: () {
  111. MyTools().hideKeyboard(context);
  112. },
  113. child: Scaffold(
  114. body: Column(
  115. children: [
  116. MyViews().myAppBar(widget.data.shopName, context, [
  117. Visibility(
  118. visible: false,
  119. child: IconButton(
  120. icon: Icon(Icons.qr_code_scanner),
  121. onPressed: () async {
  122. MyTools().toPage(context, ScanPage(), (then) {
  123. if (then is String) {
  124. if (then.isNotEmpty &&
  125. then != null &&
  126. then.length == 8) {
  127. Timer(Duration(milliseconds: 200), () {
  128. StoreBeanDataData store = StoreBeanDataData();
  129. store.ownerUid = widget.data.ownerUid;
  130. store.ownerName = widget.data.ownerName;
  131. store.uid = widget.data.shopUid;
  132. MyTools().toPage(
  133. context,
  134. AddMemberPage(
  135. store: store,
  136. qrUID: then,
  137. ),
  138. (then) {});
  139. MyTools().hideKeyboard(context);
  140. controller.requestRefresh();
  141. });
  142. }
  143. }
  144. });
  145. }),
  146. ),
  147. Visibility(
  148. visible: false,
  149. child: IconButton(
  150. icon: Icon(Icons.more_horiz),
  151. onPressed: () {
  152. MyTools().toPage(
  153. context, GangInformationPage(widget.data), (then) {
  154. if (then == '删除货帮') {
  155. Navigator.pop(context, '删除货帮');
  156. }
  157. });
  158. }),
  159. ),
  160. PopupMenuButton<String>(
  161. icon: Icon(Icons.more_horiz),
  162. onSelected: (v) {
  163. switch (v) {
  164. case '扫一扫':
  165. MyTools().toPage(context, ScanPage(), (then) {
  166. if (then is String) {
  167. if (then.isNotEmpty &&
  168. then != null &&
  169. then.length == 8) {
  170. Timer(Duration(milliseconds: 200), () {
  171. StoreBeanDataData store = StoreBeanDataData();
  172. store.ownerUid = widget.data.ownerUid;
  173. store.ownerName = widget.data.ownerName;
  174. store.uid = widget.data.shopUid;
  175. MyTools().toPage(
  176. context,
  177. AddMemberPage(
  178. store: store,
  179. qrUID: then,
  180. ),
  181. (then) {});
  182. MyTools().hideKeyboard(context);
  183. controller.requestRefresh();
  184. });
  185. }
  186. }
  187. });
  188. break;
  189. case '发布商品':
  190. MyTools().toPage(
  191. context, ReleaseGoodsPage(null, widget.data.shopName),
  192. (then) {
  193. controller.requestRefresh();
  194. });
  195. break;
  196. case '货帮详情':
  197. MyTools().toPage(
  198. context, GangInformationPage(widget.data), (then) {
  199. queryStoreInformation();
  200. if (then == '删除货帮') {
  201. Navigator.pop(context, '删除货帮');
  202. }
  203. });
  204. break;
  205. case '收款二维码':
  206. MyTools().toPage(context,
  207. QRCodeForStorePaymentPage(widget.data), (then) {});
  208. break;
  209. case '货帮流水':
  210. MyTools().toPage(
  211. context, ShopFlowPage(widget.data), (then) {});
  212. break;
  213. case '推荐人':
  214. MyTools().toPage(
  215. context, ReferrerPage(data: widget.data), (then) {});
  216. break;
  217. case '发送红包':
  218. MyTools().toPage(
  219. context, SendRedEnvelopePage(widget.data), (then) {
  220. queryRedEnvelope();
  221. });
  222. break;
  223. default:
  224. break;
  225. }
  226. },
  227. itemBuilder: (context) {
  228. return <PopupMenuEntry<String>>[
  229. if (canSendGood)
  230. PopupMenuItem<String>(
  231. value: '发布商品',
  232. child: Row(
  233. children: [
  234. SvgPicture.asset(
  235. 'images/svg/发布商品_icon.svg',
  236. height: 22,
  237. width: 22,
  238. ),
  239. Container(
  240. child: Text(
  241. '发布商品',
  242. style: TextStyle(
  243. fontSize: 14, color: MyColors.c333333),
  244. ),
  245. margin: EdgeInsets.only(left: 5),
  246. ),
  247. ],
  248. ),
  249. ),
  250. PopupMenuItem<String>(
  251. value: '货帮详情',
  252. child: Row(
  253. children: [
  254. SvgPicture.asset(
  255. 'images/svg/货帮详情_icon.svg',
  256. height: 20,
  257. width: 20,
  258. ),
  259. Container(
  260. child: Text(
  261. '货帮详情',
  262. style: TextStyle(
  263. fontSize: 14, color: MyColors.c333333),
  264. ),
  265. margin: EdgeInsets.only(left: 5),
  266. ),
  267. ],
  268. ),
  269. ),
  270. if (addMemberPermissions(widget.data.role))
  271. PopupMenuItem<String>(
  272. value: '扫一扫',
  273. child: Row(
  274. children: [
  275. SvgPicture.asset(
  276. 'images/svg/扫一扫_icon.svg',
  277. height: 20,
  278. width: 20,
  279. ),
  280. Container(
  281. child: Text(
  282. '扫一扫',
  283. style: TextStyle(
  284. fontSize: 14, color: MyColors.c333333),
  285. ),
  286. margin: EdgeInsets.only(left: 5),
  287. ),
  288. ],
  289. ),
  290. ),
  291. if (MyCookie().getUID() == widget.data.ownerUid &&
  292. !widget.data.privateShop)
  293. PopupMenuItem<String>(
  294. value: '收款二维码',
  295. child: Row(
  296. children: [
  297. SvgPicture.asset(
  298. 'images/svg/二维码.svg',
  299. height: 20,
  300. width: 20,
  301. ),
  302. Container(
  303. child: Text(
  304. '收款二维码',
  305. style: TextStyle(
  306. fontSize: 14, color: MyColors.c333333),
  307. ),
  308. margin: EdgeInsets.only(left: 5),
  309. ),
  310. ],
  311. ),
  312. ),
  313. if (checkStoreFlowPermissions(widget.data.role))
  314. PopupMenuItem<String>(
  315. value: '货帮流水',
  316. child: Row(
  317. children: [
  318. SvgPicture.asset(
  319. 'images/svg/流水.svg',
  320. height: 20,
  321. width: 20,
  322. ),
  323. Container(
  324. child: Text(
  325. '货帮流水',
  326. style: TextStyle(
  327. fontSize: 14, color: MyColors.c333333),
  328. ),
  329. margin: EdgeInsets.only(left: 5),
  330. ),
  331. ],
  332. ),
  333. ),
  334. if (viewReferralAuthority(widget.data.role))
  335. PopupMenuItem<String>(
  336. value: '推荐人',
  337. child: Row(
  338. children: [
  339. SvgPicture.asset(
  340. 'images/svg/推荐人.svg',
  341. height: 20,
  342. width: 20,
  343. ),
  344. Container(
  345. child: Text(
  346. '推荐人',
  347. style: TextStyle(
  348. fontSize: 14, color: MyColors.c333333),
  349. ),
  350. margin: EdgeInsets.only(left: 5),
  351. ),
  352. ],
  353. ),
  354. ),
  355. PopupMenuItem<String>(
  356. value: '发送红包',
  357. child: Row(
  358. children: [
  359. SvgPicture.asset(
  360. 'images/svg/红包_icon.svg',
  361. height: 20,
  362. width: 20,
  363. ),
  364. Container(
  365. child: Text(
  366. '发送红包',
  367. style: TextStyle(
  368. fontSize: 14, color: MyColors.c333333),
  369. ),
  370. margin: EdgeInsets.only(left: 5),
  371. ),
  372. ],
  373. ),
  374. ),
  375. ];
  376. },
  377. )
  378. ]),
  379. Container(
  380. color: MyColors.cF7F7F7,
  381. child: Container(
  382. decoration: BoxDecoration(
  383. borderRadius: BorderRadius.circular(4),
  384. color: Colors.white),
  385. margin: EdgeInsets.only(top: 10, left: 10, right: 10),
  386. child: Column(
  387. children: [
  388. Row(
  389. children: [
  390. Container(
  391. margin: EdgeInsets.only(
  392. right: 10, top: 6, left: 6, bottom: 6),
  393. child: GestureDetector(
  394. onTap: () {
  395. shopInfo();
  396. },
  397. behavior: HitTestBehavior.translucent,
  398. child: ClipRRect(
  399. child: MyViews()
  400. .netImg(imgURL(widget.data.shopPic), 65, 65),
  401. borderRadius: BorderRadius.circular(4),
  402. ),
  403. ),
  404. ),
  405. Expanded(
  406. child: Container(
  407. height: 65,
  408. margin: EdgeInsets.only(right: 6),
  409. child: Column(
  410. children: [
  411. Row(
  412. children: [
  413. Text(
  414. widget.data.shopName,
  415. style: TextStyle(
  416. color: MyColors.c333333,
  417. fontSize: 13),
  418. maxLines: 1,
  419. overflow: TextOverflow.ellipsis,
  420. softWrap: true,
  421. ),
  422. ],
  423. mainAxisAlignment:
  424. MainAxisAlignment.spaceBetween,
  425. ),
  426. Row(
  427. children: [
  428. Expanded(
  429. child: Text(
  430. store != null &&
  431. store.introduction.isNotEmpty
  432. ? '货帮介绍:${store.introduction}'
  433. : '货帮介绍:暂无',
  434. style: TextStyle(
  435. color: MyColors.c666666,
  436. fontSize: 11),
  437. maxLines: 1,
  438. overflow: TextOverflow.ellipsis,
  439. softWrap: true,
  440. ),
  441. ),
  442. ],
  443. crossAxisAlignment: CrossAxisAlignment.center,
  444. ),
  445. GestureDetector(
  446. onTap: () {
  447. MyViews().mapNavigationPopup(store.latitude,
  448. store.longitude, context);
  449. },
  450. behavior: HitTestBehavior.translucent,
  451. child: Row(
  452. children: [
  453. SvgPicture.asset(
  454. 'images/svg/地址.svg',
  455. color: MyColors.c666666,
  456. height: 12,
  457. width: 12,
  458. ),
  459. Container(
  460. width: 5,
  461. ),
  462. Expanded(
  463. child: Text(
  464. store != null &&
  465. store.address.isNotEmpty
  466. ? store.address
  467. : '暂无',
  468. style: TextStyle(
  469. color: MyColors.c666666,
  470. fontSize: 11),
  471. maxLines: 1,
  472. overflow: TextOverflow.ellipsis,
  473. softWrap: true,
  474. ),
  475. ),
  476. ],
  477. ),
  478. ),
  479. ],
  480. crossAxisAlignment: CrossAxisAlignment.start,
  481. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  482. ),
  483. ),
  484. ),
  485. Visibility(
  486. visible: !widget.data.privateShop,
  487. child: GestureDetector(
  488. child: Container(
  489. margin: EdgeInsets.all(12),
  490. child: SvgPicture.asset(
  491. collect
  492. ? 'images/svg/已收藏.svg'
  493. : 'images/svg/未收藏.svg',
  494. height: 20,
  495. width: 20,
  496. ),
  497. ),
  498. onTap: () {
  499. if (MyCookie().getUID() == widget.data.ownerUid) {
  500. return;
  501. }
  502. EasyLoading.show();
  503. collectionShop();
  504. },
  505. ),
  506. ),
  507. ],
  508. ),
  509. Container(
  510. height: 0.5,
  511. color: MyColors.cE7E7E7,
  512. ),
  513. Visibility(
  514. visible: store != null && store.mobile.isNotEmpty,
  515. child: Container(
  516. margin: EdgeInsets.all(6),
  517. child: Row(
  518. children: [
  519. Row(
  520. children: [
  521. SvgPicture.asset(
  522. 'images/svg/电话.svg',
  523. height: 18,
  524. width: 18,
  525. ),
  526. Container(
  527. width: 5,
  528. ),
  529. Text(
  530. store == null ? '暂无' : store.mobile,
  531. style: TextStyle(
  532. color: MyColors.cFF4233, fontSize: 12),
  533. ),
  534. ],
  535. ),
  536. GestureDetector(
  537. onTap: () {
  538. launch('tel:${store.mobile}');
  539. },
  540. behavior: HitTestBehavior.translucent,
  541. child: Container(
  542. decoration: BoxDecoration(
  543. color: MyColors.cFF4233,
  544. borderRadius: BorderRadius.circular(10),
  545. ),
  546. height: 20,
  547. width: 50,
  548. child:
  549. MyViews().myText('点击拨打', Colors.white, 9),
  550. alignment: Alignment.center,
  551. ),
  552. )
  553. ],
  554. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  555. ),
  556. ),
  557. )
  558. ],
  559. ),
  560. ),
  561. ),
  562. if (store != null && store.notice.isNotEmpty)
  563. GestureDetector(
  564. onTap: () {
  565. setState(() {
  566. showMore = !showMore;
  567. });
  568. },
  569. behavior: HitTestBehavior.translucent,
  570. child: AnimatedContainer(
  571. child: showMore
  572. ? Text(
  573. '货帮公告 : ${store.notice.isEmpty ? '暂无' : store.notice}',
  574. )
  575. : Text(
  576. '货帮公告 : ${store.notice.isEmpty ? '暂无' : store.notice}',
  577. maxLines: 1,
  578. overflow: TextOverflow.ellipsis,
  579. softWrap: true,
  580. ),
  581. color: Colors.white,
  582. width: double.infinity,
  583. padding: EdgeInsets.all(12),
  584. margin: EdgeInsets.only(top: 10),
  585. duration: Duration(seconds: 1),
  586. ),
  587. ),
  588. if (redEnvelopes.isNotEmpty) redEnvelopeWall(),
  589. Visibility(
  590. visible:
  591. widget.data.privateShop || paymentAuthority(widget.data.role),
  592. child: Container(
  593. height: 40,
  594. margin: EdgeInsets.only(top: 10),
  595. color: Colors.white,
  596. child: Row(
  597. children: [
  598. Expanded(
  599. flex: 1,
  600. child: GestureDetector(
  601. onTap: () {
  602. setState(() {
  603. selectedIndex = 0;
  604. controller.requestRefresh();
  605. });
  606. },
  607. behavior: HitTestBehavior.translucent,
  608. child: Padding(
  609. padding: EdgeInsets.only(left: 10, right: 10),
  610. child: Column(
  611. children: [
  612. Text(
  613. '货帮商品',
  614. style: TextStyle(
  615. color: selectedIndex == 0
  616. ? MyColors.cFF4233
  617. : MyColors.c666666,
  618. fontSize: 15),
  619. ),
  620. Container(
  621. height: 10,
  622. child: Visibility(
  623. child: SvgPicture.asset('images/svg/tab.svg'),
  624. visible: selectedIndex == 0,
  625. ),
  626. )
  627. ],
  628. mainAxisAlignment: MainAxisAlignment.end,
  629. ),
  630. ),
  631. ),
  632. ),
  633. Expanded(
  634. flex: 1,
  635. child: GestureDetector(
  636. onTap: () {
  637. setState(() {
  638. selectedIndex = 1;
  639. controller.requestRefresh();
  640. });
  641. },
  642. behavior: HitTestBehavior.translucent,
  643. child: Padding(
  644. padding: EdgeInsets.only(left: 10, right: 10),
  645. child: Column(
  646. children: [
  647. Text(
  648. paymentAuthority(widget.data.role)
  649. ? '未付订单'
  650. : '未收订单',
  651. style: TextStyle(
  652. color: selectedIndex == 1
  653. ? MyColors.cFF4233
  654. : MyColors.c666666,
  655. fontSize: 15),
  656. ),
  657. Container(
  658. height: 10,
  659. child: Visibility(
  660. child: SvgPicture.asset('images/svg/tab.svg'),
  661. visible: selectedIndex == 1,
  662. ),
  663. )
  664. ],
  665. mainAxisAlignment: MainAxisAlignment.end,
  666. ),
  667. ),
  668. ),
  669. ),
  670. Expanded(
  671. flex: 1,
  672. child: GestureDetector(
  673. onTap: () {
  674. setState(() {
  675. selectedIndex = 2;
  676. controller.requestRefresh();
  677. });
  678. },
  679. behavior: HitTestBehavior.translucent,
  680. child: Padding(
  681. padding: EdgeInsets.only(left: 10, right: 10),
  682. child: Column(
  683. children: [
  684. Text(
  685. paymentAuthority(widget.data.role)
  686. ? '已付订单'
  687. : '未付订单',
  688. style: TextStyle(
  689. color: selectedIndex == 2
  690. ? MyColors.cFF4233
  691. : MyColors.c666666,
  692. fontSize: 15),
  693. ),
  694. Container(
  695. height: 10,
  696. child: Visibility(
  697. child: SvgPicture.asset('images/svg/tab.svg'),
  698. visible: selectedIndex == 2,
  699. ),
  700. )
  701. ],
  702. mainAxisAlignment: MainAxisAlignment.end,
  703. ),
  704. ),
  705. ),
  706. ),
  707. Expanded(
  708. flex: MyCookie().getUID() == widget.data.ownerUid ||
  709. !hideMember
  710. ? 1
  711. : 0,
  712. child: Visibility(
  713. visible: MyCookie().getUID() == widget.data.ownerUid ||
  714. !hideMember,
  715. child: GestureDetector(
  716. onTap: () {
  717. setState(() {
  718. selectedIndex = 3;
  719. controller.requestRefresh();
  720. });
  721. },
  722. behavior: HitTestBehavior.translucent,
  723. child: Padding(
  724. padding: EdgeInsets.only(left: 10, right: 10),
  725. child: Column(
  726. children: [
  727. Text(
  728. '货帮成员',
  729. style: TextStyle(
  730. color: selectedIndex == 3
  731. ? MyColors.cFF4233
  732. : MyColors.c666666,
  733. fontSize: 15),
  734. ),
  735. Container(
  736. height: 10,
  737. child: Visibility(
  738. child:
  739. SvgPicture.asset('images/svg/tab.svg'),
  740. visible: selectedIndex == 3,
  741. ),
  742. )
  743. ],
  744. mainAxisAlignment: MainAxisAlignment.end,
  745. ),
  746. ),
  747. ),
  748. ),
  749. )
  750. ],
  751. ),
  752. ),
  753. ),
  754. body(),
  755. Container(
  756. color: Colors.white,
  757. child: SafeArea(
  758. top: false,
  759. child: Container(
  760. padding: EdgeInsets.symmetric(horizontal: 37),
  761. color: Colors.white,
  762. width: double.infinity,
  763. height: 60,
  764. child: Row(
  765. children: [
  766. Expanded(
  767. child: GestureDetector(
  768. onTap: () {
  769. if (!widget.data.privateShop &&
  770. MyCookie().getUID() == widget.data.ownerUid) {
  771. MyTools().toPage(context,
  772. SetAmountPage(widget.data), (then) {});
  773. } else {
  774. queryShopMembers(true);
  775. }
  776. },
  777. behavior: HitTestBehavior.translucent,
  778. child: Container(
  779. decoration: BoxDecoration(
  780. borderRadius: !hideOfflinePay
  781. ? BorderRadius.only(
  782. topLeft: Radius.circular(20),
  783. bottomLeft: Radius.circular(20),
  784. )
  785. : BorderRadius.circular(20),
  786. border: Border.all(
  787. color: MyColors.cFF4233, width: 1)),
  788. height: 40,
  789. child: MyViews().myText(
  790. !widget.data.privateShop &&
  791. MyCookie().getUID() ==
  792. widget.data.ownerUid
  793. ? '扫码收款'
  794. : '联系帮主',
  795. MyColors.cFF4233,
  796. 14),
  797. alignment: Alignment.center),
  798. ),
  799. ),
  800. if (!hideOfflinePay)
  801. Expanded(
  802. child: GestureDetector(
  803. onTap: () {
  804. if (MyCookie().getUID() == widget.data.ownerUid) {
  805. MyTools().toPage(context,
  806. InitiateCollectionPage(widget.data),
  807. (then) {
  808. if (then is String && then == '发起收款') {
  809. controller.requestRefresh();
  810. }
  811. });
  812. } else {
  813. MyTools().toPage(context,
  814. PayToTheHelperPage(widget.data), (then) {});
  815. }
  816. },
  817. behavior: HitTestBehavior.translucent,
  818. child: Container(
  819. decoration: BoxDecoration(
  820. borderRadius: BorderRadius.only(
  821. topRight: Radius.circular(20),
  822. bottomRight: Radius.circular(20),
  823. ),
  824. color: MyColors.cFF4233),
  825. height: 40,
  826. child: MyViews().myText(
  827. MyCookie().getUID() == widget.data.ownerUid
  828. ? '发起收款'
  829. : '到店付款',
  830. Colors.white,
  831. 14),
  832. alignment: Alignment.center),
  833. ),
  834. )
  835. ],
  836. ),
  837. ),
  838. ),
  839. )
  840. ],
  841. ),
  842. ),
  843. );
  844. }
  845. body() {
  846. if (selectedIndex == 0) {
  847. return Expanded(
  848. child: SmartRefresher(
  849. controller: controller,
  850. onRefresh: onRefresh,
  851. onLoading: onLoading,
  852. enablePullDown: true,
  853. enablePullUp: true,
  854. child: goods.length == 0
  855. ? SingleChildScrollView(child: noData())
  856. : GridView.builder(
  857. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  858. crossAxisCount: 2, //每行三列
  859. childAspectRatio: 164 / 261, //显示区域宽高相等
  860. mainAxisSpacing: 8,
  861. crossAxisSpacing: 8),
  862. itemCount: goods.length,
  863. padding:
  864. EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
  865. itemBuilder: (context, index) {
  866. return MyViews().getGoodsItem(goods[index], context);
  867. }),
  868. ),
  869. );
  870. } else if (selectedIndex == 1) {
  871. return Expanded(
  872. child: SmartRefresher(
  873. controller: controller,
  874. onRefresh: onRefresh,
  875. onLoading: onLoading,
  876. enablePullDown: true,
  877. enablePullUp: true,
  878. child: orders.length == 0
  879. ? SingleChildScrollView(child: noData())
  880. : ListView.builder(
  881. itemBuilder: (c, index) {
  882. return Slidable(
  883. child: MyViews().getNoPayGoodsItem(orders[index], context,
  884. widget.data.ownerUid, widget.data.role),
  885. actionPane: SlidableDrawerActionPane(),
  886. enabled: paymentAuthority(widget.data.role),
  887. actionExtentRatio: 0.25,
  888. secondaryActions: <Widget>[
  889. SlideAction(
  890. child: Container(
  891. child: Container(
  892. decoration: BoxDecoration(
  893. borderRadius: BorderRadius.circular(30),
  894. color: MyColors.cFF4233,
  895. ),
  896. height: 60,
  897. width: 60,
  898. child: SvgPicture.asset(
  899. 'images/svg/del.svg',
  900. height: 40,
  901. width: 40,
  902. ),
  903. alignment: Alignment.center,
  904. ),
  905. ),
  906. onTap: () {
  907. showSimpleDialog(
  908. '将删除订单(${orders[index].uid})', context, () {
  909. Navigator.pop(context);
  910. deleteOrder(orders[index]);
  911. });
  912. },
  913. )
  914. ],
  915. );
  916. },
  917. itemCount: orders.length,
  918. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  919. ),
  920. ),
  921. );
  922. } else if (selectedIndex == 2) {
  923. return Expanded(
  924. child: SmartRefresher(
  925. controller: controller,
  926. onRefresh: onRefresh,
  927. onLoading: onLoading,
  928. enablePullDown: true,
  929. enablePullUp: true,
  930. child: orders.length == 0
  931. ? SingleChildScrollView(child: noData())
  932. : ListView.builder(
  933. itemBuilder: (c, index) {
  934. return Slidable(
  935. child: MyViews().getNoPayGoodsItem(orders[index], context,
  936. widget.data.ownerUid, widget.data.role),
  937. actionPane: SlidableDrawerActionPane(),
  938. enabled: orders[index].type == orderTypeOfflineTransfer &&
  939. orders[index].buyerUid == MyCookie().getUID(),
  940. actionExtentRatio: 0.25,
  941. secondaryActions: <Widget>[
  942. SlideAction(
  943. child: Container(
  944. child: Container(
  945. decoration: BoxDecoration(
  946. borderRadius: BorderRadius.circular(30),
  947. color: MyColors.cFF4233,
  948. ),
  949. height: 60,
  950. width: 60,
  951. child: SvgPicture.asset(
  952. 'images/svg/del.svg',
  953. height: 40,
  954. width: 40,
  955. ),
  956. alignment: Alignment.center,
  957. ),
  958. ),
  959. onTap: () {
  960. showSimpleDialog(
  961. '将删除订单(${orders[index].uid})', context, () {
  962. Navigator.pop(context);
  963. deleteOrder(orders[index]);
  964. });
  965. },
  966. )
  967. ],
  968. );
  969. },
  970. itemCount: orders.length,
  971. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  972. ),
  973. ),
  974. );
  975. } else if (selectedIndex == 3) {
  976. return Expanded(
  977. child: Column(
  978. children: [
  979. Container(
  980. height: 40,
  981. decoration: BoxDecoration(
  982. borderRadius: BorderRadius.circular(20), color: Colors.white),
  983. margin: EdgeInsets.only(left: 15, right: 15, top: 10),
  984. child: Row(
  985. children: [
  986. Expanded(
  987. child: TextField(
  988. controller: _textEditingController,
  989. decoration: InputDecoration(
  990. border: InputBorder.none,
  991. disabledBorder: InputBorder.none,
  992. enabledBorder: InputBorder.none,
  993. focusedBorder: InputBorder.none,
  994. isDense: true,
  995. hintText: '请输入信息',
  996. hintStyle:
  997. TextStyle(color: MyColors.c999999, fontSize: 16),
  998. contentPadding:
  999. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
  1000. ),
  1001. )),
  1002. GestureDetector(
  1003. onTap: () {
  1004. controller.requestRefresh();
  1005. MyTools().hideKeyboard(context);
  1006. },
  1007. behavior: HitTestBehavior.translucent,
  1008. child: Container(
  1009. decoration: BoxDecoration(
  1010. borderRadius: BorderRadius.circular(20),
  1011. color: MyColors.cFF4233),
  1012. height: 40,
  1013. width: 80,
  1014. child: Text(
  1015. '搜 索',
  1016. style: TextStyle(color: Colors.white, fontSize: 14),
  1017. ),
  1018. alignment: Alignment.center,
  1019. ),
  1020. )
  1021. ],
  1022. ),
  1023. ),
  1024. Expanded(
  1025. child: SmartRefresher(
  1026. controller: controller,
  1027. onRefresh: onRefresh,
  1028. onLoading: onLoading,
  1029. enablePullDown: true,
  1030. enablePullUp: true,
  1031. child: member.length == 0
  1032. ? SingleChildScrollView(child: noData())
  1033. : ListView.builder(
  1034. itemBuilder: (BuildContext context, int index) {
  1035. return GestureDetector(
  1036. onTap: () {
  1037. if (permissionToModifyCustomerName(
  1038. widget.data.role)) {
  1039. if (MyCookie().getUID() !=
  1040. member[index].userUid) {
  1041. MyTools().toPage(
  1042. context, MemberDetailsPage(member[index]),
  1043. (then) {
  1044. controller.requestRefresh();
  1045. });
  1046. }
  1047. } else {
  1048. return;
  1049. }
  1050. },
  1051. behavior: HitTestBehavior.translucent,
  1052. child: Container(
  1053. padding: EdgeInsets.only(left: 15, right: 15),
  1054. color: Colors.white,
  1055. child: Column(
  1056. children: [
  1057. Container(
  1058. margin: EdgeInsets.only(top: 8, bottom: 6),
  1059. child: Row(
  1060. children: [
  1061. Row(
  1062. children: [
  1063. Container(
  1064. margin: EdgeInsets.only(right: 6),
  1065. child: ClipRRect(
  1066. child: MyViews().netImg(
  1067. imgURL(
  1068. member[index].userPic),
  1069. 42,
  1070. 42),
  1071. borderRadius:
  1072. BorderRadius.circular(21),
  1073. ),
  1074. ),
  1075. MyViews().myText(
  1076. '${member[index].userName} ${store.ownerUid == MyCookie().getUID() ? '(${member[index].userUid})' : ''}',
  1077. MyColors.c333333,
  1078. 15),
  1079. Visibility(
  1080. visible: member[index].role !=
  1081. shopUserMember,
  1082. child: Container(
  1083. decoration: BoxDecoration(
  1084. color: MyColors.cFFCD00,
  1085. borderRadius:
  1086. BorderRadius.circular(
  1087. 8)),
  1088. height: 16,
  1089. padding: EdgeInsets.symmetric(
  1090. horizontal: 5),
  1091. child: MyViews().myText(
  1092. roleText(
  1093. member[index].role),
  1094. Colors.white,
  1095. 10),
  1096. alignment: Alignment.center,
  1097. margin:
  1098. EdgeInsets.only(left: 5),
  1099. ),
  1100. )
  1101. ],
  1102. ),
  1103. Visibility(
  1104. visible: member[index].role !=
  1105. shopUserOwner &&
  1106. member[index].userUid !=
  1107. MyCookie().getUID(),
  1108. child: GestureDetector(
  1109. child: Container(
  1110. margin:
  1111. EdgeInsets.only(right: 10),
  1112. child: SvgPicture.asset(
  1113. 'images/svg/透视.svg',
  1114. height: 25,
  1115. width: 25,
  1116. ),
  1117. ),
  1118. onTap: () {
  1119. queryWhetherThereIsANumberOfPerspectives(
  1120. member[index],
  1121. store,
  1122. context);
  1123. },
  1124. behavior:
  1125. HitTestBehavior.translucent,
  1126. ),
  1127. ),
  1128. ],
  1129. mainAxisAlignment:
  1130. MainAxisAlignment.spaceBetween,
  1131. ),
  1132. ),
  1133. Container(
  1134. height: 0.5,
  1135. color: MyColors.cE7E7E7,
  1136. )
  1137. ],
  1138. ),
  1139. ),
  1140. );
  1141. },
  1142. itemCount: member.length,
  1143. padding: EdgeInsets.only(top: 10),
  1144. ),
  1145. ),
  1146. ),
  1147. ],
  1148. ),
  1149. );
  1150. } else {
  1151. return SingleChildScrollView(child: noData());
  1152. }
  1153. }
  1154. void onRefresh() {
  1155. page = 1;
  1156. if (selectedIndex == 0) {
  1157. queryProducts();
  1158. } else if (selectedIndex == 1) {
  1159. unreceivedOrder();
  1160. } else if (selectedIndex == 3) {
  1161. queryShopMembers(false);
  1162. } else {
  1163. unpaidOrder();
  1164. }
  1165. }
  1166. void onLoading() {
  1167. page++;
  1168. if (selectedIndex == 0) {
  1169. queryProducts();
  1170. } else if (selectedIndex == 1) {
  1171. unreceivedOrder();
  1172. } else if (selectedIndex == 3) {
  1173. queryShopMembers(false);
  1174. } else {
  1175. unpaidOrder();
  1176. }
  1177. }
  1178. //查询商品
  1179. void queryProducts() {
  1180. MyDio().query({
  1181. "key": "commodity",
  1182. "filters": {
  1183. "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"]
  1184. },
  1185. "dims": commodityDims,
  1186. "order_by": ["id,desc", "no,desc"],
  1187. "paging": [page, 20]
  1188. }, (response, hasError) {
  1189. if (!hasError) {
  1190. GoodsBeanEntity entity =
  1191. GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
  1192. if (page == 1) {
  1193. goods.clear();
  1194. }
  1195. goods.addAll(entity.data.data);
  1196. }
  1197. setState(() {
  1198. endRe(controller);
  1199. });
  1200. }, (error) {
  1201. setState(() {
  1202. endRe(controller);
  1203. });
  1204. });
  1205. }
  1206. //查询未收订单
  1207. void unreceivedOrder() {
  1208. var conditions = [];
  1209. if (paymentAuthority(widget.data.role)) {
  1210. conditions.add('state == $orderStateUnpaid');
  1211. conditions.add('shop_uid == ${widget.data.shopUid}');
  1212. } else {
  1213. conditions.add('state == $orderStateUnpaid');
  1214. conditions.add('shop_uid == ${widget.data.shopUid}');
  1215. conditions.add('seller_uid == ${MyCookie().getUID()}');
  1216. }
  1217. MyDio().query({
  1218. "key": "order",
  1219. "filters": {"conditions": conditions},
  1220. "dims": orderDims,
  1221. "paging": [page, 20],
  1222. "order_by": ["create_time,DESC"]
  1223. }, (response, hasError) {
  1224. if (!hasError) {
  1225. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1226. .fromJson(json.decode(response.data.toString()));
  1227. if (page == 1) {
  1228. orders.clear();
  1229. }
  1230. orders.addAll(entity.data.data);
  1231. setState(() {});
  1232. }
  1233. endRe(controller);
  1234. }, (error) {});
  1235. }
  1236. //查询未付订单
  1237. void unpaidOrder() {
  1238. var conditions = [];
  1239. if (paymentAuthority(widget.data.role)) {
  1240. conditions.add('state == $orderStatePaid');
  1241. conditions.add('shop_uid == ${widget.data.shopUid}');
  1242. } else {
  1243. conditions.add('state == $orderStateUnpaid');
  1244. conditions.add('shop_uid == ${widget.data.shopUid}');
  1245. conditions.add('buyer_uid==0');
  1246. conditions.add('buyer_name LIKE ${MyCookie().getName()}');
  1247. }
  1248. var filters;
  1249. if (paymentAuthority(widget.data.role)) {
  1250. filters = {"conditions": conditions};
  1251. } else {
  1252. filters = {
  1253. "conditions": conditions,
  1254. "or": true,
  1255. "filters": [
  1256. {
  1257. "conditions": [
  1258. "state == $orderStateUnpaid",
  1259. 'shop_uid == ${widget.data.shopUid}',
  1260. 'buyer_uid==${MyCookie().getUID()}'
  1261. ]
  1262. }
  1263. ]
  1264. };
  1265. }
  1266. MyDio().query({
  1267. "key": "order",
  1268. "filters": filters,
  1269. "dims": orderDims,
  1270. "paging": [page, 20],
  1271. "order_by": ["create_time,DESC"]
  1272. }, (response, hasError) {
  1273. if (!hasError) {
  1274. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1275. .fromJson(json.decode(response.data.toString()));
  1276. if (page == 1) {
  1277. orders.clear();
  1278. }
  1279. orders.addAll(entity.data.data);
  1280. setState(() {});
  1281. }
  1282. endRe(controller);
  1283. }, (error) {});
  1284. }
  1285. payTheOrder() {
  1286. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  1287. data.sellerUid = widget.order.sellerUID;
  1288. data.sellerName = widget.order.sellerName;
  1289. data.sellerPic = widget.order.sellerPic;
  1290. data.buyerUid = 0;
  1291. data.buyerName = widget.order.buyerName;
  1292. data.buyerPic = '';
  1293. data.amount = widget.order.amount;
  1294. data.uid = widget.order.uID;
  1295. MyTools().toPage(
  1296. context,
  1297. OrderInformationPage(
  1298. false,
  1299. orderType: orderTypeThirdPlatform,
  1300. amount: widget.order.amount,
  1301. uid: widget.order.uID,
  1302. buyerUid: MyCookie().getUID(),
  1303. buyerName: widget.order.buyerName,
  1304. buyerPic: MyCookie().getPic(),
  1305. commodityCount: 1,
  1306. commodityTitle: '第三方订单',
  1307. commodityCover: '',
  1308. sellName: widget.order.sellerName,
  1309. sellPic: widget.order.sellerPic,
  1310. sellUid: widget.order.sellerUID,
  1311. ), (then) {
  1312. controller.requestRefresh();
  1313. PopUpQueue().onShow = false;
  1314. PopUpQueue().showNext();
  1315. });
  1316. // showPayDialog(data, context, () {
  1317. // Navigator.pop(context);
  1318. // // MyTools().toPage(context,
  1319. // // PayPage(widget.order.uID, false, widget.order.amount), (then) {});
  1320. //
  1321. // });
  1322. }
  1323. List<MyShopBeanDataData> member = [];
  1324. List<MyShopBeanDataData> helper = [];
  1325. queryShopMembers(bool toOwner) {
  1326. var conditions = ["shop_uid==${store.uid}", "review_state==1"];
  1327. if (_textEditingController.text.isNotEmpty) {
  1328. conditions
  1329. .add('user_name LIKE ${_textEditingController.text.toString()}');
  1330. }
  1331. MyDio().query({
  1332. "key": "shop_user",
  1333. "filters": {"conditions": conditions},
  1334. "dims": shopUserDims,
  1335. "paging": [page, 50]
  1336. }, (response, hasError) {
  1337. if (!hasError) {
  1338. MyShopBeanEntity entity =
  1339. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1340. if (page == 1) {
  1341. member.clear();
  1342. }
  1343. member.addAll(entity.data.data);
  1344. if (toOwner) {
  1345. helper.clear();
  1346. member.forEach((element) {
  1347. if (element.role == shopUserStaff) {
  1348. helper.add(element);
  1349. }
  1350. });
  1351. MyShopBeanDataData chatWith;
  1352. // if (helper.length == 0) {
  1353. chatWith = member[
  1354. member.indexWhere((element) => element.role == shopUserOwner)];
  1355. // } else {
  1356. // chatWith = helper[Random().nextInt(helper.length)];
  1357. // }
  1358. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1359. } else {
  1360. controller.refreshCompleted();
  1361. controller.loadComplete();
  1362. setState(() {});
  1363. }
  1364. _textEditingController.clear();
  1365. }
  1366. }, (error) {});
  1367. }
  1368. void deleteOrder(SmartOrderBeanDataData order) {
  1369. MyDio().del({
  1370. 'key': 'order',
  1371. 'ids': [order.id]
  1372. }, (response, hasError) {
  1373. if (!hasError) {
  1374. orders.remove(order);
  1375. setState(() {});
  1376. }
  1377. }, (error) {});
  1378. }
  1379. StoreBeanDataData store;
  1380. bool hideMember = true;
  1381. queryStoreInformation() {
  1382. MyDio().query({
  1383. "key": "shop",
  1384. "filters": {
  1385. "conditions": ["uid == ${widget.data.shopUid}"]
  1386. },
  1387. "dims": shopDims,
  1388. "paging": [1, 5]
  1389. }, (response, hasError) {
  1390. if (!hasError) {
  1391. StoreBeanEntity entity =
  1392. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1393. store = entity.data.data[0];
  1394. hideMember = store.hideMembers;
  1395. hideOfflinePay = store.hideOfflinePay;
  1396. //自己的公开店铺
  1397. if (!store.private && store.ownerUid == MyCookie().getUID()) {
  1398. canSendGood = true;
  1399. }
  1400. //自己在某个允许顾客间交易的私有店铺中
  1401. if (store.innerTrade) {
  1402. canSendGood = true;
  1403. }
  1404. setState(() {});
  1405. }
  1406. endRe(controller);
  1407. }, (error) {});
  1408. }
  1409. void queryWhetherThereIsANumberOfPerspectives(
  1410. MyShopBeanDataData data, StoreBeanDataData store, BuildContext context) {
  1411. MyDio().query({
  1412. "key": "user_vp",
  1413. "filters": {
  1414. "conditions": [
  1415. "user_uid == ${MyCookie().getUID()}",
  1416. "vp_key == $vpKeyXRay"
  1417. ]
  1418. },
  1419. "dims": userVpDims,
  1420. "paging": [1, 2000]
  1421. }, (response, hasError) {
  1422. UserVpBeanEntity entity =
  1423. UserVpBeanEntity().fromJson(json.decode(response.data.toString()));
  1424. if (entity.data.data.length != 0) {
  1425. MyTools().toPage(context, OtherPeopleSTurnoverPage(data), (then) {});
  1426. } else {
  1427. // showSimpleDialog('你还未获取透视道具或道具用完,请先购买次数再查看。', context, () {
  1428. // Navigator.pop(context);
  1429. // MyShopBeanDataData shop = MyShopBeanDataData();
  1430. // shop.shopUid = store.uid;
  1431. // shop.shopName = store.name;
  1432. // shop.shopPic = store.picture;
  1433. // MyTools().toPage(
  1434. // context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1435. // });
  1436. MyShopBeanDataData shop = MyShopBeanDataData();
  1437. shop.shopUid = store.uid;
  1438. shop.shopName = store.name;
  1439. shop.shopPic = store.picture;
  1440. MyTools().toPage(
  1441. context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1442. }
  1443. }, (error) {});
  1444. }
  1445. void shopInfo() {
  1446. showDialog(
  1447. context: context,
  1448. builder: (BuildContext context) {
  1449. return GestureDetector(
  1450. onTap: () {
  1451. Navigator.pop(context);
  1452. },
  1453. child: Material(
  1454. color: Colors.black12,
  1455. child: Center(
  1456. child: GestureDetector(
  1457. onTap: () {},
  1458. child: Container(
  1459. decoration: BoxDecoration(
  1460. borderRadius: BorderRadius.circular(16),
  1461. color: Colors.white,
  1462. ),
  1463. height: 510,
  1464. margin: EdgeInsets.symmetric(horizontal: 28),
  1465. padding: EdgeInsets.symmetric(horizontal: 14, vertical: 15),
  1466. child: Column(
  1467. children: [
  1468. Container(
  1469. height: MediaQuery.of(context).size.width - 71,
  1470. width: MediaQuery.of(context).size.width - 56,
  1471. child: ClipRRect(
  1472. child: MyViews().netImg(
  1473. imgURL(widget.data.shopPic),
  1474. MediaQuery.of(context).size.width - 84,
  1475. MediaQuery.of(context).size.width - 84),
  1476. borderRadius: BorderRadius.circular(4),
  1477. ),
  1478. ),
  1479. Row(
  1480. children: [
  1481. SvgPicture.asset(
  1482. 'images/svg/店铺.svg',
  1483. height: 21,
  1484. width: 21,
  1485. ),
  1486. Container(
  1487. width: 6,
  1488. ),
  1489. Expanded(
  1490. child: Text(
  1491. widget.data.shopName,
  1492. style: TextStyle(
  1493. color: MyColors.c333333, fontSize: 16),
  1494. ))
  1495. ],
  1496. ),
  1497. Container(
  1498. height: 10,
  1499. ),
  1500. Text(
  1501. store != null && store.introduction.isNotEmpty
  1502. ? '货帮介绍:${store.introduction}'
  1503. : '货帮介绍:暂无',
  1504. style: TextStyle(
  1505. color: MyColors.c333333,
  1506. fontSize: 12,
  1507. ),
  1508. maxLines: 3,
  1509. overflow: TextOverflow.ellipsis,
  1510. softWrap: true,
  1511. ),
  1512. Container(
  1513. height: 10,
  1514. ),
  1515. Row(
  1516. children: [
  1517. SvgPicture.asset(
  1518. 'images/svg/地址.svg',
  1519. color: MyColors.c666666,
  1520. height: 12,
  1521. width: 12,
  1522. ),
  1523. Container(
  1524. width: 5,
  1525. ),
  1526. Expanded(
  1527. child: Text(
  1528. store != null && store.address.isNotEmpty
  1529. ? store.address
  1530. : '暂无',
  1531. style: TextStyle(
  1532. color: MyColors.c666666, fontSize: 11),
  1533. maxLines: 1,
  1534. overflow: TextOverflow.ellipsis,
  1535. softWrap: true,
  1536. ),
  1537. ),
  1538. ],
  1539. ),
  1540. Container(
  1541. height: 10,
  1542. ),
  1543. Visibility(
  1544. visible: store != null && store.mobile.isNotEmpty,
  1545. child: GestureDetector(
  1546. onTap: () {
  1547. launch('tel:${store.mobile}');
  1548. },
  1549. behavior: HitTestBehavior.translucent,
  1550. child: Container(
  1551. decoration: BoxDecoration(
  1552. color: MyColors.cFF4233,
  1553. borderRadius: BorderRadius.circular(20),
  1554. ),
  1555. height: 40,
  1556. child: Row(
  1557. children: [
  1558. SvgPicture.asset(
  1559. 'images/svg/电话.svg',
  1560. color: Colors.white,
  1561. height: 24,
  1562. width: 24,
  1563. ),
  1564. Container(
  1565. width: 4,
  1566. ),
  1567. Text(
  1568. store == null ? '' : store.mobile,
  1569. style: TextStyle(
  1570. color: Colors.white, fontSize: 15),
  1571. ),
  1572. ],
  1573. mainAxisAlignment: MainAxisAlignment.center,
  1574. ),
  1575. alignment: Alignment.center,
  1576. ),
  1577. ),
  1578. )
  1579. ],
  1580. mainAxisAlignment: MainAxisAlignment.spaceAround,
  1581. crossAxisAlignment: CrossAxisAlignment.start,
  1582. ),
  1583. ),
  1584. ),
  1585. ),
  1586. ),
  1587. );
  1588. },
  1589. );
  1590. }
  1591. void collectionShop() {
  1592. if (!collect) {
  1593. MyDio().save({
  1594. 'key': 'shop_user',
  1595. 'object': {
  1596. 'review_state': 1,
  1597. 'user_uid': MyCookie().getUID(),
  1598. 'shop_uid': widget.data.shopUid,
  1599. 'role': shopUserMember
  1600. }
  1601. }, (response, hasError) {
  1602. if (!hasError) {
  1603. needRE = !needRE;
  1604. EventBus().emit('needRE', needRE);
  1605. showToast('收藏成功');
  1606. queryWhetherToFollow();
  1607. }
  1608. }, (error) {});
  1609. } else {
  1610. MyDio().del({
  1611. 'key': 'shop_user',
  1612. 'ids': [shopUserID]
  1613. }, (response, hasError) {
  1614. if (!hasError) {
  1615. needRE = !needRE;
  1616. EventBus().emit('needRE', needRE);
  1617. showToast('取消收藏');
  1618. collect = false;
  1619. shopUserID = null;
  1620. setState(() {});
  1621. }
  1622. }, (error) {});
  1623. }
  1624. }
  1625. int shopUserID;
  1626. void queryWhetherToFollow() {
  1627. MyDio().query({
  1628. "key": "shop_user",
  1629. "filters": {
  1630. "conditions": [
  1631. "shop_uid==${widget.data.shopUid}",
  1632. "user_uid==${MyCookie().getUID()}"
  1633. ]
  1634. },
  1635. "dims": shopUserDims,
  1636. "paging": [1, 1]
  1637. }, (response, hasError) {
  1638. if (!hasError) {
  1639. MyShopBeanEntity entity =
  1640. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1641. collect = entity.data.data.length != 0;
  1642. if (entity.data.data.isNotEmpty) {
  1643. shopUserID = entity.data.data[0].id;
  1644. }
  1645. setState(() {});
  1646. }
  1647. }, (error) {});
  1648. }
  1649. ScrollController _controller = ScrollController();
  1650. redEnvelopeWall() {
  1651. return Column(
  1652. children: [
  1653. Container(
  1654. height: redWallShowMore
  1655. ? 375 / 3 * ppx / 19 * 48
  1656. : 375 / 3 * ppx / 19 * 24,
  1657. child: GridView.builder(
  1658. controller: _controller,
  1659. itemBuilder: (BuildContext context, int index) {
  1660. return Stack(
  1661. children: [
  1662. Positioned(
  1663. child: Container(
  1664. width: 375 / 3 * ppx,
  1665. height: 375 / 3 * ppx / 19 * 24,
  1666. decoration: BoxDecoration(
  1667. borderRadius: BorderRadius.circular(16),
  1668. color: MyColors.cF25D4B),
  1669. alignment: Alignment.bottomCenter,
  1670. child: CustomPaint(
  1671. painter: RedEnvelope1Path(),
  1672. size: Size(375 / 3 * ppx, 375 / 171 * 24 * ppx)),
  1673. ),
  1674. ),
  1675. Positioned(
  1676. top: 375 / 185 * 43.2 * ppx,
  1677. child: GestureDetector(
  1678. onTap: () {
  1679. grabARedEnvelope(redEnvelopes[index]);
  1680. },
  1681. behavior: HitTestBehavior.translucent,
  1682. child: Container(
  1683. decoration: BoxDecoration(
  1684. color: MyColors.cF1D19B,
  1685. borderRadius: BorderRadius.circular(45 * ppx)),
  1686. height: 375 / 57 * ppx * 5,
  1687. width: 375 / 57 * ppx * 5,
  1688. child: Text(
  1689. '开',
  1690. style: TextStyle(
  1691. color: MyColors.c333333,
  1692. fontSize: 375 / 57 * ppx * 3,
  1693. decoration: TextDecoration.none,
  1694. fontWeight: FontWeight.normal),
  1695. ),
  1696. alignment: Alignment.center,
  1697. ),
  1698. ),
  1699. ),
  1700. Positioned(
  1701. top: 15,
  1702. child: Column(
  1703. children: [
  1704. ClipRRect(
  1705. child: MyViews().netImg(
  1706. imgURL(redEnvelopes[index].payerPic),
  1707. 375 / 57 * ppx * 4,
  1708. 375 / 57 * ppx * 4),
  1709. borderRadius:
  1710. BorderRadius.circular(375 / 57 * ppx * 2),
  1711. ),
  1712. Container(
  1713. child: Text(
  1714. '${redEnvelopes[index].payerName}(${hideUID(redEnvelopes[index].payerUid.toString())})',
  1715. style: TextStyle(
  1716. color: Colors.white, fontSize: 25 / 3 * ppx),
  1717. maxLines: 1,
  1718. ),
  1719. margin: EdgeInsets.symmetric(vertical: 5),
  1720. ),
  1721. Text(
  1722. '${redEnvelopes[index].title}',
  1723. style: TextStyle(
  1724. color: Colors.white, fontSize: 25 / 3 * ppx),
  1725. maxLines: 1,
  1726. )
  1727. ],
  1728. ),
  1729. ),
  1730. ],
  1731. alignment: Alignment.topCenter,
  1732. );
  1733. },
  1734. physics: redWallShowMore ? null : NeverScrollableScrollPhysics(),
  1735. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  1736. crossAxisCount: 3,
  1737. childAspectRatio: 19 / 24,
  1738. mainAxisSpacing: 8,
  1739. crossAxisSpacing: 8),
  1740. itemCount: redEnvelopes.length,
  1741. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  1742. ),
  1743. ),
  1744. GestureDetector(
  1745. onTap: () {
  1746. setState(() {
  1747. redWallShowMore = !redWallShowMore;
  1748. if (!redWallShowMore) {
  1749. _controller.animateTo(0.0,
  1750. duration: Duration(milliseconds: 500), curve: Curves.ease);
  1751. }
  1752. });
  1753. },
  1754. behavior: HitTestBehavior.translucent,
  1755. child: Container(
  1756. height: 30,
  1757. child: Icon(redWallShowMore
  1758. ? Icons.keyboard_arrow_up
  1759. : Icons.keyboard_arrow_down),
  1760. alignment: Alignment.center,
  1761. ),
  1762. )
  1763. ],
  1764. );
  1765. }
  1766. int rPage = 1;
  1767. void queryRedEnvelope() {
  1768. MyDio().query({
  1769. "key": "red_packet",
  1770. "filters": {
  1771. "conditions": ["shop_uid==${widget.data.shopUid}", 'left_count>0'],
  1772. },
  1773. "dims": redPacketDims,
  1774. "paging": [rPage, 10]
  1775. }, (response, hasError) {
  1776. if (!hasError) {
  1777. RedEnvelopeWallBeanEntity entity = RedEnvelopeWallBeanEntity()
  1778. .fromJson(json.decode(response.toString()));
  1779. if (rPage == 1) {
  1780. redEnvelopes.clear();
  1781. }
  1782. redEnvelopes.addAll(entity.data.data);
  1783. setState(() {});
  1784. }
  1785. }, (error) {});
  1786. }
  1787. void grabARedEnvelope(RedEnvelopeWallBeanDataData redEnvelope) {
  1788. EasyLoading.show();
  1789. MyDio().post('/pay/applyForRedPacket2', {
  1790. 'id': redEnvelope.id,
  1791. 'user_uid': MyCookie().getUID()
  1792. }, (response, hasError) {
  1793. if (!hasError) {
  1794. rPage = 1;
  1795. queryRedEnvelope();
  1796. ApplyForRedPacketBeanEntity entity = ApplyForRedPacketBeanEntity()
  1797. .fromJson(json.decode(response.toString()));
  1798. showResult(entity.data,redEnvelope);
  1799. EasyLoading.dismiss();
  1800. }
  1801. }, (error) {});
  1802. }
  1803. void showResult(ApplyForRedPacketBeanData data, RedEnvelopeWallBeanDataData redEnvelope) {
  1804. showDialog<void>(
  1805. context: context,
  1806. barrierDismissible: false,
  1807. // false = user must tap button, true = tap outside dialog
  1808. builder: (BuildContext dialogContext) {
  1809. return StatefulBuilder(
  1810. builder:
  1811. (BuildContext context, void Function(void Function()) setState) {
  1812. return Container(
  1813. child: Column(
  1814. children: [
  1815. Stack(
  1816. children: [
  1817. Positioned(
  1818. child: Container(
  1819. height: 396 * ppx,
  1820. width: double.infinity,
  1821. decoration: BoxDecoration(
  1822. borderRadius: BorderRadius.circular(16),
  1823. color: MyColors.cEB4935),
  1824. margin: EdgeInsets.symmetric(horizontal: 45 * ppx),
  1825. alignment: Alignment.bottomCenter,
  1826. ),
  1827. ),
  1828. Positioned(
  1829. child: Column(
  1830. children: [
  1831. SvgPicture.asset('images/svg/logo.svg'),
  1832. Container(
  1833. margin: EdgeInsets.only(top: 67 * ppx),
  1834. child: Text(
  1835. '${double.parse(data.amount.toString()).toStringAsFixed(2)}元',
  1836. style: TextStyle(
  1837. color: MyColors.cF1D19B,
  1838. fontSize: 38 * ppx,
  1839. fontWeight: FontWeight.bold,
  1840. decoration: TextDecoration.none),
  1841. ),
  1842. ),
  1843. Container(
  1844. margin: EdgeInsets.only(top: 20 * ppx),
  1845. child: Text(
  1846. '${redEnvelope.title}',
  1847. style: TextStyle(
  1848. color: Colors.white,
  1849. fontSize: 20 * ppx,
  1850. decoration: TextDecoration.none),
  1851. ),
  1852. ),
  1853. ],
  1854. ),
  1855. top: 37 * ppx,
  1856. ),
  1857. ],
  1858. alignment: Alignment.topCenter,
  1859. ),
  1860. GestureDetector(
  1861. onTap: () {
  1862. Navigator.pop(context);
  1863. },
  1864. child: Container(
  1865. margin: EdgeInsets.only(top: 24 * ppx),
  1866. child: Icon(
  1867. Icons.clear,
  1868. color: Colors.white,
  1869. ),
  1870. height: 28 * ppx,
  1871. width: 28 * ppx,
  1872. alignment: Alignment.center,
  1873. decoration: BoxDecoration(
  1874. color: MyColors.c25E7E7E7,
  1875. borderRadius: BorderRadius.circular(14 * ppx)),
  1876. ),
  1877. )
  1878. ],
  1879. mainAxisAlignment: MainAxisAlignment.center,
  1880. ),
  1881. alignment: Alignment.center,
  1882. );
  1883. },
  1884. );
  1885. },
  1886. );
  1887. }
  1888. }
  1889. class RedEnvelope1Path extends CustomPainter {
  1890. Paint _paint = Paint()
  1891. ..color = MyColors.cF55544 //画笔颜色
  1892. ..strokeCap = StrokeCap.round //画笔笔触类型
  1893. ..isAntiAlias = true //是否启动抗锯齿
  1894. ..strokeWidth = 15.0; //画笔的宽度
  1895. @override
  1896. void paint(Canvas canvas, Size size) {
  1897. var path = Path()
  1898. ..moveTo(0, 0)
  1899. ..quadraticBezierTo(size.width / 2, 25, size.width, 0)
  1900. ..lineTo(size.width, size.height - 16)
  1901. ..quadraticBezierTo(size.width, size.height, size.width - 16, size.height)
  1902. ..lineTo(16, size.height)
  1903. ..quadraticBezierTo(0, size.height, 0, size.height - 16)
  1904. ..close();
  1905. canvas.drawPath(path, _paint);
  1906. }
  1907. @override
  1908. bool shouldRepaint(covariant CustomPainter oldDelegate) {
  1909. return false;
  1910. }
  1911. }