gang_in_page.dart 76 KB

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