gang_in_page.dart 38 KB

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