gang_in_page.dart 39 KB

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