main.dart 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  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 {
  203. print('Clipboard-----\n${text.text}');
  204. clipboardT = text.text;
  205. Clipboard.setData(ClipboardData(text: ''));
  206. getOnlineTemplate();
  207. } catch (e) {
  208. PopUpQueue().onShow = false;
  209. PopUpQueue().showNext();
  210. }
  211. }
  212. //获取线上模板
  213. void getOnlineTemplate() {
  214. MyDio().query({
  215. 'key': 'order_template',
  216. "dims": ["id", "sid", "template"],
  217. "filters": {}
  218. }, (response, hasError) {
  219. if (!hasError) {
  220. TemplateBeanEntity entity = TemplateBeanEntity()
  221. .fromJson(json.decode(response.data.toString()));
  222. checkOrder(entity.data);
  223. } else {
  224. PopUpQueue().onShow = false;
  225. PopUpQueue().showNext();
  226. }
  227. }, (error) {
  228. PopUpQueue().onShow = false;
  229. PopUpQueue().showNext();
  230. });
  231. }
  232. var orderHash;
  233. //匹配模板去除不是自己的订单
  234. void checkOrder(List<TemplateBeanData> data) {
  235. bool hasMatch = false;
  236. w:
  237. for (int i = 0; i < data.length; i++) {
  238. try {
  239. var res = parseString2(
  240. data[i].template.replaceAll('\r', ''), '''$clipboardT''');
  241. if (res != null) {
  242. print(data[i].template);
  243. print(json.encode(res));
  244. var order = parse2(res);
  245. order.removeWhere((element) =>
  246. !element.seller.name
  247. .contains(MyCookie().loginInformation.data.extra.name) &&
  248. !MyCookie()
  249. .loginInformation
  250. .data
  251. .extra
  252. .name
  253. .contains(element.seller.name));
  254. if (order.length > 0) {
  255. hasMatch = true;
  256. orderHash = computeOrderHash(res);
  257. getShop(order);
  258. }
  259. break w;
  260. }
  261. } catch (e) {}
  262. }
  263. if (!hasMatch) {
  264. PopUpQueue().onShow = false;
  265. PopUpQueue().showNext();
  266. }
  267. }
  268. //订单视图
  269. items(List<OrderInfo2> order) {
  270. List<Widget> items = [];
  271. order.forEach((element) {
  272. items.add(Container(
  273. child: Column(
  274. children: [
  275. Row(
  276. children: [
  277. Container(
  278. margin: EdgeInsets.only(left: 8, right: 7),
  279. child: ClipRRect(
  280. child: MyViews().netImg(
  281. imgURL(MyCookie().loginInformation.data.extra.picture),
  282. 35,
  283. 35),
  284. borderRadius: BorderRadius.circular(17.5),
  285. ),
  286. ),
  287. Expanded(
  288. child: Container(
  289. height: 35,
  290. child: Column(
  291. children: [
  292. Text(
  293. '付款人:${element.payer.name}',
  294. style: TextStyle(
  295. color: MyColors.c333333,
  296. fontSize: 13,
  297. decoration: TextDecoration.none,
  298. ),
  299. ),
  300. Text(
  301. '订单时间:${element.time}',
  302. style: TextStyle(
  303. color: MyColors.c666666,
  304. fontSize: 10,
  305. decoration: TextDecoration.none,
  306. ),
  307. ),
  308. ],
  309. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  310. crossAxisAlignment: CrossAxisAlignment.start,
  311. ),
  312. ),
  313. ),
  314. Container(
  315. margin: EdgeInsets.only(right: 10),
  316. child: Text(
  317. '¥${(element.payer.amount * element.factor).toStringAsFixed(2)}',
  318. style: TextStyle(
  319. color: MyColors.cFF4233,
  320. fontSize: 14,
  321. decoration: TextDecoration.none,
  322. ),
  323. ),
  324. ),
  325. ],
  326. crossAxisAlignment: CrossAxisAlignment.center,
  327. ),
  328. Container(
  329. height: 0.5,
  330. margin: EdgeInsets.only(right: 10, left: 50, top: 5),
  331. color: MyColors.cE7E7E7,
  332. )
  333. ],
  334. ),
  335. margin: EdgeInsets.only(top: 5),
  336. ));
  337. });
  338. return items;
  339. }
  340. //获取用户所在店铺
  341. void getShop(List<OrderInfo2> order) {
  342. shopIndex = 0;
  343. MyDio().query({
  344. "key": "shop_user",
  345. "filters": {
  346. "or": true,
  347. "conditions": [
  348. "role!=0",
  349. "user_uid==${MyCookie().getUID()}",
  350. "review_state==1"
  351. ],
  352. "filters": [
  353. {
  354. "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
  355. }
  356. ]
  357. },
  358. "dims": shopUserDims,
  359. "paging": [1, 20000]
  360. }, (response, hasError) {
  361. if (!hasError) {
  362. MyShopBeanEntity entity =
  363. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  364. shops = entity.data.data;
  365. shops.removeWhere((element) => !element.privateShop);
  366. if (shops.length == 0) {
  367. showToast('你还没有添加任何货帮,暂时不能发送智能订单');
  368. PopUpQueue().onShow = false;
  369. PopUpQueue().showNext();
  370. } else {
  371. EasyLoading.instance
  372. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  373. ..alignment = Alignment.bottomCenter
  374. ..loadingStyle = EasyLoadingStyle.light
  375. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  376. EasyLoading.show(
  377. indicator: Material(
  378. color: Colors.white,
  379. child: StatefulBuilder(
  380. builder: (c, s) {
  381. ss = s;
  382. return Column(
  383. children: [
  384. Container(
  385. child: Stack(
  386. children: [
  387. Container(
  388. child: MyViews()
  389. .myText('智能订单', MyColors.c333333, 14),
  390. alignment: Alignment.center,
  391. height: 22,
  392. ),
  393. Positioned(
  394. right: 0,
  395. child: GestureDetector(
  396. onTap: () {
  397. PopUpQueue().onShow = false;
  398. PopUpQueue().showNext();
  399. },
  400. behavior: HitTestBehavior.translucent,
  401. child: Container(
  402. child: Icon(
  403. Icons.close,
  404. size: 20,
  405. color: Colors.white,
  406. ),
  407. decoration: BoxDecoration(
  408. color: MyColors.cB6B6B6,
  409. borderRadius: BorderRadius.circular(11)),
  410. height: 22,
  411. width: 22,
  412. ),
  413. ),
  414. )
  415. ],
  416. alignment: Alignment.center,
  417. ),
  418. height: 30,
  419. padding: EdgeInsets.symmetric(horizontal: 12),
  420. ),
  421. Container(
  422. height: 5,
  423. color: MyColors.cF7F7F7,
  424. margin: EdgeInsets.only(top: 10),
  425. ),
  426. Column(
  427. children: items(order),
  428. ),
  429. Container(
  430. height: 5,
  431. color: MyColors.cF7F7F7,
  432. margin: EdgeInsets.only(top: 10),
  433. ),
  434. Visibility(
  435. child: Column(
  436. children: [
  437. Container(
  438. child: MyViews()
  439. .myText('货帮选择', MyColors.c333333, 13),
  440. margin: EdgeInsets.only(left: 7, top: 11),
  441. ),
  442. Container(
  443. margin: EdgeInsets.symmetric(
  444. horizontal: 7, vertical: 10),
  445. height: (shops.length * 1.0 / 2).ceil() *
  446. (double.parse(
  447. '${MediaQuery.of(buildContext).size.width - 74}') /
  448. 2 /
  449. 3.8 +
  450. 10) -
  451. 10,
  452. child: GridView(
  453. gridDelegate:
  454. SliverGridDelegateWithFixedCrossAxisCount(
  455. crossAxisCount: 2, //横轴三个子widget
  456. childAspectRatio: 3.8,
  457. crossAxisSpacing: 10,
  458. mainAxisSpacing: 8 //宽高比为1时,子widget
  459. ),
  460. children: shop(shops),
  461. padding: EdgeInsets.all(0),
  462. ),
  463. ),
  464. ],
  465. crossAxisAlignment: CrossAxisAlignment.start,
  466. ),
  467. visible: shops.length != 1,
  468. ),
  469. Container(
  470. height: 0.5,
  471. color: MyColors.cF7F7F7,
  472. margin: EdgeInsets.only(bottom: 10),
  473. ),
  474. Container(
  475. child: GestureDetector(
  476. onTap: () {
  477. EventBus().on('saveOrder', (arg) {
  478. amountCompleted++;
  479. if (amountCompleted == order.length) {
  480. amountCompleted = 0;
  481. EasyLoading.dismiss();
  482. showToast('发送成功');
  483. clipboardT = '';
  484. EventBus().off('saveOrder');
  485. PopUpQueue().onShow = false;
  486. PopUpQueue().showNext();
  487. }
  488. });
  489. order.forEach((element) {
  490. sendOrder(element);
  491. });
  492. },
  493. behavior: HitTestBehavior.translucent,
  494. child: Container(
  495. decoration: BoxDecoration(
  496. color: MyColors.cFF4233,
  497. borderRadius: BorderRadius.circular(20),
  498. ),
  499. height: 40,
  500. width: 150,
  501. child: MyViews().myText('发送订单', Colors.white, 14),
  502. alignment: Alignment.center,
  503. ),
  504. ),
  505. alignment: Alignment.center,
  506. )
  507. ],
  508. mainAxisAlignment: MainAxisAlignment.start,
  509. crossAxisAlignment: CrossAxisAlignment.start,
  510. );
  511. },
  512. ),
  513. ),
  514. );
  515. }
  516. } else {
  517. PopUpQueue().onShow = false;
  518. PopUpQueue().showNext();
  519. }
  520. }, (error) {
  521. PopUpQueue().onShow = false;
  522. PopUpQueue().showNext();
  523. });
  524. }
  525. //店铺视图
  526. shop(List<MyShopBeanDataData> shops) {
  527. List<Widget> items = [];
  528. for (int i = 0; i < shops.length; i++) {
  529. items.add(GestureDetector(
  530. onTap: () {
  531. shopIndex = i;
  532. ss(() {});
  533. },
  534. behavior: HitTestBehavior.translucent,
  535. child: Container(
  536. child: Row(
  537. children: [
  538. Container(
  539. margin: EdgeInsets.only(right: 5),
  540. child: ClipRRect(
  541. child: MyViews().netImg(imgURL(shops[i].shopPic), 30, 30),
  542. borderRadius: BorderRadius.circular(15),
  543. ),
  544. ),
  545. Expanded(
  546. child: Column(
  547. children: [
  548. Text(
  549. shops[i].shopName,
  550. style: TextStyle(
  551. color: i == shopIndex
  552. ? MyColors.cFF4233
  553. : MyColors.c666666,
  554. fontSize: 12,
  555. ),
  556. maxLines: 1,
  557. overflow: TextOverflow.ellipsis,
  558. softWrap: true,
  559. ),
  560. Text(
  561. 'ID:${shops[i].shopUid}',
  562. style: TextStyle(
  563. color: i == shopIndex
  564. ? MyColors.cFF4233
  565. : MyColors.c666666,
  566. fontSize: 10,
  567. ),
  568. maxLines: 1,
  569. overflow: TextOverflow.ellipsis,
  570. softWrap: true,
  571. ),
  572. ],
  573. crossAxisAlignment: CrossAxisAlignment.start,
  574. ),
  575. ),
  576. ],
  577. ),
  578. decoration: BoxDecoration(
  579. color: i == shopIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
  580. borderRadius: BorderRadius.circular(4),
  581. ),
  582. constraints: BoxConstraints(maxWidth: 150),
  583. padding: EdgeInsets.symmetric(horizontal: 6, vertical: 6),
  584. ),
  585. ));
  586. }
  587. return items;
  588. }
  589. //发送订单
  590. void sendOrder(OrderInfo2 element) {
  591. MyDio().save({
  592. 'key': 'order',
  593. 'object': {
  594. 'uuid':orderHash,
  595. 'shop_uid': shops[shopIndex].shopUid,
  596. 'shop_pic': shops[shopIndex].shopPic,
  597. 'shop_name': shops[shopIndex].shopName,
  598. 'seller_pic': MyCookie().loginInformation.data.extra.picture,
  599. 'seller_uid': MyCookie().getUID(),
  600. 'seller_name': MyCookie().loginInformation.data.extra.name,
  601. 'buyer_name': element.payer.name,
  602. 'type': orderTypeThirdPlatform,
  603. 'amount': NumUtil.multiply(element.payer.amount, element.factor)
  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. newOrder.content.buyerPic==null?'images/svg/第三方.svg':'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(newOrder.content.buyerPic==null?'第三方订单':'线下付款', 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(newOrder.content.buyerPic==null?'':imgURL(newOrder.content.buyerPic), 23, 23),
  733. borderRadius: BorderRadius.circular(11.5),
  734. ),
  735. ),
  736. MyViews().myText('${newOrder.content.buyerName} ${newOrder.content.buyerUID!=null&&newOrder.content.buyerUID.toString().length>0?'(${newOrder.content.buyerUID})':''}',
  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. }