Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
netrain_flutter_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邹志胜
netrain_flutter_app
Commits
c89d948f
Commit
c89d948f
authored
Jul 07, 2021
by
laishanqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mqtt
parent
3780e441
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
254 additions
and
123 deletions
+254
-123
build.gradle
netrain_flutter_app/android/build.gradle
+13
-4
ic_back_black.png
netrain_flutter_app/assets/images/2.0x/ic_back_black.png
+0
-0
ic_back_black.png
netrain_flutter_app/assets/images/3.0x/ic_back_black.png
+0
-0
ic_back_black.png
netrain_flutter_app/assets/images/ic_back_black.png
+0
-0
Login.dart
netrain_flutter_app/lib/laishanqi/Login.dart
+0
-97
MqttClient.dart
netrain_flutter_app/lib/laishanqi/mqtt/MqttClient.dart
+81
-0
HttpUtil.dart
netrain_flutter_app/lib/laishanqi/netrain/Http/HttpUtil.dart
+56
-0
Images.dart
netrain_flutter_app/lib/laishanqi/netrain/Images.dart
+1
-0
RegisterPage.dart
..._flutter_app/lib/laishanqi/netrain/user/RegisterPage.dart
+48
-0
loginPage.dart
...ain_flutter_app/lib/laishanqi/netrain/user/loginPage.dart
+29
-11
main.dart
netrain_flutter_app/lib/main.dart
+22
-11
pubspec.yaml
netrain_flutter_app/pubspec.yaml
+4
-0
No files found.
netrain_flutter_app/android/build.gradle
View file @
c89d948f
buildscript
{
ext
.
kotlin_version
=
'1.3.50'
repositories
{
google
()
jcenter
()
//google()
//jcenter()
maven
{
url
'https://maven.aliyun.com/repository/google'
}
maven
{
url
'https://maven.aliyun.com/repository/jcenter'
}
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public'
}
maven
{
url
"http://download.flutter.io"
}
}
dependencies
{
...
...
@@ -13,8 +18,12 @@ buildscript {
allprojects
{
repositories
{
google
()
jcenter
()
// google()
// jcenter()
maven
{
url
'https://maven.aliyun.com/repository/google'
}
maven
{
url
'https://maven.aliyun.com/repository/jcenter'
}
maven
{
url
'http://maven.aliyun.com/nexus/content/groups/public'
}
maven
{
url
"http://download.flutter.io"
}
}
}
...
...
netrain_flutter_app/assets/images/2.0x/ic_back_black.png
0 → 100644
View file @
c89d948f
383 Bytes
netrain_flutter_app/assets/images/3.0x/ic_back_black.png
0 → 100644
View file @
c89d948f
347 Bytes
netrain_flutter_app/assets/images/ic_back_black.png
0 → 100644
View file @
c89d948f
234 Bytes
netrain_flutter_app/lib/laishanqi/Login.dart
deleted
100644 → 0
View file @
3780e441
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/laishanqi/netrain/Images.dart'
;
class
Login
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
var
controller
=
TextEditingController
();
return
MaterialApp
(
home:
Scaffold
(
body:
Container
(
margin:
EdgeInsets
.
only
(
top:
108
),
alignment:
Alignment
.
center
,
child:
Column
(
children:
[
Image
.
asset
(
Images
.
logo_01
),
Container
(
margin:
EdgeInsets
.
only
(
top:
91
),
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
baseline
,
mainAxisAlignment:
MainAxisAlignment
.
spaceEvenly
,
children:
[
Column
(
children:
[
Text
(
"验证码登录"
,
style:
TextStyle
(
color:
Color
(
0xff2893FF
),
fontWeight:
FontWeight
.
bold
,
fontSize:
17
),
),
Container
(
height:
6
,
),
Image
.
asset
(
Images
.
ic_login_mode
)
],
),
Text
(
"密码登录"
,
style:
TextStyle
(
color:
Color
(
0xff949494
),
fontWeight:
FontWeight
.
bold
,
fontSize:
17
)),
],
),
),
Container
(
margin:
EdgeInsets
.
only
(
top:
26
),
child:
Stack
(
children:
[
Container
(
child:
TextField
(
controller:
controller
,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
only
(
left:
19
),
hintText:
"请输入手机号"
,
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
borderSide:
BorderSide
(
color:
Color
(
0xffF1F1F1
),
width:
1
)),
),
),
margin:
EdgeInsets
.
only
(
left:
32
,
right:
32
),
height:
47
,
),
Positioned
(
top:
12
,
right:
50
,
child:
Text
(
"获取验证码"
,
style:
TextStyle
(
color:
Color
(
0xff727272
)),
))
],
),
),
Container
(
child:
TextField
(
controller:
controller
,
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
only
(
left:
19
),
hintText:
"请输入密码"
,
border:
OutlineInputBorder
(
borderRadius:
BorderRadius
.
circular
(
20
),
borderSide:
BorderSide
(
color:
Color
(
0xffF1F1F1
),
width:
1
)),
),
),
margin:
EdgeInsets
.
only
(
left:
32
,
right:
32
,
top:
11
),
height:
47
,
),
],
),
),
),
);
}
}
netrain_flutter_app/lib/laishanqi/mqtt/MqttClient.dart
0 → 100644
View file @
c89d948f
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:mqtt_client/mqtt_client.dart'
;
import
'package:mqtt_client/mqtt_server_client.dart'
;
class
MqttClient
{
Future
<
MqttServerClient
>
connect
()
async
{
MqttServerClient
client
=
// MqttServerClient.withPort('emqtt.hdmedicine.naiterui.com', '180.76.145.155', 61630);
MqttServerClient
.
withPort
(
'broker.emqx.io'
,
'flutter_client'
,
1883
);
client
.
logging
(
on:
true
);
client
.
onConnected
=
onConnected
;
client
.
onDisconnected
=
onDisconnected
;
client
.
onUnsubscribed
=
onUnsubscribed
;
client
.
onSubscribed
=
onSubscribed
;
client
.
onSubscribeFail
=
onSubscribeFail
;
client
.
pongCallback
=
pong
;
final
connMessage
=
MqttConnectMessage
()
.
authenticateAs
(
'androiduser'
,
'Cf3Jf3tM06200G+Up0'
)
.
keepAliveFor
(
60
)
.
withWillTopic
(
'clientWillDead'
)
.
withWillMessage
(
'{"i":"dr_133","c":0,"t":3}'
)
.
startClean
()
.
withWillQos
(
MqttQos
.
atLeastOnce
);
client
.
connectionMessage
=
connMessage
;
try
{
await
client
.
connect
();
}
catch
(
e
)
{
print
(
'Exception:
$e
'
);
client
.
disconnect
();
}
client
.
updates
.
listen
((
List
<
MqttReceivedMessage
<
MqttMessage
>>
c
)
{
final
MqttPublishMessage
message
=
c
[
0
].
payload
;
final
payload
=
MqttPublishPayload
.
bytesToStringAsString
(
message
.
payload
.
message
);
print
(
'收到消息 Received message:
$payload
from topic:
${c[0].topic}
>'
);
Fluttertoast
.
showToast
(
msg:
"flutter 收到MQtt消息
$payload
"
);
});
client
.
subscribe
(
"topic/test"
,
MqttQos
.
atLeastOnce
);
return
client
;
}
// 连接成功
void
onConnected
()
{
print
(
'连接 --- Connected'
);
}
// 连接断开
void
onDisconnected
()
{
print
(
'连接 --- Disconnected'
);
}
// 订阅主题成功
void
onSubscribed
(
String
topic
)
{
print
(
'连接 --- Subscribed topic:
$topic
'
);
}
// 订阅主题失败
void
onSubscribeFail
(
String
topic
)
{
print
(
'连接 --- Failed to subscribe
$topic
'
);
}
// 成功取消订阅
void
onUnsubscribed
(
String
topic
)
{
print
(
'连接 --- Unsubscribed topic:
$topic
'
);
}
// 收到 PING 响应
void
pong
()
{
print
(
'连接 --- Ping response client callback invoked'
);
}
MqttClient
();
}
netrain_flutter_app/lib/laishanqi/netrain/Http/HttpUtil.dart
0 → 100644
View file @
c89d948f
import
'dart:collection'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'package:http/http.dart'
as
http
;
class
HttpUtil
{
static
HttpClient
httpClient
=
HttpClient
();
static
HashMap
<
String
,
String
>
headers
;
static
String
scheme
=
"http"
;
static
String
host
=
"api-docker.naiterui.com"
;
static
String
global_config
=
"ad/doctorInfo/globalConfig"
;
static
Future
<
http
.
Response
>
get
(
String
path
,{
Map
<
String
,
dynamic
>
queryParameters
})
async
{
var
response
=
await
http
.
get
(
"http://
$host
/
$path
"
);
// _get(path, host: HttpUtil.host, queryParameters: queryParameters);
return
response
;
}
static
_get
(
String
path
,
{
String
host
,
Map
<
String
,
dynamic
>
queryParameters
,
})
async
{
Uri
uri
=
Uri
(
scheme:
scheme
,
host:
host
,
path:
path
,
queryParameters:
queryParameters
);
HttpClientRequest
request
=
await
httpClient
.
getUrl
(
uri
);
addHeaders
(
request
);
print
(
'http url--->
$uri
\n
headers--->
\n
${request.headers}
queryParameters --->
${uri.queryParameters}
'
);
HttpClientResponse
response
=
await
request
.
close
();
String
responseBody
=
await
response
.
transform
(
Utf8Decoder
()).
join
();
print
(
'http responseBody --->
\n
$responseBody
'
);
}
static
void
addHeaders
(
HttpClientRequest
request
)
{
request
.
headers
.
add
(
"_p"
,
"0"
);
request
.
headers
.
add
(
"_o"
,
"1"
);
request
.
headers
.
add
(
"_n"
,
"1"
);
request
.
headers
.
add
(
"_v"
,
"1.0.0"
);
request
.
headers
.
add
(
"_nv"
,
"1.0.0"
);
}
post
()
{}
postBody
()
{}
}
netrain_flutter_app/lib/laishanqi/netrain/Images.dart
View file @
c89d948f
...
...
@@ -17,4 +17,5 @@ class Images{
static
const
ic_prescription
=
"
${imagesPath}
ic_prescription.png"
;
static
const
ic_privacy
=
"
${imagesPath}
ic_privacy.png"
;
static
const
ic_sign
=
"
${imagesPath}
ic_sign.png"
;
static
const
ic_back_black
=
"
${imagesPath}
ic_back_black.png"
;
}
\ No newline at end of file
netrain_flutter_app/lib/laishanqi/netrain/user/RegisterPage.dart
0 → 100644
View file @
c89d948f
import
'package:flutter/material.dart'
;
/**
* 注册页
*/
class
RegisterPage
extends
StatefulWidget
{
@override
State
createState
()
=>
_RegisterState
();
}
class
_RegisterState
extends
State
{
@override
Widget
build
(
BuildContext
context
)
{
return
registerWidget
();
}
Widget
registerWidget
()
{
return
MaterialApp
(
theme:
ThemeData
(
primaryColor:
Colors
.
white
,
),
home:
Scaffold
(
appBar:
AppBar
(
leading:
IconButton
(
icon:
Icon
(
Icons
.
arrow_back
),
onPressed:
(){
Navigator
.
of
(
context
).
pushNamed
(
"/"
);
},
),
centerTitle:
true
,
title:
Text
(
"注册"
),
elevation:
0
,
),
body:
ListView
(
children:
[
],
),
),
);
}
}
\ No newline at end of file
netrain_flutter_app/lib/laishanqi/netrain/loginPage.dart
→
netrain_flutter_app/lib/laishanqi/netrain/
user/
loginPage.dart
View file @
c89d948f
import
'package:flutter/material.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:http/http.dart'
;
import
'package:netrain_flutter_app/laishanqi/mqtt/MqttClient.dart'
;
import
'package:netrain_flutter_app/laishanqi/netrain/Http/HttpUtil.dart'
;
import
'package:netrain_flutter_app/laishanqi/netrain/user/RegisterPage.dart'
;
import
'HomePage.dart'
;
import
'Images.dart'
;
import
'
../
HomePage.dart'
;
import
'
../
Images.dart'
;
/// 登录页
class
LoginPage
extends
StatefulWidget
{
...
...
@@ -18,6 +22,14 @@ class _LoginState extends State<LoginPage> {
@override
Widget
build
(
BuildContext
context
)
{
var
mqtt
=
MqttClient
();
mqtt
.
connect
();
HttpUtil
.
get
(
HttpUtil
.
global_config
).
then
((
Response
value
)
{
Fluttertoast
.
showToast
(
msg:
"global_config 请求成功 "
);
});
return
MaterialApp
(
title:
'登陆页'
,
theme:
ThemeData
(
...
...
@@ -74,7 +86,8 @@ class _LoginState extends State<LoginPage> {
return
;
}
// 跳转
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)=>
HomePage
()));
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
HomePage
()));
Fluttertoast
.
showToast
(
msg:
"登录 手机号:
${phoneController.text}
验证码或密码:
${codeController.text}
"
);
...
...
@@ -92,10 +105,16 @@ class _LoginState extends State<LoginPage> {
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
MaterialButton
(
onPressed:
()
{
Navigator
.
pushNamed
(
context
,
"register"
);
// Navigator.push(context,MaterialPageRoute(builder: (context) => RegisterPage()));
},
child:
Text
(
"快速注册"
,
style:
TextStyle
(
color:
Colors
.
blue
),
),
),
Text
(
" | "
,
style:
TextStyle
(
color:
Colors
.
blue
)),
Text
(
"忘记密码"
,
style:
TextStyle
(
color:
Colors
.
blue
))
],
...
...
@@ -114,16 +133,15 @@ class _LoginState extends State<LoginPage> {
height:
46
,
margin:
EdgeInsets
.
only
(
left:
32
,
right:
32
,
top:
10
),
child:
TextField
(
obscureText:
select
==
2
,
obscureText:
select
==
2
,
controller:
codeController
,
style:
TextStyle
(
color:
Colors
.
blue
,
fontSize:
16
),
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
only
(
left:
10
,
right:
10
,
top:
10
,
bottom:
10
),
contentPadding:
EdgeInsets
.
only
(
left:
10
,
right:
10
,
top:
10
,
bottom:
10
),
hintText:
checkText
,
enabledBorder:
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Color
(
0xFFf1f1f1
),
width:
1
),
borderSide:
BorderSide
(
color:
Color
(
0xFFf1f1f1
),
width:
1
),
borderRadius:
BorderRadius
.
circular
(
23
),
),
focusedBorder:
OutlineInputBorder
(
...
...
netrain_flutter_app/lib/main.dart
View file @
c89d948f
import
'package:flutter/material.dart'
;
import
'package:netrain_flutter_app/TestPage.dart'
;
import
'package:netrain_flutter_app/laishanqi/Login.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'laishanqi/Stateful_page.dart'
;
import
'laishanqi/Stateless_page.dart'
;
import
'laishanqi/layout_page.dart'
;
import
'laishanqi/netrain/loginPage.dart'
;
import
'laishanqi/netrain/user/loginPage.dart'
;
import
'laishanqi/netrain/user/RegisterPage.dart'
;
import
'laishanqi/photo.dart'
;
void
main
(
)
{
// runApp(MyApp());
runApp
(
Login
());
runApp
(
MyApp
());
// runApp(Login());
// runApp(TestPage());
print
(
"启动"
);
}
class
MyApp
extends
StatelessWidget
{
// This widget is the root of your application.
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
WillPopScope
(
child:
MaterialApp
(
title:
'Flutter Demo'
,
initialRoute:
"/"
,
theme:
ThemeData
(
primarySwatch:
Colors
.
blue
,
visualDensity:
VisualDensity
.
adaptivePlatformDensity
,
...
...
@@ -27,13 +31,20 @@ class MyApp extends StatelessWidget {
title:
Text
(
"路由"
),
),
body:
RouterNavigator
(
title:
'Flutter Demo Home Page'
),
),
routes:
<
String
,
WidgetBuilder
>{
"less"
:
(
BuildContext
context
)
=>
LessGroupPage
(),
"ful"
:
(
BuildContext
context
)
=>
FulGroupPage
(),
"layout"
:
(
BuildContext
context
)
=>
LayoutPage
(),
"photo"
:
(
BuildContext
context
)
=>
PhotoApp
(),
"less"
:
(
context
)
=>
LessGroupPage
(),
"ful"
:
(
context
)
=>
FulGroupPage
(),
"layout"
:
(
context
)
=>
LayoutPage
(),
"photo"
:
(
context
)
=>
PhotoApp
(),
"register"
:
(
context
)
=>
RegisterPage
(),
},
),
onWillPop:
()
async
{
Fluttertoast
.
showToast
(
msg:
"退出"
);
return
true
;
});
}
}
...
...
netrain_flutter_app/pubspec.yaml
View file @
c89d948f
...
...
@@ -20,6 +20,7 @@ version: 1.0.0+1
environment
:
sdk
:
"
>=2.7.0
<3.0.0"
dependencies
:
flutter
:
sdk
:
flutter
...
...
@@ -30,6 +31,9 @@ dependencies:
cupertino_icons
:
^0.1.3
image_picker
:
^0.6.7+11
fluttertoast
:
^3.1.3
http
:
0.12.2
mqtt_client
:
^9.3.2
dev_dependencies
:
flutter_test
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment