修改登陆页面
parent
3eac96e2d2
commit
e2f2e45ac8
|
|
@ -3,14 +3,17 @@ import 'package:dio/dio.dart';
|
|||
|
||||
Dio dio = new Dio();
|
||||
|
||||
class ChattingApi{
|
||||
|
||||
|
||||
|
||||
class ChattingApi {
|
||||
//登陆提交
|
||||
loginSubmit(String username,String password) async {
|
||||
var result = await dio.get('');
|
||||
return result.data;
|
||||
}
|
||||
|
||||
//获取通讯录列表
|
||||
getContactList(String id) async {
|
||||
var result = await dio.get('http://www.liulongbin.top:3005/api/v2/movie/subject/$id');
|
||||
var result = await dio
|
||||
.get('http://www.liulongbin.top:3005/api/v2/movie/subject/$id');
|
||||
return result.data;
|
||||
}
|
||||
|
||||
|
|
@ -25,4 +28,4 @@ class ChattingApi{
|
|||
var result = await dio.get('');
|
||||
return result.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/**
|
||||
* 首页 加载页
|
||||
|
|
@ -10,6 +11,27 @@ class LoadingPage extends StatefulWidget {
|
|||
|
||||
class _LoadingPageState extends State<LoadingPage> {
|
||||
|
||||
//0 未登录 ,1 已登录
|
||||
|
||||
void initData() async {
|
||||
final prefs = await SharedPreferences.getInstance(); //获取SP的实例
|
||||
int loginStatus=prefs.getInt('loginStatus') ?? 0;
|
||||
print(prefs.getInt('current_num'));
|
||||
if(loginStatus == 0){
|
||||
Navigator.of(context).pushReplacementNamed("login");
|
||||
}else{
|
||||
loginStatus=1;
|
||||
Navigator.of(context).pushReplacementNamed("app");
|
||||
}
|
||||
|
||||
/*prefs.setInt('current_num', 999); //存储数据
|
||||
var currentNum = prefs.getInt('current_num') ?? 0; //读取数据,默认为0
|
||||
print('读取数据 $currentNum');
|
||||
prefs.remove('current_num');//删除数据
|
||||
var delCurrentNum = prefs.getInt('current_num') ?? 0; //读取数据,默认为0
|
||||
print('删除数据 $delCurrentNum');*/
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -17,8 +39,7 @@ class _LoadingPageState extends State<LoadingPage> {
|
|||
Future.delayed(Duration(seconds: 3),(){
|
||||
print("仿微信app页面正在加载中");
|
||||
//判断是否登录,如果没有登陆则跳转至登录页,如果登录则跳转至聊天页
|
||||
Navigator.of(context).pushReplacementNamed("login");
|
||||
//Navigator.of(context).pushReplacementNamed("app");
|
||||
initData();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:date_format/date_format.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:chatting/chatting_api.dart';
|
||||
|
||||
class LoginPag extends StatefulWidget {
|
||||
@override
|
||||
|
|
@ -43,7 +44,8 @@ class _LoginPagState extends State<LoginPag> {
|
|||
height: 80,
|
||||
),
|
||||
buildEditWidget(context),
|
||||
buildLoginButton()
|
||||
buildLoginButton(),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -209,6 +211,7 @@ class _LoginPagState extends State<LoginPag> {
|
|||
timeInSecForIos: 2,
|
||||
textColor: Colors.white,
|
||||
fontSize: 14.0);
|
||||
return ChattingApi().loginSubmit(_userNameEditController.text, _pwdEditController.text);
|
||||
}
|
||||
},
|
||||
child: Text("登录"),
|
||||
|
|
|
|||
41
pubspec.lock
41
pubspec.lock
|
|
@ -95,6 +95,11 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_webview_plugin:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -144,6 +149,13 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: provider
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -151,6 +163,34 @@ packages:
|
|||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shared_preferences
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.5.7+3"
|
||||
shared_preferences_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_macos
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.0.1+10"
|
||||
shared_preferences_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_platform_interface
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_web
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.2+7"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
|
@ -221,3 +261,4 @@ packages:
|
|||
version: "3.6.1"
|
||||
sdks:
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ dependencies:
|
|||
date_format: ^1.0.4
|
||||
dio: ^1.0.9
|
||||
fluttertoast: ^3.0.3
|
||||
|
||||
provider: ^3.2.0
|
||||
shared_preferences: ^0.5.7+3
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
|
|
|||
Loading…
Reference in New Issue