Browse Source

safety

master
fmk 3 years ago
parent
commit
6201ef03a4
  1. 19
      lib/login/login_page.dart
  2. 8
      lib/retrofit/min_api.dart
  3. 5
      lib/retrofit/retrofit_api.dart
  4. 9
      lib/store/store_order.dart

19
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(() {});
})); }));
} }
@ -129,9 +129,9 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
changeAlpha = (changeAlpha > 255 ? 255 : changeAlpha); changeAlpha = (changeAlpha > 255 ? 255 : changeAlpha);
changeAlpha = (changeAlpha < 0 ? 0 : changeAlpha); changeAlpha = (changeAlpha < 0 ? 0 : changeAlpha);
alpha = (initAlpha + alpha = (initAlpha +
scrollController.offset / scrollController.offset /
(height - chaHeight) * (height - chaHeight) *
(255 - initAlpha)) (255 - initAlpha))
.toInt(); .toInt();
alpha = (alpha > 255 ? 255 : alpha); alpha = (alpha > 255 ? 255 : alpha);
alpha = (alpha < 0 ? 0 : alpha); alpha = (alpha < 0 ? 0 : alpha);
@ -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();

8
lib/retrofit/min_api.dart

@ -97,16 +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);
} }
} }

5
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();

9
lib/store/store_order.dart

@ -65,13 +65,12 @@ class _StoreOrderPage extends State<StoreOrderPage>
), ),
]; ];
minLogin();
queryStoreInfo(); queryStoreInfo();
} }
///
minLogin() { minLogin() {
apiService.minLogin(storeInfo.id) apiService.minLogin(widget.arguments["id"])
.catchError((onError){}).then((baseData) { .catchError((onError){}).then((baseData) {
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
UserEntity userEntity = UserEntity.fromJson(baseData.data); UserEntity userEntity = UserEntity.fromJson(baseData.data);
@ -88,6 +87,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
}); });
} }
///
queryStoreInfo() async { queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance(); final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService( apiService = ApiService(
@ -95,6 +95,9 @@ class _StoreOrderPage extends State<StoreOrderPage>
context: context, context: context,
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) {

Loading…
Cancel
Save