main.dart 42 KB

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