Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
a6bc143c
提交
a6bc143c
authored
1月 25, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
结算界面 所有逻辑完成(除提交接口)
上级
8c870c25
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
188 行增加
和
56 行删除
+188
-56
unused_coupon.png
assets/images/2.0x/unused_coupon.png
+0
-0
unused_coupon.png
assets/images/3.0x/unused_coupon.png
+0
-0
unused_coupon.png
assets/images/unused_coupon.png
+0
-0
shop.dart
lib/apis/shop.dart
+15
-0
mine.dart
lib/models/mine.dart
+6
-4
shop.dart
lib/models/shop.dart
+27
-0
controller.dart
lib/pages/book_pay/controller.dart
+29
-3
view.dart
lib/pages/book_pay/view.dart
+28
-10
pay_count.dart
lib/pages/book_pay/widgets/pay_count.dart
+8
-3
controller.dart
lib/pages/pay_coupon/controller.dart
+14
-10
index.dart
lib/pages/pay_coupon/index.dart
+2
-0
view.dart
lib/pages/pay_coupon/view.dart
+40
-15
item.dart
lib/pages/pay_coupon/widgets/item.dart
+15
-10
routes.dart
lib/routes/routes.dart
+3
-1
styles.dart
lib/utils/styles.dart
+1
-0
没有找到文件。
assets/images/2.0x/unused_coupon.png
0 → 100644
浏览文件 @
a6bc143c
932 Bytes
assets/images/3.0x/unused_coupon.png
0 → 100644
浏览文件 @
a6bc143c
1.8 KB
assets/images/unused_coupon.png
0 → 100644
浏览文件 @
a6bc143c
434 Bytes
lib/apis/shop.dart
浏览文件 @
a6bc143c
...
@@ -95,5 +95,19 @@ abstract class ShopAPI {
...
@@ -95,5 +95,19 @@ abstract class ShopAPI {
return
CouponListModel
.
fromJson
(
result
.
data
);
return
CouponListModel
.
fromJson
(
result
.
data
);
}
}
/// 7、获取优惠券可使用和不可使用数量
static
Future
<
CouponNumModel
>
couponNum
({
required
String
price
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/coupon/Coupon/getCouponNum'
,
params:
{
'price'
:
price
},
);
if
(
result
.
data
is
!
Map
)
return
CouponNumModel
();
return
CouponNumModel
.
fromJson
(
result
.
data
);
}
}
}
\ No newline at end of file
lib/models/mine.dart
浏览文件 @
a6bc143c
...
@@ -71,17 +71,18 @@ class RecordModel {
...
@@ -71,17 +71,18 @@ class RecordModel {
class
CouponModel
{
class
CouponModel
{
CouponModel
({
CouponModel
({
this
.
couponRecId
,
this
.
couponRecId
,
//
this.endTime,
this
.
endTime
,
this
.
couponId
,
this
.
couponId
,
this
.
useStatus
,
this
.
useStatus
,
this
.
couponName
,
this
.
couponName
,
this
.
normPrice
,
this
.
normPrice
,
this
.
reducedPrice
,
this
.
reducedPrice
,
this
.
type
});
});
CouponModel
.
fromJson
(
dynamic
json
)
{
CouponModel
.
fromJson
(
dynamic
json
)
{
couponRecId
=
json
[
'coupon_rec_id'
];
couponRecId
=
json
[
'coupon_rec_id'
];
//
endTime = json['end_time'];
endTime
=
json
[
'end_time'
];
couponId
=
json
[
'coupon_id'
];
couponId
=
json
[
'coupon_id'
];
useStatus
=
json
[
'use_status'
];
useStatus
=
json
[
'use_status'
];
couponName
=
json
[
'coupon_name'
];
couponName
=
json
[
'coupon_name'
];
...
@@ -90,12 +91,13 @@ class CouponModel {
...
@@ -90,12 +91,13 @@ class CouponModel {
}
}
num
?
couponRecId
;
num
?
couponRecId
;
//
String? endTime;
String
?
endTime
;
num
?
couponId
;
num
?
couponId
;
num
?
useStatus
;
num
?
useStatus
;
String
?
couponName
;
String
?
couponName
;
num
?
normPrice
;
num
?
normPrice
;
String
?
reducedPrice
;
String
?
reducedPrice
;
num
?
type
;
CouponModel
copyWith
({
CouponModel
copyWith
({
num
?
couponRecId
,
num
?
couponRecId
,
...
@@ -108,7 +110,7 @@ class CouponModel {
...
@@ -108,7 +110,7 @@ class CouponModel {
})
=>
})
=>
CouponModel
(
CouponModel
(
couponRecId:
couponRecId
??
this
.
couponRecId
,
couponRecId:
couponRecId
??
this
.
couponRecId
,
//
endTime: endTime ?? this.endTime,
endTime:
endTime
??
this
.
endTime
,
couponId:
couponId
??
this
.
couponId
,
couponId:
couponId
??
this
.
couponId
,
useStatus:
useStatus
??
this
.
useStatus
,
useStatus:
useStatus
??
this
.
useStatus
,
couponName:
couponName
??
this
.
couponName
,
couponName:
couponName
??
this
.
couponName
,
...
...
lib/models/shop.dart
浏览文件 @
a6bc143c
...
@@ -123,3 +123,29 @@ class CouponListModel {
...
@@ -123,3 +123,29 @@ class CouponListModel {
}
}
}
}
/// 优惠券可使用和不可使用数量
class
CouponNumModel
{
CouponNumModel
({
this
.
availableNum
,
this
.
unavailableNum
,});
CouponNumModel
.
fromJson
(
dynamic
json
)
{
availableNum
=
json
[
'available_num'
];
unavailableNum
=
json
[
'unavailable_num'
];
}
num
?
availableNum
;
num
?
unavailableNum
;
CouponNumModel
copyWith
({
num
?
availableNum
,
num
?
unavailableNum
,
})
=>
CouponNumModel
(
availableNum:
availableNum
??
this
.
availableNum
,
unavailableNum:
unavailableNum
??
this
.
unavailableNum
,
);
Map
<
String
,
dynamic
>
toJson
()
{
final
map
=
<
String
,
dynamic
>{};
map
[
'available_num'
]
=
availableNum
;
map
[
'unavailable_num'
]
=
unavailableNum
;
return
map
;
}
}
\ No newline at end of file
lib/pages/book_pay/controller.dart
浏览文件 @
a6bc143c
...
@@ -11,6 +11,10 @@ class BookPayController extends GetxController {
...
@@ -11,6 +11,10 @@ class BookPayController extends GetxController {
// 是否使用积分
// 是否使用积分
bool
useCreditPoint
=
false
;
bool
useCreditPoint
=
false
;
// 优惠券可用不可用数量模型
CouponNumModel
couponNumModel
=
CouponNumModel
();
// 选择的优惠券模型
late
CouponModel
useCouponModel
=
CouponModel
(
couponId:
0
,
reducedPrice:
'0.00'
);
// 支付方式
// 支付方式
List
<
PayModel
>
pays
=
Platform
.
isIOS
?[
List
<
PayModel
>
pays
=
Platform
.
isIOS
?[
...
@@ -29,23 +33,34 @@ class BookPayController extends GetxController {
...
@@ -29,23 +33,34 @@ class BookPayController extends GetxController {
late
double
finalPrice
=
0.00
;
late
double
finalPrice
=
0.00
;
@override
@override
void
onReady
()
{
void
onReady
()
{
_getCreditPoints
(
price:
'100'
);
_getCreditPoints
(
price:
originalPrice
.
toString
()
);
_getShow
();
_getShow
();
computeFinalPrice
();
computeFinalPrice
();
_getCouponNumber
();
super
.
onReady
();
super
.
onReady
();
}
}
// 支付方式
/// 使用优惠券
void
setUseCoupon
(
CouponModel
model
){
useCouponModel
=
model
;
print
(
'使用优惠券。。。。。。。。。。。。。。。。'
);
computeFinalPrice
();
}
/// 支付方式 默认第一个
late
PayModel
_payModel
=
pays
.
first
;
late
PayModel
_payModel
=
pays
.
first
;
PayModel
get
payModel
=>
_payModel
;
PayModel
get
payModel
=>
_payModel
;
/// 选择积分状态
void
show
(){
void
show
(){
showDetail
=
!
showDetail
;
showDetail
=
!
showDetail
;
update
();
update
();
}
}
/// 设置支付渠道
void
setPayModel
(
PayModel
payModel
){
void
setPayModel
(
PayModel
payModel
){
for
(
PayModel
model
in
pays
)
{
for
(
PayModel
model
in
pays
)
{
if
(
model
.
type
==
payModel
.
type
){
if
(
model
.
type
==
payModel
.
type
){
...
@@ -59,6 +74,7 @@ class BookPayController extends GetxController {
...
@@ -59,6 +74,7 @@ class BookPayController extends GetxController {
update
();
update
();
}
}
/// 是否使用积分
void
setUse
(){
void
setUse
(){
useCreditPoint
=
!
useCreditPoint
;
useCreditPoint
=
!
useCreditPoint
;
// 计算
// 计算
...
@@ -74,12 +90,18 @@ class BookPayController extends GetxController {
...
@@ -74,12 +90,18 @@ class BookPayController extends GetxController {
creditPointModel
=
await
ShopAPI
.
creditPoints
(
price:
price
);
creditPointModel
=
await
ShopAPI
.
creditPoints
(
price:
price
);
update
();
update
();
}
}
/// 是否展示优惠券 和积分使用 模型
void
_getShow
()
async
{
void
_getShow
()
async
{
showModel
=
await
ShopAPI
.
show
();
showModel
=
await
ShopAPI
.
show
();
update
();
update
();
}
}
/// 获取优惠券可用数量与不可用数量模型
void
_getCouponNumber
()
async
{
couponNumModel
=
await
ShopAPI
.
couponNum
(
price:
originalPrice
.
toString
());
update
();
}
/// 获取优惠前的价钱
/// 获取优惠前的价钱
/// 总价钱
/// 总价钱
...
@@ -101,6 +123,10 @@ class BookPayController extends GetxController {
...
@@ -101,6 +123,10 @@ class BookPayController extends GetxController {
if
(
useCreditPoint
){
if
(
useCreditPoint
){
finalPrice
=
finalPrice
-
Decimal
.
parse
(
creditPointModel
.
deductibleAmount
??
'0.00'
).
toDouble
();
finalPrice
=
finalPrice
-
Decimal
.
parse
(
creditPointModel
.
deductibleAmount
??
'0.00'
).
toDouble
();
}
}
// 不等0的时候证明使用了 优惠券
if
(
useCouponModel
.
couponId
!=
0
){
finalPrice
=
finalPrice
-
Decimal
.
parse
(
useCouponModel
.
reducedPrice
??
'0.00'
).
toDouble
();
}
update
();
update
();
}
}
...
...
lib/pages/book_pay/view.dart
浏览文件 @
a6bc143c
...
@@ -55,7 +55,7 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -55,7 +55,7 @@ class _BookPayPageState extends State<BookPayPage> {
controller
.
showModel
.
couponSwitch
==
'0'
?
const
SizedBox
():
GestureDetector
(
controller
.
showModel
.
couponSwitch
==
'0'
?
const
SizedBox
():
GestureDetector
(
child:
_buildCouponWidget
(
controller
,
title:
'优惠券'
,
icon:
'assets/images/pay_coupon.png'
,),
child:
_buildCouponWidget
(
controller
,
title:
'优惠券'
,
icon:
'assets/images/pay_coupon.png'
,),
onTap:
(){
onTap:
(){
context
.
pushNamed
(
Routes
.
payCoupon
);
context
.
pushNamed
(
Routes
.
payCoupon
,
extra:
controller
);
},
},
),
),
Container
(
height:
0.5
.
w
,
color:
Colours
.
cF0
,
margin:
EdgeInsets
.
only
(
left:
10
.
w
),),
Container
(
height:
0.5
.
w
,
color:
Colours
.
cF0
,
margin:
EdgeInsets
.
only
(
left:
10
.
w
),),
...
@@ -109,7 +109,7 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -109,7 +109,7 @@ class _BookPayPageState extends State<BookPayPage> {
showTap:
(){
showTap:
(){
controller
.
show
();
controller
.
show
();
Console
.
log
(
'--------------展示优惠详情------------------'
);
Console
.
log
(
'--------------展示优惠详情------------------'
);
}
}
,
controller:
controller
,
)),
)),
),
),
controller
.
showDetail
?
Positioned
(
controller
.
showDetail
?
Positioned
(
...
@@ -153,7 +153,7 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -153,7 +153,7 @@ class _BookPayPageState extends State<BookPayPage> {
child:
const
Row
(
child:
const
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Text
(
'应付明细'
,
textAlign:
TextAlign
.
center
),
Text
(
'应付明细'
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
fontSize:
15
,
height:
1.1
,
color:
Colours
.
c3
,
fontWeight:
Fonts
.
medium
),
),
],
],
),
),
),
),
...
@@ -182,25 +182,25 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -182,25 +182,25 @@ class _BookPayPageState extends State<BookPayPage> {
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
children:
[
Text
(
'总价'
,
style:
TextStyle
(
fontSize:
16
.
w
,
height:
1.5
,
color:
Colours
.
c3
,
fontWeight:
Fonts
.
medium
),),
Text
(
'总价'
,
style:
TextStyle
(
fontSize:
16
.
w
,
height:
1.5
,
color:
Colours
.
c3
,
fontWeight:
Fonts
.
medium
),),
Text
(
'¥
199.80
'
,
style:
TextStyle
(
fontSize:
15
.
w
,
height:
1.5
,
color:
AppTheme
.
primary
,
fontWeight:
Fonts
.
medium
),)
Text
(
'¥
${controller.finalPrice}
'
,
style:
TextStyle
(
fontSize:
15
.
w
,
height:
1.5
,
color:
AppTheme
.
primary
,
fontWeight:
Fonts
.
medium
),)
],
],
),
),
Gaps
.
vGaps15
,
Gaps
.
vGaps15
,
Row
(
controller
.
showModel
.
couponSwitch
==
'1'
?
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
children:
[
Text
(
'优惠券抵扣'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),),
Text
(
'优惠券抵扣'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),),
Text
(
'减¥
199.80
'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
AppTheme
.
primary
),)
Text
(
'减¥
${controller.useCouponModel.reducedPrice}
'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
AppTheme
.
primary
),)
],
],
),
)
:
const
SizedBox
()
,
Gaps
.
vGaps10
,
Gaps
.
vGaps10
,
Row
(
controller
.
showModel
.
integralSwitch
==
'1'
?
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
children:
[
Text
(
'积分抵扣'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),),
Text
(
'积分抵扣'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),),
Text
(
'减¥
199.80
'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
AppTheme
.
primary
),)
Text
(
'减¥
${controller.useCreditPoint?controller.creditPointModel.deductibleAmount:'0.00'}
'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
AppTheme
.
primary
),)
],
],
)
)
:
const
SizedBox
()
],
],
),
),
)
)
...
@@ -232,6 +232,22 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -232,6 +232,22 @@ class _BookPayPageState extends State<BookPayPage> {
Text
(
title
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.1
)),
Text
(
title
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.1
)),
],
],
),
),
Row
(
children:
[
controller
.
useCouponModel
.
couponId
!=
0
?
Row
(
children:
[
Text
(
'「满
${controller.useCouponModel.normPrice}
减
${controller.useCouponModel.reducedPrice}
」-¥
${controller.useCouponModel.reducedPrice}
'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.3
,
color:
AppTheme
.
primary
),),
Gaps
.
hGaps10
,
GestureDetector
(
child:
Image
.
asset
(
'assets/images/unused_coupon.png'
),
onTap:
(){
CouponModel
model
=
CouponModel
(
couponId:
0
);
controller
.
setUseCoupon
(
model
);
},
)
],
):
controller
.
couponNumModel
.
availableNum
==
0
?
Text
(
'暂无可用'
,
style:
TextStyle
(
fontSize:
13
.
w
,
color:
Colours
.
c9
,
height:
1.4
)):
Text
(
'
${controller.couponNumModel.availableNum??''}
个可用'
,
style:
TextStyle
(
fontSize:
13
.
w
,
color:
AppTheme
.
primary
,
height:
1.4
)),
Gaps
.
hGaps10
,
SizedBox
(
SizedBox
(
// color: Colors.cyan,
// color: Colors.cyan,
width:
5
.
w
,
width:
5
.
w
,
...
@@ -239,6 +255,8 @@ class _BookPayPageState extends State<BookPayPage> {
...
@@ -239,6 +255,8 @@ class _BookPayPageState extends State<BookPayPage> {
child:
Image
.
asset
(
'assets/images/right_arrow.png'
),
child:
Image
.
asset
(
'assets/images/right_arrow.png'
),
),
),
],
],
)
],
),
),
);
);
}
}
...
...
lib/pages/book_pay/widgets/pay_count.dart
浏览文件 @
a6bc143c
...
@@ -3,10 +3,12 @@ part of book_pay;
...
@@ -3,10 +3,12 @@ part of book_pay;
class
BuildPayCount
extends
StatelessWidget
{
class
BuildPayCount
extends
StatelessWidget
{
final
void
Function
()?
payTap
;
final
void
Function
()?
payTap
;
final
void
Function
()?
showTap
;
final
void
Function
()?
showTap
;
final
BookPayController
controller
;
const
BuildPayCount
({
const
BuildPayCount
({
Key
?
key
,
Key
?
key
,
required
this
.
payTap
,
required
this
.
payTap
,
required
this
.
showTap
,
required
this
.
showTap
,
required
this
.
controller
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
...
@@ -22,22 +24,25 @@ class BuildPayCount extends StatelessWidget {
...
@@ -22,22 +24,25 @@ class BuildPayCount extends StatelessWidget {
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
children:
[
GestureDetector
(
IgnorePointer
(
ignoring:
controller
.
showModel
.
integralSwitch
==
'0'
&&
controller
.
showModel
.
couponSwitch
==
''
?
true
:
false
,
child:
GestureDetector
(
onTap:
showTap
,
onTap:
showTap
,
child:
Row
(
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
children:
[
Text
(
'应付:'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.1
),),
Text
(
'应付:'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
,
height:
1.1
),),
Text
(
'¥
${controller.finalPrice}
'
,
style:
TextStyle
(
fontSize:
15
.
w
,
color:
AppTheme
.
primary
,
fontWeight:
Fonts
.
medium
,
height:
1.1
),),
Text
(
'¥
${controller.finalPrice}
'
,
style:
TextStyle
(
fontSize:
15
.
w
,
color:
AppTheme
.
primary
,
fontWeight:
Fonts
.
medium
,
height:
1.1
),),
SizedBox
(
controller
.
showModel
.
integralSwitch
==
'1'
&&
controller
.
showModel
.
couponSwitch
==
'1'
?
SizedBox
(
// color: Colors.cyan,
// color: Colors.cyan,
width:
20
.
w
,
width:
20
.
w
,
height:
20
.
w
,
height:
20
.
w
,
child:
Image
.
asset
(
'assets/images/pay_up.png'
)
child:
Image
.
asset
(
'assets/images/pay_up.png'
)
)
):
const
SizedBox
(
)
],
],
),
),
),
),
),
GestureDetector
(
GestureDetector
(
onTap:
payTap
,
onTap:
payTap
,
child:
Container
(
child:
Container
(
...
...
lib/pages/pay_coupon/controller.dart
浏览文件 @
a6bc143c
part of
pay_coupon
;
part of
pay_coupon
;
class
PayCouponController
extends
GetxController
with
GetSingleTickerProviderStateMixin
{
class
PayCouponController
extends
GetxController
with
GetSingleTickerProviderStateMixin
{
final
String
tag
;
final
String
tag
;
PayCouponController
(
this
.
tag
);
final
BookPayController
payController
;
PayCouponController
(
this
.
tag
,
this
.
payController
){
// tabs = [
// Tab(text: '可用(${payController.couponNumModel.availableNum})',),
// Tab(text: '不可用(${payController.couponNumModel.unavailableNum})',),
// ];
}
List
<
Widget
>
tabs
=
[
// List <Widget>tabs = [];
const
Tab
(
text:
'可用'
,),
// late TabController tabController = TabController(length:tabs.length, vsync: this);
const
Tab
(
text:
'不可用'
,),
];
late
TabController
tabController
=
TabController
(
length:
tabs
.
length
,
vsync:
this
);
final
EasyRefreshController
refreshController
=
EasyRefreshController
(
final
EasyRefreshController
refreshController
=
EasyRefreshController
(
controlFinishLoad:
true
,
controlFinishLoad:
true
,
...
@@ -36,11 +40,11 @@ class PayCouponController extends GetxController with GetSingleTickerProviderSta
...
@@ -36,11 +40,11 @@ class PayCouponController extends GetxController with GetSingleTickerProviderSta
type:
tag
,
type:
tag
,
price:
price
price:
price
);
);
for
(
CouponModel
model
in
result
.
list
!)
{
print
(
'================================
${tag}
'
);
model
.
type
=
num
.
parse
(
tag
);
}
tabs
=
[
Tab
(
text:
'可用(
${tag =='0'?result.list!.length:''}
)'
,),
Tab
(
text:
'不可用(
${tag =='1'?result.list!.length:''}
)'
,),
];
// 如果是刷新 清理数据
// 如果是刷新 清理数据
if
(
isRefresh
)
coupons
.
clear
();
if
(
isRefresh
)
coupons
.
clear
();
...
...
lib/pages/pay_coupon/index.dart
浏览文件 @
a6bc143c
...
@@ -7,11 +7,13 @@ import 'package:flutter_book/pages/user_coupon/index.dart';
...
@@ -7,11 +7,13 @@ import 'package:flutter_book/pages/user_coupon/index.dart';
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:go_router/go_router.dart'
;
import
'../../apis/index.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
import
'../../models/index.dart'
;
import
'../../theme.dart'
;
import
'../../theme.dart'
;
import
'../../utils/index.dart'
;
import
'../../utils/index.dart'
;
import
'../book_pay/index.dart'
;
part
'view.dart'
;
part
'view.dart'
;
...
...
lib/pages/pay_coupon/view.dart
浏览文件 @
a6bc143c
...
@@ -3,18 +3,34 @@ part of pay_coupon;
...
@@ -3,18 +3,34 @@ part of pay_coupon;
class
PayCouponPage
extends
StatefulWidget
{
class
PayCouponPage
extends
StatefulWidget
{
const
PayCouponPage
({
Key
?
key
})
:
super
(
key:
key
);
final
BookPayController
payController
;
const
PayCouponPage
({
Key
?
key
,
required
this
.
payController
})
:
super
(
key:
key
);
@override
@override
State
<
PayCouponPage
>
createState
()
=>
_PayCouponPageState
();
State
<
PayCouponPage
>
createState
()
=>
_PayCouponPageState
();
}
}
class
_PayCouponPageState
extends
State
<
PayCouponPage
>
{
class
_PayCouponPageState
extends
State
<
PayCouponPage
>
with
SingleTickerProviderStateMixin
{
List
<
Widget
>
tabs
=
[];
late
TabController
tabController
;
@override
void
initState
()
{
tabs
=
[
Tab
(
text:
'可用(
${widget.payController.couponNumModel.availableNum}
)'
,),
Tab
(
text:
'不可用(
${widget.payController.couponNumModel.unavailableNum}
)'
,),
];
tabController
=
TabController
(
length:
tabs
.
length
,
vsync:
this
);
super
.
initState
();
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
PayCouponController
>(
return
Scaffold
(
init:
PayCouponController
(
'main'
),
builder:
(
controller
)
=>
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
centerTitle:
true
,
centerTitle:
true
,
title:
const
Text
(
'选择优惠券'
),
title:
const
Text
(
'选择优惠券'
),
...
@@ -28,41 +44,44 @@ class _PayCouponPageState extends State<PayCouponPage> {
...
@@ -28,41 +44,44 @@ class _PayCouponPageState extends State<PayCouponPage> {
unselectedLabelStyle:
TextStyle
(
fontSize:
15
.
w
,
height:
1.4
),
unselectedLabelStyle:
TextStyle
(
fontSize:
15
.
w
,
height:
1.4
),
indicatorSize:
TabBarIndicatorSize
.
label
,
indicatorSize:
TabBarIndicatorSize
.
label
,
indicatorColor:
AppTheme
.
primary
,
indicatorColor:
AppTheme
.
primary
,
tabs:
controller
.
tabs
,
tabs:
tabs
,
physics:
const
NeverScrollableScrollPhysics
(),
physics:
const
NeverScrollableScrollPhysics
(),
controller:
controller
.
tabController
,
controller:
tabController
,
),
),
Expanded
(
Expanded
(
child:
TabBarView
(
child:
TabBarView
(
controller:
controller
.
tabController
,
controller:
tabController
,
children:
List
.
generate
(
controller
.
tabs
.
length
,
(
index
){
children:
List
.
generate
(
tabs
.
length
,
(
index
){
return
CouponPage
(
tag:
'
$
index
'
);
return
CouponPage
(
tag:
'
$
{1-index}
'
,
payController:
widget
.
payController
,
);
})
})
),
),
),
),
],
],
),
),
),
);
);
}
}
}
}
class
CouponPage
extends
StatefulWidget
{
class
CouponPage
extends
StatefulWidget
{
final
String
tag
;
final
String
tag
;
final
BookPayController
payController
;
const
CouponPage
({
const
CouponPage
({
Key
?
key
,
Key
?
key
,
required
this
.
tag
required
this
.
tag
,
required
this
.
payController
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
@override
@override
State
<
CouponPage
>
createState
()
=>
_CouponPageState
();
State
<
CouponPage
>
createState
()
=>
_CouponPageState
();
}
}
class
_CouponPageState
extends
State
<
CouponPage
>
{
class
_CouponPageState
extends
State
<
CouponPage
>
with
AutomaticKeepAliveClientMixin
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
PayCouponController
>(
return
GetBuilder
<
PayCouponController
>(
init:
PayCouponController
(
widget
.
tag
),
tag:
widget
.
tag
,
init:
PayCouponController
(
widget
.
tag
,
widget
.
payController
),
builder:
(
controller
)
=>
CustomPullScrollView
(
builder:
(
controller
)
=>
CustomPullScrollView
(
controller:
controller
.
refreshController
,
controller:
controller
.
refreshController
,
onRefresh:
controller
.
onRefresh
,
onRefresh:
controller
.
onRefresh
,
...
@@ -70,13 +89,19 @@ class _CouponPageState extends State<CouponPage> {
...
@@ -70,13 +89,19 @@ class _CouponPageState extends State<CouponPage> {
child:
ListView
.
builder
(
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
itemBuilder:
(
BuildContext
context
,
int
index
){
CouponModel
model
=
controller
.
coupons
[
index
];
CouponModel
model
=
controller
.
coupons
[
index
];
return
BuildItem
(
model:
model
,);
return
BuildItem
(
model:
model
,
useTap:
(){
widget
.
payController
.
setUseCoupon
(
model
);
context
.
pop
();
},);
},
},
itemCount:
controller
.
coupons
.
length
,
itemCount:
controller
.
coupons
.
length
,
),
),
),
),
);
);
}
}
@override
bool
get
wantKeepAlive
=>
true
;
}
}
...
...
lib/pages/pay_coupon/widgets/item.dart
浏览文件 @
a6bc143c
...
@@ -2,9 +2,11 @@ part of pay_coupon;
...
@@ -2,9 +2,11 @@ part of pay_coupon;
class
BuildItem
extends
StatelessWidget
{
class
BuildItem
extends
StatelessWidget
{
final
CouponModel
model
;
final
CouponModel
model
;
final
void
Function
()?
useTap
;
const
BuildItem
({
const
BuildItem
({
Key
?
key
,
Key
?
key
,
required
this
.
model
required
this
.
model
,
required
this
.
useTap
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
@override
@override
...
@@ -28,7 +30,7 @@ class BuildItem extends StatelessWidget {
...
@@ -28,7 +30,7 @@ class BuildItem extends StatelessWidget {
children:
[
children:
[
Stack
(
Stack
(
children:
[
children:
[
Image
.
asset
(
'assets/images/coupon_yes
.png'
),
Image
.
asset
(
model
.
type
==
1
?
'assets/images/coupon_yes.png'
:
'assets/images/coupon_no
.png'
),
Positioned
(
Positioned
(
left:
0
.
w
,
left:
0
.
w
,
right:
0
.
w
,
right:
0
.
w
,
...
@@ -42,16 +44,16 @@ class BuildItem extends StatelessWidget {
...
@@ -42,16 +44,16 @@ class BuildItem extends StatelessWidget {
children:
<
TextSpan
>[
children:
<
TextSpan
>[
TextSpan
(
TextSpan
(
text:
'¥'
,
text:
'¥'
,
style:
TextStyle
(
fontSize:
15
.
w
,
fontWeight:
Fonts
.
boldSemi
,
height:
1.5
,
color:
Colors
.
white
)
style:
TextStyle
(
fontSize:
15
.
w
,
fontWeight:
Fonts
.
boldSemi
,
height:
1.5
,
color:
model
.
type
==
1
?
Colors
.
white
:
Colours
.
cC8
)
),
),
TextSpan
(
TextSpan
(
text:
'5
'
,
text:
model
.
reducedPrice
??
'
'
,
style:
TextStyle
(
fontSize:
40
.
w
,
fontWeight:
Fonts
.
boldSemi
,
height:
1.5
,
color:
Colors
.
white
)
style:
TextStyle
(
fontSize:
40
.
w
,
fontWeight:
Fonts
.
boldSemi
,
height:
1.5
,
color:
model
.
type
==
1
?
Colors
.
white
:
Colours
.
cC8
)
),
),
]
]
),
),
),
),
Text
(
'满
${model.normPrice}
可用'
,
style:
TextStyle
(
fontSize:
11
.
w
,
height:
1.5
,
color:
Colors
.
white
),)
Text
(
'满
${model.normPrice}
可用'
,
style:
TextStyle
(
fontSize:
11
.
w
,
height:
1.5
,
color:
model
.
type
==
1
?
Colors
.
white
:
Colours
.
cC8
),)
],
],
),
),
)
)
...
@@ -67,14 +69,16 @@ class BuildItem extends StatelessWidget {
...
@@ -67,14 +69,16 @@ class BuildItem extends StatelessWidget {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Text
(
model
.
couponName
??
''
,
style:
TextStyle
(
fontSize:
16
.
w
,
fontWeight:
Fonts
.
medium
,
height:
1.5
,
color:
Colours
.
c3
),),
Text
(
model
.
couponName
??
''
,
style:
TextStyle
(
fontSize:
16
.
w
,
fontWeight:
Fonts
.
medium
,
height:
1.5
,
color:
model
.
type
==
1
?
Colours
.
c3
:
Colours
.
c9
),),
Gaps
.
vGaps5
,
Gaps
.
vGaps5
,
Text
(
'满
${model.normPrice}
减
${model.reducedPrice}
元'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
),),
Text
(
'满
${model.normPrice}
减
${model.reducedPrice}
元'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
),),
Gaps
.
vGaps5
,
Gaps
.
vGaps5
,
Text
(
'有效
期
'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
),),
Text
(
'有效
至:
${model.endTime}
'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
),),
],
],
),
),
Container
(
if
(
model
.
type
==
1
)
GestureDetector
(
onTap:
useTap
,
child:
Container
(
width:
65
.
w
,
width:
65
.
w
,
height:
24
.
w
,
height:
24
.
w
,
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
...
@@ -84,7 +88,8 @@ class BuildItem extends StatelessWidget {
...
@@ -84,7 +88,8 @@ class BuildItem extends StatelessWidget {
border:
Border
.
all
(
width:
1
.
w
,
color:
AppTheme
.
primary
)
border:
Border
.
all
(
width:
1
.
w
,
color:
AppTheme
.
primary
)
),
),
child:
Text
(
'立即使用'
,
style:
TextStyle
(
fontSize:
12
.
w
,
fontWeight:
Fonts
.
medium
,
color:
AppTheme
.
primary
),),
child:
Text
(
'立即使用'
,
style:
TextStyle
(
fontSize:
12
.
w
,
fontWeight:
Fonts
.
medium
,
color:
AppTheme
.
primary
),),
)
),
)
else
const
SizedBox
()
],
],
),
),
),
),
...
...
lib/routes/routes.dart
浏览文件 @
a6bc143c
...
@@ -287,7 +287,9 @@ abstract class Routes {
...
@@ -287,7 +287,9 @@ abstract class Routes {
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
pageBuilder:
(
context
,
state
)
=>
CupertinoPage
(
name:
state
.
uri
.
toString
(),
name:
state
.
uri
.
toString
(),
key:
state
.
pageKey
,
key:
state
.
pageKey
,
child:
const
PayCouponPage
()
child:
PayCouponPage
(
payController:
state
.
extra
as
BookPayController
,
)
)
)
),
),
GoRoute
(
GoRoute
(
...
...
lib/utils/styles.dart
浏览文件 @
a6bc143c
...
@@ -35,6 +35,7 @@ class Colours {
...
@@ -35,6 +35,7 @@ class Colours {
static
const
cF8
=
Color
(
0xFFF8F8F8
);
static
const
cF8
=
Color
(
0xFFF8F8F8
);
static
const
cF9
=
Color
(
0xFFF9F9F9
);
static
const
cF9
=
Color
(
0xFFF9F9F9
);
static
const
cC7
=
Color
(
0xFFC7C7C7
);
static
const
cC7
=
Color
(
0xFFC7C7C7
);
static
const
cC8
=
Color
(
0xFFC8C8C8
);
static
const
cAB1941
=
Color
(
0xB3AB1941
);
static
const
cAB1941
=
Color
(
0xB3AB1941
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论