main.dart 45 KB

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