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
3280ec6b
Commit
3280ec6b
authored
Jul 06, 2020
by
杜欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二级方案
parent
fea4eaf7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
106 deletions
+108
-106
LevelTwoModel.dart
lib/ClueModel/page/levelTwo/LevelTwoModel.dart
+50
-75
LevelTwoPage.dart
lib/ClueModel/page/levelTwo/LevelTwoPage.dart
+0
-0
MechanismBoxPage.dart
lib/ClueModel/page/mechanismBox/MechanismBoxPage.dart
+29
-7
MechanismModel.dart
lib/ClueModel/page/mechanismBox/MechanismModel.dart
+13
-12
PlanOverviewBean.dart
lib/ClueModel/server/entity/PlanOverviewBean.dart
+16
-12
No files found.
lib/ClueModel/page/levelTwo/LevelTwoModel.dart
View file @
3280ec6b
...
...
@@ -5,98 +5,73 @@
import
'package:flutter/material.dart'
;
import
'package:flutter_common/commonModel/live/BaseModel.dart'
;
import
'package:flutter_common/commonModel/live/LiveData.dart'
;
import
'package:flutter_common/commonModel/toast/NativeToast.dart'
;
import
'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/LevelOneFeedList.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/PlanOverviewBean.dart'
;
import
'package:gm_flutter/commonModel/GMBase.dart'
;
import
'package:gm_flutter/commonModel/bean/Pair.dart'
;
import
'package:gm_flutter/commonModel/rx/RxDispose.dart'
;
import
'package:gm_flutter/commonModel/util/PrintUtil.dart'
;
import
'package:
pull_to_refresh/pull_to_refresh
.dart'
;
import
'package:
gm_flutter/commonModel/bean/Pair
.dart'
;
class
LevelTwoModel
extends
BaseModel
{
LiveData
<
double
>
appBarLive
=
LiveData
();
LiveData
<
List
<
String
>>
rectLive
=
LiveData
();
LiveData
<
List
<
String
>>
explainLive
=
LiveData
();
LiveData
<
bool
>
showTab
=
LiveData
();
LiveData
<
int
>
topIndexLive
=
new
LiveData
();
LiveData
<
double
>
topScrollLive
=
new
LiveData
();
LiveData
<
bool
>
loadingLive
=
LiveData
();
RxDispose
rxDispose
=
RxDispose
();
LiveData
<
Pair
<
int
,
List
<
Cards
>>>
cardsLive
=
LiveData
();
import
'../../../commonModel/bean/Pair.dart'
;
Map
<
int
,
List
<
Cards
>>
data
=
new
Map
();
List
list
=
[
"hospital"
,
"doctor"
];
List
pageList
=
[
1
,
1
];
List
pageHeightList
=
[
149
,
118
];
class
LevelTwoModel
extends
BaseModel
{
LiveData
<
Pair
<
int
,
String
>>
nameLive
=
LiveData
();
LiveData
<
Pair
<
int
,
String
>>
imageUrlLive
=
LiveData
();
LiveData
<
Pair
<
int
,
List
<
OverviewAttrsEntity
>>>
overviewAttrsLive
=
LiveData
();
LiveData
<
Pair
<
int
,
List
<
ExplanationAttrsEntity
>>>
explanationAttrsLive
=
LiveData
();
LiveData
<
Pair
<
int
,
List
<
Tabs
>>>
tabsLive
=
LiveData
();
void
refreshView
(
bool
clear
,
{
RefreshController
refreshListener
})
{
Future
.
delayed
(
Duration
(
seconds:
1
),
()
{
Cards
cards
=
Cards
(
cardType:
"plan"
,
plan:
Plan
(
planName:
"ww"
,
minPrice:
"50"
,
maxPrice:
"500"
));
List
<
Cards
>
a
=
[
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
cards
,
];
List
<
Cards
>
b
=
[
cards
];
print
(
"INDEX
${currentIndex}
"
);
if
(
currentIndex
==
1
)
{
data
[
currentIndex
]
=
b
;
}
else
{
data
[
currentIndex
]
=
a
;
}
LiveData
<
int
>
stateLive
=
LiveData
();
LiveData
<
Pair
<
int
,
List
<
Cards
>>>
cardsLive
=
LiveData
();
RxDispose
rxDispose
=
RxDispose
();
cardsLive
.
notifyView
(
Pair
(
ENDLOADING
,
data
));
});
int
index
=
currentIndex
;
if
(
clear
)
{
data
.
clear
();
pageList
=
[
1
,
1
];
}
getPlanOverview
(
int
plan_id
)
{
ClueApiImpl
.
getInstance
()
.
getLevelOneList
(
DioUtil
.
getInstance
().
getDio
(),
123
,
list
[
index
],
pageList
[
index
])
.
listen
((
event
)
{})
.
getPlanOverviewBean
(
DioUtil
.
getInstance
().
getDio
(),
plan_id
)
.
listen
((
event
)
{
if
(
event
.
error
==
0
)
{
stateLive
.
notifyView
(
ENDLOADING
);
nameLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
name
));
imageUrlLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
banner
.
imageUrl
));
overviewAttrsLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
overviewAttrs
));
explanationAttrsLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
explanationAttrs
));
tabsLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
tabs
));
}
else
{
NativeToast
.
showNativeToast
(
event
.
message
);
commonError
();
}
})
.
addToDispose
(
rxDispose
)
.
onError
((
err
)
{
PrintUtil
.
printBug
(
err
);
});
commonError
();
PrintUtil
.
printBug
(
err
);
});
}
int
currentIndex
=
0
;
commonError
()
{
stateLive
.
notifyView
(
FAIL
);
nameLive
.
notifyView
(
Pair
(
FAIL
,
null
));
imageUrlLive
.
notifyView
(
Pair
(
FAIL
,
null
));
overviewAttrsLive
.
notifyView
(
Pair
(
FAIL
,
null
));
explanationAttrsLive
.
notifyView
(
Pair
(
FAIL
,
null
));
tabsLive
.
notifyView
(
Pair
(
FAIL
,
null
));
}
@override
void
dispose
()
{
showTab
.
dispost
();
cardsLive
.
dispost
();
appBarLive
.
dispost
();
rectLive
.
dispost
();
topIndexLive
.
dispost
();
topScrollLive
.
dispost
();
loadingLive
.
dispost
();
}
void
selectPage
(
int
index
)
{
if
(
currentIndex
==
index
)
{
return
;
}
currentIndex
=
index
;
if
(
data
[
currentIndex
]
==
null
)
{
cardsLive
.
notifyView
(
Pair
(
LOADING
,
null
));
refreshView
(
true
);
}
else
{
cardsLive
.
notifyView
(
Pair
(
ENDLOADING
,
data
[
currentIndex
]));
}
nameLive
.
dispost
();
imageUrlLive
.
dispost
();
overviewAttrsLive
.
dispost
();
explanationAttrsLive
.
dispost
();
tabsLive
.
dispost
();
stateLive
.
dispost
();
rxDispose
.
dispose
();
}
void
loadMore
()
{}
...
...
lib/ClueModel/page/levelTwo/LevelTwoPage.dart
View file @
3280ec6b
This diff is collapsed.
Click to expand it.
lib/ClueModel/page/mechanismBox/MechanismBoxPage.dart
View file @
3280ec6b
...
...
@@ -5,6 +5,7 @@ import 'package:flutter_common/commonModel/toast/NativeToast.dart';
import
'package:gm_flutter/ClueModel/view/FiveStarView.dart'
;
import
'package:gm_flutter/commonModel/base/BaseComponent.dart'
;
import
'package:gm_flutter/ClueModel/page/mechanismBox/MechanismModel.dart'
;
import
'package:gm_flutter/commonModel/bean/Pair.dart'
;
class
MechanismBox
implements
IBottomPicker
{
VoidCallback
dismissCall
;
...
...
@@ -24,6 +25,30 @@ class MechanismBox implements IBottomPicker {
}
Widget
build
(
BuildContext
context
)
{
return
StreamBuilder
(
stream:
_model
.
stateLive
.
stream
,
initialData:
_model
.
stateLive
.
data
??
LOADING
,
builder:
(
c
,
data
)
{
if
(
data
.
data
==
FAIL
)
{
return
errorItem
(
MediaQuery
.
of
(
context
).
size
.
width
,
MediaQuery
.
of
(
context
).
size
.
height
,
()
{
_model
.
getQuestions
(
plan_id
);
});
}
if
(
data
.
data
==
LOADING
)
{
return
loadingItem
();
}
return
setupHome
(
context
);
},
);
}
@override
void
dispose
()
{
textController
.
dispose
();
}
setupHome
(
context
)
{
MediaQueryData
mq
=
MediaQuery
.
of
(
context
);
double
keyHeight
=
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
;
return
ClipRRect
(
...
...
@@ -44,11 +69,6 @@ class MechanismBox implements IBottomPicker {
);
}
@override
void
dispose
()
{
textController
.
dispose
();
}
// 弹窗标题
Widget
title
(
mq
)
{
return
Container
(
...
...
@@ -197,14 +217,16 @@ class MechanismBox implements IBottomPicker {
fontSize:
12
),
)),
Expanded
(
child:
StreamBuilder
<
List
<
String
>>(
child:
StreamBuilder
<
Pair
<
int
,
List
<
String
>
>>(
stream:
_model
.
questionsLive
.
stream
,
initialData:
_model
.
questionsLive
.
data
??
null
,
builder:
(
c
,
e
)
{
print
(
'dssdadsadas'
);
print
(
e
.
data
.
toString
());
if
(
e
.
data
==
null
)
{
return
Container
();
}
List
<
String
>
questions
=
e
.
data
;
List
<
String
>
questions
=
e
.
data
.
second
;
return
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
//横向滚动
itemBuilder:
(
c
,
index
)
{
...
...
lib/ClueModel/page/mechanismBox/MechanismModel.dart
View file @
3280ec6b
...
...
@@ -9,17 +9,15 @@ import 'package:flutter_common/commonModel/live/BaseModel.dart';
import
'package:flutter_common/commonModel/live/LiveData.dart'
;
import
'package:flutter_common/commonModel/toast/NativeToast.dart'
;
import
'package:gm_flutter/ClueModel/server/api/ClueApi.serv.dart'
;
import
'package:gm_flutter/ClueModel/server/entity/ConsultQuestionsBean.dart'
;
import
'package:gm_flutter/commonModel/net/DioUtil.dart'
;
import
'package:gm_flutter/commonModel/rx/RxDispose.dart'
;
import
'package:gm_flutter/commonModel/util/PrintUtil.dart'
;
import
'../../../commonModel/net/DioUtil.dart'
;
import
'../../../commonModel/util/PrintUtil.dart'
;
import
'../../server/api/ClueApi.serv.dart'
;
import
'package:gm_flutter/commonModel/bean/Pair.dart'
;
class
MechanismModel
extends
BaseModel
{
LiveData
<
List
<
String
>>
questionsLive
=
LiveData
();
LiveData
<
Pair
<
int
,
List
<
String
>>>
questionsLive
=
LiveData
();
LiveData
<
int
>
stateLive
=
LiveData
();
LiveData
messageLive
=
LiveData
();
RxDispose
rxDispose
=
RxDispose
();
...
...
@@ -28,26 +26,28 @@ class MechanismModel extends BaseModel {
.
getConsultQuestions
(
DioUtil
.
getInstance
().
getDio
(),
plan_id
)
.
listen
((
event
)
{
if
(
event
.
error
==
0
)
{
questionsLive
.
notifyView
(
event
.
data
.
questions
);
stateLive
.
notifyView
(
ENDLOADING
);
questionsLive
.
notifyView
(
Pair
(
ENDLOADING
,
event
.
data
.
questions
));
}
else
{
stateLive
.
notifyView
(
FAIL
);
questionsLive
.
notifyView
(
Pair
(
FAIL
,
null
));
NativeToast
.
showNativeToast
(
event
.
message
);
//TODO
}
})
.
addToDispose
(
rxDispose
)
.
onError
((
err
)
{
stateLive
.
notifyView
(
FAIL
);
questionsLive
.
notifyView
(
Pair
(
FAIL
,
null
));
PrintUtil
.
printBug
(
err
);
});
}
sendMessage
(
List
<
int
>
doctor_ids
,
String
question
,
int
plan_id
)
{
ClueApiImpl
.
getInstance
()
.
sendMessage
(
DioUtil
.
getInstance
().
getDio
(),
doctor_ids
,
question
,
plan_id
)
.
sendMessage
(
DioUtil
.
getInstance
().
getDio
(),
doctor_ids
,
question
,
plan_id
)
.
listen
((
event
)
{
print
(
'11111'
);
if
(
event
.
error
==
0
)
{
print
(
'kljfjkfdhkhkdfsklkds'
);
messageLive
.
notifyView
(
event
.
data
.
success
);
}
else
{
NativeToast
.
showNativeToast
(
event
.
message
);
...
...
@@ -62,6 +62,7 @@ class MechanismModel extends BaseModel {
@override
void
dispose
()
{
questionsLive
.
dispost
();
stateLive
.
dispost
();
rxDispose
.
dispose
();
}
}
lib/ClueModel/server/entity/PlanOverviewBean.dart
View file @
3280ec6b
...
...
@@ -58,8 +58,9 @@ class Data {
String
positiveRate
;
String
salesCount
;
String
planDescription
;
List
<
OverviewAttrs
>
overviewAttrs
;
List
<
ExplanationAttrs
>
explanationAttrs
;
String
guidePrice
;
List
<
OverviewAttrsEntity
>
overviewAttrs
;
List
<
ExplanationAttrsEntity
>
explanationAttrs
;
List
<
Tabs
>
tabs
;
Data
(
...
...
@@ -68,6 +69,7 @@ class Data {
this
.
positiveRate
,
this
.
salesCount
,
this
.
planDescription
,
this
.
guidePrice
,
this
.
overviewAttrs
,
this
.
explanationAttrs
,
this
.
tabs
});
...
...
@@ -79,16 +81,17 @@ class Data {
positiveRate
=
json
[
'positive_rate'
];
salesCount
=
json
[
'sales_count'
];
planDescription
=
json
[
'plan_description'
];
guidePrice
=
json
[
'guide_price'
];
if
(
json
[
'overview_attrs'
]
!=
null
)
{
overviewAttrs
=
new
List
<
OverviewAttrs
>();
overviewAttrs
=
new
List
<
OverviewAttrs
Entity
>();
json
[
'overview_attrs'
].
forEach
((
v
)
{
overviewAttrs
.
add
(
new
OverviewAttrs
.
fromJson
(
v
));
overviewAttrs
.
add
(
new
OverviewAttrs
Entity
.
fromJson
(
v
));
});
}
if
(
json
[
'explanation_attrs'
]
!=
null
)
{
explanationAttrs
=
new
List
<
ExplanationAttrs
>();
explanationAttrs
=
new
List
<
ExplanationAttrs
Entity
>();
json
[
'explanation_attrs'
].
forEach
((
v
)
{
explanationAttrs
.
add
(
new
ExplanationAttrs
.
fromJson
(
v
));
explanationAttrs
.
add
(
new
ExplanationAttrs
Entity
.
fromJson
(
v
));
});
}
if
(
json
[
'tabs'
]
!=
null
)
{
...
...
@@ -108,6 +111,7 @@ class Data {
data
[
'positive_rate'
]
=
this
.
positiveRate
;
data
[
'sales_count'
]
=
this
.
salesCount
;
data
[
'plan_description'
]
=
this
.
planDescription
;
data
[
'guide_price'
]
=
this
.
guidePrice
;
if
(
this
.
overviewAttrs
!=
null
)
{
data
[
'overview_attrs'
]
=
this
.
overviewAttrs
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
...
...
@@ -145,14 +149,14 @@ class Banner {
}
}
class
OverviewAttrs
{
class
OverviewAttrs
Entity
{
int
attrId
;
String
attrName
;
String
attrValue
;
OverviewAttrs
({
this
.
attrId
,
this
.
attrName
,
this
.
attrValue
});
OverviewAttrs
Entity
({
this
.
attrId
,
this
.
attrName
,
this
.
attrValue
});
OverviewAttrs
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
OverviewAttrs
Entity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
attrId
=
json
[
'attr_id'
];
attrName
=
json
[
'attr_name'
];
attrValue
=
json
[
'attr_value'
];
...
...
@@ -167,14 +171,14 @@ class OverviewAttrs {
}
}
class
ExplanationAttrs
{
class
ExplanationAttrs
Entity
{
int
attrId
;
String
attrName
;
String
attrValue
;
ExplanationAttrs
({
this
.
attrId
,
this
.
attrName
,
this
.
attrValue
});
ExplanationAttrs
Entity
({
this
.
attrId
,
this
.
attrName
,
this
.
attrValue
});
ExplanationAttrs
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
ExplanationAttrs
Entity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
attrId
=
json
[
'attr_id'
];
attrName
=
json
[
'attr_name'
];
attrValue
=
json
[
'attr_value'
];
...
...
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