main.dart 50 KB

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