Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
b855e8d1
提交
b855e8d1
authored
1月 22, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
紫荆币充值界面及接口
上级
0bfcbbe5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
186 行增加
和
72 行删除
+186
-72
mine.dart
lib/apis/mine.dart
+18
-0
mine.dart
lib/models/mine.dart
+48
-0
controller.dart
lib/pages/user_coin_recharge/controller.dart
+36
-0
index.dart
lib/pages/user_coin_recharge/index.dart
+4
-0
view.dart
lib/pages/user_coin_recharge/view.dart
+80
-72
没有找到文件。
lib/apis/mine.dart
浏览文件 @
b855e8d1
...
@@ -309,4 +309,22 @@ abstract class MineAPI {
...
@@ -309,4 +309,22 @@ abstract class MineAPI {
}
}
return
false
;
return
false
;
}
}
/// 19、紫荆币充值列表
///
static
Future
<
List
<
CoinModel
>>
coinsRechargeList
(
{
required
String
type
,
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/orders/Orders/getRechargeConfig'
,
params:
{
'config_type'
:
type
,
},
);
if
(
result
.
data
is
!
Map
&&
result
.
data
[
'list'
]
is
!
List
)
return
[];
return
List
.
generate
(
result
.
data
[
'list'
].
length
,
(
index
)
{
return
CoinModel
.
fromJson
(
result
.
data
[
'list'
][
index
]);
});
}
}
}
lib/models/mine.dart
浏览文件 @
b855e8d1
...
@@ -612,3 +612,51 @@ class HelpCenterContentModel {
...
@@ -612,3 +612,51 @@ class HelpCenterContentModel {
return
map
;
return
map
;
}
}
}
}
/// 紫荆币模型
class
CoinModel
{
CoinModel
({
this
.
beanName
,
this
.
beanValue
,
this
.
priceName
,
this
.
priceValue
,
this
.
identifying
,
this
.
selected
=
false
,
});
CoinModel
.
fromJson
(
dynamic
json
)
{
beanName
=
json
[
'bean_name'
];
beanValue
=
json
[
'bean_value'
];
priceName
=
json
[
'price_name'
];
priceValue
=
json
[
'price_value'
];
identifying
=
json
[
'identifying'
];
selected
=
false
;
}
String
?
beanName
;
String
?
beanValue
;
String
?
priceName
;
String
?
priceValue
;
String
?
identifying
;
late
bool
selected
;
CoinModel
copyWith
({
String
?
beanName
,
String
?
beanValue
,
String
?
priceName
,
String
?
priceValue
,
String
?
identifying
,
})
=>
CoinModel
(
beanName:
beanName
??
this
.
beanName
,
beanValue:
beanValue
??
this
.
beanValue
,
priceName:
priceName
??
this
.
priceName
,
priceValue:
priceValue
??
this
.
priceValue
,
identifying:
identifying
??
this
.
identifying
,
);
Map
<
String
,
dynamic
>
toJson
()
{
final
map
=
<
String
,
dynamic
>{};
map
[
'bean_name'
]
=
beanName
;
map
[
'bean_value'
]
=
beanValue
;
map
[
'price_name'
]
=
priceName
;
map
[
'price_value'
]
=
priceValue
;
map
[
'identifying'
]
=
identifying
;
return
map
;
}
}
lib/pages/user_coin_recharge/controller.dart
浏览文件 @
b855e8d1
...
@@ -7,12 +7,22 @@ class CoinRechargeController extends GetxController {
...
@@ -7,12 +7,22 @@ class CoinRechargeController extends GetxController {
PayModel
(
type:
1
,
name:
'微信'
,
icon:
'assets/images/pay_wechat.png'
,
selected:
true
),
PayModel
(
type:
1
,
name:
'微信'
,
icon:
'assets/images/pay_wechat.png'
,
selected:
true
),
PayModel
(
type:
2
,
name:
'支付宝'
,
icon:
'assets/images/pay_ali.png'
,
selected:
false
),
PayModel
(
type:
2
,
name:
'支付宝'
,
icon:
'assets/images/pay_ali.png'
,
selected:
false
),
];
];
List
<
CoinModel
>
data
=
[];
late
CoinModel
rechargeModel
=
CoinModel
();
// 支付方式
// 支付方式
late
PayModel
_payModel
=
pays
.
first
;
late
PayModel
_payModel
=
pays
.
first
;
PayModel
get
payModel
=>
_payModel
;
PayModel
get
payModel
=>
_payModel
;
@override
void
onReady
()
{
_getlist
();
super
.
onReady
();
}
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
){
...
@@ -25,4 +35,29 @@ class CoinRechargeController extends GetxController {
...
@@ -25,4 +35,29 @@ class CoinRechargeController extends GetxController {
}
}
update
();
update
();
}
}
void
choose
(
CoinModel
coinModel
){
for
(
CoinModel
model
in
data
)
{
model
.
selected
=
(
model
==
coinModel
);
}
rechargeModel
=
coinModel
;
update
();
}
void
_getlist
()
async
{
String
type
=
''
;
if
(
Platform
.
isIOS
){
type
=
'ios'
;
}
if
(
Platform
.
isAndroid
){
type
=
'android'
;
}
final
result
=
await
MineAPI
.
coinsRechargeList
(
type:
type
);
data
=
result
;
update
();
}
}
}
\ No newline at end of file
lib/pages/user_coin_recharge/index.dart
浏览文件 @
b855e8d1
...
@@ -2,9 +2,13 @@ library recharge;
...
@@ -2,9 +2,13 @@ library recharge;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/apis/index.dart'
;
import
'package:flutter_book/models/index.dart'
;
import
'package:flutter_book/theme.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:get/get_state_manager/src/simple/get_controllers.dart'
;
import
'package:get/get_state_manager/src/simple/get_controllers.dart'
;
import
'package:go_router/go_router.dart'
;
import
'../../models/shop.dart'
;
import
'../../models/shop.dart'
;
import
'../../utils/index.dart'
;
import
'../../utils/index.dart'
;
...
...
lib/pages/user_coin_recharge/view.dart
浏览文件 @
b855e8d1
...
@@ -14,74 +14,76 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
...
@@ -14,74 +14,76 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
CoinRechargeController
>(
return
GetBuilder
<
CoinRechargeController
>(
init:
CoinRechargeController
(),
init:
CoinRechargeController
(),
builder:
(
controller
)
=>
Container
(
builder:
(
controller
)
=>
Column
(
// height: 100,
mainAxisSize:
MainAxisSize
.
min
,
// color: Colors.amberAccent,
children:
[
child:
Column
(
Container
(
mainAxisSize:
MainAxisSize
.
min
,
color:
Colors
.
white
,
children:
[
padding:
EdgeInsets
.
symmetric
(
vertical:
17
.
w
),
Container
(
width:
double
.
infinity
,
padding:
EdgeInsets
.
symmetric
(
vertical:
17
),
margin:
EdgeInsets
.
fromLTRB
(
10
.
w
,
0
.
w
,
10
.
w
,
0
.
w
),
width:
double
.
infinity
,
child:
Container
(
margin:
EdgeInsets
.
fromLTRB
(
10
,
10
,
10
,
0
),
// color: Colors.red,
child:
Container
(
child:
Stack
(
color:
Colors
.
red
,
children:
[
child:
Stack
(
const
Row
(
children:
[
mainAxisAlignment:
MainAxisAlignment
.
center
,
Row
(
children:
[
mainAxisAlignment:
MainAxisAlignment
.
center
,
Text
(
'紫荆币充值'
,
textAlign:
TextAlign
.
center
),
children:
[
],
Text
(
'紫荆币充值'
,
textAlign:
TextAlign
.
center
),
),
],
Positioned
(
),
right:
0
.
w
,
Positioned
(
top:
0
.
w
,
right:
0
,
child:
GestureDetector
(
top:
0
,
onTap:
(){
child:
Container
(
context
.
pop
();
width:
20
,
},
height:
20
,
child:
SizedBox
(
color:
Colors
.
green
,
width:
20
.
w
,
height:
20
.
w
,
child:
Image
.
asset
(
'assets/images/close.png'
),
),
),
)
),
],
)
)
],
),
)
),
Container
(
margin:
EdgeInsets
.
symmetric
(
horizontal:
20
),
child:
_buildAudioGridView
()
),
),
Gaps
.
vGaps15
,
),
_buildListView
(
controller
),
Container
(
Gaps
.
vGaps15
,
margin:
EdgeInsets
.
symmetric
(
horizontal:
20
.
w
),
Container
(
child:
_buildAudioGridView
(
controller
)
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
),
),
child:
CustomGradientButton
(
Gaps
.
vGaps15
,
text:
'立即充值'
,
_buildListView
(
controller
),
isEnabled:
true
,
Gaps
.
vGaps15
,
onPressed:
()
{
Container
(
// context.goNamed(Routes.login);
margin:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
},
child:
CustomGradientButton
(
),
text:
'立即充值
${controller.rechargeModel.priceName??''}
'
,
isEnabled:
true
,
onPressed:
()
{
// context.goNamed(Routes.login);
},
),
),
Gaps
.
vGaps15
,
)
,
RichText
(
text:
TextSpan
(
Gaps
.
vGaps15
,
children:
[
RichText
(
text:
TextSpan
(
TextSpan
(
text:
'充值即代表同意'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Colours
.
c9
)),
children:
[
TextSpan
(
text:
'《用户充值协议》'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Color
(
0xFF2A82D9
)
)),
TextSpan
(
text:
'充值即代表同意'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Colours
.
c9
)),
]
TextSpan
(
text:
'《用户充值协议》'
,
style:
TextStyle
(
fontSize:
13
.
w
,
height:
1.5
,
color:
Color
(
0xFF2A82D9
))),
)),
]
Gaps
.
vGaps15
)),
],
Gaps
.
vGaps15
)
,
]
,
),
),
);
);
}
}
Widget
_buildAudioGridView
(){
Widget
_buildAudioGridView
(
CoinRechargeController
controller
){
return
GridView
.
builder
(
return
GridView
.
builder
(
// padding: const EdgeInsets.only(left: 13,top: 10),
// padding: const EdgeInsets.only(left: 13,top: 10),
physics:
NeverScrollableScrollPhysics
(),
physics:
const
NeverScrollableScrollPhysics
(),
shrinkWrap:
true
,
shrinkWrap:
true
,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount
(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
3
,
crossAxisCount:
3
,
...
@@ -90,23 +92,29 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
...
@@ -90,23 +92,29 @@ class _CoinRechargePageState extends State<CoinRechargePage> {
childAspectRatio:
2
childAspectRatio:
2
),
),
itemBuilder:
(
BuildContext
context
,
int
index
)
{
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
Container
(
CoinModel
model
=
controller
.
data
[
index
];
decoration:
BoxDecoration
(
return
GestureDetector
(
color:
Colors
.
red
,
onTap:
(){
borderRadius:
BorderRadius
.
circular
(
8
.
w
),
controller
.
choose
(
model
);
border:
Border
.
all
(
width:
0.5
.
w
,
color:
Color
(
0xFFDADADA
))
},
),
child:
Container
(
decoration:
BoxDecoration
(
color:
model
.
selected
?
AppTheme
.
primary
.
withOpacity
(
0.1
):
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
8
.
w
),
border:
Border
.
all
(
width:
0.5
.
w
,
color:
model
.
selected
?
AppTheme
.
primary
:
const
Color
(
0xFFDADADA
))
),
child:
Column
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
children:
[
Text
(
'42紫荆币'
,
style:
TextStyle
(
color:
Colours
.
c3
,
fontSize:
14
,
height:
1.5
),),
Text
(
model
.
beanName
??
''
,
style:
TextStyle
(
color:
model
.
selected
?
AppTheme
.
primary
:
Colours
.
c3
,
fontSize:
14
.
w
,
height:
1.5
),),
Text
(
'6元'
,
style:
TextStyle
(
color:
Colours
.
c9
,
fontSize:
11
,
height:
1.5
),),
Text
(
model
.
priceName
??
''
,
style:
TextStyle
(
color:
model
.
selected
?
AppTheme
.
primary
:
Colours
.
c9
,
fontSize:
11
.
w
,
height:
1.5
),),
],
],
),
),
),
);
);
},
},
itemCount:
6
,
itemCount:
controller
.
data
.
length
,
);
);
}
}
Widget
_buildListView
(
CoinRechargeController
controller
){
Widget
_buildListView
(
CoinRechargeController
controller
){
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论