main.dart 46 KB

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