main.dart 50 KB

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