main.dart 50 KB

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