gang_in_page.dart 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  1. import 'dart:convert';
  2. import 'dart:math';
  3. import 'package:bbyyy/beans/alipay_result_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/pay_by_alipay_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_balance_entity.dart';
  11. import 'package:bbyyy/https/MyDio.dart';
  12. import 'package:bbyyy/https/my_request.dart';
  13. import 'package:bbyyy/https/url.dart';
  14. import 'package:bbyyy/my_tools/const.dart';
  15. import 'package:bbyyy/my_tools/dims.dart';
  16. import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
  17. import 'package:bbyyy/my_tools/event_bus.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/paegs/chat_page/chat_page.dart';
  23. import 'package:bbyyy/paegs/gang_page/gang_in_page/pay_to_the_helper_page/pay_to_the_helper_page.dart';
  24. import 'package:bbyyy/pay/pay_tools.dart';
  25. import 'package:flutter/cupertino.dart';
  26. import 'package:flutter/material.dart';
  27. import 'package:flutter_slidable/flutter_slidable.dart';
  28. import 'package:flutter_svg/svg.dart';
  29. import 'package:pull_to_refresh/pull_to_refresh.dart';
  30. import 'package:tobias/tobias.dart';
  31. import 'package:url_launcher/url_launcher.dart';
  32. import 'gang_information_page/gang_information_page.dart';
  33. class GangInPage extends StatefulWidget {
  34. MyShopBeanDataData data;
  35. NewOrderBeanContent order;
  36. GangInPage(this.data, this.order);
  37. @override
  38. _GangInPageState createState() => _GangInPageState();
  39. }
  40. class _GangInPageState extends State<GangInPage> {
  41. int selectedIndex = 0;
  42. RefreshController controller = RefreshController(initialRefresh: true);
  43. int page = 1;
  44. _GangInPageState();
  45. List<GoodsBeanDataData> goods = [];
  46. List<SmartOrderBeanDataData> orders = [];
  47. @override
  48. void initState() {
  49. // TODO: implement initState
  50. super.initState();
  51. EventBus().on('payAnOrder', (arg) {
  52. controller.requestRefresh();
  53. });
  54. EventBus().on('reNoPayOrder', (arg) {
  55. controller.requestRefresh();
  56. });
  57. Future.delayed(Duration.zero, () {
  58. if (widget.order != null) {
  59. setState(() {
  60. selectedIndex = 2;
  61. payTheOrder();
  62. });
  63. }
  64. });
  65. if (widget.data.ownerUid == MyCookie().getUID()) {
  66. selectedIndex = 1;
  67. }
  68. queryStoreInformation();
  69. }
  70. @override
  71. void dispose() {
  72. // TODO: implement dispose
  73. super.dispose();
  74. EventBus().off('payAnOrder');
  75. EventBus().off('reNoPayOrder');
  76. }
  77. @override
  78. Widget build(BuildContext context) {
  79. return Scaffold(
  80. body: Column(
  81. children: [
  82. MyViews().myAppBar(widget.data.shopName, context, [
  83. Visibility(
  84. visible: widget.data.ownerUid == MyCookie().getUID(),
  85. child: IconButton(
  86. icon: Icon(Icons.more_horiz),
  87. onPressed: () {
  88. MyTools().toPage(context, GangInformationPage(widget.data),
  89. (then) {
  90. if (then == '删除货帮') {
  91. Navigator.pop(context, '删除货帮');
  92. }
  93. });
  94. }),
  95. )
  96. ]),
  97. Container(
  98. color: MyColors.cF7F7F7,
  99. child: Container(
  100. decoration: BoxDecoration(
  101. borderRadius: BorderRadius.circular(4), color: Colors.white),
  102. margin: EdgeInsets.all(10),
  103. child: Column(
  104. children: [
  105. GestureDetector(
  106. onTap: () {
  107. showDialog(
  108. context: context,
  109. builder: (BuildContext context) {
  110. return Material(
  111. color: Colors.black12,
  112. child: Center(
  113. child: Container(
  114. decoration: BoxDecoration(
  115. borderRadius: BorderRadius.circular(16),
  116. color: Colors.white,
  117. ),
  118. height: 510,
  119. margin: EdgeInsets.symmetric(horizontal: 28),
  120. padding: EdgeInsets.symmetric(
  121. horizontal: 14, vertical: 15),
  122. child: Column(
  123. children: [
  124. Container(
  125. height:
  126. MediaQuery.of(context).size.width -
  127. 71,
  128. width: MediaQuery.of(context).size.width -
  129. 56,
  130. child: Stack(
  131. children: [
  132. ClipRRect(
  133. child: MyViews().netImg(
  134. imgURL(widget.data.shopPic),
  135. MediaQuery.of(context)
  136. .size
  137. .width -
  138. 84,
  139. MediaQuery.of(context)
  140. .size
  141. .width -
  142. 84),
  143. borderRadius:
  144. BorderRadius.circular(4),
  145. ),
  146. Positioned(
  147. right: 0,
  148. top: 0,
  149. child: IconButton(
  150. icon: Icon(
  151. Icons.cancel,
  152. color: MyColors.cC9C9C9,
  153. size: 24,
  154. ),
  155. onPressed: () {
  156. Navigator.pop(context);
  157. }),
  158. ),
  159. ],
  160. ),
  161. ),
  162. Row(
  163. children: [
  164. SvgPicture.asset(
  165. 'images/svg/店铺.svg',
  166. height: 21,
  167. width: 21,
  168. ),
  169. Container(
  170. width: 6,
  171. ),
  172. Expanded(
  173. child: Text(
  174. widget.data.shopName,
  175. style: TextStyle(
  176. color: MyColors.c333333,
  177. fontSize: 16),
  178. ))
  179. ],
  180. ),
  181. Container(height: 10,),
  182. Text(
  183. store == null
  184. ? '店铺介绍:暂无'
  185. : '店铺介绍:${store.introduction}',
  186. style: TextStyle(
  187. color: MyColors.c333333,
  188. fontSize: 12,
  189. ),
  190. maxLines: 3,
  191. overflow: TextOverflow.ellipsis,
  192. softWrap: true,
  193. ), Container(height: 10,),
  194. Row(
  195. children: [
  196. SvgPicture.asset(
  197. 'images/svg/地址.svg',
  198. color: MyColors.c666666,
  199. height: 12,
  200. width: 12,
  201. ),
  202. Container(
  203. width: 5,
  204. ),
  205. Expanded(
  206. child: Text(
  207. store == null
  208. ? '暂无'
  209. : store.address,
  210. style: TextStyle(
  211. color: MyColors.c666666,
  212. fontSize: 11),
  213. maxLines: 1,
  214. overflow: TextOverflow.ellipsis,
  215. softWrap: true,
  216. ),
  217. ),
  218. ],
  219. ), Container(height: 10,),
  220. GestureDetector(
  221. onTap: (){
  222. launch('tel:${store.mobile}');
  223. },
  224. behavior: HitTestBehavior.translucent,
  225. child: Container(
  226. decoration: BoxDecoration(
  227. color: MyColors.cFF4233,
  228. borderRadius: BorderRadius.circular(20),
  229. ),
  230. height: 40,
  231. child: Row(children: [
  232. SvgPicture.asset('images/svg/电话.svg',color: Colors.white,height: 24,width: 24,),
  233. Container(width: 4,),
  234. Text(store==null?'':store.mobile,style: TextStyle(color: Colors.white,fontSize: 15),),
  235. ],mainAxisAlignment: MainAxisAlignment.center,),
  236. alignment: Alignment.center,
  237. ),
  238. )
  239. ],
  240. mainAxisAlignment:
  241. MainAxisAlignment.spaceAround,
  242. crossAxisAlignment: CrossAxisAlignment.start,
  243. ),
  244. ),
  245. ),
  246. );
  247. },
  248. );
  249. },
  250. behavior: HitTestBehavior.translucent,
  251. child: Row(
  252. children: [
  253. Container(
  254. margin: EdgeInsets.only(
  255. right: 10, top: 6, left: 6, bottom: 6),
  256. child: ClipRRect(
  257. child: MyViews()
  258. .netImg(imgURL(widget.data.shopPic), 65, 65),
  259. borderRadius: BorderRadius.circular(4),
  260. ),
  261. ),
  262. Expanded(
  263. child: Container(
  264. height: 65,
  265. margin: EdgeInsets.only(right: 6),
  266. child: Column(
  267. children: [
  268. Text(
  269. widget.data.shopName,
  270. style: TextStyle(
  271. color: MyColors.c333333, fontSize: 13),
  272. maxLines: 1,
  273. overflow: TextOverflow.ellipsis,
  274. softWrap: true,
  275. ),
  276. Row(
  277. children: [
  278. Expanded(
  279. child: Text(
  280. store == null
  281. ? '店铺介绍:无'
  282. : '店铺介绍:${store.introduction}',
  283. style: TextStyle(
  284. color: MyColors.c666666,
  285. fontSize: 11),
  286. maxLines: 1,
  287. overflow: TextOverflow.ellipsis,
  288. softWrap: true,
  289. ),
  290. ),
  291. SvgPicture.asset(
  292. 'images/svg/箭头.svg',
  293. color: MyColors.c666666,
  294. height: 10,
  295. width: 10,
  296. )
  297. ],
  298. crossAxisAlignment: CrossAxisAlignment.center,
  299. ),
  300. Row(
  301. children: [
  302. SvgPicture.asset(
  303. 'images/svg/地址.svg',
  304. color: MyColors.c666666,
  305. height: 12,
  306. width: 12,
  307. ),
  308. Container(
  309. width: 5,
  310. ),
  311. Expanded(
  312. child: Text(
  313. store == null ? '暂无' : store.address,
  314. style: TextStyle(
  315. color: MyColors.c666666,
  316. fontSize: 11),
  317. maxLines: 1,
  318. overflow: TextOverflow.ellipsis,
  319. softWrap: true,
  320. ),
  321. ),
  322. ],
  323. ),
  324. ],
  325. crossAxisAlignment: CrossAxisAlignment.start,
  326. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  327. ),
  328. ),
  329. )
  330. ],
  331. ),
  332. ),
  333. Container(
  334. height: 0.5,
  335. color: MyColors.cE7E7E7,
  336. ),
  337. Container(
  338. margin: EdgeInsets.all(6),
  339. child: Row(
  340. children: [
  341. Row(
  342. children: [
  343. SvgPicture.asset(
  344. 'images/svg/电话.svg',
  345. height: 18,
  346. width: 18,
  347. ),
  348. Container(
  349. width: 5,
  350. ),
  351. Text(
  352. store == null ? '暂无' : store.mobile,
  353. style: TextStyle(
  354. color: MyColors.cFF4233, fontSize: 12),
  355. ),
  356. ],
  357. ),
  358. GestureDetector(
  359. onTap: () {
  360. launch('tel:${store.mobile}');
  361. },
  362. behavior: HitTestBehavior.translucent,
  363. child: Container(
  364. decoration: BoxDecoration(
  365. color: MyColors.cFF4233,
  366. borderRadius: BorderRadius.circular(10),
  367. ),
  368. height: 20,
  369. width: 50,
  370. child: MyViews().myText('点击拨打', Colors.white, 9),
  371. alignment: Alignment.center,
  372. ),
  373. )
  374. ],
  375. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  376. ),
  377. )
  378. ],
  379. ),
  380. ),
  381. ),
  382. Visibility(
  383. visible: widget.data.privateShop ||
  384. widget.data.ownerUid == MyCookie().getUID(),
  385. child: Container(
  386. height: 40,
  387. color: Colors.white,
  388. child: Row(
  389. children: [
  390. GestureDetector(
  391. onTap: () {
  392. setState(() {
  393. selectedIndex = 0;
  394. controller.requestRefresh();
  395. });
  396. },
  397. behavior: HitTestBehavior.translucent,
  398. child: Padding(
  399. padding: EdgeInsets.only(left: 10, right: 10),
  400. child: Column(
  401. children: [
  402. Text(
  403. '货帮商品',
  404. style: TextStyle(
  405. color: selectedIndex == 0
  406. ? MyColors.cFF4233
  407. : MyColors.c666666,
  408. fontSize: 15),
  409. ),
  410. Container(
  411. height: 10,
  412. child: Visibility(
  413. child: SvgPicture.asset('images/svg/tab.svg'),
  414. visible: selectedIndex == 0,
  415. ),
  416. )
  417. ],
  418. mainAxisAlignment: MainAxisAlignment.end,
  419. ),
  420. ),
  421. ),
  422. GestureDetector(
  423. onTap: () {
  424. setState(() {
  425. selectedIndex = 1;
  426. controller.requestRefresh();
  427. });
  428. },
  429. behavior: HitTestBehavior.translucent,
  430. child: Padding(
  431. padding: EdgeInsets.only(left: 10, right: 10),
  432. child: Column(
  433. children: [
  434. Text(
  435. widget.data.ownerUid == MyCookie().getUID()
  436. ? '未付订单'
  437. : '未收订单',
  438. style: TextStyle(
  439. color: selectedIndex == 1
  440. ? MyColors.cFF4233
  441. : MyColors.c666666,
  442. fontSize: 15),
  443. ),
  444. Container(
  445. height: 10,
  446. child: Visibility(
  447. child: SvgPicture.asset('images/svg/tab.svg'),
  448. visible: selectedIndex == 1,
  449. ),
  450. )
  451. ],
  452. mainAxisAlignment: MainAxisAlignment.end,
  453. ),
  454. ),
  455. ),
  456. GestureDetector(
  457. onTap: () {
  458. setState(() {
  459. selectedIndex = 2;
  460. controller.requestRefresh();
  461. });
  462. },
  463. behavior: HitTestBehavior.translucent,
  464. child: Padding(
  465. padding: EdgeInsets.only(left: 10, right: 10),
  466. child: Column(
  467. children: [
  468. Text(
  469. widget.data.ownerUid == MyCookie().getUID()
  470. ? '已付订单'
  471. : '未付订单',
  472. style: TextStyle(
  473. color: selectedIndex == 2
  474. ? MyColors.cFF4233
  475. : MyColors.c666666,
  476. fontSize: 15),
  477. ),
  478. Container(
  479. height: 10,
  480. child: Visibility(
  481. child: SvgPicture.asset('images/svg/tab.svg'),
  482. visible: selectedIndex == 2,
  483. ),
  484. )
  485. ],
  486. mainAxisAlignment: MainAxisAlignment.end,
  487. ),
  488. ),
  489. )
  490. ],
  491. mainAxisAlignment: MainAxisAlignment.spaceAround,
  492. ),
  493. ),
  494. ),
  495. body(),
  496. Container(
  497. color: Colors.white,
  498. child: SafeArea(
  499. top: false,
  500. child: Container(
  501. padding: EdgeInsets.symmetric(horizontal: 37),
  502. color: Colors.white,
  503. width: double.infinity,
  504. height: 60,
  505. child: Row(
  506. children: [
  507. Expanded(
  508. child: GestureDetector(
  509. onTap: () {
  510. queryShopMembers();
  511. },
  512. behavior: HitTestBehavior.translucent,
  513. child: Container(
  514. decoration: BoxDecoration(
  515. borderRadius: BorderRadius.only(
  516. topLeft: Radius.circular(20),
  517. bottomLeft: Radius.circular(20),
  518. ),
  519. border: Border.all(
  520. color: MyColors.cFF4233, width: 1)),
  521. height: 40,
  522. child: MyViews().myText('联系帮主', MyColors.cFF4233, 14),
  523. alignment: Alignment.center),
  524. ),
  525. ),
  526. Expanded(
  527. child: GestureDetector(
  528. onTap: () {
  529. MyTools().toPage(context,
  530. PayToTheHelperPage(widget.data), (then) {});
  531. },
  532. behavior: HitTestBehavior.translucent,
  533. child: Container(
  534. decoration: BoxDecoration(
  535. borderRadius: BorderRadius.only(
  536. topRight: Radius.circular(20),
  537. bottomRight: Radius.circular(20),
  538. ),
  539. color: MyColors.cFF4233),
  540. height: 40,
  541. child: MyViews().myText('到店付款', Colors.white, 14),
  542. alignment: Alignment.center),
  543. ),
  544. )
  545. ],
  546. ),
  547. ),
  548. ),
  549. )
  550. ],
  551. ),
  552. );
  553. }
  554. body() {
  555. if (selectedIndex == 0) {
  556. return Expanded(
  557. child: SmartRefresher(
  558. controller: controller,
  559. onRefresh: onRefresh,
  560. onLoading: onLoading,
  561. enablePullDown: true,
  562. enablePullUp: true,
  563. child: goods.length == 0
  564. ? SingleChildScrollView(child: noData())
  565. : GridView.builder(
  566. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  567. crossAxisCount: 2, //每行三列
  568. childAspectRatio: 164 / 261, //显示区域宽高相等
  569. mainAxisSpacing: 8,
  570. crossAxisSpacing: 8),
  571. itemCount: goods.length,
  572. padding:
  573. EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
  574. itemBuilder: (context, index) {
  575. return MyViews().getGoodsItem(goods[index], context);
  576. }),
  577. ),
  578. );
  579. } else if (selectedIndex == 1) {
  580. return Expanded(
  581. child: SmartRefresher(
  582. controller: controller,
  583. onRefresh: onRefresh,
  584. onLoading: onLoading,
  585. enablePullDown: true,
  586. enablePullUp: true,
  587. child: orders.length == 0
  588. ? SingleChildScrollView(child: noData())
  589. : ListView.builder(
  590. itemBuilder: (c, index) {
  591. return Slidable(
  592. child: MyViews().getNoPayGoodsItem(
  593. orders[index], context, widget.data.ownerUid),
  594. actionPane: SlidableDrawerActionPane(),
  595. enabled: widget.data.ownerUid == MyCookie().getUID(),
  596. actionExtentRatio: 0.25,
  597. secondaryActions: <Widget>[
  598. SlideAction(
  599. child: Container(
  600. child: Container(
  601. decoration: BoxDecoration(
  602. borderRadius: BorderRadius.circular(30),
  603. color: MyColors.cFF4233,
  604. ),
  605. height: 60,
  606. width: 60,
  607. child: SvgPicture.asset(
  608. 'images/svg/del.svg',
  609. height: 40,
  610. width: 40,
  611. ),
  612. alignment: Alignment.center,
  613. ),
  614. ),
  615. onTap: () {
  616. showSimpleDialog(
  617. '将删除订单(${orders[index].uid})', context, () {
  618. Navigator.pop(context);
  619. deleteOrder(orders[index]);
  620. });
  621. },
  622. )
  623. ],
  624. );
  625. },
  626. itemCount: orders.length,
  627. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  628. ),
  629. ),
  630. );
  631. } else if (selectedIndex == 2) {
  632. return Expanded(
  633. child: SmartRefresher(
  634. controller: controller,
  635. onRefresh: onRefresh,
  636. onLoading: onLoading,
  637. enablePullDown: true,
  638. enablePullUp: true,
  639. child: orders.length == 0
  640. ? SingleChildScrollView(child: noData())
  641. : ListView.builder(
  642. itemBuilder: (c, index) {
  643. return MyViews().getNoPayGoodsItem(
  644. orders[index], context, widget.data.ownerUid);
  645. },
  646. itemCount: orders.length,
  647. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  648. ),
  649. ),
  650. );
  651. } else {
  652. return SingleChildScrollView(child: noData());
  653. }
  654. }
  655. void onRefresh() {
  656. page = 1;
  657. if (selectedIndex == 0) {
  658. queryProducts();
  659. } else if (selectedIndex == 1) {
  660. unreceivedOrder();
  661. } else {
  662. unpaidOrder();
  663. }
  664. }
  665. void onLoading() {
  666. page++;
  667. if (selectedIndex == 0) {
  668. queryProducts();
  669. } else if (selectedIndex == 1) {
  670. unreceivedOrder();
  671. } else {
  672. unpaidOrder();
  673. }
  674. }
  675. //查询商品
  676. void queryProducts() {
  677. MyDio().query({
  678. "key": "commodity",
  679. "filters": {
  680. "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"]
  681. },
  682. "dims": commodityDims,
  683. "paging": [page, 20]
  684. }, (response, hasError) {
  685. if (!hasError) {
  686. GoodsBeanEntity entity =
  687. GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
  688. if (page == 1) {
  689. goods.clear();
  690. }
  691. goods.addAll(entity.data.data);
  692. }
  693. setState(() {
  694. endRe(controller);
  695. });
  696. }, (error) {
  697. setState(() {
  698. endRe(controller);
  699. });
  700. });
  701. }
  702. //查询未收订单
  703. void unreceivedOrder() {
  704. var conditions = [];
  705. if (widget.data.ownerUid == MyCookie().getUID()) {
  706. conditions.add('state == $orderStateUnpaid');
  707. conditions.add('shop_uid == ${widget.data.shopUid}');
  708. } else {
  709. conditions.add('state == $orderStateUnpaid');
  710. conditions.add('shop_uid == ${widget.data.shopUid}');
  711. conditions.add('seller_uid == ${MyCookie().getUID()}');
  712. }
  713. MyDio().query({
  714. "key": "order",
  715. "filters": {"conditions": conditions},
  716. "dims": orderDims,
  717. "paging": [page, 20],
  718. "order_by": ["create_time,DESC"]
  719. }, (response, hasError) {
  720. if (!hasError) {
  721. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  722. .fromJson(json.decode(response.data.toString()));
  723. if (page == 1) {
  724. orders.clear();
  725. }
  726. orders.addAll(entity.data.data);
  727. setState(() {});
  728. }
  729. endRe(controller);
  730. }, (error) {});
  731. }
  732. //查询未付订单
  733. void unpaidOrder() {
  734. var conditions = [];
  735. if (widget.data.ownerUid == MyCookie().getUID()) {
  736. conditions.add('state == $orderStatePaid');
  737. conditions.add('shop_uid == ${widget.data.shopUid}');
  738. } else {
  739. conditions.add('state == $orderStateUnpaid');
  740. conditions.add('shop_uid == ${widget.data.shopUid}');
  741. conditions.add('buyer_name LIKE ${MyCookie().getName()}');
  742. }
  743. MyDio().query({
  744. "key": "order",
  745. "filters": {"conditions": conditions},
  746. "dims": orderDims,
  747. "paging": [page, 20],
  748. "order_by": ["create_time,DESC"]
  749. }, (response, hasError) {
  750. if (!hasError) {
  751. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  752. .fromJson(json.decode(response.data.toString()));
  753. if (page == 1) {
  754. orders.clear();
  755. }
  756. orders.addAll(entity.data.data);
  757. setState(() {});
  758. }
  759. endRe(controller);
  760. }, (error) {});
  761. }
  762. payTheOrder() {
  763. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  764. data.sellerUid = widget.order.sellerUID;
  765. data.sellerName = widget.order.sellerName;
  766. data.sellerPic = widget.order.sellerPic;
  767. data.buyerUid = 0;
  768. data.buyerName = widget.order.buyerName;
  769. data.buyerPic = '';
  770. data.amount = widget.order.amount;
  771. data.uid = widget.order.uID;
  772. showPayDialog(data, context, () {
  773. Navigator.pop(context);
  774. getUserWalletBalance((re, hE) {
  775. if (!hE) {
  776. UserBalanceEntity balance =
  777. UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  778. if (balance.data >= widget.order.amount) {
  779. payOrder(payWayWallet, widget.order.uID, (re, hE) {
  780. if (!hE) {
  781. showToast('支付成功');
  782. EventBus().emit('payAnOrder');
  783. }
  784. }, (e) {}, context);
  785. } else {
  786. payOrder(payWayAliPay, widget.order.uID, (re, hE) {
  787. if (!hE) {
  788. PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
  789. .fromJson(json.decode(re.data.toString()));
  790. EventBus().on('alipayPaymentCallback', (arg) {
  791. EventBus().off('alipayPaymentCallback');
  792. EasyLoading.dismiss();
  793. showToast('支付成功');
  794. EventBus().emit('reNoPayOrder');
  795. });
  796. print(entity.data);
  797. EasyLoading.instance
  798. ..contentPadding =
  799. EdgeInsets.symmetric(horizontal: 20, vertical: 12)
  800. ..alignment = Alignment.center
  801. ..loadingStyle = EasyLoadingStyle.light
  802. ..contentMargin = EdgeInsets.all(20);
  803. EasyLoading.show();
  804. aliPay(entity.data).then((value) {
  805. print(json.encode(value));
  806. AlipayResultBeanEntity e = AlipayResultBeanEntity()
  807. .fromJson(json.decode(json.encode(value)));
  808. try {
  809. int r = int.parse(e.resultStatus);
  810. if (r == 9000) {
  811. showToast('支付成功');
  812. } else {
  813. showToast(aliPayResultStatus(r));
  814. resetOrder(widget.order.uID);
  815. }
  816. } catch (e) {
  817. EasyLoading.dismiss();
  818. }
  819. });
  820. // EventBus().emit('payAnOrder');
  821. }
  822. }, (e) {}, context);
  823. // showToast('积分余额不足');
  824. }
  825. }
  826. }, (e) {}, context);
  827. });
  828. // showDialog(
  829. // context: context,
  830. // builder: (BuildContext context) {
  831. // return Center(
  832. // child: Container(
  833. // decoration: BoxDecoration(
  834. // color: Colors.white,
  835. // borderRadius: BorderRadius.all(Radius.circular(8))),
  836. // child: Column(
  837. // children: [
  838. // Expanded(
  839. // child: Center(
  840. // child: Padding(
  841. // padding: const EdgeInsets.only(left: 15, right: 15),
  842. // child: Column(
  843. // children: [
  844. // Text(
  845. // '确认支付订单(${widget.order.uID})',
  846. // style: TextStyle(
  847. // color: MyColors.c333333,
  848. // fontSize: 16,
  849. // fontWeight: FontWeight.normal,
  850. // decoration: TextDecoration.none),
  851. // ),
  852. // Text(
  853. // '付款人:${widget.order.buyerName}',
  854. // style: TextStyle(
  855. // color: MyColors.c333333,
  856. // fontSize: 16,
  857. // fontWeight: FontWeight.normal,
  858. // decoration: TextDecoration.none),
  859. // ),
  860. // Text(
  861. // '收款人:${widget.order.sellerName}',
  862. // style: TextStyle(
  863. // color: MyColors.c333333,
  864. // fontSize: 16,
  865. // fontWeight: FontWeight.normal,
  866. // decoration: TextDecoration.none),
  867. // ),
  868. // ],
  869. // mainAxisAlignment: MainAxisAlignment.center,
  870. // ),
  871. // ),
  872. // ),
  873. // ),
  874. // Container(
  875. // height: 0.5,
  876. // color: MyColors.cE7E7E7,
  877. // ),
  878. // Row(
  879. // children: [
  880. // Expanded(
  881. // child: GestureDetector(
  882. // onTap: () {
  883. // Navigator.pop(context);
  884. // },
  885. // behavior: HitTestBehavior.translucent,
  886. // child: Container(
  887. // alignment: Alignment.center,
  888. // height: 55,
  889. // child: Text(
  890. // '取消',
  891. // style: TextStyle(
  892. // color: MyColors.c999999,
  893. // fontSize: 16,
  894. // fontWeight: FontWeight.normal,
  895. // decoration: TextDecoration.none),
  896. // ),
  897. // ),
  898. // )),
  899. // Container(
  900. // width: 0.5,
  901. // height: 55,
  902. // color: MyColors.cE7E7E7,
  903. // ),
  904. // Expanded(
  905. // child: GestureDetector(
  906. // onTap: () async {
  907. // Navigator.pop(context);
  908. // getUserWalletBalance((re, hE) {
  909. // if (!hE) {
  910. // UserBalanceEntity balance = UserBalanceEntity()
  911. // .fromJson(json.decode(re.data.toString()));
  912. // if (balance.data >= widget.order.amount) {
  913. // payOrder(payWayWallet, widget.order.uID,
  914. // (re, hE) {
  915. // if (!hE) {
  916. // showToast('支付成功');
  917. // EventBus().emit('payAnOrder');
  918. // }
  919. // }, (e) {}, context);
  920. // } else {
  921. // payOrder(payWayAliPay, widget.order.uID,
  922. // (re, hE) {
  923. // if (!hE) {
  924. // PayByAlipayBeanEntity entity =
  925. // PayByAlipayBeanEntity().fromJson(
  926. // json.decode(re.data.toString()));
  927. // EventBus().on('alipayPaymentCallback',
  928. // (arg) {
  929. // EventBus().off('alipayPaymentCallback');
  930. // EasyLoading.dismiss();
  931. // showToast('支付成功');
  932. // EventBus().emit('reNoPayOrder');
  933. // });
  934. // print(entity.data);
  935. // EasyLoading.instance
  936. // ..contentPadding = EdgeInsets.symmetric(
  937. // horizontal: 20, vertical: 12)
  938. // ..alignment = Alignment.center
  939. // ..contentMargin = EdgeInsets.all(20);
  940. // EasyLoading.show();
  941. // aliPay(entity.data).then((value) {
  942. // print(json.encode(value));
  943. // AlipayResultBeanEntity e =
  944. // AlipayResultBeanEntity().fromJson(
  945. // json.decode(json.encode(value)));
  946. // try {
  947. // int r = int.parse(e.resultStatus);
  948. // if (r == 9000) {
  949. // showToast('支付成功');
  950. // } else {
  951. // showToast(aliPayResultStatus(r));
  952. // resetOrder(widget.order.uID);
  953. // }
  954. // } catch (e) {
  955. // EasyLoading.dismiss();
  956. // }
  957. // });
  958. // // EventBus().emit('payAnOrder');
  959. // }
  960. // }, (e) {}, context);
  961. // // showToast('积分余额不足');
  962. // }
  963. // }
  964. // }, (e) {}, context);
  965. // },
  966. // behavior: HitTestBehavior.translucent,
  967. // child: Container(
  968. // alignment: Alignment.center,
  969. // height: 55,
  970. // child: Text(
  971. // '确定',
  972. // style: TextStyle(
  973. // color: MyColors.cFF4233,
  974. // fontSize: 16,
  975. // fontWeight: FontWeight.normal,
  976. // decoration: TextDecoration.none),
  977. // ),
  978. // ),
  979. // ),
  980. // ),
  981. // ],
  982. // )
  983. // ],
  984. // ),
  985. // height: 200,
  986. // margin: EdgeInsets.only(left: 48, right: 48),
  987. // ),
  988. // );
  989. // },
  990. // );
  991. }
  992. List<MyShopBeanDataData> member = [];
  993. List<MyShopBeanDataData> helper = [];
  994. queryShopMembers() {
  995. MyDio().query({
  996. "key": "shop_user",
  997. "filters": {
  998. "conditions": ["shop_uid==${widget.data.shopUid}", "review_state==1"]
  999. },
  1000. "dims": shopUserDims,
  1001. "paging": [1, 2000]
  1002. }, (response, hasError) {
  1003. if (!hasError) {
  1004. MyShopBeanEntity entity =
  1005. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1006. member = entity.data.data;
  1007. helper.clear();
  1008. member.forEach((element) {
  1009. if (element.role == shopUserStaff) {
  1010. helper.add(element);
  1011. }
  1012. });
  1013. MyShopBeanDataData chatWith;
  1014. if (helper.length == 0) {
  1015. chatWith = member[
  1016. member.indexWhere((element) => element.role == shopUserOwner)];
  1017. } else {
  1018. chatWith = helper[Random().nextInt(helper.length)];
  1019. }
  1020. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1021. }
  1022. }, (error) {});
  1023. }
  1024. void deleteOrder(SmartOrderBeanDataData order) {
  1025. MyDio().del({
  1026. 'key': 'order',
  1027. 'ids': [order.id]
  1028. }, (response, hasError) {
  1029. if (!hasError) {
  1030. orders.remove(order);
  1031. setState(() {});
  1032. }
  1033. }, (error) {});
  1034. }
  1035. StoreBeanDataData store;
  1036. queryStoreInformation() {
  1037. MyDio().query({
  1038. "key": "shop",
  1039. "filters": {
  1040. "conditions": ["uid == ${widget.data.shopUid}"]
  1041. },
  1042. "dims": shopDims,
  1043. "paging": [1, 5]
  1044. }, (response, hasError) {
  1045. if (!hasError) {
  1046. StoreBeanEntity entity =
  1047. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1048. store = entity.data.data[0];
  1049. setState(() {});
  1050. }
  1051. endRe(controller);
  1052. }, (error) {});
  1053. }
  1054. }