forked from alibaba/flutter-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alibaba#206 from Nealyang/master
登陆
- Loading branch information
Showing
24 changed files
with
643 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>android</name> | ||
<comment>Project android created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
connection.project.dir= | ||
eclipse.preferences.version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/> | ||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | ||
<classpathentry kind="output" path="bin/default"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>app</name> | ||
<comment>Project app created by Buildship.</comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
connection.project.dir=.. | ||
eclipse.preferences.version=1 |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Api{ | ||
// static const String BASE_URL = 'http://127.0.0.1:6001/'; | ||
static const String BASE_URL = 'http://flutter-go.alibaba.net/'; | ||
|
||
static const String DO_LOGIN = BASE_URL+'doLogin';//登陆 | ||
|
||
static const String CHECK_LOGIN = BASE_URL+'checkLogin';//验证登陆 | ||
|
||
static const String LOGOUT = BASE_URL+'logout';//退出登陆 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class UserInfo { | ||
String username; | ||
int id; | ||
String avatarPic; | ||
String themeColor; | ||
String urlName; | ||
|
||
UserInfo({ | ||
this.avatarPic, | ||
this.id, | ||
this.themeColor, | ||
this.urlName, | ||
this.username, | ||
}); | ||
|
||
factory UserInfo.fromJson(Map<String, dynamic> json) { | ||
return UserInfo( | ||
avatarPic: json['avatar_pic'], | ||
id: int.parse(json['id']), | ||
username: json['name'], | ||
themeColor: json['theme_color'], | ||
urlName: json['url_name']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/// @Author: 一凨 | ||
/// @Date: 2019-01-07 16:24:42 | ||
/// @Last Modified by: 一凨 | ||
/// @Last Modified time: 2019-01-08 17:37:42 | ||
import 'dart:async'; | ||
|
||
import 'package:flutter_go/utils/sql.dart'; | ||
|
||
abstract class UserInfoInterface { | ||
String get username; | ||
String get password; | ||
} | ||
|
||
class UserInfo implements UserInfoInterface { | ||
String username; | ||
String password; | ||
|
||
UserInfo({this.username, this.password}); | ||
|
||
factory UserInfo.fromJSON(Map json){ | ||
return UserInfo(username: json['username'],password: json['password']); | ||
} | ||
|
||
Object toMap() { | ||
return {'username': username, 'password': password}; | ||
} | ||
} | ||
|
||
class UserInfoControlModel { | ||
final String table = 'userInfo'; | ||
Sql sql; | ||
|
||
UserInfoControlModel() { | ||
sql = Sql.setTable(table); | ||
} | ||
|
||
// 获取所有的收藏 | ||
|
||
// 插入新的缓存 | ||
Future insert(UserInfo userInfo) { | ||
var result = | ||
sql.insert({'username': userInfo.username, 'password': userInfo.password}); | ||
return result; | ||
} | ||
|
||
// 获取用户信息 | ||
Future<List<UserInfo>> getAllInfo() async { | ||
List list = await sql.getByCondition(); | ||
List<UserInfo> resultList = []; | ||
list.forEach((item){ | ||
print(item); | ||
resultList.add(UserInfo.fromJSON(item)); | ||
}); | ||
return resultList; | ||
} | ||
|
||
// 清空表中数据 | ||
Future deleteAll() async{ | ||
return await sql.deleteAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:async' show Future; | ||
|
||
import './net_utils.dart'; | ||
import '../model/user_info.dart'; | ||
import 'package:flutter_go/api/api.dart'; | ||
|
||
|
||
class DataUtils{ | ||
// 登陆获取用户信息 | ||
static Future<UserInfo> doLogin(Map<String,String> params) async{ | ||
var response = await NetUtils.post(Api.DO_LOGIN, params); | ||
UserInfo userInfo = UserInfo.fromJson(response['data']); | ||
return userInfo; | ||
} | ||
|
||
// 验证登陆 | ||
|
||
static Future<bool> checkLogin() async{ | ||
var response = await NetUtils.get(Api.CHECK_LOGIN); | ||
print('验证登陆:$response'); | ||
return response['success']; | ||
} | ||
|
||
// 退出登陆 | ||
static Future<bool> logout() async{ | ||
var response = await NetUtils.get(Api.LOGOUT); | ||
print('退出登陆 $response'); | ||
return response['success']; | ||
} | ||
} |
Oops, something went wrong.