gang_in_page.dart 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914
  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. child: GestureDetector(
  1081. child: Container(
  1082. margin: EdgeInsets.only(right: 10),
  1083. child: SvgPicture.asset(
  1084. 'images/svg/透视.svg',
  1085. height: 25,
  1086. width: 25,
  1087. ),
  1088. ),
  1089. onTap: () {
  1090. queryWhetherThereIsANumberOfPerspectives(
  1091. member[index], store, context);
  1092. },
  1093. behavior: HitTestBehavior.translucent,
  1094. ),
  1095. ),
  1096. ],
  1097. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1098. ),
  1099. ),
  1100. Container(
  1101. height: 0.5,
  1102. color: MyColors.cE7E7E7,
  1103. )
  1104. ],
  1105. ),
  1106. ),
  1107. );
  1108. },
  1109. itemCount: member.length,
  1110. padding: EdgeInsets.only(top: 10),
  1111. );
  1112. } else {
  1113. return SingleChildScrollView(child: noData());
  1114. }
  1115. }
  1116. void onRefresh() {
  1117. page = 1;
  1118. if (selectedIndex == 0) {
  1119. queryProducts();
  1120. } else if (selectedIndex == 1) {
  1121. unreceivedOrder();
  1122. } else if (selectedIndex == 3) {
  1123. queryShopMembers(false);
  1124. } else {
  1125. unpaidOrder();
  1126. }
  1127. }
  1128. void onLoading() {
  1129. page++;
  1130. if (selectedIndex == 0) {
  1131. queryProducts();
  1132. } else if (selectedIndex == 1) {
  1133. unreceivedOrder();
  1134. } else if (selectedIndex == 3) {
  1135. queryShopMembers(false);
  1136. } else {
  1137. unpaidOrder();
  1138. }
  1139. }
  1140. //查询商品
  1141. void queryProducts() {
  1142. MyDio().query({
  1143. "key": "commodity",
  1144. "filters": {
  1145. "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"]
  1146. },
  1147. "dims": commodityDims,
  1148. "order_by": ["id,desc", "no,desc"],
  1149. "paging": [page, 20]
  1150. }, (response, hasError) {
  1151. if (!hasError) {
  1152. GoodsBeanEntity entity =
  1153. GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
  1154. if (page == 1) {
  1155. goods.clear();
  1156. }
  1157. goods.addAll(entity.data.data);
  1158. }
  1159. setState(() {
  1160. endRe(controller);
  1161. });
  1162. }, (error) {
  1163. setState(() {
  1164. endRe(controller);
  1165. });
  1166. });
  1167. }
  1168. //查询未收订单
  1169. void unreceivedOrder() {
  1170. var conditions = [];
  1171. if (paymentAuthority(widget.data.role)) {
  1172. conditions.add('state == $orderStateUnpaid');
  1173. conditions.add('shop_uid == ${widget.data.shopUid}');
  1174. } else {
  1175. conditions.add('state == $orderStateUnpaid');
  1176. conditions.add('shop_uid == ${widget.data.shopUid}');
  1177. conditions.add('seller_uid == ${MyCookie().getUID()}');
  1178. }
  1179. MyDio().query({
  1180. "key": "order",
  1181. "filters": {"conditions": conditions},
  1182. "dims": orderDims,
  1183. "paging": [page, 20],
  1184. "order_by": ["create_time,DESC"]
  1185. }, (response, hasError) {
  1186. if (!hasError) {
  1187. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1188. .fromJson(json.decode(response.data.toString()));
  1189. if (page == 1) {
  1190. orders.clear();
  1191. }
  1192. orders.addAll(entity.data.data);
  1193. setState(() {});
  1194. }
  1195. endRe(controller);
  1196. }, (error) {});
  1197. }
  1198. //查询未付订单
  1199. void unpaidOrder() {
  1200. var conditions = [];
  1201. if (paymentAuthority(widget.data.role)) {
  1202. conditions.add('state == $orderStatePaid');
  1203. conditions.add('shop_uid == ${widget.data.shopUid}');
  1204. } else {
  1205. conditions.add('state == $orderStateUnpaid');
  1206. conditions.add('shop_uid == ${widget.data.shopUid}');
  1207. conditions.add('buyer_uid==0');
  1208. conditions.add('buyer_name LIKE ${MyCookie().getName()}');
  1209. }
  1210. var filters;
  1211. if (paymentAuthority(widget.data.role)) {
  1212. filters = {"conditions": conditions};
  1213. } else {
  1214. filters = {
  1215. "conditions": conditions,
  1216. "or": true,
  1217. "filters": [
  1218. {
  1219. "conditions": [
  1220. "state == $orderStateUnpaid",
  1221. 'shop_uid == ${widget.data.shopUid}',
  1222. 'buyer_uid==${MyCookie().getUID()}'
  1223. ]
  1224. }
  1225. ]
  1226. };
  1227. }
  1228. MyDio().query({
  1229. "key": "order",
  1230. "filters": filters,
  1231. "dims": orderDims,
  1232. "paging": [page, 20],
  1233. "order_by": ["create_time,DESC"]
  1234. }, (response, hasError) {
  1235. if (!hasError) {
  1236. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1237. .fromJson(json.decode(response.data.toString()));
  1238. if (page == 1) {
  1239. orders.clear();
  1240. }
  1241. orders.addAll(entity.data.data);
  1242. setState(() {});
  1243. }
  1244. endRe(controller);
  1245. }, (error) {});
  1246. }
  1247. payTheOrder() {
  1248. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  1249. data.sellerUid = widget.order.sellerUID;
  1250. data.sellerName = widget.order.sellerName;
  1251. data.sellerPic = widget.order.sellerPic;
  1252. data.buyerUid = 0;
  1253. data.buyerName = widget.order.buyerName;
  1254. data.buyerPic = '';
  1255. data.amount = widget.order.amount;
  1256. data.uid = widget.order.uID;
  1257. MyTools().toPage(
  1258. context,
  1259. OrderInformationPage(
  1260. false,
  1261. orderType: orderTypeThirdPlatform,
  1262. amount: widget.order.amount,
  1263. uid: widget.order.uID,
  1264. buyerUid: MyCookie().getUID(),
  1265. buyerName: widget.order.buyerName,
  1266. buyerPic: MyCookie().getPic(),
  1267. commodityCount: 1,
  1268. commodityTitle: '第三方订单',
  1269. commodityCover: '',
  1270. sellName: widget.order.sellerName,
  1271. sellPic: widget.order.sellerPic,
  1272. sellUid: widget.order.sellerUID,
  1273. ), (then) {
  1274. controller.requestRefresh();
  1275. PopUpQueue().onShow = false;
  1276. PopUpQueue().showNext();
  1277. });
  1278. // showPayDialog(data, context, () {
  1279. // Navigator.pop(context);
  1280. // // MyTools().toPage(context,
  1281. // // PayPage(widget.order.uID, false, widget.order.amount), (then) {});
  1282. //
  1283. // });
  1284. }
  1285. List<MyShopBeanDataData> member = [];
  1286. List<MyShopBeanDataData> helper = [];
  1287. queryShopMembers(bool toOwner) {
  1288. var conditions = ["shop_uid==${store.uid}", "review_state==1"];
  1289. if (_textEditingController.text.isNotEmpty) {
  1290. conditions
  1291. .add('user_name LIKE ${_textEditingController.text.toString()}');
  1292. }
  1293. MyDio().query({
  1294. "key": "shop_user",
  1295. "filters": {"conditions": conditions},
  1296. "dims": shopUserDims,
  1297. "paging": [page, 50]
  1298. }, (response, hasError) {
  1299. if (!hasError) {
  1300. MyShopBeanEntity entity =
  1301. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1302. if (page == 1) {
  1303. member.clear();
  1304. }
  1305. member.addAll(entity.data.data);
  1306. if (toOwner) {
  1307. helper.clear();
  1308. member.forEach((element) {
  1309. if (element.role == shopUserStaff) {
  1310. helper.add(element);
  1311. }
  1312. });
  1313. MyShopBeanDataData chatWith;
  1314. // if (helper.length == 0) {
  1315. chatWith = member[
  1316. member.indexWhere((element) => element.role == shopUserOwner)];
  1317. // } else {
  1318. // chatWith = helper[Random().nextInt(helper.length)];
  1319. // }
  1320. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1321. } else {
  1322. controller.refreshCompleted();
  1323. controller.loadComplete();
  1324. setState(() {});
  1325. }
  1326. _textEditingController.clear();
  1327. }
  1328. }, (error) {});
  1329. }
  1330. void deleteOrder(SmartOrderBeanDataData order) {
  1331. MyDio().del({
  1332. 'key': 'order',
  1333. 'ids': [order.id]
  1334. }, (response, hasError) {
  1335. if (!hasError) {
  1336. orders.remove(order);
  1337. setState(() {});
  1338. }
  1339. }, (error) {});
  1340. }
  1341. StoreBeanDataData store;
  1342. bool hideMember = true;
  1343. queryStoreInformation() {
  1344. MyDio().query({
  1345. "key": "shop",
  1346. "filters": {
  1347. "conditions": ["uid == ${widget.data.shopUid}"]
  1348. },
  1349. "dims": shopDims,
  1350. "paging": [1, 5]
  1351. }, (response, hasError) {
  1352. if (!hasError) {
  1353. StoreBeanEntity entity =
  1354. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1355. store = entity.data.data[0];
  1356. hideMember = store.hideMembers;
  1357. hideOfflinePay = store.hideOfflinePay;
  1358. //自己的公开店铺
  1359. if (!store.private && store.ownerUid == MyCookie().getUID()) {
  1360. canSendGood = true;
  1361. }
  1362. //自己在某个允许顾客间交易的私有店铺中
  1363. if (store.innerTrade&&store.private) {
  1364. canSendGood = true;
  1365. }
  1366. setState(() {});
  1367. }
  1368. endRe(controller);
  1369. }, (error) {});
  1370. }
  1371. void queryWhetherThereIsANumberOfPerspectives(
  1372. MyShopBeanDataData data, StoreBeanDataData store, BuildContext context) {
  1373. MyDio().query({
  1374. "key": "user_vp",
  1375. "filters": {
  1376. "conditions": [
  1377. "user_uid == ${MyCookie().getUID()}",
  1378. "vp_key == $vpKeyXRay"
  1379. ]
  1380. },
  1381. "dims": userVpDims,
  1382. "paging": [1, 2000]
  1383. }, (response, hasError) {
  1384. UserVpBeanEntity entity =
  1385. UserVpBeanEntity().fromJson(json.decode(response.data.toString()));
  1386. if (entity.data.data.length != 0) {
  1387. MyTools().toPage(context, OtherPeopleSTurnoverPage(data), (then) {});
  1388. } else {
  1389. // showSimpleDialog('你还未获取透视道具或道具用完,请先购买次数再查看。', context, () {
  1390. // Navigator.pop(context);
  1391. // MyShopBeanDataData shop = MyShopBeanDataData();
  1392. // shop.shopUid = store.uid;
  1393. // shop.shopName = store.name;
  1394. // shop.shopPic = store.picture;
  1395. // MyTools().toPage(
  1396. // context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1397. // });
  1398. MyShopBeanDataData shop = MyShopBeanDataData();
  1399. shop.shopUid = store.uid;
  1400. shop.shopName = store.name;
  1401. shop.shopPic = store.picture;
  1402. MyTools().toPage(
  1403. context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1404. }
  1405. }, (error) {});
  1406. }
  1407. void shopInfo() {
  1408. showDialog(
  1409. context: context,
  1410. builder: (BuildContext context) {
  1411. return GestureDetector(
  1412. onTap: () {
  1413. Navigator.pop(context);
  1414. },
  1415. child: Material(
  1416. color: Colors.black12,
  1417. child: Center(
  1418. child: GestureDetector(
  1419. onTap: () {},
  1420. child: Container(
  1421. decoration: BoxDecoration(
  1422. borderRadius: BorderRadius.circular(16),
  1423. color: Colors.white,
  1424. ),
  1425. height: 510,
  1426. margin: EdgeInsets.symmetric(horizontal: 28),
  1427. padding: EdgeInsets.symmetric(horizontal: 14, vertical: 15),
  1428. child: Column(
  1429. children: [
  1430. Container(
  1431. height: MediaQuery.of(context).size.width - 71,
  1432. width: MediaQuery.of(context).size.width - 56,
  1433. child: ClipRRect(
  1434. child: MyViews().netImg(
  1435. imgURL(widget.data.shopPic),
  1436. MediaQuery.of(context).size.width - 84,
  1437. MediaQuery.of(context).size.width - 84),
  1438. borderRadius: BorderRadius.circular(4),
  1439. ),
  1440. ),
  1441. Row(
  1442. children: [
  1443. SvgPicture.asset(
  1444. 'images/svg/店铺.svg',
  1445. height: 21,
  1446. width: 21,
  1447. ),
  1448. Container(
  1449. width: 6,
  1450. ),
  1451. Expanded(
  1452. child: Text(
  1453. widget.data.shopName,
  1454. style: TextStyle(
  1455. color: MyColors.c333333, fontSize: 16),
  1456. ))
  1457. ],
  1458. ),
  1459. Container(
  1460. height: 10,
  1461. ),
  1462. Text(
  1463. store != null && store.introduction.isNotEmpty
  1464. ? '货帮介绍:${store.introduction}'
  1465. : '货帮介绍:暂无',
  1466. style: TextStyle(
  1467. color: MyColors.c333333,
  1468. fontSize: 12,
  1469. ),
  1470. maxLines: 3,
  1471. overflow: TextOverflow.ellipsis,
  1472. softWrap: true,
  1473. ),
  1474. Container(
  1475. height: 10,
  1476. ),
  1477. Row(
  1478. children: [
  1479. SvgPicture.asset(
  1480. 'images/svg/地址.svg',
  1481. color: MyColors.c666666,
  1482. height: 12,
  1483. width: 12,
  1484. ),
  1485. Container(
  1486. width: 5,
  1487. ),
  1488. Expanded(
  1489. child: Text(
  1490. store != null && store.address.isNotEmpty
  1491. ? store.address
  1492. : '暂无',
  1493. style: TextStyle(
  1494. color: MyColors.c666666, fontSize: 11),
  1495. maxLines: 1,
  1496. overflow: TextOverflow.ellipsis,
  1497. softWrap: true,
  1498. ),
  1499. ),
  1500. ],
  1501. ),
  1502. Container(
  1503. height: 10,
  1504. ),
  1505. Visibility(
  1506. visible: store != null && store.mobile.isNotEmpty,
  1507. child: GestureDetector(
  1508. onTap: () {
  1509. launch('tel:${store.mobile}');
  1510. },
  1511. behavior: HitTestBehavior.translucent,
  1512. child: Container(
  1513. decoration: BoxDecoration(
  1514. color: MyColors.cFF4233,
  1515. borderRadius: BorderRadius.circular(20),
  1516. ),
  1517. height: 40,
  1518. child: Row(
  1519. children: [
  1520. SvgPicture.asset(
  1521. 'images/svg/电话.svg',
  1522. color: Colors.white,
  1523. height: 24,
  1524. width: 24,
  1525. ),
  1526. Container(
  1527. width: 4,
  1528. ),
  1529. Text(
  1530. store == null ? '' : store.mobile,
  1531. style: TextStyle(
  1532. color: Colors.white, fontSize: 15),
  1533. ),
  1534. ],
  1535. mainAxisAlignment: MainAxisAlignment.center,
  1536. ),
  1537. alignment: Alignment.center,
  1538. ),
  1539. ),
  1540. )
  1541. ],
  1542. mainAxisAlignment: MainAxisAlignment.spaceAround,
  1543. crossAxisAlignment: CrossAxisAlignment.start,
  1544. ),
  1545. ),
  1546. ),
  1547. ),
  1548. ),
  1549. );
  1550. },
  1551. );
  1552. }
  1553. void collectionShop() {
  1554. if (!collect) {
  1555. MyDio().save({
  1556. 'key': 'shop_user',
  1557. 'object': {
  1558. 'review_state': 1,
  1559. 'user_uid': MyCookie().getUID(),
  1560. 'shop_uid': widget.data.shopUid,
  1561. 'role': shopUserMember
  1562. }
  1563. }, (response, hasError) {
  1564. if (!hasError) {
  1565. needRE = !needRE;
  1566. EventBus().emit('needRE', needRE);
  1567. showToast('收藏成功');
  1568. queryWhetherToFollow();
  1569. }
  1570. }, (error) {});
  1571. } else {
  1572. MyDio().del({
  1573. 'key': 'shop_user',
  1574. 'ids': [shopUserID]
  1575. }, (response, hasError) {
  1576. if (!hasError) {
  1577. needRE = !needRE;
  1578. EventBus().emit('needRE', needRE);
  1579. showToast('取消收藏');
  1580. collect = false;
  1581. shopUserID = null;
  1582. setState(() {});
  1583. }
  1584. }, (error) {});
  1585. }
  1586. }
  1587. int shopUserID;
  1588. void queryWhetherToFollow() {
  1589. MyDio().query({
  1590. "key": "shop_user",
  1591. "filters": {
  1592. "conditions": [
  1593. "shop_uid==${widget.data.shopUid}",
  1594. "user_uid==${MyCookie().getUID()}"
  1595. ]
  1596. },
  1597. "dims": shopUserDims,
  1598. "paging": [1, 1]
  1599. }, (response, hasError) {
  1600. if (!hasError) {
  1601. MyShopBeanEntity entity =
  1602. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1603. collect = entity.data.data.length != 0;
  1604. if (entity.data.data.isNotEmpty) {
  1605. shopUserID = entity.data.data[0].id;
  1606. }
  1607. setState(() {});
  1608. }
  1609. }, (error) {});
  1610. }
  1611. ScrollController _controller = ScrollController();
  1612. redEnvelopeWall() {
  1613. return Column(
  1614. children: [
  1615. Container(
  1616. height: redWallShowMore
  1617. ? 375 / 3 * ppx / 19 * 48
  1618. : 375 / 3 * ppx / 19 * 24,
  1619. child: GridView.builder(
  1620. controller: _controller,
  1621. itemBuilder: (BuildContext context, int index) {
  1622. return Stack(
  1623. children: [
  1624. Positioned(
  1625. child: Container(
  1626. width: 375 / 3 * ppx,
  1627. height: 375 / 3 * ppx / 19 * 24,
  1628. decoration: BoxDecoration(
  1629. borderRadius: BorderRadius.circular(16),
  1630. color: MyColors.cF25D4B),
  1631. alignment: Alignment.bottomCenter,
  1632. child: CustomPaint(
  1633. painter: RedEnvelope1Path(),
  1634. size: Size(375 / 3 * ppx, 375 / 171 * 24 * ppx)),
  1635. ),
  1636. ),
  1637. Positioned(
  1638. top: 375 / 185 * 43.2 * ppx,
  1639. child: GestureDetector(
  1640. onTap: () {
  1641. grabARedEnvelope(redEnvelopes[index]);
  1642. },
  1643. behavior: HitTestBehavior.translucent,
  1644. child: Container(
  1645. decoration: BoxDecoration(
  1646. color: MyColors.cF1D19B,
  1647. borderRadius: BorderRadius.circular(45 * ppx)),
  1648. height: 375 / 57 * ppx * 5,
  1649. width: 375 / 57 * ppx * 5,
  1650. child: Text(
  1651. '开',
  1652. style: TextStyle(
  1653. color: MyColors.c333333,
  1654. fontSize: 375 / 57 * ppx * 3,
  1655. decoration: TextDecoration.none,
  1656. fontWeight: FontWeight.normal),
  1657. ),
  1658. alignment: Alignment.center,
  1659. ),
  1660. ),
  1661. ),
  1662. Positioned(
  1663. top: 15,
  1664. child: Column(
  1665. children: [
  1666. ClipRRect(
  1667. child: MyViews().netImg(
  1668. imgURL(redEnvelopes[index].payerPic),
  1669. 375 / 57 * ppx * 4,
  1670. 375 / 57 * ppx * 4),
  1671. borderRadius:
  1672. BorderRadius.circular(375 / 57 * ppx * 2),
  1673. ),
  1674. Container(
  1675. child: Text(
  1676. '${redEnvelopes[index].payerName}(${hideUID(redEnvelopes[index].payerUid.toString())})',
  1677. style: TextStyle(
  1678. color: Colors.white, fontSize: 25 / 3 * ppx),
  1679. maxLines: 1,
  1680. ),
  1681. margin: EdgeInsets.symmetric(vertical: 5),
  1682. ),
  1683. Text(
  1684. '${redEnvelopes[index].title}',
  1685. style: TextStyle(
  1686. color: Colors.white, fontSize: 25 / 3 * ppx),
  1687. maxLines: 1,
  1688. )
  1689. ],
  1690. ),
  1691. ),
  1692. ],
  1693. alignment: Alignment.topCenter,
  1694. );
  1695. },
  1696. physics: redWallShowMore ? null : NeverScrollableScrollPhysics(),
  1697. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  1698. crossAxisCount: 3,
  1699. childAspectRatio: 19 / 24,
  1700. mainAxisSpacing: 8,
  1701. crossAxisSpacing: 8),
  1702. itemCount: redEnvelopes.length,
  1703. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  1704. ),
  1705. ),
  1706. GestureDetector(
  1707. onTap: () {
  1708. setState(() {
  1709. redWallShowMore = !redWallShowMore;
  1710. if (!redWallShowMore) {
  1711. _controller.animateTo(0.0,
  1712. duration: Duration(milliseconds: 500), curve: Curves.ease);
  1713. }
  1714. });
  1715. },
  1716. behavior: HitTestBehavior.translucent,
  1717. child: Container(
  1718. height: 30,
  1719. child: Icon(redWallShowMore
  1720. ? Icons.keyboard_arrow_up
  1721. : Icons.keyboard_arrow_down),
  1722. alignment: Alignment.center,
  1723. ),
  1724. )
  1725. ],
  1726. );
  1727. }
  1728. int rPage = 1;
  1729. void queryRedEnvelope() {
  1730. MyDio().query({
  1731. "key": "red_packet",
  1732. "filters": {
  1733. "conditions": ["shop_uid==${widget.data.shopUid}", 'left_count>0'],
  1734. },
  1735. "dims": redPacketDims,
  1736. "paging": [rPage, 10]
  1737. }, (response, hasError) {
  1738. if (!hasError) {
  1739. RedEnvelopeWallBeanEntity entity = RedEnvelopeWallBeanEntity()
  1740. .fromJson(json.decode(response.toString()));
  1741. if (rPage == 1) {
  1742. redEnvelopes.clear();
  1743. }
  1744. redEnvelopes.addAll(entity.data.data);
  1745. setState(() {});
  1746. }
  1747. }, (error) {});
  1748. }
  1749. void grabARedEnvelope(RedEnvelopeWallBeanDataData redEnvelope) {
  1750. EasyLoading.show();
  1751. MyDio().post(MyApis.getApi('applyForRedPacket2'), {
  1752. 'id': redEnvelope.id,
  1753. 'user_uid': MyCookie().getUID()
  1754. }, (response, hasError) {
  1755. if (!hasError) {
  1756. rPage = 1;
  1757. queryRedEnvelope();
  1758. ApplyForRedPacketBeanEntity entity = ApplyForRedPacketBeanEntity()
  1759. .fromJson(json.decode(response.toString()));
  1760. showResult(entity.data, redEnvelope);
  1761. EasyLoading.dismiss();
  1762. }
  1763. }, (error) {});
  1764. }
  1765. void showResult(
  1766. ApplyForRedPacketBeanData data, RedEnvelopeWallBeanDataData redEnvelope) {
  1767. showDialog<void>(
  1768. context: context,
  1769. barrierDismissible: false,
  1770. // false = user must tap button, true = tap outside dialog
  1771. builder: (BuildContext dialogContext) {
  1772. return StatefulBuilder(
  1773. builder:
  1774. (BuildContext context, void Function(void Function()) setState) {
  1775. return Container(
  1776. child: Column(
  1777. children: [
  1778. Stack(
  1779. children: [
  1780. Positioned(
  1781. child: Container(
  1782. height: 396 * ppx,
  1783. width: double.infinity,
  1784. decoration: BoxDecoration(
  1785. borderRadius: BorderRadius.circular(16),
  1786. color: MyColors.cEB4935),
  1787. margin: EdgeInsets.symmetric(horizontal: 45 * ppx),
  1788. alignment: Alignment.bottomCenter,
  1789. ),
  1790. ),
  1791. Positioned(
  1792. child: Column(
  1793. children: [
  1794. SvgPicture.asset('images/svg/logo.svg'),
  1795. Container(
  1796. margin: EdgeInsets.only(top: 67 * ppx),
  1797. child: Text(
  1798. '${double.parse(data.amount.toString()).toStringAsFixed(2)}元',
  1799. style: TextStyle(
  1800. color: MyColors.cF1D19B,
  1801. fontSize: 38 * ppx,
  1802. fontWeight: FontWeight.bold,
  1803. decoration: TextDecoration.none),
  1804. ),
  1805. ),
  1806. Container(
  1807. margin: EdgeInsets.only(top: 20 * ppx),
  1808. child: Text(
  1809. '${redEnvelope.title}',
  1810. style: TextStyle(
  1811. color: Colors.white,
  1812. fontSize: 20 * ppx,
  1813. decoration: TextDecoration.none),
  1814. ),
  1815. ),
  1816. ],
  1817. ),
  1818. top: 37 * ppx,
  1819. ),
  1820. ],
  1821. alignment: Alignment.topCenter,
  1822. ),
  1823. GestureDetector(
  1824. onTap: () {
  1825. Navigator.pop(context);
  1826. },
  1827. child: Container(
  1828. margin: EdgeInsets.only(top: 24 * ppx),
  1829. child: Icon(
  1830. Icons.clear,
  1831. color: Colors.white,
  1832. ),
  1833. height: 28 * ppx,
  1834. width: 28 * ppx,
  1835. alignment: Alignment.center,
  1836. decoration: BoxDecoration(
  1837. color: MyColors.c25E7E7E7,
  1838. borderRadius: BorderRadius.circular(14 * ppx)),
  1839. ),
  1840. )
  1841. ],
  1842. mainAxisAlignment: MainAxisAlignment.center,
  1843. ),
  1844. alignment: Alignment.center,
  1845. );
  1846. },
  1847. );
  1848. },
  1849. );
  1850. }
  1851. }
  1852. class RedEnvelope1Path extends CustomPainter {
  1853. Paint _paint = Paint()
  1854. ..color = MyColors.cF55544 //画笔颜色
  1855. ..strokeCap = StrokeCap.round //画笔笔触类型
  1856. ..isAntiAlias = true //是否启动抗锯齿
  1857. ..strokeWidth = 15.0; //画笔的宽度
  1858. @override
  1859. void paint(Canvas canvas, Size size) {
  1860. var path = Path()
  1861. ..moveTo(0, 0)
  1862. ..quadraticBezierTo(size.width / 2, 25, size.width, 0)
  1863. ..lineTo(size.width, size.height - 16)
  1864. ..quadraticBezierTo(size.width, size.height, size.width - 16, size.height)
  1865. ..lineTo(16, size.height)
  1866. ..quadraticBezierTo(0, size.height, 0, size.height - 16)
  1867. ..close();
  1868. canvas.drawPath(path, _paint);
  1869. }
  1870. @override
  1871. bool shouldRepaint(covariant CustomPainter oldDelegate) {
  1872. return false;
  1873. }
  1874. }