main.dart 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'package:bbyyy/beans/template_bean_entity.dart';
  4. import 'package:bbyyy/https/url.dart';
  5. import 'package:bbyyy/my_tools/event_bus.dart';
  6. import 'package:bbyyy/my_tools/my_cookie.dart';
  7. import 'package:bbyyy/my_tools/my_tools.dart';
  8. import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_in_page.dart';
  9. import 'package:bbyyy/paegs/login_page/login_page.dart';
  10. import 'package:bbyyy/paegs/root_page/root_page_view.dart';
  11. import 'package:bbyyy/paegs/welcome_page/welcome_page.dart';
  12. import 'package:flustars/flustars.dart';
  13. import 'package:flutter/cupertino.dart';
  14. import 'package:flutter/material.dart';
  15. import 'package:flutter/services.dart';
  16. import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  17. import 'package:flutter_localizations/flutter_localizations.dart';
  18. import 'package:flutter_svg/flutter_svg.dart';
  19. import 'package:pull_to_refresh/pull_to_refresh.dart';
  20. import 'package:rxdart/rxdart.dart';
  21. import 'beans/my_shop_bean_entity.dart';
  22. import 'beans/new_order_bean_entity.dart';
  23. import 'https/MyDio.dart';
  24. import 'my_tools/const.dart';
  25. import 'my_tools/dims.dart';
  26. import 'my_tools/easy_loading/easy_loading.dart';
  27. import 'my_tools/easy_loading/loading.dart';
  28. import 'my_tools/global.dart';
  29. import 'my_tools/my_colors.dart';
  30. import 'my_tools/my_views.dart';
  31. import 'my_tools/order.dart';
  32. final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
  33. FlutterLocalNotificationsPlugin();
  34. final BehaviorSubject<ReceivedNotification> didReceiveLocalNotificationSubject =
  35. BehaviorSubject<ReceivedNotification>();
  36. final BehaviorSubject<String> selectNotificationSubject =
  37. BehaviorSubject<String>();
  38. class ReceivedNotification {
  39. ReceivedNotification({
  40. @required this.id,
  41. @required this.title,
  42. @required this.body,
  43. @required this.payload,
  44. });
  45. final int id;
  46. final String title;
  47. final String body;
  48. final String payload;
  49. }
  50. Future<void> main() async {
  51. WidgetsFlutterBinding.ensureInitialized();
  52. const AndroidInitializationSettings initializationSettingsAndroid =
  53. AndroidInitializationSettings('@mipmap/app_logo');
  54. /// Note: permissions aren't requested here just to demonstrate that can be
  55. /// done later
  56. final IOSInitializationSettings initializationSettingsIOS =
  57. IOSInitializationSettings(
  58. requestAlertPermission: true,
  59. requestBadgePermission: true,
  60. requestSoundPermission: true,
  61. onDidReceiveLocalNotification:
  62. (int id, String title, String body, String payload) async {
  63. didReceiveLocalNotificationSubject.add(ReceivedNotification(
  64. id: id, title: title, body: body, payload: payload));
  65. });
  66. const MacOSInitializationSettings initializationSettingsMacOS =
  67. MacOSInitializationSettings(
  68. requestAlertPermission: true,
  69. requestBadgePermission: true,
  70. requestSoundPermission: true);
  71. final InitializationSettings initializationSettings = InitializationSettings(
  72. android: initializationSettingsAndroid,
  73. iOS: initializationSettingsIOS,
  74. macOS: initializationSettingsMacOS);
  75. await flutterLocalNotificationsPlugin.initialize(initializationSettings,
  76. onSelectNotification: (String payload) async {
  77. if (payload != null) {
  78. if(payload==notifyTypeNewMsg){
  79. RootPageView().bNIndex = 2;
  80. EventBus().emit('ChangePage');
  81. }
  82. debugPrint('notification payload: $payload');
  83. }
  84. selectNotificationSubject.add(payload);
  85. });
  86. runApp(MyApp());
  87. }
  88. class MyApp extends StatelessWidget with WidgetsBindingObserver {
  89. BuildContext buildContext;
  90. StateSetter ss;
  91. List<MyShopBeanDataData> shops = [];
  92. int shopIndex = 0;
  93. String clipboardT;
  94. int amountCompleted = 0;
  95. NewOrderBeanEntity newOrder;
  96. @override
  97. StatelessElement createElement() {
  98. // TODO: implement createElement
  99. WidgetsBinding.instance.addObserver(this);
  100. MyCookie().initP();
  101. EventBus().on('hasNewOrder', (arg) {
  102. print('fnlasnfiansfinasfnoasnfi---------1');
  103. newOrder = arg;
  104. displayPendingOrders();
  105. });
  106. return super.createElement();
  107. }
  108. @override
  109. Widget build(BuildContext context) {
  110. return RefreshConfiguration(
  111. child: MaterialApp(
  112. navigatorKey: navigatorKey,
  113. theme: ThemeData(fontFamily: 'PingFang'),
  114. debugShowCheckedModeBanner: false,
  115. home: WelcomePage(),
  116. routes: {
  117. '/loginPage': (context) => LoginPage(),
  118. },
  119. supportedLocales: [const Locale('zh', 'CH')],
  120. localizationsDelegates: [
  121. RefreshLocalizations.delegate,
  122. GlobalMaterialLocalizations.delegate,
  123. GlobalWidgetsLocalizations.delegate,
  124. const FallbackCupertinoLocalisationsDelegate(),
  125. ],
  126. builder: (BuildContext context, Widget child) {
  127. buildContext = context;
  128. return MediaQuery(
  129. data: MediaQuery.of(context)
  130. .copyWith(textScaleFactor: 1.0), //设置字体不随系统字体大小改变
  131. child: FlutterEasyLoading(
  132. child: child,
  133. ),
  134. );
  135. },
  136. ),
  137. hideFooterWhenNotFull: true,
  138. footerBuilder: () {
  139. return ClassicFooter(
  140. loadStyle: LoadStyle.ShowWhenLoading,
  141. );
  142. },
  143. );
  144. }
  145. @override
  146. void didChangeAppLifecycleState(AppLifecycleState state) {
  147. super.didChangeAppLifecycleState(state);
  148. if (state == AppLifecycleState.paused) {
  149. print('went to Background');
  150. }
  151. if (state == AppLifecycleState.resumed) {
  152. print('came back to Foreground');
  153. if (MyCookie().loginInformation != null) {
  154. Timer(Duration(seconds: 1), () {
  155. getClipboardData();
  156. });
  157. }
  158. }
  159. }
  160. //获取剪切板文字
  161. Future<void> getClipboardData() async {
  162. ClipboardData text = await Clipboard.getData(Clipboard.kTextPlain);
  163. print('Clipboard-----\n${text.text}');
  164. clipboardT = text.text;
  165. Clipboard.setData(ClipboardData(text: ''));
  166. getOnlineTemplate();
  167. }
  168. //获取线上模板
  169. void getOnlineTemplate() {
  170. MyDio().query({
  171. 'key': 'order_template',
  172. "dims": ["id", "sid", "template"],
  173. "filters": {}
  174. }, (response, hasError) {
  175. if (!hasError) {
  176. TemplateBeanEntity entity = TemplateBeanEntity()
  177. .fromJson(json.decode(response.data.toString()));
  178. checkOrder(entity.data);
  179. }
  180. }, (error) {});
  181. }
  182. //匹配模板去除不是自己的订单
  183. void checkOrder(List<TemplateBeanData> data) {
  184. w:
  185. for (int i = 0; i < data.length; i++) {
  186. try {
  187. var res = parseString2(
  188. data[i].template.replaceAll('\r', ''), '''$clipboardT''');
  189. if (res != null) {
  190. print(data[i].template);
  191. print(json.encode(res));
  192. var order = parse2(res);
  193. order.removeWhere((element) =>
  194. !element.seller.name
  195. .contains(MyCookie().loginInformation.data.extra.name) &&
  196. !MyCookie()
  197. .loginInformation
  198. .data
  199. .extra
  200. .name
  201. .contains(element.seller.name));
  202. if (order.length > 0) {
  203. getShop(order);
  204. }
  205. break w;
  206. }
  207. } catch (e) {}
  208. }
  209. }
  210. //订单视图
  211. items(List<OrderInfo2> order) {
  212. List<Widget> items = [];
  213. order.forEach((element) {
  214. items.add(Container(
  215. child: Column(
  216. children: [
  217. Row(
  218. children: [
  219. Container(
  220. margin: EdgeInsets.only(left: 8, right: 7),
  221. child: ClipRRect(
  222. child: MyViews().netImg(
  223. imgURL(MyCookie().loginInformation.data.extra.picture),
  224. 35,
  225. 35),
  226. borderRadius: BorderRadius.circular(17.5),
  227. ),
  228. ),
  229. Expanded(
  230. child: Container(
  231. height: 35,
  232. child: Column(
  233. children: [
  234. Text(
  235. '付款人:${element.payer.name}',
  236. style: TextStyle(
  237. color: MyColors.c333333,
  238. fontSize: 13,
  239. decoration: TextDecoration.none,
  240. ),
  241. ),
  242. Text(
  243. '订单时间:${element.time}',
  244. style: TextStyle(
  245. color: MyColors.c666666,
  246. fontSize: 10,
  247. decoration: TextDecoration.none,
  248. ),
  249. ),
  250. ],
  251. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  252. crossAxisAlignment: CrossAxisAlignment.start,
  253. ),
  254. ),
  255. ),
  256. Container(
  257. margin: EdgeInsets.only(right: 10),
  258. child: Text(
  259. '¥${(element.payer.amount * element.factor).toStringAsFixed(2)}',
  260. style: TextStyle(
  261. color: MyColors.cFF4233,
  262. fontSize: 14,
  263. decoration: TextDecoration.none,
  264. ),
  265. ),
  266. ),
  267. ],
  268. crossAxisAlignment: CrossAxisAlignment.center,
  269. ),
  270. Container(
  271. height: 0.5,
  272. margin: EdgeInsets.only(right: 10, left: 50, top: 5),
  273. color: MyColors.cE7E7E7,
  274. )
  275. ],
  276. ),
  277. margin: EdgeInsets.only(top: 5),
  278. ));
  279. });
  280. return items;
  281. }
  282. //获取用户所在店铺
  283. void getShop(List<OrderInfo2> order) {
  284. shopIndex = 0;
  285. MyDio().query({
  286. "key": "shop_user",
  287. "filters": {
  288. "or": true,
  289. "conditions": [
  290. "role!=0",
  291. "user_uid==${MyCookie().getUID()}",
  292. "review_state==1"
  293. ],
  294. "filters": [
  295. {
  296. "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
  297. }
  298. ]
  299. },
  300. "dims": shopUserDims,
  301. "paging": [1, 20000]
  302. }, (response, hasError) {
  303. if (!hasError) {
  304. MyShopBeanEntity entity =
  305. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  306. shops = entity.data.data;
  307. shops.removeWhere((element) => !element.privateShop);
  308. if (shops.length == 0) {
  309. showToast('你还没有添加任何货帮,暂时不能发送智能订单');
  310. } else {
  311. EasyLoading.instance
  312. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  313. ..alignment = Alignment.bottomCenter
  314. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  315. EasyLoading.show(
  316. indicator: Material(
  317. color: Colors.white,
  318. child: StatefulBuilder(
  319. builder: (c, s) {
  320. ss = s;
  321. return Column(
  322. children: [
  323. Container(
  324. child: Stack(
  325. children: [
  326. Container(
  327. child: MyViews()
  328. .myText('智能订单', MyColors.c333333, 14),
  329. alignment: Alignment.center,
  330. height: 22,
  331. ),
  332. Positioned(
  333. right: 0,
  334. child: GestureDetector(
  335. onTap: () {
  336. EasyLoading.dismiss();
  337. },
  338. behavior: HitTestBehavior.translucent,
  339. child: Container(
  340. child: Icon(
  341. Icons.close,
  342. size: 20,
  343. color: Colors.white,
  344. ),
  345. decoration: BoxDecoration(
  346. color: MyColors.cB6B6B6,
  347. borderRadius: BorderRadius.circular(11)),
  348. height: 22,
  349. width: 22,
  350. ),
  351. ),
  352. )
  353. ],
  354. alignment: Alignment.center,
  355. ),
  356. height: 30,
  357. padding: EdgeInsets.symmetric(horizontal: 12),
  358. ),
  359. Container(
  360. height: 5,
  361. color: MyColors.cF7F7F7,
  362. margin: EdgeInsets.only(top: 10),
  363. ),
  364. Column(
  365. children: items(order),
  366. ),
  367. Container(
  368. height: 5,
  369. color: MyColors.cF7F7F7,
  370. margin: EdgeInsets.only(top: 10),
  371. ),
  372. Visibility(
  373. child: Column(
  374. children: [
  375. Container(
  376. child: MyViews()
  377. .myText('货帮选择', MyColors.c333333, 13),
  378. margin: EdgeInsets.only(left: 7, top: 11),
  379. ),
  380. Container(
  381. margin: EdgeInsets.symmetric(
  382. horizontal: 7, vertical: 10),
  383. height: (shops.length * 1.0 / 2).ceil() *
  384. (double.parse(
  385. '${MediaQuery.of(buildContext).size.width - 74}') /
  386. 2 /
  387. 3.8 +
  388. 10) -
  389. 10,
  390. child: GridView(
  391. gridDelegate:
  392. SliverGridDelegateWithFixedCrossAxisCount(
  393. crossAxisCount: 2, //横轴三个子widget
  394. childAspectRatio: 3.8,
  395. crossAxisSpacing: 10,
  396. mainAxisSpacing: 8 //宽高比为1时,子widget
  397. ),
  398. children: shop(shops),
  399. padding: EdgeInsets.all(0),
  400. ),
  401. ),
  402. ],
  403. crossAxisAlignment: CrossAxisAlignment.start,
  404. ),
  405. visible: shops.length != 1,
  406. ),
  407. Container(
  408. height: 0.5,
  409. color: MyColors.cF7F7F7,
  410. margin: EdgeInsets.only(bottom: 10),
  411. ),
  412. Container(
  413. child: GestureDetector(
  414. onTap: () {
  415. EventBus().on('saveOrder', (arg) {
  416. amountCompleted++;
  417. if (amountCompleted == order.length) {
  418. amountCompleted = 0;
  419. EasyLoading.dismiss();
  420. showToast('发送成功');
  421. clipboardT = '';
  422. EventBus().off('saveOrder');
  423. }
  424. });
  425. order.forEach((element) {
  426. sendOrder(element);
  427. });
  428. },
  429. behavior: HitTestBehavior.translucent,
  430. child: Container(
  431. decoration: BoxDecoration(
  432. color: MyColors.cFF4233,
  433. borderRadius: BorderRadius.circular(20),
  434. ),
  435. height: 40,
  436. width: 150,
  437. child: MyViews().myText('发送订单', Colors.white, 14),
  438. alignment: Alignment.center,
  439. ),
  440. ),
  441. alignment: Alignment.center,
  442. )
  443. ],
  444. mainAxisAlignment: MainAxisAlignment.start,
  445. crossAxisAlignment: CrossAxisAlignment.start,
  446. );
  447. },
  448. ),
  449. ),
  450. );
  451. }
  452. }
  453. }, (error) {});
  454. }
  455. //店铺视图
  456. shop(List<MyShopBeanDataData> shops) {
  457. List<Widget> items = [];
  458. for (int i = 0; i < shops.length; i++) {
  459. items.add(GestureDetector(
  460. onTap: () {
  461. shopIndex = i;
  462. ss(() {});
  463. },
  464. behavior: HitTestBehavior.translucent,
  465. child: Container(
  466. child: Row(
  467. children: [
  468. Container(
  469. margin: EdgeInsets.only(right: 5),
  470. child: ClipRRect(
  471. child: MyViews().netImg(imgURL(shops[i].shopPic), 30, 30),
  472. borderRadius: BorderRadius.circular(15),
  473. ),
  474. ),
  475. Expanded(
  476. child: Column(
  477. children: [
  478. Text(
  479. shops[i].shopName,
  480. style: TextStyle(
  481. color: i == shopIndex
  482. ? MyColors.cFF4233
  483. : MyColors.c666666,
  484. fontSize: 12,
  485. ),
  486. maxLines: 1,
  487. overflow: TextOverflow.ellipsis,
  488. softWrap: true,
  489. ),
  490. Text(
  491. 'ID:${shops[i].shopUid}',
  492. style: TextStyle(
  493. color: i == shopIndex
  494. ? MyColors.cFF4233
  495. : MyColors.c666666,
  496. fontSize: 10,
  497. ),
  498. maxLines: 1,
  499. overflow: TextOverflow.ellipsis,
  500. softWrap: true,
  501. ),
  502. ],
  503. crossAxisAlignment: CrossAxisAlignment.start,
  504. ),
  505. ),
  506. ],
  507. ),
  508. decoration: BoxDecoration(
  509. color: i == shopIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
  510. borderRadius: BorderRadius.circular(4),
  511. ),
  512. constraints: BoxConstraints(maxWidth: 150),
  513. padding: EdgeInsets.symmetric(horizontal: 6, vertical: 6),
  514. ),
  515. ));
  516. }
  517. return items;
  518. }
  519. //发送订单
  520. void sendOrder(OrderInfo2 element) {
  521. MyDio().save({
  522. 'key': 'order',
  523. 'object': {
  524. 'uuid': generateMd5(reOS(clipboardT)),
  525. 'shop_uid': shops[shopIndex].shopUid,
  526. 'shop_pic': shops[shopIndex].shopPic,
  527. 'shop_name': shops[shopIndex].shopName,
  528. // 'seller_id': MyCookie().loginInformation.data.extra.id,
  529. 'seller_pic': MyCookie().loginInformation.data.extra.picture,
  530. 'seller_uid': MyCookie().getUID(),
  531. 'seller_name': MyCookie().loginInformation.data.extra.name,
  532. 'buyer_name': element.payer.name,
  533. 'type': orderTypeThirdPlatform,
  534. 'amount': NumUtil.multiply(element.payer.amount, element.factor)
  535. // 'amount':0.01
  536. }
  537. }, (response, hasError) {
  538. if (!hasError) {
  539. EventBus().emit('saveOrder');
  540. }
  541. }, (error) {});
  542. }
  543. //待支付订单视图
  544. void displayPendingOrders() {
  545. EasyLoading.instance
  546. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  547. ..alignment = Alignment.bottomCenter
  548. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  549. EasyLoading.show(
  550. indicator: Material(
  551. color: Colors.white,
  552. child: Column(
  553. children: [
  554. Container(
  555. padding: EdgeInsets.symmetric(horizontal: 12),
  556. child: Row(
  557. children: [
  558. Container(
  559. margin: EdgeInsets.only(right: 7),
  560. child: ClipRRect(
  561. child: MyViews()
  562. .netImg(imgURL(newOrder.content.shopPic), 25, 25),
  563. borderRadius: BorderRadius.circular(12.5),
  564. ),
  565. ),
  566. MyViews().myText(
  567. '${newOrder.content.shopName}(${newOrder.content.shopUID})',
  568. MyColors.c333333,
  569. 14),
  570. ],
  571. ),
  572. ),
  573. Container(
  574. margin: EdgeInsets.only(top: 11, left: 12, right: 12, bottom: 11),
  575. height: 0.5,
  576. color: MyColors.cE7E7E7,
  577. ),
  578. Container(
  579. margin: EdgeInsets.symmetric(horizontal: 12),
  580. child: Row(
  581. children: [
  582. Container(
  583. child: SvgPicture.asset(
  584. 'images/svg/第三方.svg',
  585. height: 27,
  586. width: 27,
  587. ),
  588. margin: EdgeInsets.only(right: 8),
  589. height: 45,
  590. width: 45,
  591. decoration: BoxDecoration(
  592. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  593. alignment: Alignment.center,
  594. ),
  595. Expanded(
  596. child: Container(
  597. height: 45,
  598. child: Column(
  599. children: [
  600. MyViews().myText('第三方订单', MyColors.c333333, 13),
  601. Row(
  602. children: [
  603. MyViews().myText('¥${newOrder.content.amount}',
  604. MyColors.cFF4233, 12),
  605. MyViews().myText('x1', MyColors.c999999, 12),
  606. ],
  607. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  608. )
  609. ],
  610. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  611. crossAxisAlignment: CrossAxisAlignment.start,
  612. ),
  613. ),
  614. ),
  615. ],
  616. ),
  617. ),
  618. Container(
  619. height: 0.5,
  620. color: MyColors.cE7E7E7,
  621. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  622. ),
  623. Container(
  624. margin: EdgeInsets.symmetric(horizontal: 12),
  625. child: Row(
  626. children: [
  627. MyViews().myText('卖家信息:', MyColors.c333333, 13),
  628. Row(
  629. children: [
  630. Container(
  631. margin: EdgeInsets.only(right: 5),
  632. child: ClipRRect(
  633. child: MyViews().netImg(
  634. imgURL(newOrder.content.sellerPic), 23, 23),
  635. borderRadius: BorderRadius.circular(11.5),
  636. ),
  637. ),
  638. MyViews().myText(
  639. '${newOrder.content.sellerName}(${newOrder.content.sellerUID})',
  640. MyColors.c333333,
  641. 13),
  642. ],
  643. )
  644. ],
  645. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  646. ),
  647. ),
  648. Container(
  649. height: 0.5,
  650. color: MyColors.cE7E7E7,
  651. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  652. ),
  653. Container(
  654. margin: EdgeInsets.symmetric(horizontal: 12),
  655. child: Row(
  656. children: [
  657. MyViews().myText('买家信息:', MyColors.c333333, 13),
  658. Row(
  659. children: [
  660. Container(
  661. margin: EdgeInsets.only(right: 5),
  662. child: ClipRRect(
  663. child: MyViews().netImg('path', 23, 23),
  664. borderRadius: BorderRadius.circular(11.5),
  665. ),
  666. ),
  667. MyViews().myText('${newOrder.content.buyerName}',
  668. MyColors.c333333, 13),
  669. ],
  670. )
  671. ],
  672. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  673. ),
  674. ),
  675. Container(
  676. height: 0.5,
  677. color: MyColors.cE7E7E7,
  678. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  679. ),
  680. Container(
  681. margin: EdgeInsets.symmetric(horizontal: 12),
  682. child: Row(
  683. children: [
  684. MyViews().myText('下单时间:', MyColors.c333333, 13),
  685. MyViews().myText(
  686. '${newOrder.content.createTime}', MyColors.c333333, 13)
  687. ],
  688. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  689. ),
  690. ),
  691. Container(
  692. height: 0.5,
  693. color: MyColors.cE7E7E7,
  694. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  695. ),
  696. Container(
  697. margin: EdgeInsets.symmetric(horizontal: 20),
  698. child: Row(
  699. children: [
  700. Expanded(
  701. child: GestureDetector(
  702. onTap: () {
  703. EasyLoading.dismiss();
  704. },
  705. behavior: HitTestBehavior.translucent,
  706. child: Container(
  707. decoration: BoxDecoration(
  708. borderRadius: BorderRadius.only(
  709. topLeft: Radius.circular(20),
  710. bottomLeft: Radius.circular(20),
  711. ),
  712. border: Border.all(
  713. color: MyColors.cFF4233, width: 1)),
  714. height: 40,
  715. child: MyViews().myText('与我无瓜', MyColors.cFF4233, 14),
  716. alignment: Alignment.center),
  717. ),
  718. ),
  719. Expanded(
  720. child: GestureDetector(
  721. onTap: () {
  722. if (newOrder.content.buyerName
  723. .contains(MyCookie().getName()) ||
  724. MyCookie()
  725. .getName()
  726. .contains(newOrder.content.buyerName)) {
  727. EasyLoading.dismiss();
  728. payTheOrder();
  729. // showDialog(
  730. // context: buildContext,
  731. // builder: (BuildContext context) {
  732. // return Center(
  733. // child: Container(
  734. // decoration: BoxDecoration(
  735. // color: Colors.white,
  736. // borderRadius:
  737. // BorderRadius.all(Radius.circular(8))),
  738. // child: Column(
  739. // children: [
  740. // Expanded(
  741. // child: Center(
  742. // child: Padding(
  743. // padding: const EdgeInsets.only(
  744. // left: 15, right: 15),
  745. // child: Column(
  746. // children: [
  747. // Text(
  748. // '确认支付订单(${newOrder.content.uID})',
  749. // style: TextStyle(
  750. // color: MyColors.c333333,
  751. // fontSize: 16,
  752. // fontWeight:
  753. // FontWeight.normal,
  754. // decoration:
  755. // TextDecoration.none),
  756. // ),
  757. // Text(
  758. // '付款人:${newOrder.content.buyerName}',
  759. // style: TextStyle(
  760. // color: MyColors.c333333,
  761. // fontSize: 16,
  762. // fontWeight:
  763. // FontWeight.normal,
  764. // decoration:
  765. // TextDecoration.none),
  766. // ),
  767. // Text(
  768. // '收款人:${newOrder.content.sellerName}',
  769. // style: TextStyle(
  770. // color: MyColors.c333333,
  771. // fontSize: 16,
  772. // fontWeight:
  773. // FontWeight.normal,
  774. // decoration:
  775. // TextDecoration.none),
  776. // ),
  777. // ],
  778. // mainAxisAlignment:
  779. // MainAxisAlignment.center,
  780. // ),
  781. // ),
  782. // ),
  783. // ),
  784. // Container(
  785. // height: 0.5,
  786. // color: MyColors.cE7E7E7,
  787. // ),
  788. // Row(
  789. // children: [
  790. // Expanded(
  791. // child: GestureDetector(
  792. // onTap: () {
  793. // Navigator.pop(context);
  794. // },
  795. // behavior:
  796. // HitTestBehavior.translucent,
  797. // child: Container(
  798. // alignment: Alignment.center,
  799. // height: 55,
  800. // child: Text(
  801. // '取消',
  802. // style: TextStyle(
  803. // color: MyColors.c999999,
  804. // fontSize: 16,
  805. // fontWeight:
  806. // FontWeight.normal,
  807. // decoration:
  808. // TextDecoration.none),
  809. // ),
  810. // ),
  811. // )),
  812. // Container(
  813. // width: 0.5,
  814. // height: 55,
  815. // color: MyColors.cE7E7E7,
  816. // ),
  817. // Expanded(
  818. // child: GestureDetector(
  819. // onTap: () async {
  820. // Navigator.pop(context);
  821. // payTheOrder(context);
  822. // },
  823. // behavior:
  824. // HitTestBehavior.translucent,
  825. // child: Container(
  826. // alignment: Alignment.center,
  827. // height: 55,
  828. // child: Text(
  829. // '确定',
  830. // style: TextStyle(
  831. // color: MyColors.cFF4233,
  832. // fontSize: 16,
  833. // fontWeight:
  834. // FontWeight.normal,
  835. // decoration:
  836. // TextDecoration.none),
  837. // ),
  838. // ),
  839. // ),
  840. // ),
  841. // ],
  842. // )
  843. // ],
  844. // ),
  845. // height: 200,
  846. // margin: EdgeInsets.only(left: 48, right: 48),
  847. // ),
  848. // );
  849. // },
  850. // );
  851. } else {
  852. showToast('该订单与你无关');
  853. }
  854. },
  855. behavior: HitTestBehavior.translucent,
  856. child: Container(
  857. decoration: BoxDecoration(
  858. borderRadius: BorderRadius.only(
  859. topRight: Radius.circular(20),
  860. bottomRight: Radius.circular(20),
  861. ),
  862. color: MyColors.cFF4233),
  863. height: 40,
  864. child: MyViews().myText('立即支付', Colors.white, 14),
  865. alignment: Alignment.center),
  866. ),
  867. )
  868. ],
  869. ),
  870. )
  871. ],
  872. ),
  873. ),
  874. );
  875. }
  876. void payTheOrder() {
  877. //获取店铺信息
  878. MyDio().query({
  879. "key": "shop_user",
  880. "filters": {
  881. "conditions": ["shop_uid==${newOrder.content.shopUID}"]
  882. },
  883. "dims": shopUserDims,
  884. "paging": [1, 1],
  885. "order_by": ["shop_name,DESC"]
  886. }, (response, hasError) {
  887. if (!hasError) {
  888. MyShopBeanEntity entity =
  889. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  890. navigatorKey.currentState.push(MaterialPageRoute(
  891. builder: (context) =>
  892. GangInPage(entity.data.data[0], newOrder.content)));
  893. }
  894. }, (error) {});
  895. // getUserWalletBalance((re, hE) {
  896. // if (!hE) {
  897. // UserBalanceEntity balance =
  898. // UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  899. // if (balance.data >= newOrder.content.amount) {
  900. // payOrder(payWayWallet, newOrder.content.uID, (re, hE) {
  901. // if (!hE) {
  902. // showToast('支付成功');
  903. // EventBus().emit('payAnOrder');
  904. // }
  905. // }, (e) {}, context);
  906. // } else {
  907. // payOrder(payWayAliPay, newOrder.content.uID, (re, hE) {
  908. // if (!hE) {
  909. // PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
  910. // .fromJson(json.decode(re.data.toString()));
  911. // EventBus().on('alipayPaymentCallback', (arg) {
  912. // EventBus().off('alipayPaymentCallback');
  913. // EasyLoading.dismiss();
  914. // showToast('支付成功');
  915. // EventBus().emit('reNoPayOrder');
  916. // });
  917. // print(entity.data);
  918. // EasyLoading.instance
  919. // ..contentPadding =
  920. // EdgeInsets.symmetric(horizontal: 20, vertical: 12)
  921. // ..alignment = Alignment.center
  922. // ..contentMargin = EdgeInsets.all(20);
  923. // EasyLoading.show();
  924. // aliPay(entity.data).then((value) {
  925. // print(json.encode(value));
  926. // AlipayResultBeanEntity e = AlipayResultBeanEntity()
  927. // .fromJson(json.decode(json.encode(value)));
  928. // try {
  929. // int r = int.parse(e.resultStatus);
  930. // if (r == 9000) {
  931. // showToast('支付成功');
  932. // } else {
  933. // showToast(aliPayResultStatus(r));
  934. // resetOrder(newOrder.content.uID, context);
  935. // }
  936. // } catch (e) {
  937. // EasyLoading.dismiss();
  938. // }
  939. // });
  940. // // EventBus().emit('payAnOrder');
  941. // }
  942. // }, (e) {}, context);
  943. // // showToast('积分余额不足');
  944. // }
  945. // }
  946. // }, (e) {}, context);
  947. }
  948. }
  949. class FallbackCupertinoLocalisationsDelegate
  950. extends LocalizationsDelegate<CupertinoLocalizations> {
  951. const FallbackCupertinoLocalisationsDelegate();
  952. @override
  953. bool isSupported(Locale locale) => true;
  954. @override
  955. Future<CupertinoLocalizations> load(Locale locale) =>
  956. DefaultCupertinoLocalizations.load(locale);
  957. @override
  958. bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
  959. }