main.dart 45 KB

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