Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
811b4ba5
提交
811b4ba5
authored
1月 12, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
评分及书评界面 接口调试与数据绑定
上级
c2ab2006
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
200 行增加
和
16 行删除
+200
-16
library.dart
lib/apis/library.dart
+22
-3
library.dart
lib/models/library.dart
+68
-0
view.dart
lib/pages/book_info/view.dart
+1
-1
controller.dart
lib/pages/book_score/controller.dart
+70
-0
index.dart
lib/pages/book_score/index.dart
+7
-0
view.dart
lib/pages/book_score/view.dart
+17
-5
item.dart
lib/pages/book_score/widgets/item.dart
+12
-6
routes.dart
lib/routes/routes.dart
+3
-1
没有找到文件。
lib/apis/library.dart
浏览文件 @
811b4ba5
...
...
@@ -33,7 +33,7 @@ abstract class LibraryAPI {
///
static
Future
<
List
<
CourseModel
>>
books
({
int
page
=
1
,
int
limit
=
2
0
,
int
limit
=
1
0
,
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/book/category/getBookList'
,
...
...
@@ -48,8 +48,26 @@ abstract class LibraryAPI {
});
}
/// 4、评分及书评
///
static
Future
<
List
<
ScoreModel
>>
scores
({
int
page
=
1
,
int
limit
=
10
,
required
String
bookId
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/book/Information/getBookCommentList'
,
params:
{
'page'
:
page
,
'pageSize'
:
limit
,
'book_id'
:
bookId
},
);
if
(
result
.
data
is
!
Map
&&
result
.
data
[
'list'
]
is
!
List
)
return
[];
return
List
.
generate
(
result
.
data
[
'list'
].
length
,
(
index
){
return
ScoreModel
.
fromJson
(
result
.
data
[
'list'
][
index
]);
});
}
}
\ No newline at end of file
lib/models/library.dart
浏览文件 @
811b4ba5
...
...
@@ -52,5 +52,73 @@ class LabelModel {
map
[
'name'
]
=
name
;
return
map
;
}
}
/// 3、书籍评价模型
///
/// book_comment_id : 4
/// comments : "bbbbbbb"
/// rating : 4.5
/// create_time : "2021-09-01 18:38:27"
/// members_id : 385
/// users : "王多余5"
/// users_img : ""
class
ScoreModel
{
ScoreModel
({
this
.
bookCommentId
,
this
.
comments
,
this
.
rating
,
this
.
createTime
,
this
.
membersId
,
this
.
users
,
this
.
usersImg
,});
ScoreModel
.
fromJson
(
dynamic
json
)
{
bookCommentId
=
json
[
'book_comment_id'
];
comments
=
json
[
'comments'
];
rating
=
json
[
'rating'
];
createTime
=
json
[
'create_time'
];
membersId
=
json
[
'members_id'
];
users
=
json
[
'users'
];
usersImg
=
json
[
'users_img'
];
}
num
?
bookCommentId
;
String
?
comments
;
num
?
rating
;
String
?
createTime
;
num
?
membersId
;
String
?
users
;
String
?
usersImg
;
ScoreModel
copyWith
({
num
?
bookCommentId
,
String
?
comments
,
num
?
rating
,
String
?
createTime
,
num
?
membersId
,
String
?
users
,
String
?
usersImg
,
})
=>
ScoreModel
(
bookCommentId:
bookCommentId
??
this
.
bookCommentId
,
comments:
comments
??
this
.
comments
,
rating:
rating
??
this
.
rating
,
createTime:
createTime
??
this
.
createTime
,
membersId:
membersId
??
this
.
membersId
,
users:
users
??
this
.
users
,
usersImg:
usersImg
??
this
.
usersImg
,
);
Map
<
String
,
dynamic
>
toJson
()
{
final
map
=
<
String
,
dynamic
>{};
map
[
'book_comment_id'
]
=
bookCommentId
;
map
[
'comments'
]
=
comments
;
map
[
'rating'
]
=
rating
;
map
[
'create_time'
]
=
createTime
;
map
[
'members_id'
]
=
membersId
;
map
[
'users'
]
=
users
;
map
[
'users_img'
]
=
usersImg
;
return
map
;
}
}
lib/pages/book_info/view.dart
浏览文件 @
811b4ba5
...
...
@@ -29,7 +29,7 @@ class _BookInfoPageState extends State<BookInfoPage> {
GestureDetector
(
child:
const
Text
(
'查看全部'
,
style:
TextStyle
(
fontSize:
11
,
color:
Colours
.
c9
),),
onTap:
(){
context
.
pushNamed
(
Routes
.
bookScore
);
context
.
pushNamed
(
Routes
.
bookScore
,
queryParameters:
{
'book_id'
:
'110'
}
);
},
),
Gaps
.
hGaps5
,
...
...
lib/pages/book_score/controller.dart
0 → 100644
浏览文件 @
811b4ba5
part of
book_score
;
class
BookScoreController
extends
GetxController
{
final
String
bookId
;
BookScoreController
(
this
.
bookId
);
final
EasyRefreshController
refreshController
=
EasyRefreshController
(
controlFinishLoad:
true
,
controlFinishRefresh:
true
,
);
// 评价列表
List
<
ScoreModel
>
scores
=
[];
@override
void
onClose
()
{
refreshController
.
dispose
();
super
.
onClose
();
}
final
int
_limit
=
10
;
int
_page
=
1
;
bool
_noMore
=
false
;
/// 获取课程内图书列表
Future
<
void
>
_getScores
(
String
bookId
,[
bool
isRefresh
=
false
])
async
{
if
(
isRefresh
)
_page
=
1
;
// 网路请求
final
result
=
await
LibraryAPI
.
scores
(
page:
_page
,
limit:
_limit
,
bookId:
bookId
);
// 如果是刷新 清理数据
if
(
isRefresh
)
scores
.
clear
();
scores
.
addAll
(
result
);
_page
++;
_noMore
=
result
.
length
<
_limit
;
update
();
}
void
onRefresh
()
async
{
try
{
await
_getScores
(
bookId
,
true
);
refreshController
.
finishRefresh
(
IndicatorResult
.
success
);
refreshController
.
resetFooter
();
}
catch
(
error
)
{
refreshController
.
finishRefresh
(
IndicatorResult
.
fail
);
}
}
void
onLoading
()
async
{
if
(
_noMore
)
{
refreshController
.
finishLoad
(
IndicatorResult
.
noMore
);
return
;
}
try
{
await
_getScores
(
bookId
);
refreshController
.
finishLoad
();
}
catch
(
error
)
{
refreshController
.
finishLoad
(
IndicatorResult
.
fail
);
}
}
}
\ No newline at end of file
lib/pages/book_score/index.dart
浏览文件 @
811b4ba5
library
book_score
;
import
'package:easy_refresh/easy_refresh.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_star/flutter_star.dart'
;
import
'package:get/get.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
part
'view.dart'
;
part
'widgets/item.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/book_score/view.dart
浏览文件 @
811b4ba5
...
...
@@ -3,7 +3,11 @@ part of book_score;
class
BookScorePage
extends
StatefulWidget
{
const
BookScorePage
({
Key
?
key
})
:
super
(
key:
key
);
final
String
bookId
;
const
BookScorePage
({
Key
?
key
,
required
this
.
bookId
})
:
super
(
key:
key
);
@override
State
<
BookScorePage
>
createState
()
=>
_BookScorePageState
();
...
...
@@ -12,16 +16,24 @@ class BookScorePage extends StatefulWidget {
class
_BookScorePageState
extends
State
<
BookScorePage
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
GetBuilder
<
BookScoreController
>(
init:
BookScoreController
(
widget
.
bookId
),
builder:
(
controller
)
=>
Scaffold
(
appBar:
AppBar
(
centerTitle:
true
,
title:
const
Text
(
'评分及书评'
),
),
body:
ListView
.
builder
(
body:
CustomPullScrollView
(
controller:
controller
.
refreshController
,
onRefresh:
controller
.
onRefresh
,
onLoading:
controller
.
onLoading
,
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
return
BuildItem
(
);
return
BuildItem
(
model:
controller
.
scores
[
index
],
);
},
itemCount:
5
,
itemCount:
controller
.
scores
.
length
,
),
),
),
);
}
...
...
lib/pages/book_score/widgets/item.dart
浏览文件 @
811b4ba5
part of
book_score
;
class
BuildItem
extends
StatelessWidget
{
const
BuildItem
({
Key
?
key
})
:
super
(
key:
key
);
final
ScoreModel
model
;
const
BuildItem
({
Key
?
key
,
required
this
.
model
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -22,6 +26,7 @@ class BuildItem extends StatelessWidget {
borderRadius:
BorderRadius
.
circular
(
8
)
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Row
(
children:
[
...
...
@@ -32,6 +37,7 @@ class BuildItem extends StatelessWidget {
color:
Colors
.
cyan
,
borderRadius:
BorderRadius
.
circular
(
17.5
)
),
child:
CustomImage
.
network
(
url:
model
.
usersImg
??
''
),
),
Gaps
.
hGaps10
,
Expanded
(
...
...
@@ -41,18 +47,18 @@ class BuildItem extends StatelessWidget {
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Text
(
'张三'
,
style:
TextStyle
(
fontSize:
12
,
height:
1.3
,
color:
Colours
.
c9
),),
Text
(
model
.
users
??
''
,
style:
const
TextStyle
(
fontSize:
12
,
height:
1.3
,
color:
Colours
.
c9
),),
// Spacer(),
Text
(
'2023-12-07'
,
style:
TextStyle
(
fontSize:
12
,
height:
1.3
,
color:
Colours
.
c9
),)
Text
(
model
.
createTime
??
''
,
style:
const
TextStyle
(
fontSize:
12
,
height:
1.3
,
color:
Colours
.
c9
),)
],
),
AbsorbPointer
(
absorbing:
true
,
child:
CustomRating
(
max:
5
,
score:
4.5
,
score:
model
.
rating
!.
toDouble
()
,
star:
const
Star
(
progress:
4
,
progress:
7
,
fillColor:
AppTheme
.
primary
,
size:
12
,
emptyColor:
Colours
.
cE2
,
...
...
@@ -65,7 +71,7 @@ class BuildItem extends StatelessWidget {
],
),
Gaps
.
vGaps15
,
const
Text
(
'这本书里有很多我比较喜欢的内容,总体来说真的很不错,很喜欢。'
,
style:
TextStyle
(
fontSize:
14
,
height:
1.5
,
color:
Colours
.
c3
),)
Text
(
model
.
comments
??
''
,
style:
const
TextStyle
(
fontSize:
14
,
height:
1.5
,
color:
Colours
.
c3
),)
],
),
),
...
...
lib/routes/routes.dart
浏览文件 @
811b4ba5
...
...
@@ -222,7 +222,9 @@ abstract class Routes {
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
name:
state
.
uri
.
toString
(),
key:
state
.
pageKey
,
child:
const
BookScorePage
()
child:
BookScorePage
(
bookId:
state
.
uri
.
queryParameters
[
'book_id'
].
toString
(),
)
)
),
GoRoute
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论