Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
6dc2c36c
提交
6dc2c36c
authored
1月 13, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
购物车 条目左滑删除
上级
7233760d
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
279 行增加
和
149 行删除
+279
-149
course.dart
lib/models/course.dart
+13
-1
index.dart
lib/pages/book_pay/index.dart
+6
-2
view.dart
lib/pages/book_pay/view.dart
+1
-1
item.dart
lib/pages/book_pay/widgets/item.dart
+92
-0
controller.dart
lib/pages/book_shop/controller.dart
+21
-1
index.dart
lib/pages/book_shop/index.dart
+1
-0
view.dart
lib/pages/book_shop/view.dart
+5
-54
book.dart
lib/pages/book_shop/widgets/book.dart
+82
-69
count.dart
lib/pages/book_shop/widgets/count.dart
+48
-21
pubspec.lock
pubspec.lock
+8
-0
pubspec.yaml
pubspec.yaml
+2
-0
没有找到文件。
lib/models/course.dart
浏览文件 @
6dc2c36c
...
...
@@ -29,7 +29,8 @@ class CourseModel {
this
.
price
,
this
.
vipPrice
,
this
.
status
,
this
.
cartId
this
.
cartId
,
this
.
selected
=
false
///
});
...
...
@@ -47,6 +48,13 @@ class CourseModel {
readNum
=
json
[
'read_num'
];
isCollection
=
json
[
'is_collection'
];
collectionId
=
json
[
'collection_id'
];
/// 购物车列表需要参数
price
=
json
[
'price'
];
vipPrice
=
json
[
'vip_price'
];
status
=
json
[
'status'
];
cartId
=
json
[
'cart_id'
];
selected
=
false
;
///
}
num
?
bookId
;
String
?
bookName
;
...
...
@@ -66,10 +74,14 @@ class CourseModel {
String
?
vipPrice
;
num
?
status
;
num
?
cartId
;
// 选中状态
late
bool
selected
;
///
int
get
type
{
if
(
progress
==
'0.00%'
){
return
0
;
...
...
lib/pages/book_pay/index.dart
浏览文件 @
6dc2c36c
...
...
@@ -3,8 +3,12 @@ library book_pay;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_slidable/flutter_slidable.dart'
;
import
'../../models/index.dart'
;
import
'../../utils/index.dart'
;
import
'../book_shop/index.dart'
;
part
'controller.dart'
;
part
'view.dart'
;
\ No newline at end of file
part
'view.dart'
;
part
'widgets/item.dart'
;
\ No newline at end of file
lib/pages/book_pay/view.dart
浏览文件 @
6dc2c36c
...
...
@@ -34,7 +34,7 @@ class _BookPayPageState extends State<BookPayPage> {
child:
SingleChildScrollView
(
child:
Column
(
children:
[
const
B
ookCell
(
type:
BookCellType
.
pay
,
),
const
B
uildItem
(
),
const
SizedBox
(
height:
10
,),
Container
(
height:
100
,
...
...
lib/pages/book_pay/widgets/item.dart
0 → 100644
浏览文件 @
6dc2c36c
part of
book_pay
;
class
BuildItem
extends
StatelessWidget
{
final
CourseModel
?
model
;
const
BuildItem
({
super
.
key
,
this
.
model
,
});
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
5
),
color:
Colors
.
white
,
boxShadow:
[
BoxShadow
(
color:
const
Color
(
0xFFC7C7C7
).
withOpacity
(
0.5
),
spreadRadius:
2
,
blurRadius:
5
,
offset:
const
Offset
(
3
,
0
),
// changes the position of the shadow
),
]
),
margin:
const
EdgeInsets
.
only
(
left:
10
,
right:
10
,
top:
10
),
height:
110
,
child:
Row
(
children:
[
///左侧
Container
(
margin:
const
EdgeInsets
.
only
(
left:
12
,
right:
11
),
child:
Row
(
children:
[
Container
(
height:
17
,
width:
17
,
color:
Colors
.
cyan
,
),
const
SizedBox
(
width:
12
,),
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
cyan
,
borderRadius:
BorderRadius
.
circular
(
3
),
boxShadow:
[
BoxShadow
(
color:
const
Color
(
0xFF707070
).
withOpacity
(
0.5
),
spreadRadius:
2
,
blurRadius:
5
,
offset:
const
Offset
(
3
,
0
),
// changes the position of the shadow
),
]
),
// color: Colors.white,
height:
86
,
width:
72
,
child:
Container
(
padding:
const
EdgeInsets
.
all
(
2
),
child:
Container
(
color:
Colors
.
cyan
,
),
),
)
],
),
),
///右侧
Expanded
(
child:
Container
(
padding:
const
EdgeInsets
.
only
(
top:
12
,
bottom:
10
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
model
!=
null
?
model
!.
bookName
.
toString
():
''
,
style:
const
TextStyle
(
fontSize:
13
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,),
const
SizedBox
(
height:
5
,),
Text
(
model
!=
null
?
model
!.
authors
.
toString
():
''
,
style:
const
TextStyle
(
fontSize:
11
,
color:
Colours
.
c9
)),
],
),
Text
(
'¥
${model != null?model!.authors.toString():''}
'
,
style:
const
TextStyle
(
fontSize:
14
,
fontWeight:
FontWeight
.
w500
,
color:
AppTheme
.
primary
)),
],
),
),
)
],
)
);
}
}
lib/pages/book_shop/controller.dart
浏览文件 @
6dc2c36c
...
...
@@ -20,7 +20,16 @@ class BookshopController extends GetxController {
super
.
onClose
();
}
/// 删除购物车 单个书籍
void
delCart
({
required
String
cartId
,
})
async
{
bool
result
=
await
ShopAPI
.
delCart
(
cartId:
cartId
);
if
(
result
)
{
onRefresh
();
}
}
/// 获取课程内图书列表
Future
<
void
>
_getCart
([
bool
isRefresh
=
false
])
async
{
...
...
@@ -33,12 +42,14 @@ class BookshopController extends GetxController {
// 如果是刷新 清理数据
if
(
isRefresh
)
carts
.
clear
();
carts
.
addAll
(
result
);
carts
.
addAll
(
_test
());
_page
++;
_noMore
=
result
.
length
<
_limit
;
update
();
}
void
onRefresh
()
async
{
try
{
await
_getCart
(
true
);
...
...
@@ -62,4 +73,12 @@ class BookshopController extends GetxController {
}
}
List
<
CourseModel
>
_test
(){
return
[
CourseModel
(),
CourseModel
(),
CourseModel
(),
];
}
}
\ No newline at end of file
lib/pages/book_shop/index.dart
浏览文件 @
6dc2c36c
...
...
@@ -4,6 +4,7 @@ import 'package:easy_refresh/easy_refresh.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_slidable/flutter_slidable.dart'
;
import
'package:get/get.dart'
;
import
'package:go_router/go_router.dart'
;
...
...
lib/pages/book_shop/view.dart
浏览文件 @
6dc2c36c
...
...
@@ -25,69 +25,20 @@ class _BookShopPageState extends State<BookShopPage> {
onLoading:
controller
.
onLoading
,
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
return
BookCell
(
model:
controller
.
carts
[
index
],);
CourseModel
model
=
controller
.
carts
[
index
];
return
BookCell
(
model:
model
,
onTap:
(){
controller
.
delCart
(
cartId:
model
.
cartId
.
toString
());
},);
},
itemCount:
controller
.
carts
.
length
,
),
),
),
create
Counter
()
Build
Counter
()
],
),
),
);
}
Widget
createCounter
()
{
return
Container
(
color:
Colors
.
white
,
padding:
const
EdgeInsets
.
only
(
left:
20
,
right:
15
),
child:
Column
(
children:
[
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Row
(
children:
[
Container
(
height:
17
,
width:
17
,
color:
Colors
.
yellow
,
),
const
SizedBox
(
width:
11
),
const
Text
(
'全选'
,
style:
TextStyle
(
color:
Color
(
0xFF333333
),
fontSize:
12
,
fontWeight:
FontWeight
.
w500
)),
const
SizedBox
(
width:
15
,),
const
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'合计 ¥98.9'
,
style:
TextStyle
(
color:
AppTheme
.
primary
,
fontSize:
12
,
fontWeight:
FontWeight
.
w500
)),
Text
(
'已选 2 件'
,
style:
TextStyle
(
color:
Color
(
0xFF999999
),
fontSize:
10
,))
],
)
],
),
GestureDetector
(
onTap:
(){
context
.
pushNamed
(
Routes
.
bookPay
);
},
child:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
vertical:
9
),
decoration:
BoxDecoration
(
color:
AppTheme
.
primary
,
borderRadius:
BorderRadius
.
circular
(
15
),
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
5
,
horizontal:
18
),
child:
const
Text
(
'结算(2)'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
12
,
fontWeight:
FontWeight
.
w500
),),
),
)
],
),
Container
(
height:
1
,
color:
const
Color
(
0xFFF9F9F9
),
)
],
),
);
}
}
lib/pages/book_shop/widgets/book.dart
浏览文件 @
6dc2c36c
part of
book_shop
;
enum
BookCellType
{
normal
,
pay
,
}
class
BookCell
extends
StatelessWidget
{
final
BookCellType
?
type
;
final
CourseModel
?
model
;
final
CourseModel
model
;
final
void
Function
()
onTap
;
const
BookCell
({
super
.
key
,
this
.
type
=
BookCellType
.
norma
l
,
this
.
model
required
this
.
mode
l
,
required
this
.
onTap
});
@override
...
...
@@ -23,76 +18,94 @@ class BookCell extends StatelessWidget {
boxShadow:
[
BoxShadow
(
color:
const
Color
(
0xFFC7C7C7
).
withOpacity
(
0.5
),
spreadRadius:
2
,
blurRadius:
5
,
spreadRadius:
0
,
blurRadius:
10
,
offset:
const
Offset
(
3
,
0
),
// changes the position of the shadow
),
]
],
border:
Border
.
all
(
width:
0.5
,
color:
AppTheme
.
primary
)
),
margin:
const
EdgeInsets
.
only
(
left:
10
,
right:
10
,
top:
10
),
height:
110
,
child:
Row
(
children:
[
///左侧
Container
(
margin:
const
EdgeInsets
.
only
(
left:
12
,
right:
11
),
child:
Row
(
children:
[
type
==
BookCellType
.
normal
?
Container
(
height:
17
,
width:
17
,
color:
Colors
.
cyan
,
):
const
SizedBox
(),
type
==
BookCellType
.
normal
?
const
SizedBox
(
width:
12
,):
const
SizedBox
(),
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
cyan
,
borderRadius:
BorderRadius
.
circular
(
3
),
boxShadow:
[
BoxShadow
(
color:
const
Color
(
0xFF707070
).
withOpacity
(
0.5
),
spreadRadius:
2
,
blurRadius:
5
,
offset:
const
Offset
(
3
,
0
),
// changes the position of the shadow
),
]
child:
Slidable
(
endActionPane:
ActionPane
(
motion:
const
ScrollMotion
(),
children:
[
SlidableAction
(
// An action can be bigger than the others.
onPressed:
(
BuildContext
context
){
onTap
;
},
backgroundColor:
AppTheme
.
primary
,
foregroundColor:
Colors
.
white
,
// icon: Icons.archive,
label:
'删除'
,
),
],
),
child:
Row
(
children:
[
///左侧
Container
(
margin:
const
EdgeInsets
.
only
(
left:
12
,
right:
11
),
child:
Row
(
children:
[
Container
(
height:
17
,
width:
17
,
color:
Colors
.
cyan
,
),
// color: Colors.white,
height:
86
,
width:
72
,
child:
Container
(
padding:
const
EdgeInsets
.
all
(
2
),
const
SizedBox
(
width:
12
,),
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
cyan
,
borderRadius:
BorderRadius
.
circular
(
3
),
boxShadow:
[
BoxShadow
(
color:
const
Color
(
0xFF707070
).
withOpacity
(
0.5
),
spreadRadius:
2
,
blurRadius:
5
,
offset:
const
Offset
(
3
,
0
),
// changes the position of the shadow
),
]
),
// color: Colors.white,
height:
86
,
width:
72
,
child:
Container
(
color:
Colors
.
cyan
,
padding:
const
EdgeInsets
.
all
(
2
),
child:
Container
(
color:
Colors
.
cyan
,
),
),
),
)
],
),
),
///右侧
Expanded
(
child:
Container
(
padding:
const
EdgeInsets
.
only
(
top:
12
,
bottom:
10
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
model
!=
null
?
model
!.
bookName
.
toString
():
''
,
style:
const
TextStyle
(
fontSize:
13
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,),
const
SizedBox
(
height:
5
,),
Text
(
model
!=
null
?
model
!.
authors
.
toString
():
''
,
style:
const
TextStyle
(
fontSize:
11
,
color:
Colours
.
c9
)),
],
),
Text
(
'¥
${model != null?model!.authors.toString():''}
'
,
style:
const
TextStyle
(
fontSize:
14
,
fontWeight:
FontWeight
.
w500
,
color:
AppTheme
.
primary
)),
],
),
)
],
),
),
)
],
///右侧
Expanded
(
child:
Container
(
padding:
const
EdgeInsets
.
only
(
top:
12
,
bottom:
10
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
model
!=
null
?
model
!.
bookName
.
toString
():
''
,
style:
const
TextStyle
(
fontSize:
13
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,),
const
SizedBox
(
height:
5
,),
Text
(
model
!=
null
?
model
!.
authors
.
toString
():
''
,
style:
const
TextStyle
(
fontSize:
11
,
color:
Colours
.
c9
)),
],
),
Text
(
'¥
${model != null?model!.authors.toString():''}
'
,
style:
const
TextStyle
(
fontSize:
14
,
fontWeight:
FontWeight
.
w500
,
color:
AppTheme
.
primary
)),
],
),
),
)
],
),
)
);
}
...
...
lib/pages/book_shop/widgets/count.dart
浏览文件 @
6dc2c36c
part of
book_shop
;
class
Counter
extends
StatelessWidget
{
const
Counter
({
Key
?
key
})
:
super
(
key:
key
);
class
Build
Counter
extends
StatelessWidget
{
const
Build
Counter
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Row
(
c
hildren:
[
GestureDetector
(
onTap:
(){
},
child:
Row
(
return
Container
(
c
olor:
Colors
.
white
,
padding:
const
EdgeInsets
.
only
(
left:
20
,
right:
15
),
child:
Column
(
children:
[
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Container
(
width:
20
,
height:
20
,
color:
Colors
.
cyan
,),
const
SizedBox
(
width:
11
,),
const
Text
(
'全选'
,
style:
TextStyle
(
color:
Color
(
0xFF333333
),
fontSize:
12
,
fontWeight:
FontWeight
.
w500
)),
Row
(
children:
[
Container
(
height:
17
,
width:
17
,
color:
Colors
.
yellow
,
),
const
SizedBox
(
width:
11
),
const
Text
(
'全选'
,
style:
TextStyle
(
color:
Color
(
0xFF333333
),
fontSize:
12
,
fontWeight:
FontWeight
.
w500
)),
const
SizedBox
(
width:
15
,),
const
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'合计 ¥98.9'
,
style:
TextStyle
(
color:
AppTheme
.
primary
,
fontSize:
12
,
fontWeight:
FontWeight
.
w500
)),
Text
(
'已选 2 件'
,
style:
TextStyle
(
color:
Color
(
0xFF999999
),
fontSize:
10
,))
],
)
],
),
GestureDetector
(
onTap:
(){
context
.
pushNamed
(
Routes
.
bookPay
);
},
child:
Container
(
margin:
const
EdgeInsets
.
symmetric
(
vertical:
9
),
decoration:
BoxDecoration
(
color:
AppTheme
.
primary
,
borderRadius:
BorderRadius
.
circular
(
15
),
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
5
,
horizontal:
18
),
child:
const
Text
(
'结算(2)'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
12
,
fontWeight:
FontWeight
.
w500
),),
),
)
],
),
),
Column
(
children:
[
Text
(
'合计'
,
style:
TextStyle
(
color:
AppTheme
.
primary
)),
Text
(
'已选1件'
,
style:
TextStyle
(
color:
Color
(
0xFF333333
)),)
],
),
],
Container
(
height:
1
,
color:
const
Color
(
0xFFF9F9F9
),
)
],
),
);
}
}
pubspec.lock
浏览文件 @
6dc2c36c
...
...
@@ -187,6 +187,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.8.2"
flutter_slidable:
dependency: "direct main"
description:
name: flutter_slidable
sha256: "19ed4813003a6ff4e9c6bcce37e792a2a358919d7603b2b31ff200229191e44c"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
flutter_sound:
dependency: "direct main"
description:
...
...
pubspec.yaml
浏览文件 @
6dc2c36c
...
...
@@ -79,6 +79,8 @@ dependencies:
flutter_star
:
^1.2.0
# toast
oktoast
:
^3.0.0
# 策划
flutter_slidable
:
^3.0.1
dev_dependencies
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论