gang_in_page.dart 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  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. ..contentMargin = EdgeInsets.all(20);
  799. EasyLoading.show();
  800. aliPay(entity.data).then((value) {
  801. print(json.encode(value));
  802. AlipayResultBeanEntity e = AlipayResultBeanEntity()
  803. .fromJson(json.decode(json.encode(value)));
  804. try {
  805. int r = int.parse(e.resultStatus);
  806. if (r == 9000) {
  807. showToast('支付成功');
  808. } else {
  809. showToast(aliPayResultStatus(r));
  810. resetOrder(widget.order.uID);
  811. }
  812. } catch (e) {
  813. EasyLoading.dismiss();
  814. }
  815. });
  816. // EventBus().emit('payAnOrder');
  817. }
  818. }, (e) {}, context);
  819. // showToast('积分余额不足');
  820. }
  821. }
  822. }, (e) {}, context);
  823. });
  824. // showDialog(
  825. // context: context,
  826. // builder: (BuildContext context) {
  827. // return Center(
  828. // child: Container(
  829. // decoration: BoxDecoration(
  830. // color: Colors.white,
  831. // borderRadius: BorderRadius.all(Radius.circular(8))),
  832. // child: Column(
  833. // children: [
  834. // Expanded(
  835. // child: Center(
  836. // child: Padding(
  837. // padding: const EdgeInsets.only(left: 15, right: 15),
  838. // child: Column(
  839. // children: [
  840. // Text(
  841. // '确认支付订单(${widget.order.uID})',
  842. // style: TextStyle(
  843. // color: MyColors.c333333,
  844. // fontSize: 16,
  845. // fontWeight: FontWeight.normal,
  846. // decoration: TextDecoration.none),
  847. // ),
  848. // Text(
  849. // '付款人:${widget.order.buyerName}',
  850. // style: TextStyle(
  851. // color: MyColors.c333333,
  852. // fontSize: 16,
  853. // fontWeight: FontWeight.normal,
  854. // decoration: TextDecoration.none),
  855. // ),
  856. // Text(
  857. // '收款人:${widget.order.sellerName}',
  858. // style: TextStyle(
  859. // color: MyColors.c333333,
  860. // fontSize: 16,
  861. // fontWeight: FontWeight.normal,
  862. // decoration: TextDecoration.none),
  863. // ),
  864. // ],
  865. // mainAxisAlignment: MainAxisAlignment.center,
  866. // ),
  867. // ),
  868. // ),
  869. // ),
  870. // Container(
  871. // height: 0.5,
  872. // color: MyColors.cE7E7E7,
  873. // ),
  874. // Row(
  875. // children: [
  876. // Expanded(
  877. // child: GestureDetector(
  878. // onTap: () {
  879. // Navigator.pop(context);
  880. // },
  881. // behavior: HitTestBehavior.translucent,
  882. // child: Container(
  883. // alignment: Alignment.center,
  884. // height: 55,
  885. // child: Text(
  886. // '取消',
  887. // style: TextStyle(
  888. // color: MyColors.c999999,
  889. // fontSize: 16,
  890. // fontWeight: FontWeight.normal,
  891. // decoration: TextDecoration.none),
  892. // ),
  893. // ),
  894. // )),
  895. // Container(
  896. // width: 0.5,
  897. // height: 55,
  898. // color: MyColors.cE7E7E7,
  899. // ),
  900. // Expanded(
  901. // child: GestureDetector(
  902. // onTap: () async {
  903. // Navigator.pop(context);
  904. // getUserWalletBalance((re, hE) {
  905. // if (!hE) {
  906. // UserBalanceEntity balance = UserBalanceEntity()
  907. // .fromJson(json.decode(re.data.toString()));
  908. // if (balance.data >= widget.order.amount) {
  909. // payOrder(payWayWallet, widget.order.uID,
  910. // (re, hE) {
  911. // if (!hE) {
  912. // showToast('支付成功');
  913. // EventBus().emit('payAnOrder');
  914. // }
  915. // }, (e) {}, context);
  916. // } else {
  917. // payOrder(payWayAliPay, widget.order.uID,
  918. // (re, hE) {
  919. // if (!hE) {
  920. // PayByAlipayBeanEntity entity =
  921. // PayByAlipayBeanEntity().fromJson(
  922. // json.decode(re.data.toString()));
  923. // EventBus().on('alipayPaymentCallback',
  924. // (arg) {
  925. // EventBus().off('alipayPaymentCallback');
  926. // EasyLoading.dismiss();
  927. // showToast('支付成功');
  928. // EventBus().emit('reNoPayOrder');
  929. // });
  930. // print(entity.data);
  931. // EasyLoading.instance
  932. // ..contentPadding = EdgeInsets.symmetric(
  933. // horizontal: 20, vertical: 12)
  934. // ..alignment = Alignment.center
  935. // ..contentMargin = EdgeInsets.all(20);
  936. // EasyLoading.show();
  937. // aliPay(entity.data).then((value) {
  938. // print(json.encode(value));
  939. // AlipayResultBeanEntity e =
  940. // AlipayResultBeanEntity().fromJson(
  941. // json.decode(json.encode(value)));
  942. // try {
  943. // int r = int.parse(e.resultStatus);
  944. // if (r == 9000) {
  945. // showToast('支付成功');
  946. // } else {
  947. // showToast(aliPayResultStatus(r));
  948. // resetOrder(widget.order.uID);
  949. // }
  950. // } catch (e) {
  951. // EasyLoading.dismiss();
  952. // }
  953. // });
  954. // // EventBus().emit('payAnOrder');
  955. // }
  956. // }, (e) {}, context);
  957. // // showToast('积分余额不足');
  958. // }
  959. // }
  960. // }, (e) {}, context);
  961. // },
  962. // behavior: HitTestBehavior.translucent,
  963. // child: Container(
  964. // alignment: Alignment.center,
  965. // height: 55,
  966. // child: Text(
  967. // '确定',
  968. // style: TextStyle(
  969. // color: MyColors.cFF4233,
  970. // fontSize: 16,
  971. // fontWeight: FontWeight.normal,
  972. // decoration: TextDecoration.none),
  973. // ),
  974. // ),
  975. // ),
  976. // ),
  977. // ],
  978. // )
  979. // ],
  980. // ),
  981. // height: 200,
  982. // margin: EdgeInsets.only(left: 48, right: 48),
  983. // ),
  984. // );
  985. // },
  986. // );
  987. }
  988. List<MyShopBeanDataData> member = [];
  989. List<MyShopBeanDataData> helper = [];
  990. queryShopMembers() {
  991. MyDio().query({
  992. "key": "shop_user",
  993. "filters": {
  994. "conditions": ["shop_uid==${widget.data.shopUid}", "review_state==1"]
  995. },
  996. "dims": shopUserDims,
  997. "paging": [1, 2000]
  998. }, (response, hasError) {
  999. if (!hasError) {
  1000. MyShopBeanEntity entity =
  1001. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  1002. member = entity.data.data;
  1003. helper.clear();
  1004. member.forEach((element) {
  1005. if (element.role == shopUserStaff) {
  1006. helper.add(element);
  1007. }
  1008. });
  1009. MyShopBeanDataData chatWith;
  1010. if (helper.length == 0) {
  1011. chatWith = member[
  1012. member.indexWhere((element) => element.role == shopUserOwner)];
  1013. } else {
  1014. chatWith = helper[Random().nextInt(helper.length)];
  1015. }
  1016. MyTools().toPage(context, ChatPage(chatWith, null), (then) {});
  1017. }
  1018. }, (error) {});
  1019. }
  1020. void deleteOrder(SmartOrderBeanDataData order) {
  1021. MyDio().del({
  1022. 'key': 'order',
  1023. 'ids': [order.id]
  1024. }, (response, hasError) {
  1025. if (!hasError) {
  1026. orders.remove(order);
  1027. setState(() {});
  1028. }
  1029. }, (error) {});
  1030. }
  1031. StoreBeanDataData store;
  1032. queryStoreInformation() {
  1033. MyDio().query({
  1034. "key": "shop",
  1035. "filters": {
  1036. "conditions": ["uid == ${widget.data.shopUid}"]
  1037. },
  1038. "dims": shopDims,
  1039. "paging": [1, 5]
  1040. }, (response, hasError) {
  1041. if (!hasError) {
  1042. StoreBeanEntity entity =
  1043. StoreBeanEntity().fromJson(json.decode(response.data.toString()));
  1044. store = entity.data.data[0];
  1045. setState(() {});
  1046. }
  1047. endRe(controller);
  1048. }, (error) {});
  1049. }
  1050. }