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. 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*/ false) 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. });
  605. controller.requestRefresh();
  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. });
  640. controller.requestRefresh();
  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. });
  677. controller.requestRefresh();
  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. });
  720. controller.requestRefresh();
  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. Expanded(
  755. child: Column(
  756. children: [
  757. if (selectedIndex == 3)
  758. Container(
  759. height: 40,
  760. decoration: BoxDecoration(
  761. borderRadius: BorderRadius.circular(20),
  762. color: Colors.white),
  763. margin: EdgeInsets.only(left: 15, right: 15, top: 10),
  764. child: Row(
  765. children: [
  766. Expanded(
  767. child: TextField(
  768. controller: _textEditingController,
  769. decoration: InputDecoration(
  770. border: InputBorder.none,
  771. disabledBorder: InputBorder.none,
  772. enabledBorder: InputBorder.none,
  773. focusedBorder: InputBorder.none,
  774. isDense: true,
  775. hintText: '请输入信息',
  776. hintStyle: TextStyle(
  777. color: MyColors.c999999, fontSize: 16),
  778. contentPadding:
  779. const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5),
  780. ),
  781. )),
  782. GestureDetector(
  783. onTap: () {
  784. controller.requestRefresh();
  785. MyTools().hideKeyboard(context);
  786. },
  787. behavior: HitTestBehavior.translucent,
  788. child: Container(
  789. decoration: BoxDecoration(
  790. borderRadius: BorderRadius.circular(20),
  791. color: MyColors.cFF4233),
  792. height: 40,
  793. width: 80,
  794. child: Text(
  795. '搜 索',
  796. style: TextStyle(
  797. color: Colors.white, fontSize: 14),
  798. ),
  799. alignment: Alignment.center,
  800. ),
  801. )
  802. ],
  803. ),
  804. ),
  805. Expanded(
  806. child: SmartRefresher(
  807. controller: controller,
  808. onRefresh: onRefresh,
  809. onLoading: onLoading,
  810. enablePullDown: true,
  811. enablePullUp: true,
  812. child: body(),
  813. ),
  814. ),
  815. ],
  816. ),
  817. ),
  818. Container(
  819. color: Colors.white,
  820. child: SafeArea(
  821. top: false,
  822. child: Container(
  823. padding: EdgeInsets.symmetric(horizontal: 37),
  824. color: Colors.white,
  825. width: double.infinity,
  826. height: 60,
  827. child: Row(
  828. children: [
  829. Expanded(
  830. child: GestureDetector(
  831. onTap: () {
  832. if (!widget.data.privateShop &&
  833. MyCookie().getUID() == widget.data.ownerUid) {
  834. MyTools().toPage(context,
  835. SetAmountPage(widget.data), (then) {});
  836. } else {
  837. queryShopMembers(true);
  838. }
  839. },
  840. behavior: HitTestBehavior.translucent,
  841. child: Container(
  842. decoration: BoxDecoration(
  843. borderRadius: !hideOfflinePay
  844. ? BorderRadius.only(
  845. topLeft: Radius.circular(20),
  846. bottomLeft: Radius.circular(20),
  847. )
  848. : BorderRadius.circular(20),
  849. border: Border.all(
  850. color: MyColors.cFF4233, width: 1)),
  851. height: 40,
  852. child: MyViews().myText(
  853. !widget.data.privateShop &&
  854. MyCookie().getUID() ==
  855. widget.data.ownerUid
  856. ? '扫码收款'
  857. : '联系帮主',
  858. MyColors.cFF4233,
  859. 14),
  860. alignment: Alignment.center),
  861. ),
  862. ),
  863. if (!hideOfflinePay)
  864. Expanded(
  865. child: GestureDetector(
  866. onTap: () {
  867. if (MyCookie().getUID() == widget.data.ownerUid) {
  868. MyTools().toPage(context,
  869. InitiateCollectionPage(widget.data),
  870. (then) {
  871. if (then is String && then == '发起收款') {
  872. controller.requestRefresh();
  873. }
  874. });
  875. } else {
  876. MyTools().toPage(context,
  877. PayToTheHelperPage(widget.data), (then) {});
  878. }
  879. },
  880. behavior: HitTestBehavior.translucent,
  881. child: Container(
  882. decoration: BoxDecoration(
  883. borderRadius: BorderRadius.only(
  884. topRight: Radius.circular(20),
  885. bottomRight: Radius.circular(20),
  886. ),
  887. color: MyColors.cFF4233),
  888. height: 40,
  889. child: MyViews().myText(
  890. MyCookie().getUID() == widget.data.ownerUid
  891. ? '发起收款'
  892. : '到店付款',
  893. Colors.white,
  894. 14),
  895. alignment: Alignment.center),
  896. ),
  897. )
  898. ],
  899. ),
  900. ),
  901. ),
  902. )
  903. ],
  904. ),
  905. ),
  906. );
  907. }
  908. body() {
  909. if (selectedIndex == 0) {
  910. return goods.length == 0
  911. ? SingleChildScrollView(child: noData())
  912. : GridView.builder(
  913. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  914. crossAxisCount: 2, //每行三列
  915. childAspectRatio: 164 / 261, //显示区域宽高相等
  916. mainAxisSpacing: 8,
  917. crossAxisSpacing: 8),
  918. itemCount: goods.length,
  919. padding:
  920. EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
  921. itemBuilder: (context, index) {
  922. return MyViews().getGoodsItem(goods[index], context);
  923. });
  924. } else if (selectedIndex == 1) {
  925. return orders.length == 0
  926. ? SingleChildScrollView(child: noData())
  927. : ListView.builder(
  928. itemBuilder: (c, index) {
  929. return Slidable(
  930. child: MyViews().getNoPayGoodsItem(orders[index], context,
  931. widget.data.ownerUid, widget.data.role),
  932. actionPane: SlidableDrawerActionPane(),
  933. enabled: paymentAuthority(widget.data.role),
  934. actionExtentRatio: 0.25,
  935. secondaryActions: <Widget>[
  936. SlideAction(
  937. child: Container(
  938. child: Container(
  939. decoration: BoxDecoration(
  940. borderRadius: BorderRadius.circular(30),
  941. color: MyColors.cFF4233,
  942. ),
  943. height: 60,
  944. width: 60,
  945. child: SvgPicture.asset(
  946. 'images/svg/del.svg',
  947. height: 40,
  948. width: 40,
  949. ),
  950. alignment: Alignment.center,
  951. ),
  952. ),
  953. onTap: () {
  954. showSimpleDialog('将删除订单(${orders[index].uid})', context,
  955. () {
  956. Navigator.pop(context);
  957. deleteOrder(orders[index]);
  958. });
  959. },
  960. )
  961. ],
  962. );
  963. },
  964. itemCount: orders.length,
  965. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  966. );
  967. } else if (selectedIndex == 2) {
  968. return orders.length == 0
  969. ? SingleChildScrollView(child: noData())
  970. : ListView.builder(
  971. itemBuilder: (c, index) {
  972. return Slidable(
  973. child: MyViews().getNoPayGoodsItem(orders[index], context,
  974. widget.data.ownerUid, widget.data.role),
  975. actionPane: SlidableDrawerActionPane(),
  976. enabled: orders[index].type == orderTypeOfflineTransfer &&
  977. orders[index].buyerUid == MyCookie().getUID(),
  978. actionExtentRatio: 0.25,
  979. secondaryActions: <Widget>[
  980. SlideAction(
  981. child: Container(
  982. child: Container(
  983. decoration: BoxDecoration(
  984. borderRadius: BorderRadius.circular(30),
  985. color: MyColors.cFF4233,
  986. ),
  987. height: 60,
  988. width: 60,
  989. child: SvgPicture.asset(
  990. 'images/svg/del.svg',
  991. height: 40,
  992. width: 40,
  993. ),
  994. alignment: Alignment.center,
  995. ),
  996. ),
  997. onTap: () {
  998. showSimpleDialog('将删除订单(${orders[index].uid})', context,
  999. () {
  1000. Navigator.pop(context);
  1001. deleteOrder(orders[index]);
  1002. });
  1003. },
  1004. )
  1005. ],
  1006. );
  1007. },
  1008. itemCount: orders.length,
  1009. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  1010. );
  1011. } else if (selectedIndex == 3) {
  1012. return member.length == 0
  1013. ? SingleChildScrollView(child: noData())
  1014. : ListView.builder(
  1015. itemBuilder: (BuildContext context, int index) {
  1016. return GestureDetector(
  1017. onTap: () {
  1018. if (permissionToModifyCustomerName(widget.data.role)) {
  1019. if (MyCookie().getUID() != member[index].userUid) {
  1020. MyTools().toPage(
  1021. context, MemberDetailsPage(member[index]), (then) {
  1022. controller.requestRefresh();
  1023. });
  1024. }
  1025. } else {
  1026. return;
  1027. }
  1028. },
  1029. behavior: HitTestBehavior.translucent,
  1030. child: Container(
  1031. padding: EdgeInsets.only(left: 15, right: 15),
  1032. color: Colors.white,
  1033. child: Column(
  1034. children: [
  1035. Container(
  1036. margin: EdgeInsets.only(top: 8, bottom: 6),
  1037. child: Row(
  1038. children: [
  1039. Row(
  1040. children: [
  1041. Container(
  1042. margin: EdgeInsets.only(right: 6),
  1043. child: ClipRRect(
  1044. child: MyViews().netImg(
  1045. imgURL(member[index].userPic),
  1046. 42,
  1047. 42),
  1048. borderRadius: BorderRadius.circular(21),
  1049. ),
  1050. ),
  1051. MyViews().myText(
  1052. '${member[index].userName} ${store.ownerUid == MyCookie().getUID() ? '(${member[index].userUid})' : ''}',
  1053. MyColors.c333333,
  1054. 15),
  1055. Visibility(
  1056. visible:
  1057. member[index].role != shopUserMember,
  1058. child: Container(
  1059. decoration: BoxDecoration(
  1060. color: MyColors.cFFCD00,
  1061. borderRadius:
  1062. BorderRadius.circular(8)),
  1063. height: 16,
  1064. padding:
  1065. EdgeInsets.symmetric(horizontal: 5),
  1066. child: MyViews().myText(
  1067. roleText(member[index].role),
  1068. Colors.white,
  1069. 10),
  1070. alignment: Alignment.center,
  1071. margin: EdgeInsets.only(left: 5),
  1072. ),
  1073. )
  1074. ],
  1075. ),
  1076. Visibility(
  1077. // visible: member[index].role != shopUserOwner &&
  1078. // member[index].userUid !=
  1079. // MyCookie().getUID(),
  1080. visible: false,
  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. }