gang_in_page.dart 44 KB

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