main.dart 51 KB

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