Browse Source

safety

master
fmk 3 years ago
parent
commit
1a2ebdb20b
  1. 15
      lib/main_page.dart
  2. 2
      lib/retrofit/min_api.dart
  3. 2
      lib/retrofit/retrofit_api.dart
  4. 24
      lib/store/store_order.dart
  5. 8
      lib/view_widget/login_tips_dialog.dart

15
lib/main_page.dart

@ -111,7 +111,9 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
SharedPreferences.getInstance().then((value) { SharedPreferences.getInstance().then((value) {
value.setString("pushData", customContent); value.setString("pushData", customContent);
}); });
})); },
),
);
} }
/// @typed: 1 2 3 4 5 /// @typed: 1 2 3 4 5
@ -147,8 +149,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
}, xgPushDidBindWithIdentifier: (event) async { }, xgPushDidBindWithIdentifier: (event) async {
print("xgPushDidBindWithIdentifier: ${event.toString()}"); print("xgPushDidBindWithIdentifier: ${event.toString()}");
return event; return event;
} });
);
} }
pushRoute() async { pushRoute() async {
@ -203,9 +204,11 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getString("token") == null || if (sharedPreferences.getString("token") == null ||
sharedPreferences.getString("token") == "") return; sharedPreferences.getString("token") == "") return;
BaseData<UserInfo> baseDate = await ApiService(Dio(), BaseData<UserInfo> baseDate = await ApiService(
context: context, token: sharedPreferences.getString('token')) Dio(),
.queryInfo(); context: context,
token: sharedPreferences.getString('token'),
).queryInfo().catchError((onError) {});
sharedPreferences.setString('user', jsonEncode(baseDate.data)); sharedPreferences.setString('user', jsonEncode(baseDate.data));
String mobile = baseDate.data.phone; String mobile = baseDate.data.phone;

2
lib/retrofit/min_api.dart

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:retrofit/retrofit.dart'; import 'package:retrofit/retrofit.dart';
@ -108,5 +109,4 @@ abstract class MinApiService {
print(msg); print(msg);
} }
} }

2
lib/retrofit/retrofit_api.dart

@ -278,7 +278,7 @@ abstract class ApiService {
@GET("/auth/mini/login/{storeId}") @GET("/auth/mini/login/{storeId}")
Future<BaseData> minLogin(@Path("storeId") String storeId); Future<BaseData> minLogin(@Path("storeId") String storeId);
/// ///
@POST("/member/listBill") @POST("/member/listBill")
Future<BaseData<PageInfo<UserBill>>> queryBillInfo( Future<BaseData<PageInfo<UserBill>>> queryBillInfo(
@Body() Map<String, dynamic> param); @Body() Map<String, dynamic> param);

24
lib/store/store_order.dart

@ -8,6 +8,8 @@ import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/activity.dart';
import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/retrofit/data/user_entity.dart';
import 'package:huixiang/retrofit/min_api.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/store/store_view/store_activity.dart'; import 'package:huixiang/store/store_view/store_activity.dart';
import 'package:huixiang/store/store_view/store_info.dart'; import 'package:huixiang/store/store_view/store_info.dart';
@ -38,6 +40,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin */ { with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin */ {
TabController tabcontroller; TabController tabcontroller;
ApiService apiService; ApiService apiService;
MinApiService minService;
StoreInfo storeInfo; StoreInfo storeInfo;
RefreshController refreshController; RefreshController refreshController;
List<Widget> _widgetOptions; List<Widget> _widgetOptions;
@ -63,9 +66,29 @@ class _StoreOrderPage extends State<StoreOrderPage>
), ),
]; ];
minLogin();
queryStoreInfo(); queryStoreInfo();
} }
minLogin() {
apiService.minLogin(storeInfo.id)
.catchError((onError){}).then((baseData) {
if (baseData != null && baseData.isSuccess) {
UserEntity userEntity = UserEntity.fromJson(baseData.data);
String minToken = userEntity.token;
SharedPreferences.getInstance().then((value) => {
value.setString('minToken', minToken),
});
minService = MinApiService(
Dio(),
context: context,
token: minToken,
);
}
});
}
queryStoreInfo() async { queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance(); final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService( apiService = ApiService(
@ -73,7 +96,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
context: context, context: context,
token: value.getString('token'), token: value.getString('token'),
); );
BaseData baseData = await apiService BaseData baseData = await apiService
.queryStoreInfo(widget.arguments["id"]) .queryStoreInfo(widget.arguments["id"])
.catchError((error) { .catchError((error) {

8
lib/view_widget/login_tips_dialog.dart

@ -5,7 +5,6 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'login_tips.dart'; import 'login_tips.dart';
class LoginTipsDialog { class LoginTipsDialog {
static LoginTipsDialog _instance; static LoginTipsDialog _instance;
factory LoginTipsDialog() { factory LoginTipsDialog() {
@ -33,8 +32,10 @@ class LoginTipsDialog {
value.setString("mobile", ""); value.setString("mobile", "");
value.setString("nick", ""); value.setString("nick", "");
}); });
Navigator.of(context).pushNamed('/router/login_page', Navigator.of(context).pushNamed(
arguments: {"login": "login"}); '/router/login_page',
arguments: {"login": "login"},
);
}, },
), ),
onDismiss: () { onDismiss: () {
@ -43,5 +44,4 @@ class LoginTipsDialog {
clickBgDismissTemp: false, clickBgDismissTemp: false,
); );
} }
} }
Loading…
Cancel
Save