main.dart 50 KB

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