gang_in_page.dart 37 KB

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