gang_in_page.dart 75 KB

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