Browse Source

Merge branch 'master' into dev

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

11
lib/login/login_page.dart

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

15
lib/main_page.dart

@ -111,7 +111,9 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
SharedPreferences.getInstance().then((value) {
value.setString("pushData", customContent);
});
}));
},
),
);
}
/// @typed: 1 2 3 4 5
@ -147,8 +149,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
}, xgPushDidBindWithIdentifier: (event) async {
print("xgPushDidBindWithIdentifier: ${event.toString()}");
return event;
}
);
});
}
pushRoute() async {
@ -203,9 +204,11 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
if (sharedPreferences.getString("token") == null ||
sharedPreferences.getString("token") == "") return;
BaseData<UserInfo> baseDate = await ApiService(Dio(),
context: context, token: sharedPreferences.getString('token'))
.queryInfo();
BaseData<UserInfo> baseDate = await ApiService(
Dio(),
context: context,
token: sharedPreferences.getString('token'),
).queryInfo().catchError((onError) {});
sharedPreferences.setString('user', jsonEncode(baseDate.data));
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_smart_dialog/flutter_smart_dialog.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:retrofit/retrofit.dart';
@ -96,17 +97,12 @@ abstract class MinApiService {
}
static void p(String msg) {
//String的length是字符数量不是字节数量所以为了防止中文字符过多
// 4*1024MAX字节打印长度改为1000字符数
int maxStrLength = 900;
//1000
while (msg.length > maxStrLength) {
debugPrint(msg.substring(0, maxStrLength));
msg = msg.substring(maxStrLength);
}
//
print(msg);
debugPrint(msg);
}
}

7
lib/retrofit/retrofit_api.dart

@ -89,7 +89,10 @@ abstract class ApiService {
EasyLoading.dismiss();
}
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;
if (map["code"] != 0) {
EasyLoading.dismiss();
@ -278,7 +281,7 @@ abstract class ApiService {
@GET("/auth/mini/login/{storeId}")
Future<BaseData> minLogin(@Path("storeId") String storeId);
///
///
@POST("/member/listBill")
Future<BaseData<PageInfo<UserBill>>> queryBillInfo(
@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/base_data.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/store/store_view/store_activity.dart';
import 'package:huixiang/store/store_view/store_info.dart';
@ -37,6 +39,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin */ {
TabController tabcontroller;
ApiService apiService;
MinApiService minService;
StoreInfo storeInfo;
RefreshController refreshController;
List<Widget> _widgetOptions;
@ -65,6 +68,26 @@ class _StoreOrderPage extends State<StoreOrderPage>
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 {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
@ -73,6 +96,8 @@ class _StoreOrderPage extends State<StoreOrderPage>
token: value.getString('token'),
);
minLogin();
BaseData baseData = await apiService
.queryStoreInfo(widget.arguments["id"])
.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';
class LoginTipsDialog {
static LoginTipsDialog _instance;
factory LoginTipsDialog() {
@ -33,8 +32,10 @@ class LoginTipsDialog {
value.setString("mobile", "");
value.setString("nick", "");
});
Navigator.of(context).pushNamed('/router/login_page',
arguments: {"login": "login"});
Navigator.of(context).pushNamed(
'/router/login_page',
arguments: {"login": "login"},
);
},
),
onDismiss: () {
@ -43,5 +44,4 @@ class LoginTipsDialog {
clickBgDismissTemp: false,
);
}
}
Loading…
Cancel
Save