gang_in_page.dart 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937
  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. ),
  783. GestureDetector(
  784. onTap: () {
  785. controller.requestRefresh();
  786. MyTools().hideKeyboard(context);
  787. },
  788. behavior: HitTestBehavior.translucent,
  789. child: Container(
  790. decoration: BoxDecoration(
  791. borderRadius: BorderRadius.circular(20),
  792. color: MyColors.cFF4233),
  793. height: 40,
  794. width: 80,
  795. child: Text(
  796. '搜 索',
  797. style: TextStyle(
  798. color: Colors.white, fontSize: 14),
  799. ),
  800. alignment: Alignment.center,
  801. ),
  802. ),
  803. if(addMemberPermissions(widget.data.role))
  804. GestureDetector(
  805. onTap: () {
  806. MyTools().toPage(
  807. context, AddMemberPage(store: store),
  808. (then) {
  809. controller.requestRefresh(needMove: false);
  810. });
  811. },
  812. behavior: HitTestBehavior.translucent,
  813. child: Container(
  814. decoration: BoxDecoration(
  815. borderRadius: BorderRadius.circular(20),
  816. color: MyColors.cFF4233),
  817. height: 40,
  818. width: 40,
  819. margin: EdgeInsets.only(left: 10),
  820. child:SvgPicture.asset('images/svg/添加成员.svg',height: 18,width: 18,color: Colors.white,),
  821. alignment: Alignment.center,
  822. ),
  823. ),
  824. ],
  825. ),
  826. ),
  827. Expanded(
  828. child: SmartRefresher(
  829. controller: controller,
  830. onRefresh: onRefresh,
  831. onLoading: onLoading,
  832. enablePullDown: true,
  833. enablePullUp: true,
  834. child: body(),
  835. ),
  836. ),
  837. ],
  838. ),
  839. ),
  840. Container(
  841. color: Colors.white,
  842. child: SafeArea(
  843. top: false,
  844. child: Container(
  845. padding: EdgeInsets.symmetric(horizontal: 37),
  846. color: Colors.white,
  847. width: double.infinity,
  848. height: 60,
  849. child: Row(
  850. children: [
  851. Expanded(
  852. child: GestureDetector(
  853. onTap: () {
  854. if (!widget.data.privateShop &&
  855. MyCookie().getUID() == widget.data.ownerUid) {
  856. MyTools().toPage(context,
  857. SetAmountPage(widget.data), (then) {});
  858. } else {
  859. queryShopMembers(true);
  860. }
  861. },
  862. behavior: HitTestBehavior.translucent,
  863. child: Container(
  864. decoration: BoxDecoration(
  865. borderRadius: !hideOfflinePay
  866. ? BorderRadius.only(
  867. topLeft: Radius.circular(20),
  868. bottomLeft: Radius.circular(20),
  869. )
  870. : BorderRadius.circular(20),
  871. border: Border.all(
  872. color: MyColors.cFF4233, width: 1)),
  873. height: 40,
  874. child: MyViews().myText(
  875. !widget.data.privateShop &&
  876. MyCookie().getUID() ==
  877. widget.data.ownerUid
  878. ? '扫码收款'
  879. : '联系帮主',
  880. MyColors.cFF4233,
  881. 14),
  882. alignment: Alignment.center),
  883. ),
  884. ),
  885. if (!hideOfflinePay)
  886. Expanded(
  887. child: GestureDetector(
  888. onTap: () {
  889. if (MyCookie().getUID() == widget.data.ownerUid) {
  890. MyTools().toPage(context,
  891. InitiateCollectionPage(widget.data),
  892. (then) {
  893. if (then is String && then == '发起收款') {
  894. controller.requestRefresh();
  895. }
  896. });
  897. } else {
  898. MyTools().toPage(context,
  899. PayToTheHelperPage(widget.data), (then) {});
  900. }
  901. },
  902. behavior: HitTestBehavior.translucent,
  903. child: Container(
  904. decoration: BoxDecoration(
  905. borderRadius: BorderRadius.only(
  906. topRight: Radius.circular(20),
  907. bottomRight: Radius.circular(20),
  908. ),
  909. color: MyColors.cFF4233),
  910. height: 40,
  911. child: MyViews().myText(
  912. MyCookie().getUID() == widget.data.ownerUid
  913. ? '发起收款'
  914. : '到店付款',
  915. Colors.white,
  916. 14),
  917. alignment: Alignment.center),
  918. ),
  919. )
  920. ],
  921. ),
  922. ),
  923. ),
  924. )
  925. ],
  926. ),
  927. ),
  928. );
  929. }
  930. body() {
  931. if (selectedIndex == 0) {
  932. return goods.length == 0
  933. ? SingleChildScrollView(child: noData())
  934. : GridView.builder(
  935. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  936. crossAxisCount: 2, //每行三列
  937. childAspectRatio: 164 / 261, //显示区域宽高相等
  938. mainAxisSpacing: 8,
  939. crossAxisSpacing: 8),
  940. itemCount: goods.length,
  941. padding:
  942. EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
  943. itemBuilder: (context, index) {
  944. return MyViews().getGoodsItem(goods[index], context);
  945. });
  946. } else if (selectedIndex == 1) {
  947. return orders.length == 0
  948. ? SingleChildScrollView(child: noData())
  949. : ListView.builder(
  950. itemBuilder: (c, index) {
  951. return Slidable(
  952. child: MyViews().getNoPayGoodsItem(orders[index], context,
  953. widget.data.ownerUid, widget.data.role),
  954. actionPane: SlidableDrawerActionPane(),
  955. enabled: paymentAuthority(widget.data.role),
  956. actionExtentRatio: 0.25,
  957. secondaryActions: <Widget>[
  958. SlideAction(
  959. child: Container(
  960. child: Container(
  961. decoration: BoxDecoration(
  962. borderRadius: BorderRadius.circular(30),
  963. color: MyColors.cFF4233,
  964. ),
  965. height: 60,
  966. width: 60,
  967. child: SvgPicture.asset(
  968. 'images/svg/del.svg',
  969. height: 40,
  970. width: 40,
  971. ),
  972. alignment: Alignment.center,
  973. ),
  974. ),
  975. onTap: () {
  976. showSimpleDialog('将删除订单(${orders[index].uid})', context,
  977. () {
  978. Navigator.pop(context);
  979. deleteOrder(orders[index]);
  980. });
  981. },
  982. )
  983. ],
  984. );
  985. },
  986. itemCount: orders.length,
  987. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  988. );
  989. } else if (selectedIndex == 2) {
  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: orders[index].type == orderTypeOfflineTransfer &&
  999. orders[index].buyerUid == MyCookie().getUID(),
  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 == 3) {
  1034. return member.length == 0
  1035. ? SingleChildScrollView(child: noData())
  1036. : ListView.builder(
  1037. itemBuilder: (BuildContext context, int index) {
  1038. return GestureDetector(
  1039. onTap: () {
  1040. if (permissionToModifyCustomerName(widget.data.role)) {
  1041. if (MyCookie().getUID() != member[index].userUid) {
  1042. MyTools().toPage(
  1043. context, MemberDetailsPage(member[index]), (then) {
  1044. controller.requestRefresh();
  1045. });
  1046. }
  1047. } else {
  1048. return;
  1049. }
  1050. },
  1051. behavior: HitTestBehavior.translucent,
  1052. child: Container(
  1053. padding: EdgeInsets.only(left: 15, right: 15),
  1054. color: Colors.white,
  1055. child: Column(
  1056. children: [
  1057. Container(
  1058. margin: EdgeInsets.only(top: 8, bottom: 6),
  1059. child: Row(
  1060. children: [
  1061. Row(
  1062. children: [
  1063. Container(
  1064. margin: EdgeInsets.only(right: 6),
  1065. child: ClipRRect(
  1066. child: MyViews().netImg(
  1067. imgURL(member[index].userPic),
  1068. 42,
  1069. 42),
  1070. borderRadius: BorderRadius.circular(21),
  1071. ),
  1072. ),
  1073. MyViews().myText(
  1074. '${member[index].userName} ${store.ownerUid == MyCookie().getUID() ? '(${member[index].userUid})' : ''}',
  1075. MyColors.c333333,
  1076. 15),
  1077. Visibility(
  1078. visible:
  1079. member[index].role != shopUserMember,
  1080. child: Container(
  1081. decoration: BoxDecoration(
  1082. color: MyColors.cFFCD00,
  1083. borderRadius:
  1084. BorderRadius.circular(8)),
  1085. height: 16,
  1086. padding:
  1087. EdgeInsets.symmetric(horizontal: 5),
  1088. child: MyViews().myText(
  1089. roleText(member[index].role),
  1090. Colors.white,
  1091. 10),
  1092. alignment: Alignment.center,
  1093. margin: EdgeInsets.only(left: 5),
  1094. ),
  1095. )
  1096. ],
  1097. ),
  1098. Visibility(
  1099. // visible: member[index].role != shopUserOwner &&
  1100. // member[index].userUid !=
  1101. // MyCookie().getUID(),
  1102. visible: false,
  1103. child: GestureDetector(
  1104. child: Container(
  1105. margin: EdgeInsets.only(right: 10),
  1106. child: SvgPicture.asset(
  1107. 'images/svg/透视.svg',
  1108. height: 25,
  1109. width: 25,
  1110. ),
  1111. ),
  1112. onTap: () {
  1113. queryWhetherThereIsANumberOfPerspectives(
  1114. member[index], store, context);
  1115. },
  1116. behavior: HitTestBehavior.translucent,
  1117. ),
  1118. ),
  1119. ],
  1120. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1121. ),
  1122. ),
  1123. Container(
  1124. height: 0.5,
  1125. color: MyColors.cE7E7E7,
  1126. )
  1127. ],
  1128. ),
  1129. ),
  1130. );
  1131. },
  1132. itemCount: member.length,
  1133. padding: EdgeInsets.only(top: 10),
  1134. );
  1135. } else {
  1136. return SingleChildScrollView(child: noData());
  1137. }
  1138. }
  1139. void onRefresh() {
  1140. page = 1;
  1141. if (selectedIndex == 0) {
  1142. queryProducts();
  1143. } else if (selectedIndex == 1) {
  1144. unreceivedOrder();
  1145. } else if (selectedIndex == 3) {
  1146. queryShopMembers(false);
  1147. } else {
  1148. unpaidOrder();
  1149. }
  1150. }
  1151. void onLoading() {
  1152. page++;
  1153. if (selectedIndex == 0) {
  1154. queryProducts();
  1155. } else if (selectedIndex == 1) {
  1156. unreceivedOrder();
  1157. } else if (selectedIndex == 3) {
  1158. queryShopMembers(false);
  1159. } else {
  1160. unpaidOrder();
  1161. }
  1162. }
  1163. //查询商品
  1164. void queryProducts() {
  1165. MyDio().query({
  1166. "key": "commodity",
  1167. "filters": {
  1168. "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"]
  1169. },
  1170. "dims": commodityDims,
  1171. "order_by": ["id,desc", "no,desc"],
  1172. "paging": [page, 20]
  1173. }, (response, hasError) {
  1174. if (!hasError) {
  1175. GoodsBeanEntity entity =
  1176. GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
  1177. if (page == 1) {
  1178. goods.clear();
  1179. }
  1180. goods.addAll(entity.data.data);
  1181. }
  1182. setState(() {
  1183. endRe(controller);
  1184. });
  1185. }, (error) {
  1186. setState(() {
  1187. endRe(controller);
  1188. });
  1189. });
  1190. }
  1191. //查询未收订单
  1192. void unreceivedOrder() {
  1193. var conditions = [];
  1194. if (paymentAuthority(widget.data.role)) {
  1195. conditions.add('state == $orderStateUnpaid');
  1196. conditions.add('shop_uid == ${widget.data.shopUid}');
  1197. } else {
  1198. conditions.add('state == $orderStateUnpaid');
  1199. conditions.add('shop_uid == ${widget.data.shopUid}');
  1200. conditions.add('seller_uid == ${MyCookie().getUID()}');
  1201. }
  1202. MyDio().query({
  1203. "key": "order",
  1204. "filters": {"conditions": conditions},
  1205. "dims": orderDims,
  1206. "paging": [page, 20],
  1207. "order_by": ["create_time,DESC"]
  1208. }, (response, hasError) {
  1209. if (!hasError) {
  1210. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1211. .fromJson(json.decode(response.data.toString()));
  1212. if (page == 1) {
  1213. orders.clear();
  1214. }
  1215. orders.addAll(entity.data.data);
  1216. setState(() {});
  1217. }
  1218. endRe(controller);
  1219. }, (error) {});
  1220. }
  1221. //查询未付订单
  1222. void unpaidOrder() {
  1223. var conditions = [];
  1224. if (paymentAuthority(widget.data.role)) {
  1225. conditions.add('state == $orderStatePaid');
  1226. conditions.add('shop_uid == ${widget.data.shopUid}');
  1227. } else {
  1228. conditions.add('state == $orderStateUnpaid');
  1229. conditions.add('shop_uid == ${widget.data.shopUid}');
  1230. conditions.add('buyer_uid==0');
  1231. conditions.add('buyer_name LIKE ${MyCookie().getName()}');
  1232. }
  1233. var filters;
  1234. if (paymentAuthority(widget.data.role)) {
  1235. filters = {"conditions": conditions};
  1236. } else {
  1237. filters = {
  1238. "conditions": conditions,
  1239. "or": true,
  1240. "filters": [
  1241. {
  1242. "conditions": [
  1243. "state == $orderStateUnpaid",
  1244. 'shop_uid == ${widget.data.shopUid}',
  1245. 'buyer_uid==${MyCookie().getUID()}'
  1246. ]
  1247. }
  1248. ]
  1249. };
  1250. }
  1251. MyDio().query({
  1252. "key": "order",
  1253. "filters": filters,
  1254. "dims": orderDims,
  1255. "paging": [page, 20],
  1256. "order_by": ["create_time,DESC"]
  1257. }, (response, hasError) {
  1258. if (!hasError) {
  1259. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  1260. .fromJson(json.decode(response.data.toString()));
  1261. if (page == 1) {
  1262. orders.clear();
  1263. }
  1264. orders.addAll(entity.data.data);
  1265. setState(() {});
  1266. }
  1267. endRe(controller);
  1268. }, (error) {});
  1269. }
  1270. payTheOrder() {
  1271. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  1272. data.sellerUid = widget.order.sellerUID;
  1273. data.sellerName = widget.order.sellerName;
  1274. data.sellerPic = widget.order.sellerPic;
  1275. data.buyerUid = 0;
  1276. data.buyerName = widget.order.buyerName;
  1277. data.buyerPic = '';
  1278. data.amount = widget.order.amount;
  1279. data.uid = widget.order.uID;
  1280. MyTools().toPage(
  1281. context,
  1282. OrderInformationPage(
  1283. false,
  1284. orderType: orderTypeThirdPlatform,
  1285. amount: widget.order.amount,
  1286. uid: widget.order.uID,
  1287. buyerUid: MyCookie().getUID(),
  1288. buyerName: widget.order.buyerName,
  1289. buyerPic: MyCookie().getPic(),
  1290. commodityCount: 1,
  1291. commodityTitle: '第三方订单',
  1292. commodityCover: '',
  1293. sellName: widget.order.sellerName,
  1294. sellPic: widget.order.sellerPic,
  1295. sellUid: widget.order.sellerUID,
  1296. ), (then) {
  1297. controller.requestRefresh();
  1298. PopUpQueue().onShow = false;
  1299. PopUpQueue().showNext();
  1300. });
  1301. // showPayDialog(data, context, () {
  1302. // Navigator.pop(context);
  1303. // // MyTools().toPage(context,
  1304. // // PayPage(widget.order.uID, false, widget.order.amount), (then) {});
  1305. //
  1306. // });
  1307. }
  1308. List<MyShopBeanDataData> member = [];
  1309. List<MyShopBeanDataData> helper = [];
  1310. queryShopMembers(bool toOwner) {
  1311. var conditions = ["shop_uid==${store.uid}", "review_state==1"];
  1312. if (_textEditingController.text.isNotEmpty) {
  1313. conditions
  1314. .add('user_name LIKE ${_textEditingController.text.toString()}');
  1315. }
  1316. MyDio().query({
  1317. "key": "shop_user",
  1318. "filters": {"conditions": conditions},
  1319. "dims": shopUserDims,
  1320. "paging": [page, 50]
  1321. }, (response, hasError) {
  1322. if (!hasError) {
  1323. MyShopBeanEntity entity =
  1324. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1325. if (page == 1) {
  1326. member.clear();
  1327. }
  1328. member.addAll(entity.data.data);
  1329. if (toOwner) {
  1330. helper.clear();
  1331. member.forEach((element) {
  1332. if (element.role == shopUserStaff) {
  1333. helper.add(element);
  1334. }
  1335. });
  1336. MyShopBeanDataData chatWith;
  1337. // if (helper.length == 0) {
  1338. chatWith = member[
  1339. member.indexWhere((element) => element.role == shopUserOwner)];
  1340. // } else {
  1341. // chatWith = helper[Random().nextInt(helper.length)];
  1342. // }
  1343. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1344. } else {
  1345. controller.refreshCompleted();
  1346. controller.loadComplete();
  1347. setState(() {});
  1348. }
  1349. _textEditingController.clear();
  1350. }
  1351. }, (error) {});
  1352. }
  1353. void deleteOrder(SmartOrderBeanDataData order) {
  1354. MyDio().del({
  1355. 'key': 'order',
  1356. 'ids': [order.id]
  1357. }, (response, hasError) {
  1358. if (!hasError) {
  1359. orders.remove(order);
  1360. setState(() {});
  1361. }
  1362. }, (error) {});
  1363. }
  1364. StoreBeanDataData store;
  1365. bool hideMember = true;
  1366. queryStoreInformation() {
  1367. MyDio().query({
  1368. "key": "shop",
  1369. "filters": {
  1370. "conditions": ["uid == ${widget.data.shopUid}"]
  1371. },
  1372. "dims": shopDims,
  1373. "paging": [1, 5]
  1374. }, (response, hasError) {
  1375. if (!hasError) {
  1376. StoreBeanEntity entity =
  1377. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1378. store = entity.data.data[0];
  1379. hideMember = store.hideMembers;
  1380. hideOfflinePay = store.hideOfflinePay;
  1381. //自己的公开店铺
  1382. if (!store.private && store.ownerUid == MyCookie().getUID()) {
  1383. canSendGood = true;
  1384. }
  1385. //自己在某个允许顾客间交易的私有店铺中
  1386. if (store.innerTrade && store.private) {
  1387. canSendGood = true;
  1388. }
  1389. setState(() {});
  1390. }
  1391. endRe(controller);
  1392. }, (error) {});
  1393. }
  1394. void queryWhetherThereIsANumberOfPerspectives(
  1395. MyShopBeanDataData data, StoreBeanDataData store, BuildContext context) {
  1396. MyDio().query({
  1397. "key": "user_vp",
  1398. "filters": {
  1399. "conditions": [
  1400. "user_uid == ${MyCookie().getUID()}",
  1401. "vp_key == $vpKeyXRay"
  1402. ]
  1403. },
  1404. "dims": userVpDims,
  1405. "paging": [1, 2000]
  1406. }, (response, hasError) {
  1407. UserVpBeanEntity entity =
  1408. UserVpBeanEntity().fromJson(json.decode(response.data.toString()));
  1409. if (entity.data.data.length != 0) {
  1410. MyTools().toPage(context, OtherPeopleSTurnoverPage(data), (then) {});
  1411. } else {
  1412. // showSimpleDialog('你还未获取透视道具或道具用完,请先购买次数再查看。', context, () {
  1413. // Navigator.pop(context);
  1414. // MyShopBeanDataData shop = MyShopBeanDataData();
  1415. // shop.shopUid = store.uid;
  1416. // shop.shopName = store.name;
  1417. // shop.shopPic = store.picture;
  1418. // MyTools().toPage(
  1419. // context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1420. // });
  1421. MyShopBeanDataData shop = MyShopBeanDataData();
  1422. shop.shopUid = store.uid;
  1423. shop.shopName = store.name;
  1424. shop.shopPic = store.picture;
  1425. MyTools().toPage(
  1426. context, PrivacyProtectionPropsPage(shop, vpKeyXRay), (then) {});
  1427. }
  1428. }, (error) {});
  1429. }
  1430. void shopInfo() {
  1431. showDialog(
  1432. context: context,
  1433. builder: (BuildContext context) {
  1434. return GestureDetector(
  1435. onTap: () {
  1436. Navigator.pop(context);
  1437. },
  1438. child: Material(
  1439. color: Colors.black12,
  1440. child: Center(
  1441. child: GestureDetector(
  1442. onTap: () {},
  1443. child: Container(
  1444. decoration: BoxDecoration(
  1445. borderRadius: BorderRadius.circular(16),
  1446. color: Colors.white,
  1447. ),
  1448. height: 510,
  1449. margin: EdgeInsets.symmetric(horizontal: 28),
  1450. padding: EdgeInsets.symmetric(horizontal: 14, vertical: 15),
  1451. child: Column(
  1452. children: [
  1453. Container(
  1454. height: MediaQuery.of(context).size.width - 71,
  1455. width: MediaQuery.of(context).size.width - 56,
  1456. child: ClipRRect(
  1457. child: MyViews().netImg(
  1458. imgURL(widget.data.shopPic),
  1459. MediaQuery.of(context).size.width - 84,
  1460. MediaQuery.of(context).size.width - 84),
  1461. borderRadius: BorderRadius.circular(4),
  1462. ),
  1463. ),
  1464. Row(
  1465. children: [
  1466. SvgPicture.asset(
  1467. 'images/svg/店铺.svg',
  1468. height: 21,
  1469. width: 21,
  1470. ),
  1471. Container(
  1472. width: 6,
  1473. ),
  1474. Expanded(
  1475. child: Text(
  1476. widget.data.shopName,
  1477. style: TextStyle(
  1478. color: MyColors.c333333, fontSize: 16),
  1479. ))
  1480. ],
  1481. ),
  1482. Container(
  1483. height: 10,
  1484. ),
  1485. Text(
  1486. store != null && store.introduction.isNotEmpty
  1487. ? '货帮介绍:${store.introduction}'
  1488. : '货帮介绍:暂无',
  1489. style: TextStyle(
  1490. color: MyColors.c333333,
  1491. fontSize: 12,
  1492. ),
  1493. maxLines: 3,
  1494. overflow: TextOverflow.ellipsis,
  1495. softWrap: true,
  1496. ),
  1497. Container(
  1498. height: 10,
  1499. ),
  1500. Row(
  1501. children: [
  1502. SvgPicture.asset(
  1503. 'images/svg/地址.svg',
  1504. color: MyColors.c666666,
  1505. height: 12,
  1506. width: 12,
  1507. ),
  1508. Container(
  1509. width: 5,
  1510. ),
  1511. Expanded(
  1512. child: Text(
  1513. store != null && store.address.isNotEmpty
  1514. ? store.address
  1515. : '暂无',
  1516. style: TextStyle(
  1517. color: MyColors.c666666, fontSize: 11),
  1518. maxLines: 1,
  1519. overflow: TextOverflow.ellipsis,
  1520. softWrap: true,
  1521. ),
  1522. ),
  1523. ],
  1524. ),
  1525. Container(
  1526. height: 10,
  1527. ),
  1528. Visibility(
  1529. visible: store != null && store.mobile.isNotEmpty,
  1530. child: GestureDetector(
  1531. onTap: () {
  1532. launch('tel:${store.mobile}');
  1533. },
  1534. behavior: HitTestBehavior.translucent,
  1535. child: Container(
  1536. decoration: BoxDecoration(
  1537. color: MyColors.cFF4233,
  1538. borderRadius: BorderRadius.circular(20),
  1539. ),
  1540. height: 40,
  1541. child: Row(
  1542. children: [
  1543. SvgPicture.asset(
  1544. 'images/svg/电话.svg',
  1545. color: Colors.white,
  1546. height: 24,
  1547. width: 24,
  1548. ),
  1549. Container(
  1550. width: 4,
  1551. ),
  1552. Text(
  1553. store == null ? '' : store.mobile,
  1554. style: TextStyle(
  1555. color: Colors.white, fontSize: 15),
  1556. ),
  1557. ],
  1558. mainAxisAlignment: MainAxisAlignment.center,
  1559. ),
  1560. alignment: Alignment.center,
  1561. ),
  1562. ),
  1563. )
  1564. ],
  1565. mainAxisAlignment: MainAxisAlignment.spaceAround,
  1566. crossAxisAlignment: CrossAxisAlignment.start,
  1567. ),
  1568. ),
  1569. ),
  1570. ),
  1571. ),
  1572. );
  1573. },
  1574. );
  1575. }
  1576. void collectionShop() {
  1577. if (!collect) {
  1578. MyDio().save({
  1579. 'key': 'shop_user',
  1580. 'object': {
  1581. 'review_state': 1,
  1582. 'user_uid': MyCookie().getUID(),
  1583. 'shop_uid': widget.data.shopUid,
  1584. 'role': shopUserMember
  1585. }
  1586. }, (response, hasError) {
  1587. if (!hasError) {
  1588. needRE = !needRE;
  1589. EventBus().emit('needRE', needRE);
  1590. showToast('收藏成功');
  1591. queryWhetherToFollow();
  1592. }
  1593. }, (error) {});
  1594. } else {
  1595. MyDio().del({
  1596. 'key': 'shop_user',
  1597. 'ids': [shopUserID]
  1598. }, (response, hasError) {
  1599. if (!hasError) {
  1600. needRE = !needRE;
  1601. EventBus().emit('needRE', needRE);
  1602. showToast('取消收藏');
  1603. collect = false;
  1604. shopUserID = null;
  1605. setState(() {});
  1606. }
  1607. }, (error) {});
  1608. }
  1609. }
  1610. int shopUserID;
  1611. void queryWhetherToFollow() {
  1612. MyDio().query({
  1613. "key": "shop_user",
  1614. "filters": {
  1615. "conditions": [
  1616. "shop_uid==${widget.data.shopUid}",
  1617. "user_uid==${MyCookie().getUID()}"
  1618. ]
  1619. },
  1620. "dims": shopUserDims,
  1621. "paging": [1, 1]
  1622. }, (response, hasError) {
  1623. if (!hasError) {
  1624. MyShopBeanEntity entity =
  1625. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1626. collect = entity.data.data.length != 0;
  1627. if (entity.data.data.isNotEmpty) {
  1628. shopUserID = entity.data.data[0].id;
  1629. }
  1630. setState(() {});
  1631. }
  1632. }, (error) {});
  1633. }
  1634. ScrollController _controller = ScrollController();
  1635. redEnvelopeWall() {
  1636. return Column(
  1637. children: [
  1638. Container(
  1639. height: redWallShowMore
  1640. ? 375 / 3 * ppx / 19 * 48
  1641. : 375 / 3 * ppx / 19 * 24,
  1642. child: GridView.builder(
  1643. controller: _controller,
  1644. itemBuilder: (BuildContext context, int index) {
  1645. return Stack(
  1646. children: [
  1647. Positioned(
  1648. child: Container(
  1649. width: 375 / 3 * ppx,
  1650. height: 375 / 3 * ppx / 19 * 24,
  1651. decoration: BoxDecoration(
  1652. borderRadius: BorderRadius.circular(16),
  1653. color: MyColors.cF25D4B),
  1654. alignment: Alignment.bottomCenter,
  1655. child: CustomPaint(
  1656. painter: RedEnvelope1Path(),
  1657. size: Size(375 / 3 * ppx, 375 / 171 * 24 * ppx)),
  1658. ),
  1659. ),
  1660. Positioned(
  1661. top: 375 / 185 * 43.2 * ppx,
  1662. child: GestureDetector(
  1663. onTap: () {
  1664. grabARedEnvelope(redEnvelopes[index]);
  1665. },
  1666. behavior: HitTestBehavior.translucent,
  1667. child: Container(
  1668. decoration: BoxDecoration(
  1669. color: MyColors.cF1D19B,
  1670. borderRadius: BorderRadius.circular(45 * ppx)),
  1671. height: 375 / 57 * ppx * 5,
  1672. width: 375 / 57 * ppx * 5,
  1673. child: Text(
  1674. '开',
  1675. style: TextStyle(
  1676. color: MyColors.c333333,
  1677. fontSize: 375 / 57 * ppx * 3,
  1678. decoration: TextDecoration.none,
  1679. fontWeight: FontWeight.normal),
  1680. ),
  1681. alignment: Alignment.center,
  1682. ),
  1683. ),
  1684. ),
  1685. Positioned(
  1686. top: 15,
  1687. child: Column(
  1688. children: [
  1689. ClipRRect(
  1690. child: MyViews().netImg(
  1691. imgURL(redEnvelopes[index].payerPic),
  1692. 375 / 57 * ppx * 4,
  1693. 375 / 57 * ppx * 4),
  1694. borderRadius:
  1695. BorderRadius.circular(375 / 57 * ppx * 2),
  1696. ),
  1697. Container(
  1698. child: Text(
  1699. '${redEnvelopes[index].payerName}(${hideUID(redEnvelopes[index].payerUid.toString())})',
  1700. style: TextStyle(
  1701. color: Colors.white, fontSize: 25 / 3 * ppx),
  1702. maxLines: 1,
  1703. ),
  1704. margin: EdgeInsets.symmetric(vertical: 5),
  1705. ),
  1706. Text(
  1707. '${redEnvelopes[index].title}',
  1708. style: TextStyle(
  1709. color: Colors.white, fontSize: 25 / 3 * ppx),
  1710. maxLines: 1,
  1711. )
  1712. ],
  1713. ),
  1714. ),
  1715. ],
  1716. alignment: Alignment.topCenter,
  1717. );
  1718. },
  1719. physics: redWallShowMore ? null : NeverScrollableScrollPhysics(),
  1720. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  1721. crossAxisCount: 3,
  1722. childAspectRatio: 19 / 24,
  1723. mainAxisSpacing: 8,
  1724. crossAxisSpacing: 8),
  1725. itemCount: redEnvelopes.length,
  1726. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  1727. ),
  1728. ),
  1729. GestureDetector(
  1730. onTap: () {
  1731. setState(() {
  1732. redWallShowMore = !redWallShowMore;
  1733. if (!redWallShowMore) {
  1734. _controller.animateTo(0.0,
  1735. duration: Duration(milliseconds: 500), curve: Curves.ease);
  1736. }
  1737. });
  1738. },
  1739. behavior: HitTestBehavior.translucent,
  1740. child: Container(
  1741. height: 30,
  1742. child: Icon(redWallShowMore
  1743. ? Icons.keyboard_arrow_up
  1744. : Icons.keyboard_arrow_down),
  1745. alignment: Alignment.center,
  1746. ),
  1747. )
  1748. ],
  1749. );
  1750. }
  1751. int rPage = 1;
  1752. void queryRedEnvelope() {
  1753. MyDio().query({
  1754. "key": "red_packet",
  1755. "filters": {
  1756. "conditions": ["shop_uid==${widget.data.shopUid}", 'left_count>0'],
  1757. },
  1758. "dims": redPacketDims,
  1759. "paging": [rPage, 10]
  1760. }, (response, hasError) {
  1761. if (!hasError) {
  1762. RedEnvelopeWallBeanEntity entity = RedEnvelopeWallBeanEntity()
  1763. .fromJson(json.decode(response.toString()));
  1764. if (rPage == 1) {
  1765. redEnvelopes.clear();
  1766. }
  1767. redEnvelopes.addAll(entity.data.data);
  1768. setState(() {});
  1769. }
  1770. }, (error) {});
  1771. }
  1772. void grabARedEnvelope(RedEnvelopeWallBeanDataData redEnvelope) {
  1773. EasyLoading.show();
  1774. MyDio().post(MyApis.getApi('applyForRedPacket2'), {
  1775. 'id': redEnvelope.id,
  1776. 'user_uid': MyCookie().getUID()
  1777. }, (response, hasError) {
  1778. if (!hasError) {
  1779. rPage = 1;
  1780. queryRedEnvelope();
  1781. ApplyForRedPacketBeanEntity entity = ApplyForRedPacketBeanEntity()
  1782. .fromJson(json.decode(response.toString()));
  1783. showResult(entity.data, redEnvelope);
  1784. EasyLoading.dismiss();
  1785. }
  1786. }, (error) {});
  1787. }
  1788. void showResult(
  1789. ApplyForRedPacketBeanData data, RedEnvelopeWallBeanDataData redEnvelope) {
  1790. showDialog<void>(
  1791. context: context,
  1792. barrierDismissible: false,
  1793. // false = user must tap button, true = tap outside dialog
  1794. builder: (BuildContext dialogContext) {
  1795. return StatefulBuilder(
  1796. builder:
  1797. (BuildContext context, void Function(void Function()) setState) {
  1798. return Container(
  1799. child: Column(
  1800. children: [
  1801. Stack(
  1802. children: [
  1803. Positioned(
  1804. child: Container(
  1805. height: 396 * ppx,
  1806. width: double.infinity,
  1807. decoration: BoxDecoration(
  1808. borderRadius: BorderRadius.circular(16),
  1809. color: MyColors.cEB4935),
  1810. margin: EdgeInsets.symmetric(horizontal: 45 * ppx),
  1811. alignment: Alignment.bottomCenter,
  1812. ),
  1813. ),
  1814. Positioned(
  1815. child: Column(
  1816. children: [
  1817. SvgPicture.asset('images/svg/logo.svg'),
  1818. Container(
  1819. margin: EdgeInsets.only(top: 67 * ppx),
  1820. child: Text(
  1821. '${double.parse(data.amount.toString()).toStringAsFixed(2)}元',
  1822. style: TextStyle(
  1823. color: MyColors.cF1D19B,
  1824. fontSize: 38 * ppx,
  1825. fontWeight: FontWeight.bold,
  1826. decoration: TextDecoration.none),
  1827. ),
  1828. ),
  1829. Container(
  1830. margin: EdgeInsets.only(top: 20 * ppx),
  1831. child: Text(
  1832. '${redEnvelope.title}',
  1833. style: TextStyle(
  1834. color: Colors.white,
  1835. fontSize: 20 * ppx,
  1836. decoration: TextDecoration.none),
  1837. ),
  1838. ),
  1839. ],
  1840. ),
  1841. top: 37 * ppx,
  1842. ),
  1843. ],
  1844. alignment: Alignment.topCenter,
  1845. ),
  1846. GestureDetector(
  1847. onTap: () {
  1848. Navigator.pop(context);
  1849. },
  1850. child: Container(
  1851. margin: EdgeInsets.only(top: 24 * ppx),
  1852. child: Icon(
  1853. Icons.clear,
  1854. color: Colors.white,
  1855. ),
  1856. height: 28 * ppx,
  1857. width: 28 * ppx,
  1858. alignment: Alignment.center,
  1859. decoration: BoxDecoration(
  1860. color: MyColors.c25E7E7E7,
  1861. borderRadius: BorderRadius.circular(14 * ppx)),
  1862. ),
  1863. )
  1864. ],
  1865. mainAxisAlignment: MainAxisAlignment.center,
  1866. ),
  1867. alignment: Alignment.center,
  1868. );
  1869. },
  1870. );
  1871. },
  1872. );
  1873. }
  1874. }
  1875. class RedEnvelope1Path extends CustomPainter {
  1876. Paint _paint = Paint()
  1877. ..color = MyColors.cF55544 //画笔颜色
  1878. ..strokeCap = StrokeCap.round //画笔笔触类型
  1879. ..isAntiAlias = true //是否启动抗锯齿
  1880. ..strokeWidth = 15.0; //画笔的宽度
  1881. @override
  1882. void paint(Canvas canvas, Size size) {
  1883. var path = Path()
  1884. ..moveTo(0, 0)
  1885. ..quadraticBezierTo(size.width / 2, 25, size.width, 0)
  1886. ..lineTo(size.width, size.height - 16)
  1887. ..quadraticBezierTo(size.width, size.height, size.width - 16, size.height)
  1888. ..lineTo(16, size.height)
  1889. ..quadraticBezierTo(0, size.height, 0, size.height - 16)
  1890. ..close();
  1891. canvas.drawPath(path, _paint);
  1892. }
  1893. @override
  1894. bool shouldRepaint(covariant CustomPainter oldDelegate) {
  1895. return false;
  1896. }
  1897. }