gang_in_page.dart 37 KB

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