gang_in_page.dart 45 KB

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