gang_in_page.dart 39 KB

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