Browse Source

Merge branch 'master' into dev

master
w-R 3 years ago
parent
commit
cb6bbaca78
  1. 13
      lib/login/login_page.dart
  2. 15
      lib/main_page.dart
  3. 8
      lib/retrofit/min_api.dart
  4. 9
      lib/retrofit/retrofit_api.dart
  5. 25
      lib/store/store_order.dart
  6. 8
      lib/view_widget/login_tips_dialog.dart

13
lib/login/login_page.dart

@ -83,6 +83,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
double offsetBtn = 0; double offsetBtn = 0;
double rota = 1.04; double rota = 1.04;
Image image; Image image;
buildImageInfo(BuildContext context) async { buildImageInfo(BuildContext context) async {
image = Image.asset("assets/image/laoban.png"); image = Image.asset("assets/image/laoban.png");
double screenWidth = MediaQuery.of(this.context).size.width; double screenWidth = MediaQuery.of(this.context).size.width;
@ -94,8 +95,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
if ((width / screenWidth) < rota) { if ((width / screenWidth) < rota) {
rota = (screenWidth * 1.04) / width; rota = (screenWidth * 1.04) / width;
} }
if (mounted) if (mounted) setState(() {});
setState(() {});
})); }));
} }
@ -308,8 +308,10 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
saveUserJson(value.data); saveUserJson(value.data);
eventBus.fire(EventType(3)); eventBus.fire(EventType(3));
Navigator.of(context) Navigator.of(context).pushNamedAndRemoveUntil(
.pushNamedAndRemoveUntil('/router/main_page', (route) => false); '/router/main_page',
(route) => false,
);
} else { } else {
SmartDialog.showToast("${value.msg}", alignment: Alignment.center); SmartDialog.showToast("${value.msg}", alignment: Alignment.center);
} }
@ -379,10 +381,9 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
try { try {
buildImageInfo(this.context); buildImageInfo(this.context);
} catch(ex) {} } catch (ex) {}
if (animatedContainer != null && !animatedContainer.isAnimating) { if (animatedContainer != null && !animatedContainer.isAnimating) {
animatedContainer.forward(); animatedContainer.forward();

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;

8
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';
@ -96,17 +97,12 @@ abstract class MinApiService {
} }
static void p(String msg) { static void p(String msg) {
//String的length是字符数量不是字节数量所以为了防止中文字符过多
// 4*1024MAX字节打印长度改为1000字符数
int maxStrLength = 900; int maxStrLength = 900;
//1000
while (msg.length > maxStrLength) { while (msg.length > maxStrLength) {
debugPrint(msg.substring(0, maxStrLength)); debugPrint(msg.substring(0, maxStrLength));
msg = msg.substring(maxStrLength); msg = msg.substring(maxStrLength);
} }
// debugPrint(msg);
print(msg);
} }
} }

9
lib/retrofit/retrofit_api.dart

@ -89,7 +89,10 @@ abstract class ApiService {
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
debugPrint("code = ${response.statusCode}"); debugPrint("code = ${response.statusCode}");
p(jsonEncode(response.data)); // p(jsonEncode(response.data));
debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length);
Map map = response.data; Map map = response.data;
if (map["code"] != 0) { if (map["code"] != 0) {
EasyLoading.dismiss(); EasyLoading.dismiss();
@ -274,11 +277,11 @@ abstract class ApiService {
@GET("/home/brand") @GET("/home/brand")
Future<BaseData> queryHomeBrand(); Future<BaseData> queryHomeBrand();
/// ///
@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);

25
lib/store/store_order.dart

@ -7,6 +7,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';
@ -37,6 +39,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;
@ -65,6 +68,26 @@ class _StoreOrderPage extends State<StoreOrderPage>
queryStoreInfo(); queryStoreInfo();
} }
///
minLogin() {
apiService.minLogin(widget.arguments["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,6 +96,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
token: value.getString('token'), token: value.getString('token'),
); );
minLogin();
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