main.dart 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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:flustars/flustars.dart';
  15. import 'package:flutter/cupertino.dart';
  16. import 'package:flutter/material.dart';
  17. import 'package:flutter/services.dart';
  18. import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  19. import 'package:flutter_localizations/flutter_localizations.dart';
  20. import 'package:flutter_svg/flutter_svg.dart';
  21. import 'package:pull_to_refresh/pull_to_refresh.dart';
  22. import 'package:rxdart/rxdart.dart';
  23. import 'beans/coupon_bean_entity.dart';
  24. import 'beans/my_shop_bean_entity.dart';
  25. import 'beans/new_order_bean_entity.dart';
  26. import 'beans/system_information_bean_entity.dart';
  27. import 'https/MyDio.dart';
  28. import 'https/my_request.dart';
  29. import 'my_tools/const.dart';
  30. import 'my_tools/dims.dart';
  31. import 'my_tools/easy_loading/easy_loading.dart';
  32. import 'my_tools/easy_loading/loading.dart';
  33. import 'my_tools/global.dart';
  34. import 'my_tools/my_colors.dart';
  35. import 'my_tools/my_views.dart';
  36. import 'my_tools/order.dart';
  37. import 'my_tools/pop_up_queue.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. PopUpQueue().onShow = true;
  201. ClipboardData text = await Clipboard.getData(Clipboard.kTextPlain);
  202. try{print('Clipboard-----\n${text.text}');
  203. clipboardT = text.text;
  204. Clipboard.setData(ClipboardData(text: ''));
  205. getOnlineTemplate();}catch(e){
  206. PopUpQueue().onShow = false;
  207. PopUpQueue().showNext();
  208. }
  209. }
  210. //获取线上模板
  211. void getOnlineTemplate() {
  212. MyDio().query({
  213. 'key': 'order_template',
  214. "dims": ["id", "sid", "template"],
  215. "filters": {}
  216. }, (response, hasError) {
  217. if (!hasError) {
  218. TemplateBeanEntity entity = TemplateBeanEntity()
  219. .fromJson(json.decode(response.data.toString()));
  220. checkOrder(entity.data);
  221. }else{
  222. PopUpQueue().onShow = false;
  223. PopUpQueue().showNext();
  224. }
  225. }, (error) {
  226. PopUpQueue().onShow = false;
  227. PopUpQueue().showNext();
  228. });
  229. }
  230. //匹配模板去除不是自己的订单
  231. void checkOrder(List<TemplateBeanData> data) {
  232. bool hasMatch = false;
  233. w:
  234. for (int i = 0; i < data.length; i++) {
  235. try {
  236. var res = parseString2(
  237. data[i].template.replaceAll('\r', ''), '''$clipboardT''');
  238. if (res != null) {
  239. print(data[i].template);
  240. print(json.encode(res));
  241. var order = parse2(res);
  242. order.removeWhere((element) =>
  243. !element.seller.name
  244. .contains(MyCookie().loginInformation.data.extra.name) &&
  245. !MyCookie()
  246. .loginInformation
  247. .data
  248. .extra
  249. .name
  250. .contains(element.seller.name));
  251. if (order.length > 0) {
  252. hasMatch = true;
  253. getShop(order);
  254. }
  255. break w;
  256. }
  257. } catch (e) {
  258. }
  259. }
  260. if(!hasMatch){
  261. PopUpQueue().onShow = false;
  262. PopUpQueue().showNext();
  263. }
  264. }
  265. //订单视图
  266. items(List<OrderInfo2> order) {
  267. List<Widget> items = [];
  268. order.forEach((element) {
  269. items.add(Container(
  270. child: Column(
  271. children: [
  272. Row(
  273. children: [
  274. Container(
  275. margin: EdgeInsets.only(left: 8, right: 7),
  276. child: ClipRRect(
  277. child: MyViews().netImg(
  278. imgURL(MyCookie().loginInformation.data.extra.picture),
  279. 35,
  280. 35),
  281. borderRadius: BorderRadius.circular(17.5),
  282. ),
  283. ),
  284. Expanded(
  285. child: Container(
  286. height: 35,
  287. child: Column(
  288. children: [
  289. Text(
  290. '付款人:${element.payer.name}',
  291. style: TextStyle(
  292. color: MyColors.c333333,
  293. fontSize: 13,
  294. decoration: TextDecoration.none,
  295. ),
  296. ),
  297. Text(
  298. '订单时间:${element.time}',
  299. style: TextStyle(
  300. color: MyColors.c666666,
  301. fontSize: 10,
  302. decoration: TextDecoration.none,
  303. ),
  304. ),
  305. ],
  306. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  307. crossAxisAlignment: CrossAxisAlignment.start,
  308. ),
  309. ),
  310. ),
  311. Container(
  312. margin: EdgeInsets.only(right: 10),
  313. child: Text(
  314. '¥${(element.payer.amount * element.factor).toStringAsFixed(2)}',
  315. style: TextStyle(
  316. color: MyColors.cFF4233,
  317. fontSize: 14,
  318. decoration: TextDecoration.none,
  319. ),
  320. ),
  321. ),
  322. ],
  323. crossAxisAlignment: CrossAxisAlignment.center,
  324. ),
  325. Container(
  326. height: 0.5,
  327. margin: EdgeInsets.only(right: 10, left: 50, top: 5),
  328. color: MyColors.cE7E7E7,
  329. )
  330. ],
  331. ),
  332. margin: EdgeInsets.only(top: 5),
  333. ));
  334. });
  335. return items;
  336. }
  337. //获取用户所在店铺
  338. void getShop(List<OrderInfo2> order) {
  339. shopIndex = 0;
  340. MyDio().query({
  341. "key": "shop_user",
  342. "filters": {
  343. "or": true,
  344. "conditions": [
  345. "role!=0",
  346. "user_uid==${MyCookie().getUID()}",
  347. "review_state==1"
  348. ],
  349. "filters": [
  350. {
  351. "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
  352. }
  353. ]
  354. },
  355. "dims": shopUserDims,
  356. "paging": [1, 20000]
  357. }, (response, hasError) {
  358. if (!hasError) {
  359. MyShopBeanEntity entity =
  360. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  361. shops = entity.data.data;
  362. shops.removeWhere((element) => !element.privateShop);
  363. if (shops.length == 0) {
  364. showToast('你还没有添加任何货帮,暂时不能发送智能订单');
  365. PopUpQueue().onShow = false;
  366. PopUpQueue().showNext();
  367. } else {
  368. EasyLoading.instance
  369. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  370. ..alignment = Alignment.bottomCenter
  371. ..loadingStyle = EasyLoadingStyle.light
  372. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  373. EasyLoading.show(
  374. indicator: Material(
  375. color: Colors.white,
  376. child: StatefulBuilder(
  377. builder: (c, s) {
  378. ss = s;
  379. return Column(
  380. children: [
  381. Container(
  382. child: Stack(
  383. children: [
  384. Container(
  385. child: MyViews()
  386. .myText('智能订单', MyColors.c333333, 14),
  387. alignment: Alignment.center,
  388. height: 22,
  389. ),
  390. Positioned(
  391. right: 0,
  392. child: GestureDetector(
  393. onTap: () {
  394. PopUpQueue().onShow = false;
  395. PopUpQueue().showNext();
  396. },
  397. behavior: HitTestBehavior.translucent,
  398. child: Container(
  399. child: Icon(
  400. Icons.close,
  401. size: 20,
  402. color: Colors.white,
  403. ),
  404. decoration: BoxDecoration(
  405. color: MyColors.cB6B6B6,
  406. borderRadius: BorderRadius.circular(11)),
  407. height: 22,
  408. width: 22,
  409. ),
  410. ),
  411. )
  412. ],
  413. alignment: Alignment.center,
  414. ),
  415. height: 30,
  416. padding: EdgeInsets.symmetric(horizontal: 12),
  417. ),
  418. Container(
  419. height: 5,
  420. color: MyColors.cF7F7F7,
  421. margin: EdgeInsets.only(top: 10),
  422. ),
  423. Column(
  424. children: items(order),
  425. ),
  426. Container(
  427. height: 5,
  428. color: MyColors.cF7F7F7,
  429. margin: EdgeInsets.only(top: 10),
  430. ),
  431. Visibility(
  432. child: Column(
  433. children: [
  434. Container(
  435. child: MyViews()
  436. .myText('货帮选择', MyColors.c333333, 13),
  437. margin: EdgeInsets.only(left: 7, top: 11),
  438. ),
  439. Container(
  440. margin: EdgeInsets.symmetric(
  441. horizontal: 7, vertical: 10),
  442. height: (shops.length * 1.0 / 2).ceil() *
  443. (double.parse(
  444. '${MediaQuery.of(buildContext).size.width - 74}') /
  445. 2 /
  446. 3.8 +
  447. 10) -
  448. 10,
  449. child: GridView(
  450. gridDelegate:
  451. SliverGridDelegateWithFixedCrossAxisCount(
  452. crossAxisCount: 2, //横轴三个子widget
  453. childAspectRatio: 3.8,
  454. crossAxisSpacing: 10,
  455. mainAxisSpacing: 8 //宽高比为1时,子widget
  456. ),
  457. children: shop(shops),
  458. padding: EdgeInsets.all(0),
  459. ),
  460. ),
  461. ],
  462. crossAxisAlignment: CrossAxisAlignment.start,
  463. ),
  464. visible: shops.length != 1,
  465. ),
  466. Container(
  467. height: 0.5,
  468. color: MyColors.cF7F7F7,
  469. margin: EdgeInsets.only(bottom: 10),
  470. ),
  471. Container(
  472. child: GestureDetector(
  473. onTap: () {
  474. EventBus().on('saveOrder', (arg) {
  475. amountCompleted++;
  476. if (amountCompleted == order.length) {
  477. amountCompleted = 0;
  478. EasyLoading.dismiss();
  479. showToast('发送成功');
  480. clipboardT = '';
  481. EventBus().off('saveOrder');
  482. PopUpQueue().onShow = false;
  483. PopUpQueue().showNext();
  484. }
  485. });
  486. order.forEach((element) {
  487. sendOrder(element);
  488. });
  489. },
  490. behavior: HitTestBehavior.translucent,
  491. child: Container(
  492. decoration: BoxDecoration(
  493. color: MyColors.cFF4233,
  494. borderRadius: BorderRadius.circular(20),
  495. ),
  496. height: 40,
  497. width: 150,
  498. child: MyViews().myText('发送订单', Colors.white, 14),
  499. alignment: Alignment.center,
  500. ),
  501. ),
  502. alignment: Alignment.center,
  503. )
  504. ],
  505. mainAxisAlignment: MainAxisAlignment.start,
  506. crossAxisAlignment: CrossAxisAlignment.start,
  507. );
  508. },
  509. ),
  510. ),
  511. );
  512. }
  513. }
  514. else{
  515. PopUpQueue().onShow = false;
  516. PopUpQueue().showNext();
  517. }
  518. }, (error) {
  519. PopUpQueue().onShow = false;
  520. PopUpQueue().showNext();
  521. });
  522. }
  523. //店铺视图
  524. shop(List<MyShopBeanDataData> shops) {
  525. List<Widget> items = [];
  526. for (int i = 0; i < shops.length; i++) {
  527. items.add(GestureDetector(
  528. onTap: () {
  529. shopIndex = i;
  530. ss(() {});
  531. },
  532. behavior: HitTestBehavior.translucent,
  533. child: Container(
  534. child: Row(
  535. children: [
  536. Container(
  537. margin: EdgeInsets.only(right: 5),
  538. child: ClipRRect(
  539. child: MyViews().netImg(imgURL(shops[i].shopPic), 30, 30),
  540. borderRadius: BorderRadius.circular(15),
  541. ),
  542. ),
  543. Expanded(
  544. child: Column(
  545. children: [
  546. Text(
  547. shops[i].shopName,
  548. style: TextStyle(
  549. color: i == shopIndex
  550. ? MyColors.cFF4233
  551. : MyColors.c666666,
  552. fontSize: 12,
  553. ),
  554. maxLines: 1,
  555. overflow: TextOverflow.ellipsis,
  556. softWrap: true,
  557. ),
  558. Text(
  559. 'ID:${shops[i].shopUid}',
  560. style: TextStyle(
  561. color: i == shopIndex
  562. ? MyColors.cFF4233
  563. : MyColors.c666666,
  564. fontSize: 10,
  565. ),
  566. maxLines: 1,
  567. overflow: TextOverflow.ellipsis,
  568. softWrap: true,
  569. ),
  570. ],
  571. crossAxisAlignment: CrossAxisAlignment.start,
  572. ),
  573. ),
  574. ],
  575. ),
  576. decoration: BoxDecoration(
  577. color: i == shopIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
  578. borderRadius: BorderRadius.circular(4),
  579. ),
  580. constraints: BoxConstraints(maxWidth: 150),
  581. padding: EdgeInsets.symmetric(horizontal: 6, vertical: 6),
  582. ),
  583. ));
  584. }
  585. return items;
  586. }
  587. //发送订单
  588. void sendOrder(OrderInfo2 element) {
  589. MyDio().save({
  590. 'key': 'order',
  591. 'object': {
  592. 'uuid': generateMd5(reOS(clipboardT)),
  593. 'shop_uid': shops[shopIndex].shopUid,
  594. 'shop_pic': shops[shopIndex].shopPic,
  595. 'shop_name': shops[shopIndex].shopName,
  596. // 'seller_id': MyCookie().loginInformation.data.extra.id,
  597. 'seller_pic': MyCookie().loginInformation.data.extra.picture,
  598. 'seller_uid': MyCookie().getUID(),
  599. 'seller_name': MyCookie().loginInformation.data.extra.name,
  600. 'buyer_name': element.payer.name,
  601. 'type': orderTypeThirdPlatform,
  602. 'amount': NumUtil.multiply(element.payer.amount, element.factor)
  603. // 'amount':0.01
  604. }
  605. }, (response, hasError) {
  606. if (!hasError) {
  607. EventBus().emit('saveOrder');
  608. }
  609. }, (error) {});
  610. }
  611. //待支付订单视图
  612. void displayPendingOrders() {
  613. EasyLoading.instance
  614. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  615. ..alignment = Alignment.bottomCenter
  616. ..loadingStyle = EasyLoadingStyle.light
  617. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  618. EasyLoading.show(
  619. indicator: Material(
  620. color: Colors.white,
  621. child: Column(
  622. children: [
  623. Container(
  624. padding: EdgeInsets.symmetric(horizontal: 12),
  625. child: Row(
  626. children: [
  627. Container(
  628. margin: EdgeInsets.only(right: 7),
  629. child: ClipRRect(
  630. child: MyViews()
  631. .netImg(imgURL(newOrder.content.shopPic), 25, 25),
  632. borderRadius: BorderRadius.circular(12.5),
  633. ),
  634. ),
  635. MyViews().myText(
  636. '${newOrder.content.shopName}(${newOrder.content.shopUID})',
  637. MyColors.c333333,
  638. 14),
  639. ],
  640. ),
  641. ),
  642. Container(
  643. margin: EdgeInsets.only(top: 11, left: 12, right: 12, bottom: 11),
  644. height: 0.5,
  645. color: MyColors.cE7E7E7,
  646. ),
  647. Container(
  648. margin: EdgeInsets.symmetric(horizontal: 12),
  649. child: Row(
  650. children: [
  651. Container(
  652. child: SvgPicture.asset(
  653. 'images/svg/第三方.svg',
  654. height: 27,
  655. width: 27,
  656. ),
  657. margin: EdgeInsets.only(right: 8),
  658. height: 45,
  659. width: 45,
  660. decoration: BoxDecoration(
  661. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  662. alignment: Alignment.center,
  663. ),
  664. Expanded(
  665. child: Container(
  666. height: 45,
  667. child: Column(
  668. children: [
  669. MyViews().myText('第三方订单', MyColors.c333333, 13),
  670. Row(
  671. children: [
  672. MyViews().myText('¥${newOrder.content.amount}',
  673. MyColors.cFF4233, 12),
  674. MyViews().myText('x1', MyColors.c999999, 12),
  675. ],
  676. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  677. )
  678. ],
  679. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  680. crossAxisAlignment: CrossAxisAlignment.start,
  681. ),
  682. ),
  683. ),
  684. ],
  685. ),
  686. ),
  687. Container(
  688. height: 0.5,
  689. color: MyColors.cE7E7E7,
  690. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  691. ),
  692. Container(
  693. margin: EdgeInsets.symmetric(horizontal: 12),
  694. child: Row(
  695. children: [
  696. MyViews().myText('卖家信息:', MyColors.c333333, 13),
  697. Row(
  698. children: [
  699. Container(
  700. margin: EdgeInsets.only(right: 5),
  701. child: ClipRRect(
  702. child: MyViews().netImg(
  703. imgURL(newOrder.content.sellerPic), 23, 23),
  704. borderRadius: BorderRadius.circular(11.5),
  705. ),
  706. ),
  707. MyViews().myText(
  708. '${newOrder.content.sellerName}(${hideUID(newOrder.content.sellerUID.toString())})',
  709. MyColors.c333333,
  710. 13),
  711. ],
  712. )
  713. ],
  714. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  715. ),
  716. ),
  717. Container(
  718. height: 0.5,
  719. color: MyColors.cE7E7E7,
  720. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  721. ),
  722. Container(
  723. margin: EdgeInsets.symmetric(horizontal: 12),
  724. child: Row(
  725. children: [
  726. MyViews().myText('买家信息:', MyColors.c333333, 13),
  727. Row(
  728. children: [
  729. Container(
  730. margin: EdgeInsets.only(right: 5),
  731. child: ClipRRect(
  732. child: MyViews().netImg('path', 23, 23),
  733. borderRadius: BorderRadius.circular(11.5),
  734. ),
  735. ),
  736. MyViews().myText('${newOrder.content.buyerName}',
  737. MyColors.c333333, 13),
  738. ],
  739. )
  740. ],
  741. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  742. ),
  743. ),
  744. Container(
  745. height: 0.5,
  746. color: MyColors.cE7E7E7,
  747. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  748. ),
  749. Container(
  750. margin: EdgeInsets.symmetric(horizontal: 12),
  751. child: Row(
  752. children: [
  753. MyViews().myText('下单时间:', MyColors.c333333, 13),
  754. MyViews().myText(
  755. '${newOrder.content.createTime}', MyColors.c333333, 13)
  756. ],
  757. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  758. ),
  759. ),
  760. Container(
  761. height: 0.5,
  762. color: MyColors.cE7E7E7,
  763. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  764. ),
  765. Container(
  766. margin: EdgeInsets.symmetric(horizontal: 20),
  767. child: Row(
  768. children: [
  769. Expanded(
  770. child: GestureDetector(
  771. onTap: () {
  772. PopUpQueue().onShow = false;
  773. PopUpQueue().showNext();
  774. },
  775. behavior: HitTestBehavior.translucent,
  776. child: Container(
  777. decoration: BoxDecoration(
  778. borderRadius: BorderRadius.only(
  779. topLeft: Radius.circular(20),
  780. bottomLeft: Radius.circular(20),
  781. ),
  782. border: Border.all(
  783. color: MyColors.cFF4233, width: 1)),
  784. height: 40,
  785. child: MyViews().myText('与我无瓜', MyColors.cFF4233, 14),
  786. alignment: Alignment.center),
  787. ),
  788. ),
  789. Expanded(
  790. child: GestureDetector(
  791. onTap: () {
  792. if (newOrder.content.buyerName
  793. .contains(MyCookie().getName()) ||
  794. MyCookie()
  795. .getName()
  796. .contains(newOrder.content.buyerName)) {
  797. EasyLoading.dismiss();
  798. payTheOrder();
  799. } else {
  800. showToast('该订单与你无关');
  801. PopUpQueue().onShow = false;
  802. PopUpQueue().showNext();
  803. }
  804. },
  805. behavior: HitTestBehavior.translucent,
  806. child: Container(
  807. decoration: BoxDecoration(
  808. borderRadius: BorderRadius.only(
  809. topRight: Radius.circular(20),
  810. bottomRight: Radius.circular(20),
  811. ),
  812. color: MyColors.cFF4233),
  813. height: 40,
  814. child: MyViews().myText('去支付', Colors.white, 14),
  815. alignment: Alignment.center),
  816. ),
  817. )
  818. ],
  819. ),
  820. )
  821. ],
  822. ),
  823. ),
  824. );
  825. }
  826. void payTheOrder() {
  827. //获取店铺信息
  828. MyDio().query({
  829. "key": "shop_user",
  830. "filters": {
  831. "conditions": ["shop_uid==${newOrder.content.shopUID}"]
  832. },
  833. "dims": shopUserDims,
  834. "paging": [1, 1],
  835. "order_by": ["shop_name,DESC"]
  836. }, (response, hasError) {
  837. if (!hasError) {
  838. MyShopBeanEntity entity =
  839. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  840. navigatorKey.currentState.push(MaterialPageRoute(
  841. builder: (context) =>
  842. GangInPage(entity.data.data[0], newOrder.content)));
  843. }
  844. }, (error) {});
  845. // getUserWalletBalance((re, hE) {
  846. // if (!hE) {
  847. // UserBalanceEntity balance =
  848. // UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  849. // if (balance.data >= newOrder.content.amount) {
  850. // payOrder(payWayWallet, newOrder.content.uID, (re, hE) {
  851. // if (!hE) {
  852. // showToast('支付成功');
  853. // EventBus().emit('payAnOrder');
  854. // }
  855. // }, (e) {}, context);
  856. // } else {
  857. // payOrder(payWayAliPay, newOrder.content.uID, (re, hE) {
  858. // if (!hE) {
  859. // PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
  860. // .fromJson(json.decode(re.data.toString()));
  861. // EventBus().on('alipayPaymentCallback', (arg) {
  862. // EventBus().off('alipayPaymentCallback');
  863. // EasyLoading.dismiss();
  864. // showToast('支付成功');
  865. // EventBus().emit('reNoPayOrder');
  866. // });
  867. // print(entity.data);
  868. // EasyLoading.instance
  869. // ..contentPadding =
  870. // EdgeInsets.symmetric(horizontal: 20, vertical: 12)
  871. // ..alignment = Alignment.center
  872. // ..contentMargin = EdgeInsets.all(20);
  873. // EasyLoading.show();
  874. // aliPay(entity.data).then((value) {
  875. // print(json.encode(value));
  876. // AlipayResultBeanEntity e = AlipayResultBeanEntity()
  877. // .fromJson(json.decode(json.encode(value)));
  878. // try {
  879. // int r = int.parse(e.resultStatus);
  880. // if (r == 9000) {
  881. // showToast('支付成功');
  882. // } else {
  883. // showToast(aliPayResultStatus(r));
  884. // resetOrder(newOrder.content.uID, context);
  885. // }
  886. // } catch (e) {
  887. // EasyLoading.dismiss();
  888. // }
  889. // });
  890. // // EventBus().emit('payAnOrder');
  891. // }
  892. // }, (e) {}, context);
  893. // // showToast('积分余额不足');
  894. // }
  895. // }
  896. // }, (e) {}, context);
  897. }
  898. void showSystemMessages(SystemInformationBeanEntity arg) {
  899. EasyLoading.instance
  900. ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
  901. ..alignment = Alignment.center
  902. ..loadingStyle = EasyLoadingStyle.custom
  903. ..backgroundColor = Colors.transparent
  904. ..indicatorColor = Colors.black
  905. ..progressColor = Colors.black
  906. ..maskColor = Colors.black
  907. ..textColor = Colors.black
  908. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  909. EasyLoading.show(
  910. indicator: Material(
  911. color: Colors.transparent,
  912. child: Container(
  913. decoration: BoxDecoration(
  914. borderRadius: BorderRadius.circular(16),
  915. ),
  916. height: MediaQuery.of(buildContext).size.height - 200,
  917. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  918. child: Column(
  919. children: [
  920. Expanded(child: Container()),
  921. Container(
  922. decoration: BoxDecoration(
  923. color: Colors.white,
  924. borderRadius: BorderRadius.circular(16),
  925. ),
  926. child: Column(
  927. children: [
  928. Container(
  929. child: Text(
  930. '系统消息',
  931. style: TextStyle(
  932. color: MyColors.c333333,
  933. fontSize: 14,
  934. fontWeight: FontWeight.bold),
  935. ),
  936. margin:
  937. EdgeInsets.symmetric(horizontal: 26, vertical: 15),
  938. ),
  939. Container(
  940. child: Text(
  941. arg.content.content,
  942. style: TextStyle(color: MyColors.c333333, fontSize: 14),
  943. ),
  944. margin: EdgeInsets.symmetric(horizontal: 26),
  945. alignment: Alignment.centerLeft,
  946. ),
  947. Container(
  948. height: 0.5,
  949. color: MyColors.cE7E7E7,
  950. margin: EdgeInsets.only(bottom: 12, top: 12),
  951. ),
  952. GestureDetector(
  953. onTap: () {
  954. PopUpQueue().onShow = false;
  955. PopUpQueue().showNext();
  956. },
  957. behavior: HitTestBehavior.translucent,
  958. child: Container(
  959. width: 150,
  960. margin: EdgeInsets.only(bottom: 14),
  961. decoration: BoxDecoration(
  962. borderRadius: BorderRadius.circular(20),
  963. border:
  964. Border.all(color: MyColors.cFF4233, width: 1.1),
  965. color: Colors.white),
  966. child: MyViews().myText('我知道了', MyColors.cFF4233, 14),
  967. height: 40,
  968. alignment: Alignment.center,
  969. ),
  970. )
  971. ],
  972. ),
  973. ),
  974. Expanded(child: Container()),
  975. ],
  976. ),
  977. alignment: Alignment.center,
  978. ),
  979. ),
  980. );
  981. }
  982. //优惠券弹框
  983. void couponBulletBox(CouponBeanDataData data) {
  984. EasyLoading.instance
  985. ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
  986. ..alignment = Alignment.center
  987. ..loadingStyle = EasyLoadingStyle.custom
  988. ..backgroundColor = Colors.transparent
  989. ..indicatorColor = Colors.black
  990. ..progressColor = Colors.black
  991. ..maskColor = Colors.black
  992. ..textColor = Colors.black
  993. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  994. EasyLoading.show(
  995. indicator: Material(
  996. color: Colors.transparent,
  997. child: Stack(
  998. children: [
  999. Image.asset(
  1000. 'images/优惠券.png',
  1001. height: 640,
  1002. width: double.infinity,
  1003. ),
  1004. Container(
  1005. height: 640,
  1006. margin: EdgeInsets.only(top: 24),
  1007. child: Column(
  1008. children: [
  1009. Container(
  1010. margin: EdgeInsets.only(bottom: 5),
  1011. child: Text(
  1012. '抢红包啦',
  1013. style: TextStyle(
  1014. color: Colors.white,
  1015. fontSize: 24,
  1016. fontWeight: FontWeight.bold,
  1017. shadows: [
  1018. Shadow(
  1019. offset: Offset(1.0, 1.0),
  1020. blurRadius: 3.0,
  1021. color: MyColors.cDC1717,
  1022. )
  1023. ]),
  1024. ),
  1025. ),
  1026. Container(
  1027. decoration: BoxDecoration(
  1028. color: Colors.white,
  1029. borderRadius: BorderRadius.circular(8),
  1030. ),
  1031. height: 107,
  1032. width: double.infinity,
  1033. margin: EdgeInsets.symmetric(horizontal: 25, vertical: 27),
  1034. child: Column(
  1035. children: [
  1036. Text(
  1037. '平台红包大放送!',
  1038. style: TextStyle(
  1039. color: MyColors.c333333,
  1040. fontSize: 16,
  1041. fontWeight: FontWeight.bold),
  1042. ),
  1043. Text(
  1044. '立即去抢最高${data.max}元消费红包',
  1045. style: TextStyle(
  1046. color: MyColors.cFF4233,
  1047. fontSize: 14,
  1048. fontWeight: FontWeight.bold),
  1049. ),
  1050. Text(
  1051. '活动时间${data.distributeFromDate}至${data.distributeEndDate}',
  1052. style: TextStyle(
  1053. color: MyColors.c666666,
  1054. fontSize: 11,
  1055. fontWeight: FontWeight.bold),
  1056. ),
  1057. ],
  1058. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  1059. crossAxisAlignment: CrossAxisAlignment.start,
  1060. ),
  1061. padding: EdgeInsets.symmetric(horizontal: 26),
  1062. ),
  1063. Container(
  1064. margin: EdgeInsets.symmetric(horizontal: 25),
  1065. child: Row(
  1066. children: [
  1067. Expanded(
  1068. child: GestureDetector(
  1069. onTap: () {
  1070. EasyLoading.dismiss();
  1071. },
  1072. behavior: HitTestBehavior.translucent,
  1073. child: Container(
  1074. height: 34,
  1075. decoration: BoxDecoration(
  1076. borderRadius: BorderRadius.only(
  1077. topLeft: Radius.circular(17),
  1078. bottomLeft: Radius.circular(17),
  1079. ),
  1080. border: Border.all(
  1081. color: MyColors.cFFB455, width: 1),
  1082. color: Colors.white),
  1083. child: Text(
  1084. '我已参与',
  1085. style: TextStyle(
  1086. color: MyColors.cFFB455,
  1087. fontSize: 14,
  1088. ),
  1089. ),
  1090. alignment: Alignment.center,
  1091. ),
  1092. ),
  1093. ),
  1094. Expanded(
  1095. child: GestureDetector(
  1096. onTap: () {
  1097. grabACoupon(data.id);
  1098. },
  1099. behavior: HitTestBehavior.translucent,
  1100. child: Container(
  1101. height: 34,
  1102. decoration: BoxDecoration(
  1103. borderRadius: BorderRadius.only(
  1104. topRight: Radius.circular(17),
  1105. bottomRight: Radius.circular(17),
  1106. ),
  1107. color: MyColors.cFFB455),
  1108. child: Text(
  1109. '立即去抢',
  1110. style: TextStyle(
  1111. color: Colors.white,
  1112. fontSize: 14,
  1113. ),
  1114. ),
  1115. alignment: Alignment.center,
  1116. ),
  1117. ),
  1118. ),
  1119. ],
  1120. ),
  1121. )
  1122. ],
  1123. mainAxisAlignment: MainAxisAlignment.center,
  1124. ),
  1125. alignment: Alignment.center,
  1126. )
  1127. ],
  1128. ),
  1129. ),
  1130. );
  1131. }
  1132. }
  1133. class FallbackCupertinoLocalisationsDelegate
  1134. extends LocalizationsDelegate<CupertinoLocalizations> {
  1135. const FallbackCupertinoLocalisationsDelegate();
  1136. @override
  1137. bool isSupported(Locale locale) => true;
  1138. @override
  1139. Future<CupertinoLocalizations> load(Locale locale) =>
  1140. DefaultCupertinoLocalizations.load(locale);
  1141. @override
  1142. bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
  1143. }