Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_flutter
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
林生雨
gm_flutter
Commits
085adc18
Commit
085adc18
authored
Jul 06, 2020
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
cc889c68
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
158 additions
and
22 deletions
+158
-22
ClueRouter.dart
lib/ClueModel/ClueRouter.dart
+1
-1
ClueRouterImpl.dart
lib/ClueModel/ClueRouterImpl.dart
+2
-2
LevelOnePage.dart
lib/ClueModel/page/levelOne/LevelOnePage.dart
+6
-2
MainManager.dart
lib/MainRouter/manager/MainManager.dart
+42
-1
TestPage.dart
lib/MainRouter/page/test/TestPage.dart
+1
-1
App.dart
lib/commonModel/App.dart
+31
-0
BaseComponent.dart
lib/commonModel/base/BaseComponent.dart
+1
-1
Api.dart
lib/commonModel/net/Api.dart
+1
-0
DioInterceptor.dart
lib/commonModel/net/DioInterceptor.dart
+48
-2
DioUtil.dart
lib/commonModel/net/DioUtil.dart
+20
-11
DartUtil.dart
lib/commonModel/util/DartUtil.dart
+4
-0
main.dart
lib/main.dart
+1
-1
No files found.
lib/ClueModel/ClueRouter.dart
View file @
085adc18
...
...
@@ -14,7 +14,7 @@ abstract class ClueRouter implements RouterBaser {
Widget
getPlansCompareFeed
();
Widget
getLevelOnePage
();
Widget
getLevelOnePage
(
int
planId
);
Widget
getLevelTwoPage
();
...
...
lib/ClueModel/ClueRouterImpl.dart
View file @
085adc18
...
...
@@ -20,8 +20,8 @@ class ClueRouterImpl implements ClueRouter {
}
@override
Widget
getLevelOnePage
()
{
return
LevelOnePage
();
Widget
getLevelOnePage
(
int
planId
)
{
return
LevelOnePage
(
planId
);
}
@override
...
...
lib/ClueModel/page/levelOne/LevelOnePage.dart
View file @
085adc18
...
...
@@ -24,13 +24,16 @@ import 'package:gm_flutter/main.mark.dart';
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
class
LevelOnePage
extends
StatefulWidget
{
int
planId
=
10
;
LevelOnePage
(
this
.
planId
);
@override
State
<
StatefulWidget
>
createState
()
=>
LevelOneState
();
}
class
LevelOneState
extends
BaseState
<
LevelOnePage
>
with
TickerProviderStateMixin
{
int
planId
=
10
;
LevelOneModel
_model
=
new
LevelOneModel
();
RefreshController
_refreshController
=
RefreshController
();
GlobalKey
keyTop
=
new
GlobalKey
();
...
...
@@ -46,6 +49,7 @@ class LevelOneState extends BaseState<LevelOnePage>
@override
void
initState
()
{
super
.
initState
();
_model
.
plan_id
=
widget
.
planId
;
_model
.
init
(()
{
_initTabBar
();
});
...
...
@@ -164,7 +168,7 @@ class LevelOneState extends BaseState<LevelOnePage>
list
.
add
(
extend
.
NestedScrollViewInnerScrollPositionKeyWidget
(
Key
(
"Tab
${i}
"
),
LevelOneList
(
planId
,
_model
.
tabsList
[
i
].
tabType
,
kToolbarHeight
+
d
)));
widget
.
planId
,
_model
.
tabsList
[
i
].
tabType
,
kToolbarHeight
+
d
)));
}
final
double
statusBarHeight
=
MediaQuery
.
of
(
context
).
padding
.
top
;
final
double
pinnedHeaderHeight
=
statusBarHeight
+
kToolbarHeight
;
...
...
lib/MainRouter/manager/MainManager.dart
View file @
085adc18
...
...
@@ -4,7 +4,12 @@
**/
import
'package:flutter/services.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
import
'package:gm_flutter/commonModel/GMBase.dart'
;
import
'package:gm_flutter/commonModel/base/BaseUtil.dart'
;
import
'package:gm_flutter/commonModel/cache/CacheManager.dart'
;
import
'package:gm_flutter/commonModel/util/DartUtil.dart'
;
import
'../../commonModel/App.dart'
;
class
MainManager
{
MethodChannel
flutterChannel
;
...
...
@@ -31,10 +36,46 @@ class MainManager {
flutterChannel
=
MethodChannel
(
'gm_method_channel'
);
flutterEvent
=
EventChannel
(
'gm_method_event'
);
flutterEvent
.
receiveBroadcastStream
().
listen
((
data
)
{
print
(
"LSY FLUTTER EVENT
${data}
"
);
if
(
data
is
Map
<
String
,
String
>)
{
var
map
=
Map
<
String
,
String
>.
from
(
data
);
innerSetData
(
map
,
APP_NAME
);
innerSetData
(
map
,
VERSION
);
innerSetData
(
map
,
PLATFORM
);
innerSetData
(
map
,
DEVICE_ID
);
innerSetData
(
map
,
OS_VERSION
);
innerSetData
(
map
,
MODEL
);
innerSetData
(
map
,
SCREEN
);
innerSetData
(
map
,
LAT
);
innerSetData
(
map
,
LNG
);
innerSetData
(
map
,
CHANNEL
);
innerSetData
(
map
,
MANUFACTURER
);
innerSetData
(
map
,
UUID
);
innerSetData
(
map
,
ANDROID_DEVICE_ID
);
innerSetData
(
map
,
CURRENT_CITY_ID
);
innerSetData
(
map
,
USER_AGENT
);
innerSetData
(
map
,
RELEASE
);
innerSetData
(
map
,
IDFA
);
innerSetData
(
map
,
IDFV
);
innerSetData
(
map
,
IS_WIFI
);
innerSetData
(
map
,
HARDWARE_MODEL
);
innerSetData
(
map
,
USER_ID
);
innerSetData
(
map
,
COOKIE
);
innerSetData
(
map
,
BASE_URL
);
DioUtil
.
setDefOptions
(
baseUrl:
map
[
BASE_URL
]
+
"/"
,
cookie:
map
[
COOKIE
],
agent:
map
[
USER_AGENT
]);
DioUtil
.
getInstance
().
changeOpt
();
}
});
}
void
innerSetData
(
Map
<
String
,
String
>
map
,
String
str
)
{
if
(!
map
[
str
].
empty
())
{
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
save
(
str
,
map
[
str
]);
}
}
void
buriedEvent
(
String
name
,
Map
<
String
,
dynamic
>
map
)
{
if
(!
isInit
)
{
return
;
...
...
lib/MainRouter/page/test/TestPage.dart
View file @
085adc18
...
...
@@ -27,7 +27,7 @@ class TestState extends BaseState<TestPage> {
}));
list
.
add
(
listItem
(
"一级列表页"
,
()
{
JumpUtil
.
jumpToPageRight
(
context
,
RouterCenterImpl
().
findClueRouter
().
getLevelOnePage
());
context
,
RouterCenterImpl
().
findClueRouter
().
getLevelOnePage
(
137
));
}));
list
.
add
(
listItem
(
"二级列表页"
,
()
{
JumpUtil
.
jumpToPageRight
(
...
...
lib/commonModel/App.dart
0 → 100644
View file @
085adc18
/*
* @author lsy
* @date 2020/7/6
**/
const
String
APP_NAME
=
"app_name"
;
const
String
VERSION
=
"version"
;
const
String
PLATFORM
=
"platform"
;
const
String
DEVICE_ID
=
"device_id"
;
const
String
OS_VERSION
=
"os_version"
;
const
String
MODEL
=
"model"
;
const
String
SCREEN
=
"screen"
;
const
String
LAT
=
"lat"
;
const
String
LNG
=
"lng"
;
const
String
CHANNEL
=
"channel"
;
const
String
MANUFACTURER
=
"manufacturer"
;
const
String
UUID
=
"uuid"
;
const
String
ANDROID_DEVICE_ID
=
"android_device_id"
;
const
String
CURRENT_CITY_ID
=
"current_city_id"
;
const
String
RELEASE
=
"release"
;
const
String
IDFA
=
"idfa"
;
const
String
IDFV
=
"idfv"
;
const
String
IS_WIFI
=
"is_WiFi"
;
const
String
HARDWARE_MODEL
=
"hardware_model"
;
//head
const
String
USER_AGENT
=
"User-Agent"
;
const
String
COOKIE
=
"cookie"
;
//user
const
String
USER_ID
=
"user_id"
;
const
String
BASE_URL
=
"base_url"
;
lib/commonModel/base/BaseComponent.dart
View file @
085adc18
...
...
@@ -148,7 +148,7 @@ Widget errorItem(double width, double height, VoidCallback retry,
return
Container
(
width:
width
,
height:
height
,
padding:
EdgeInsets
.
only
(
top:
paddingTop
),
padding:
EdgeInsets
.
only
(
top:
paddingTop
??
0
),
alignment:
Alignment
.
topCenter
,
child:
Container
(
width:
180
,
...
...
lib/commonModel/net/Api.dart
View file @
085adc18
...
...
@@ -20,6 +20,7 @@ const String APP_HOST_RELEASE = "https://x6cgr5y5-gengmei.mock.coding.io";
//const String APP_HOST_DEBUG = "http://backend.paas-merchant.envs";
//const String APP_HOST_DEBUG = "http://doctor.paas-merchant.env";
const
String
APP_HOST_DEBUG
=
"https://x6cgr5y5-gengmei.mock.coding.io"
;
//const String APP_HOST_DEBUG = "http://backend.paas-merchant.env";
/**
* 开发环境
...
...
lib/commonModel/net/DioInterceptor.dart
View file @
085adc18
...
...
@@ -7,6 +7,7 @@ import 'dart:io';
import
'package:dio/dio.dart'
;
import
'package:gm_flutter/commonModel/cache/CacheManager.dart'
;
import
'../App.dart'
;
import
'DioUtil.dart'
;
class
DioInterceptorManager
{
...
...
@@ -23,13 +24,58 @@ class DioInterceptorManager {
InterceptorsWrapper
getIntercept
()
{
return
new
InterceptorsWrapper
(
onRequest:
(
opt
)
{
if
(
CacheManager
.
getInstance
().
get
(
SHARE_CACHE
).
get
(
NET_COOKIE
)
!=
null
)
{
if
(
opt
.
headers
==
null
)
{
opt
.
headers
=
Map
();
}
if
(
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
COOKIE
)
!=
null
)
{
opt
.
headers
[
HttpHeaders
.
cookieHeader
]
=
CacheManager
.
getInstance
().
get
(
SHARE_CACHE
).
get
(
NET_
COOKIE
);
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
COOKIE
);
}
if
(
opt
.
queryParameters
==
null
)
{
opt
.
queryParameters
=
Map
<
String
,
dynamic
>();
}
opt
.
queryParameters
[
APP_NAME
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
APP_NAME
);
opt
.
queryParameters
[
VERSION
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
VERSION
);
opt
.
queryParameters
[
PLATFORM
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
PLATFORM
);
opt
.
queryParameters
[
DEVICE_ID
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
DEVICE_ID
);
opt
.
queryParameters
[
OS_VERSION
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
OS_VERSION
);
opt
.
queryParameters
[
MODEL
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
MODEL
);
opt
.
queryParameters
[
SCREEN
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
SCREEN
);
opt
.
queryParameters
[
LAT
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
LAT
);
opt
.
queryParameters
[
LNG
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
LNG
);
opt
.
queryParameters
[
CHANNEL
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
CHANNEL
);
opt
.
queryParameters
[
MANUFACTURER
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
MANUFACTURER
);
opt
.
queryParameters
[
UUID
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
UUID
);
if
(
Platform
.
isAndroid
)
{
opt
.
queryParameters
[
ANDROID_DEVICE_ID
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
ANDROID_DEVICE_ID
);
}
else
{
opt
.
queryParameters
[
RELEASE
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
RELEASE
);
opt
.
queryParameters
[
IDFA
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
IDFA
);
opt
.
queryParameters
[
IDFV
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
IDFV
);
opt
.
queryParameters
[
IS_WIFI
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
IS_WIFI
);
opt
.
queryParameters
[
HARDWARE_MODEL
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
HARDWARE_MODEL
);
opt
.
queryParameters
[
CURRENT_CITY_ID
]
=
CacheManager
.
getInstance
().
get
(
MEMORY_CACHE
).
get
(
CURRENT_CITY_ID
);
}
print
(
"请求之前 onRequest
${opt.headers}
"
);
},
onResponse:
(
response
)
{
print
(
"响应之前 onResponse
${response}
"
);
...
...
lib/commonModel/net/DioUtil.dart
View file @
085adc18
...
...
@@ -11,9 +11,9 @@ import 'DioInterceptor.dart';
const
NET_COOKIE
=
"NET_COOKIE"
;
class
DioUtil
{
static
BaseOptions
_options
=
BaseOptions
();
static
final
DioUtil
_instance
=
DioUtil
.
_init
();
static
Dio
_dio
;
static
BaseOptions
_options
=
getDefOptions
();
static
Map
<
String
,
dynamic
>
addHeadMap
;
...
...
@@ -31,9 +31,15 @@ class DioUtil {
static
var
interceptor
=
InterceptorsWrapper
();
DioUtil
.
_init
()
{
setDefOptions
();
_dio
=
new
Dio
(
_options
);
_dio
.
interceptors
.
add
(
DioInterceptorManager
.
getInstance
().
getIntercept
());
// _dio.interceptors.add(DioCookieManager.getInstance().getCookieManager());
}
void
changeOpt
()
{
_dio
=
new
Dio
(
_options
);
_dio
.
interceptors
.
add
(
DioInterceptorManager
.
getInstance
().
getIntercept
());
_dio
.
interceptors
.
add
(
DioCookieManager
.
getInstance
().
getCookieManager
());
}
void
clearCookie
()
{
...
...
@@ -56,16 +62,19 @@ class DioUtil {
return
_dio
;
}
static
BaseOptions
getDefOptions
()
{
BaseOptions
options
=
BaseOptions
();
options
.
connectTimeout
=
10
*
1000
;
options
.
receiveTimeout
=
20
*
1000
;
options
.
responseType
=
ResponseType
.
plain
;
static
void
setDefOptions
({
String
baseUrl
,
String
cookie
,
String
agent
})
{
_options
.
connectTimeout
=
10
*
1000
;
_options
.
receiveTimeout
=
20
*
1000
;
_options
.
responseType
=
ResponseType
.
plain
;
Map
<
String
,
dynamic
>
headers
=
Map
<
String
,
dynamic
>();
headers
[
'Accept'
]
=
'application/json'
;
headers
[
'version'
]
=
'1.0.0'
;
options
.
headers
=
headers
;
options
.
baseUrl
=
Api
.
getInstance
().
getBaseUrl
()
+
"/"
;
return
options
;
if
(
agent
!=
null
)
{
headers
[
'User-Agent'
]
=
agent
;
}
if
(
cookie
!=
null
)
{
headers
[
HttpHeaders
.
cookieHeader
]
=
cookie
;
}
_options
.
headers
=
headers
;
_options
.
baseUrl
=
baseUrl
??
Api
.
getInstance
().
getBaseUrl
()
+
"/"
;
}
}
lib/commonModel/util/DartUtil.dart
View file @
085adc18
...
...
@@ -55,4 +55,8 @@ extension StringExt on String {
'^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))
\\
d{8}
\$
'
)
.
hasMatch
(
this
);
}
bool
empty
()
{
return
this
==
null
||
this
.
isEmpty
;
}
}
lib/main.dart
View file @
085adc18
...
...
@@ -59,7 +59,7 @@ class MyApp extends State<MyAppWidget> {
super
.
initState
();
FlutterBoost
.
singleton
.
registerPageBuilders
({
'demoPage'
:
(
pageName
,
params
,
_
)
{
return
RouterCenterImpl
().
findClueRouter
().
getLevelOnePage
();
return
RouterCenterImpl
().
findClueRouter
().
getLevelOnePage
(
137
);
},
'demoPage1'
:
(
pageName
,
params
,
_
)
{
return
DemoPage1
();
...
...
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