From 1f1db4acf1e6ba1c5d3455deb5816424a3f14109 Mon Sep 17 00:00:00 2001 From: fmk Date: Wed, 25 Aug 2021 13:44:55 +0800 Subject: [PATCH 1/3] safety --- lib/home/activity_list_page.dart | 41 ++++++++++++---------------- lib/login/login_page.dart | 4 --- lib/main_page.dart | 31 +++++++++++++-------- lib/retrofit/retrofit_api.dart | 6 ++-- lib/view_widget/store_title_tab.dart | 1 + 5 files changed, 43 insertions(+), 40 deletions(-) diff --git a/lib/home/activity_list_page.dart b/lib/home/activity_list_page.dart index cbb45354..dfe9a4ec 100644 --- a/lib/home/activity_list_page.dart +++ b/lib/home/activity_list_page.dart @@ -70,25 +70,20 @@ class _ActivityListPage extends State Widget build(BuildContext context) { super.build(context); return Container( - child: SizeCacheWidget( - child: SmartRefresher( - controller: _refreshController, - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - physics: BouncingScrollPhysics(), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: () { - setState(() {}); - }, - child: FutureBuilder( - future: queryActivity(), - builder: (context, snapshot) { - return ListView.builder( + child: FutureBuilder( + future: queryActivity(), + builder: (context, snapshot) { + return SizeCacheWidget( + child: SmartRefresher( + controller: _refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: BouncingScrollPhysics(), + onRefresh: () { + setState(() {}); + }, + child: ListView.builder( itemCount: activityList == null ? 0 : activityList.length, physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { @@ -121,10 +116,10 @@ class _ActivityListPage extends State ), ); }, - ); - }, - ) - ), + ), + ), + ); + }, ), ); } diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index a8e1087c..2cb39be3 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -286,10 +286,6 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { saveUserJson(value.data); eventBus.fire(EventType(3)); - xgFlutterPlugin.setAccount(mobile, AccountType.CUSTOM); - xgFlutterPlugin.bindWithIdentifier( - identify: mobile, bindType: XGBindType.account); - Navigator.of(context) .pushNamedAndRemoveUntil('/router/main_page', (route) => false); } else { diff --git a/lib/main_page.dart b/lib/main_page.dart index 9bb26082..d99ac398 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -9,6 +9,7 @@ import 'package:huixiang/home/main_home_page.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/mine/mine_page.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/user_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/union/union_page.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -17,6 +18,7 @@ import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/utils/native_event_handler.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; class MainPage extends StatefulWidget { @override @@ -58,11 +60,10 @@ class _MainPage extends State with WidgetsBindingObserver { super.initState(); WidgetsBinding.instance.addObserver(this); - EasyLoading.instance ..indicatorType = EasyLoadingIndicatorType.circle - // ..indicatorType = EasyLoadingIndicatorType.wave - // ..indicatorType = EasyLoadingIndicatorType.threeBounce + // ..indicatorType = EasyLoadingIndicatorType.wave + // ..indicatorType = EasyLoadingIndicatorType.threeBounce ..loadingStyle = EasyLoadingStyle.dark ..indicatorSize = 35.0 ..backgroundColor = Colors.white @@ -71,7 +72,6 @@ class _MainPage extends State with WidgetsBindingObserver { ..userInteractions = false ..dismissOnTap = false; - pushRoute(); _widgetOptions = [ @@ -122,12 +122,15 @@ class _MainPage extends State with WidgetsBindingObserver { : (event["xg"]["msgtype"] == 1) && event[Platform.isAndroid ? "customMessage" : "custom"] != null) { SharedPreferences.getInstance().then((value) { - value.setString("pushData", event[Platform.isAndroid ? "customMessage" : "custom"]); + value.setString("pushData", + event[Platform.isAndroid ? "customMessage" : "custom"]); }); - if (ModalRoute.of(context).isActive && ModalRoute.of(context).isCurrent) { + if (ModalRoute.of(context).isActive && + ModalRoute.of(context).isCurrent) { pushRoute(); } else { - Navigator.of(context).pushNamedAndRemoveUntil('/router/main_page', (route) => false); + Navigator.of(context) + .pushNamedAndRemoveUntil('/router/main_page', (route) => false); } } return event; @@ -192,10 +195,17 @@ class _MainPage extends State with WidgetsBindingObserver { SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); if (sharedPreferences.getString("token") == null || sharedPreferences.getString("token") == "") return; - BaseData baseDate = await ApiService(Dio(), + BaseData baseDate = await ApiService(Dio(), context: context, token: sharedPreferences.getString('token')) .queryInfo(); sharedPreferences.setString('user', jsonEncode(baseDate.data)); + + String mobile = baseDate.data.phone; + if (mobile != null && mobile != "") { + xgFlutterPlugin.setAccount(mobile, AccountType.UNKNOWN); + xgFlutterPlugin.bindWithIdentifier( + identify: mobile, bindType: XGBindType.account); + } } requestPermission() async { @@ -234,9 +244,8 @@ class _MainPage extends State with WidgetsBindingObserver { spreadRadius: 0, ) ], - borderRadius: BorderRadius.only( - topRight: Radius.circular(4), - topLeft: Radius.circular(4), + borderRadius: BorderRadius.vertical( + top: Radius.circular(4), ), ), height: 82.h, diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index a14d01cc..1fc6bc96 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -38,9 +38,11 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +const base_url = "http://192.168.10.236:8766/app/"; +const baseUrl = "http://192.168.10.236:8766/app/"; @RestApi(baseUrl: baseUrl) abstract class ApiService { diff --git a/lib/view_widget/store_title_tab.dart b/lib/view_widget/store_title_tab.dart index 543999a4..e8155750 100644 --- a/lib/view_widget/store_title_tab.dart +++ b/lib/view_widget/store_title_tab.dart @@ -140,6 +140,7 @@ class _StoreTitleTab extends State { child: SingleChildScrollView( scrollDirection: Axis.horizontal, controller: scrollController, + physics: BouncingScrollPhysics(), child: Container( height: 52.h, constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width), From d8c6839c9059edd811ad36dacc67279614eb50ae Mon Sep 17 00:00:00 2001 From: fmk Date: Wed, 25 Aug 2021 13:50:32 +0800 Subject: [PATCH 2/3] safety --- lib/retrofit/retrofit_api.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 1fc6bc96..5fb8d307 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -38,11 +38,11 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -const base_url = "http://192.168.10.236:8766/app/"; -const baseUrl = "http://192.168.10.236:8766/app/"; +// const base_url = "http://192.168.10.236:8766/app/"; +// const baseUrl = "http://192.168.10.236:8766/app/"; @RestApi(baseUrl: baseUrl) abstract class ApiService { From d7da3a5a6e04e59a4913b58578d74fa656d6df21 Mon Sep 17 00:00:00 2001 From: fmk Date: Wed, 25 Aug 2021 18:46:16 +0800 Subject: [PATCH 3/3] safety --- lib/main_page.dart | 12 ++++++++++-- lib/mine/mine_page.dart | 8 ++++---- lib/retrofit/retrofit_api.dart | 3 +++ lib/union/store_details_page.dart | 2 +- lib/union/union_details_page.dart | 32 ++++++++++++++++--------------- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/lib/main_page.dart b/lib/main_page.dart index d99ac398..7c82ca14 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -140,7 +140,14 @@ class _MainPage extends State with WidgetsBindingObserver { }, onReceiveMessage: (event) async { print("onReceiveMessage: ${event.toString()}"); return event; - }); + }, onRegisteredDone: (event) async { + print("onRegisteredDone: ${event.toString()}"); + return event; + }, xgPushDidBindWithIdentifier: (event) async { + print("xgPushDidBindWithIdentifier: ${event.toString()}"); + return event; + } + ); } pushRoute() async { @@ -202,7 +209,8 @@ class _MainPage extends State with WidgetsBindingObserver { String mobile = baseDate.data.phone; if (mobile != null && mobile != "") { - xgFlutterPlugin.setAccount(mobile, AccountType.UNKNOWN); + xgFlutterPlugin.setAccount(mobile, AccountType.PHONE_NUMBER); + // xgFlutterPlugin.unbindWithIdentifier(identify: mobile, bindType: XGBindType.account) xgFlutterPlugin.bindWithIdentifier( identify: mobile, bindType: XGBindType.account); } diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index fb41cb92..b819c370 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -43,7 +43,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { return; } await Navigator.of(context).pushNamed('/router/user_info_page'); - queryUserInfo(); + setState(() {});; } loginTips() { @@ -76,7 +76,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { setState(() {}); } if (event.type == 3) { - queryUserInfo(); + setState(() {});; } }); } @@ -559,7 +559,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { Widget mineView() { return Container( alignment: Alignment.center, - margin: EdgeInsets.only(left: 16.w, right: 16.w), + margin: EdgeInsets.symmetric(horizontal: 16.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, @@ -700,7 +700,7 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { return; } await Navigator.of(context).pushNamed('/router/integral_page'); - queryUserInfo(); + setState(() {});; } @override diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 5fb8d307..c38538eb 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -44,6 +44,9 @@ const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 // const base_url = "http://192.168.10.236:8766/app/"; // const baseUrl = "http://192.168.10.236:8766/app/"; +// const base_url = "http://192.168.10.74:8766/app/"; +// const baseUrl = "http://192.168.10.74:8766/app/"; + @RestApi(baseUrl: baseUrl) abstract class ApiService { factory ApiService(Dio dio, diff --git a/lib/union/store_details_page.dart b/lib/union/store_details_page.dart index d278e59e..5e791df4 100644 --- a/lib/union/store_details_page.dart +++ b/lib/union/store_details_page.dart @@ -355,7 +355,7 @@ class _StoreDetailsPage extends State children: [ InkWell( child: Text( - "${activity != null ? activity.storeName : (article != null && article.author != null) ? article.author.name : ""}", + "${activity != null ? (activity.storeName ?? "") : (article != null && article.author != null) ? (article.author.name ?? "") : ""}", style: TextStyle( fontWeight: FontWeight.normal, fontSize: 14.sp, diff --git a/lib/union/union_details_page.dart b/lib/union/union_details_page.dart index ede3546d..5c06cdfb 100644 --- a/lib/union/union_details_page.dart +++ b/lib/union/union_details_page.dart @@ -78,18 +78,20 @@ class _UnionDetailsPage extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: MyAppBar( - background: Color(0xFFF7F7F7), - title: storeInfo == null ? widget.arguments["storeName"] : storeInfo.storeName, - titleColor: Colors.black87, - titleSize: 18.sp, - leadingColor: Colors.black, - ), - body: FutureBuilder( - future: queryStoreInfo(), - builder: (context, snapshot) { - return Column( + return FutureBuilder( + future: queryStoreInfo(), + builder: (context, snapshot) { + return Scaffold( + appBar: MyAppBar( + background: Color(0xFFF7F7F7), + title: storeInfo == null + ? (widget.arguments["storeName"] ?? "") + : storeInfo.storeName, + titleColor: Colors.black87, + titleSize: 18.sp, + leadingColor: Colors.black, + ), + body: Column( children: [ Expanded( child: SmartRefresher( @@ -356,9 +358,9 @@ class _UnionDetailsPage extends State { ), ), ], - ); - }, - ), + ), + ); + }, ); }