gang_in_page.dart 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  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. SafeArea(
  497. top: false,
  498. child: Container(
  499. padding: EdgeInsets.symmetric(horizontal: 37),
  500. color: Colors.white,
  501. width: double.infinity,
  502. height: 60,
  503. child: Row(
  504. children: [
  505. Expanded(
  506. child: GestureDetector(
  507. onTap: () {
  508. queryShopMembers();
  509. },
  510. behavior: HitTestBehavior.translucent,
  511. child: Container(
  512. decoration: BoxDecoration(
  513. borderRadius: BorderRadius.only(
  514. topLeft: Radius.circular(20),
  515. bottomLeft: Radius.circular(20),
  516. ),
  517. border: Border.all(
  518. color: MyColors.cFF4233, width: 1)),
  519. height: 40,
  520. child: MyViews().myText('联系帮主', MyColors.cFF4233, 14),
  521. alignment: Alignment.center),
  522. ),
  523. ),
  524. Expanded(
  525. child: GestureDetector(
  526. onTap: () {
  527. MyTools().toPage(context,
  528. PayToTheHelperPage(widget.data), (then) {});
  529. },
  530. behavior: HitTestBehavior.translucent,
  531. child: Container(
  532. decoration: BoxDecoration(
  533. borderRadius: BorderRadius.only(
  534. topRight: Radius.circular(20),
  535. bottomRight: Radius.circular(20),
  536. ),
  537. color: MyColors.cFF4233),
  538. height: 40,
  539. child: MyViews().myText('到店付款', Colors.white, 14),
  540. alignment: Alignment.center),
  541. ),
  542. )
  543. ],
  544. ),
  545. ),
  546. )
  547. ],
  548. ),
  549. );
  550. }
  551. body() {
  552. if (selectedIndex == 0) {
  553. return Expanded(
  554. child: SmartRefresher(
  555. controller: controller,
  556. onRefresh: onRefresh,
  557. onLoading: onLoading,
  558. enablePullDown: true,
  559. enablePullUp: true,
  560. child: goods.length == 0
  561. ? noData()
  562. : GridView.builder(
  563. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  564. crossAxisCount: 2, //每行三列
  565. childAspectRatio: 164 / 261, //显示区域宽高相等
  566. mainAxisSpacing: 8,
  567. crossAxisSpacing: 8),
  568. itemCount: goods.length,
  569. padding:
  570. EdgeInsets.only(left: 14, right: 14, top: 14, bottom: 65),
  571. itemBuilder: (context, index) {
  572. return MyViews().getGoodsItem(goods[index], context);
  573. }),
  574. ),
  575. );
  576. } else if (selectedIndex == 1) {
  577. return Expanded(
  578. child: SmartRefresher(
  579. controller: controller,
  580. onRefresh: onRefresh,
  581. onLoading: onLoading,
  582. enablePullDown: true,
  583. enablePullUp: true,
  584. child: orders.length == 0
  585. ? noData()
  586. : ListView.builder(
  587. itemBuilder: (c, index) {
  588. return Slidable(
  589. child: MyViews().getNoPayGoodsItem(
  590. orders[index], context, widget.data.ownerUid),
  591. actionPane: SlidableDrawerActionPane(),
  592. enabled: widget.data.ownerUid == MyCookie().getUID(),
  593. actionExtentRatio: 0.25,
  594. secondaryActions: <Widget>[
  595. SlideAction(
  596. child: Container(
  597. child: Container(
  598. decoration: BoxDecoration(
  599. borderRadius: BorderRadius.circular(30),
  600. color: MyColors.cFF4233,
  601. ),
  602. height: 60,
  603. width: 60,
  604. child: SvgPicture.asset(
  605. 'images/svg/del.svg',
  606. height: 40,
  607. width: 40,
  608. ),
  609. alignment: Alignment.center,
  610. ),
  611. ),
  612. onTap: () {
  613. showSimpleDialog(
  614. '将删除订单(${orders[index].uid})', context, () {
  615. Navigator.pop(context);
  616. deleteOrder(orders[index]);
  617. });
  618. },
  619. )
  620. ],
  621. );
  622. },
  623. itemCount: orders.length,
  624. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  625. ),
  626. ),
  627. );
  628. } else if (selectedIndex == 2) {
  629. return Expanded(
  630. child: SmartRefresher(
  631. controller: controller,
  632. onRefresh: onRefresh,
  633. onLoading: onLoading,
  634. enablePullDown: true,
  635. enablePullUp: true,
  636. child: orders.length == 0
  637. ? noData()
  638. : ListView.builder(
  639. itemBuilder: (c, index) {
  640. return MyViews().getNoPayGoodsItem(
  641. orders[index], context, widget.data.ownerUid);
  642. },
  643. itemCount: orders.length,
  644. padding: EdgeInsets.only(left: 10, right: 10, top: 10),
  645. ),
  646. ),
  647. );
  648. } else {
  649. return noData();
  650. }
  651. }
  652. void onRefresh() {
  653. page = 1;
  654. if (selectedIndex == 0) {
  655. queryProducts();
  656. } else if (selectedIndex == 1) {
  657. unreceivedOrder();
  658. } else {
  659. unpaidOrder();
  660. }
  661. }
  662. void onLoading() {
  663. page++;
  664. if (selectedIndex == 0) {
  665. queryProducts();
  666. } else if (selectedIndex == 1) {
  667. unreceivedOrder();
  668. } else {
  669. unpaidOrder();
  670. }
  671. }
  672. //查询商品
  673. void queryProducts() {
  674. MyDio().query({
  675. "key": "commodity",
  676. "filters": {
  677. "conditions": ["shop_uid == ${widget.data.shopUid}", "on_sale == true"]
  678. },
  679. "dims": commodityDims,
  680. "paging": [page, 20]
  681. }, (response, hasError) {
  682. if (!hasError) {
  683. GoodsBeanEntity entity =
  684. GoodsBeanEntity().fromJson(json.decode(response.data.toString()));
  685. if (page == 1) {
  686. goods.clear();
  687. }
  688. goods.addAll(entity.data.data);
  689. }
  690. setState(() {
  691. endRe(controller);
  692. });
  693. }, (error) {
  694. setState(() {
  695. endRe(controller);
  696. });
  697. });
  698. }
  699. //查询未收订单
  700. void unreceivedOrder() {
  701. var conditions = [];
  702. if (widget.data.ownerUid == MyCookie().getUID()) {
  703. conditions.add('state == $orderStateUnpaid');
  704. conditions.add('shop_uid == ${widget.data.shopUid}');
  705. } else {
  706. conditions.add('state == $orderStateUnpaid');
  707. conditions.add('shop_uid == ${widget.data.shopUid}');
  708. conditions.add('seller_uid == ${MyCookie().getUID()}');
  709. }
  710. MyDio().query({
  711. "key": "order",
  712. "filters": {"conditions": conditions},
  713. "dims": orderDims,
  714. "paging": [page, 20],
  715. "order_by": ["create_time,DESC"]
  716. }, (response, hasError) {
  717. if (!hasError) {
  718. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  719. .fromJson(json.decode(response.data.toString()));
  720. if (page == 1) {
  721. orders.clear();
  722. }
  723. orders.addAll(entity.data.data);
  724. setState(() {});
  725. }
  726. endRe(controller);
  727. }, (error) {});
  728. }
  729. //查询未付订单
  730. void unpaidOrder() {
  731. var conditions = [];
  732. if (widget.data.ownerUid == MyCookie().getUID()) {
  733. conditions.add('state == $orderStatePaid');
  734. conditions.add('shop_uid == ${widget.data.shopUid}');
  735. } else {
  736. conditions.add('state == $orderStateUnpaid');
  737. conditions.add('shop_uid == ${widget.data.shopUid}');
  738. conditions.add('buyer_name LIKE ${MyCookie().getName()}');
  739. }
  740. MyDio().query({
  741. "key": "order",
  742. "filters": {"conditions": conditions},
  743. "dims": orderDims,
  744. "paging": [page, 20],
  745. "order_by": ["create_time,DESC"]
  746. }, (response, hasError) {
  747. if (!hasError) {
  748. SmartOrderBeanEntity entity = SmartOrderBeanEntity()
  749. .fromJson(json.decode(response.data.toString()));
  750. if (page == 1) {
  751. orders.clear();
  752. }
  753. orders.addAll(entity.data.data);
  754. setState(() {});
  755. }
  756. endRe(controller);
  757. }, (error) {});
  758. }
  759. payTheOrder() {
  760. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  761. data.sellerUid = widget.order.sellerUID;
  762. data.sellerName = widget.order.sellerName;
  763. data.sellerPic = widget.order.sellerPic;
  764. data.buyerUid = 0;
  765. data.buyerName = widget.order.buyerName;
  766. data.buyerPic = '';
  767. data.amount = widget.order.amount;
  768. data.uid = widget.order.uID;
  769. showPayDialog(data, context, () {
  770. Navigator.pop(context);
  771. getUserWalletBalance((re, hE) {
  772. if (!hE) {
  773. UserBalanceEntity balance =
  774. UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  775. if (balance.data >= widget.order.amount) {
  776. payOrder(payWayWallet, widget.order.uID, (re, hE) {
  777. if (!hE) {
  778. showToast('支付成功');
  779. EventBus().emit('payAnOrder');
  780. }
  781. }, (e) {}, context);
  782. } else {
  783. payOrder(payWayAliPay, widget.order.uID, (re, hE) {
  784. if (!hE) {
  785. PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
  786. .fromJson(json.decode(re.data.toString()));
  787. EventBus().on('alipayPaymentCallback', (arg) {
  788. EventBus().off('alipayPaymentCallback');
  789. EasyLoading.dismiss();
  790. showToast('支付成功');
  791. EventBus().emit('reNoPayOrder');
  792. });
  793. print(entity.data);
  794. EasyLoading.instance
  795. ..contentPadding =
  796. EdgeInsets.symmetric(horizontal: 20, vertical: 12)
  797. ..alignment = Alignment.center
  798. ..loadingStyle = EasyLoadingStyle.light
  799. ..contentMargin = EdgeInsets.all(20);
  800. EasyLoading.show();
  801. aliPay(entity.data).then((value) {
  802. print(json.encode(value));
  803. AlipayResultBeanEntity e = AlipayResultBeanEntity()
  804. .fromJson(json.decode(json.encode(value)));
  805. try {
  806. int r = int.parse(e.resultStatus);
  807. if (r == 9000) {
  808. showToast('支付成功');
  809. } else {
  810. showToast(aliPayResultStatus(r));
  811. resetOrder(widget.order.uID);
  812. }
  813. } catch (e) {
  814. EasyLoading.dismiss();
  815. }
  816. });
  817. // EventBus().emit('payAnOrder');
  818. }
  819. }, (e) {}, context);
  820. // showToast('积分余额不足');
  821. }
  822. }
  823. }, (e) {}, context);
  824. });
  825. // showDialog(
  826. // context: context,
  827. // builder: (BuildContext context) {
  828. // return Center(
  829. // child: Container(
  830. // decoration: BoxDecoration(
  831. // color: Colors.white,
  832. // borderRadius: BorderRadius.all(Radius.circular(8))),
  833. // child: Column(
  834. // children: [
  835. // Expanded(
  836. // child: Center(
  837. // child: Padding(
  838. // padding: const EdgeInsets.only(left: 15, right: 15),
  839. // child: Column(
  840. // children: [
  841. // Text(
  842. // '确认支付订单(${widget.order.uID})',
  843. // style: TextStyle(
  844. // color: MyColors.c333333,
  845. // fontSize: 16,
  846. // fontWeight: FontWeight.normal,
  847. // decoration: TextDecoration.none),
  848. // ),
  849. // Text(
  850. // '付款人:${widget.order.buyerName}',
  851. // style: TextStyle(
  852. // color: MyColors.c333333,
  853. // fontSize: 16,
  854. // fontWeight: FontWeight.normal,
  855. // decoration: TextDecoration.none),
  856. // ),
  857. // Text(
  858. // '收款人:${widget.order.sellerName}',
  859. // style: TextStyle(
  860. // color: MyColors.c333333,
  861. // fontSize: 16,
  862. // fontWeight: FontWeight.normal,
  863. // decoration: TextDecoration.none),
  864. // ),
  865. // ],
  866. // mainAxisAlignment: MainAxisAlignment.center,
  867. // ),
  868. // ),
  869. // ),
  870. // ),
  871. // Container(
  872. // height: 0.5,
  873. // color: MyColors.cE7E7E7,
  874. // ),
  875. // Row(
  876. // children: [
  877. // Expanded(
  878. // child: GestureDetector(
  879. // onTap: () {
  880. // Navigator.pop(context);
  881. // },
  882. // behavior: HitTestBehavior.translucent,
  883. // child: Container(
  884. // alignment: Alignment.center,
  885. // height: 55,
  886. // child: Text(
  887. // '取消',
  888. // style: TextStyle(
  889. // color: MyColors.c999999,
  890. // fontSize: 16,
  891. // fontWeight: FontWeight.normal,
  892. // decoration: TextDecoration.none),
  893. // ),
  894. // ),
  895. // )),
  896. // Container(
  897. // width: 0.5,
  898. // height: 55,
  899. // color: MyColors.cE7E7E7,
  900. // ),
  901. // Expanded(
  902. // child: GestureDetector(
  903. // onTap: () async {
  904. // Navigator.pop(context);
  905. // getUserWalletBalance((re, hE) {
  906. // if (!hE) {
  907. // UserBalanceEntity balance = UserBalanceEntity()
  908. // .fromJson(json.decode(re.data.toString()));
  909. // if (balance.data >= widget.order.amount) {
  910. // payOrder(payWayWallet, widget.order.uID,
  911. // (re, hE) {
  912. // if (!hE) {
  913. // showToast('支付成功');
  914. // EventBus().emit('payAnOrder');
  915. // }
  916. // }, (e) {}, context);
  917. // } else {
  918. // payOrder(payWayAliPay, widget.order.uID,
  919. // (re, hE) {
  920. // if (!hE) {
  921. // PayByAlipayBeanEntity entity =
  922. // PayByAlipayBeanEntity().fromJson(
  923. // json.decode(re.data.toString()));
  924. // EventBus().on('alipayPaymentCallback',
  925. // (arg) {
  926. // EventBus().off('alipayPaymentCallback');
  927. // EasyLoading.dismiss();
  928. // showToast('支付成功');
  929. // EventBus().emit('reNoPayOrder');
  930. // });
  931. // print(entity.data);
  932. // EasyLoading.instance
  933. // ..contentPadding = EdgeInsets.symmetric(
  934. // horizontal: 20, vertical: 12)
  935. // ..alignment = Alignment.center
  936. // ..contentMargin = EdgeInsets.all(20);
  937. // EasyLoading.show();
  938. // aliPay(entity.data).then((value) {
  939. // print(json.encode(value));
  940. // AlipayResultBeanEntity e =
  941. // AlipayResultBeanEntity().fromJson(
  942. // json.decode(json.encode(value)));
  943. // try {
  944. // int r = int.parse(e.resultStatus);
  945. // if (r == 9000) {
  946. // showToast('支付成功');
  947. // } else {
  948. // showToast(aliPayResultStatus(r));
  949. // resetOrder(widget.order.uID);
  950. // }
  951. // } catch (e) {
  952. // EasyLoading.dismiss();
  953. // }
  954. // });
  955. // // EventBus().emit('payAnOrder');
  956. // }
  957. // }, (e) {}, context);
  958. // // showToast('积分余额不足');
  959. // }
  960. // }
  961. // }, (e) {}, context);
  962. // },
  963. // behavior: HitTestBehavior.translucent,
  964. // child: Container(
  965. // alignment: Alignment.center,
  966. // height: 55,
  967. // child: Text(
  968. // '确定',
  969. // style: TextStyle(
  970. // color: MyColors.cFF4233,
  971. // fontSize: 16,
  972. // fontWeight: FontWeight.normal,
  973. // decoration: TextDecoration.none),
  974. // ),
  975. // ),
  976. // ),
  977. // ),
  978. // ],
  979. // )
  980. // ],
  981. // ),
  982. // height: 200,
  983. // margin: EdgeInsets.only(left: 48, right: 48),
  984. // ),
  985. // );
  986. // },
  987. // );
  988. }
  989. List<MyShopBeanDataData> member = [];
  990. List<MyShopBeanDataData> helper = [];
  991. queryShopMembers() {
  992. MyDio().query({
  993. "key": "shop_user",
  994. "filters": {
  995. "conditions": ["shop_uid==${widget.data.shopUid}", "review_state==1"]
  996. },
  997. "dims": shopUserDims,
  998. "paging": [1, 2000]
  999. }, (response, hasError) {
  1000. if (!hasError) {
  1001. MyShopBeanEntity entity =
  1002. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1003. member = entity.data.data;
  1004. helper.clear();
  1005. member.forEach((element) {
  1006. if (element.role == shopUserStaff) {
  1007. helper.add(element);
  1008. }
  1009. });
  1010. MyShopBeanDataData chatWith;
  1011. if (helper.length == 0) {
  1012. chatWith = member[
  1013. member.indexWhere((element) => element.role == shopUserOwner)];
  1014. } else {
  1015. chatWith = helper[Random().nextInt(helper.length)];
  1016. }
  1017. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1018. }
  1019. }, (error) {});
  1020. }
  1021. void deleteOrder(SmartOrderBeanDataData order) {
  1022. MyDio().del({
  1023. 'key': 'order',
  1024. 'ids': [order.id]
  1025. }, (response, hasError) {
  1026. if (!hasError) {
  1027. orders.remove(order);
  1028. setState(() {});
  1029. }
  1030. }, (error) {});
  1031. }
  1032. StoreBeanDataData store;
  1033. queryStoreInformation() {
  1034. MyDio().query({
  1035. "key": "shop",
  1036. "filters": {
  1037. "conditions": ["uid == ${widget.data.shopUid}"]
  1038. },
  1039. "dims": shopDims,
  1040. "paging": [1, 5]
  1041. }, (response, hasError) {
  1042. if (!hasError) {
  1043. StoreBeanEntity entity =
  1044. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1045. store = entity.data.data[0];
  1046. setState(() {});
  1047. }
  1048. endRe(controller);
  1049. }, (error) {});
  1050. }
  1051. }