gang_in_page.dart 78 KB

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