4224b3f8
吴启风
feat:支付详情页ui
|
1
2
3
4
5
|
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
07599105
吴启风
feat:商品列表请求&路由
|
6
|
import 'package:wow_english/models/product_entity.dart';
|
4224b3f8
吴启风
feat:支付详情页ui
|
7
8
9
10
|
import '../../common/core/assets_const.dart';
import '../../common/widgets/we_app_bar.dart';
import '../../utils/image_util.dart';
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
11
|
import '../../utils/log_util.dart';
|
4224b3f8
吴启风
feat:支付详情页ui
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import 'bloc.dart';
import 'event.dart';
import 'state.dart';
Widget buildRadioOption({
required int value,
required ImageProvider icon,
required String text,
required int groupValue,
required ValueChanged onChanged,
}) {
return Row(
children: [
Image(image: icon,
width: 20.0.w,
height: 20.0.h,
fit: BoxFit.contain),
const SizedBox(width: 10.0),
// Expanded(
// child: Text(
// text,
// style: TextStyle(color: Color(0xFF333333), fontSize: 12.5.sp),
// ),
// ),
Text(
text,
style: TextStyle(color: Color(0xFF333333), fontSize: 12.5.sp),
),
Radio(
value: value,
groupValue: groupValue,
onChanged: onChanged
),
],
);
}
class ShoppingPage extends StatelessWidget {
|
07599105
吴启风
feat:商品列表请求&路由
|
50
51
52
|
const ShoppingPage({super.key, this.productEntity});
final ProductEntity? productEntity;
|
4224b3f8
吴启风
feat:支付详情页ui
|
53
54
55
56
57
|
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (BuildContext context) =>
|
07599105
吴启风
feat:商品列表请求&路由
|
58
|
ShoppingBloc(productEntity)
|
4224b3f8
吴启风
feat:支付详情页ui
|
59
60
61
62
63
64
65
66
67
68
69
|
..add(InitEvent()),
child: _ShoppingView(),
);
}
}
class _ShoppingView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bloc = BlocProvider.of<ShoppingBloc>(context);
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
70
|
// var title1 = bloc.productData?.name ?? '';
|
4224b3f8
吴启风
feat:支付详情页ui
|
71
72
|
return BlocListener<ShoppingBloc, ShoppingState>(
listener: (context, state) {
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
73
74
75
76
|
Log.d("wqf state=$state");
if (state is PaySuccessState) {
Navigator.pop(context);
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
77
78
79
80
|
},
child: Scaffold(
appBar: const WEAppBar(
//标题传进来的
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
81
|
titleText: "商品详情",
|
4224b3f8
吴启风
feat:支付详情页ui
|
82
83
84
85
86
87
88
|
),
body: Container(
margin: const EdgeInsets.only(left: 80.0, top: 28.0, right: 56.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CachedNetworkImage(
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
89
|
imageUrl: bloc.productData?.detailPicUrl ?? '',
|
4224b3f8
吴启风
feat:支付详情页ui
|
90
91
92
93
94
95
96
97
98
99
|
imageBuilder: (context, imageProvider) =>
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
borderRadius: BorderRadius.circular(5.0),
),
),
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
100
|
placeholder: (context, url) => const CircularProgressIndicator(),
|
4224b3f8
吴启风
feat:支付详情页ui
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// errorWidget: (context, url, error) => const Icon(Icons.error),
height: 210.0.h,
width: 210.0.w,
),
const SizedBox(width: 35.5),
_paymentWidget(),
],
),
),
),);
}
}
Widget _paymentWidget() =>
BlocBuilder<ShoppingBloc, ShoppingState>
(
builder: (context, state) {
final bloc = BlocProvider.of<ShoppingBloc>(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
|
07599105
吴启风
feat:商品列表请求&路由
|
122
|
Text('套餐价格:${bloc.productData?.price ?? ''}',
|
4224b3f8
吴启风
feat:支付详情页ui
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
style: TextStyle(
color: const Color(0xFF333333), fontSize: 16.sp)),
const SizedBox(height: 15.0),
Text('套餐名称:${bloc.productData?.name ?? ''}',
style: TextStyle(
color: const Color(0xFF333333), fontSize: 16.sp)),
const SizedBox(height: 15.0),
Container(
padding:
EdgeInsets.symmetric(horizontal: 6.w, vertical: 10.h),
decoration: BoxDecoration(
image: DecorationImage(
image: ImageUtil.getImageProviderOnDefault(
AssetsConst.bgUserInformationText),
fit: BoxFit.fill)),
child: const Text('支付方式选择',
style: TextStyle(
color: Color(0xFF333333),
fontSize: 12,
fontFamily: 'PingFangSC-Regular')),
),
const SizedBox(height: 15.0),
buildRadioOption(
value: PaymentChannel.wechatPay.payChannelType,
icon: AssetImage('weixin'.assetPng),
text: PaymentChannel.wechatPay.payChannelName,
groupValue: bloc.curPaymentChannel.payChannelType,
onChanged: (newValue) {
bloc.add(
ChangePaymentChannelEvent(PaymentChannel.wechatPay));
},
),
buildRadioOption(
value: PaymentChannel.aliPay.payChannelType,
icon: AssetImage('zhifubao'.assetPng),
text: PaymentChannel.aliPay.payChannelName,
groupValue: bloc.curPaymentChannel.payChannelType,
onChanged: (newValue) {
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
161
|
bloc.add(ChangePaymentChannelEvent(PaymentChannel.aliPay));
|
4224b3f8
吴启风
feat:支付详情页ui
|
162
163
164
165
166
167
|
},
),
const SizedBox(height: 15.0),
// 确认支付按钮
InkWell(
onTap: () {
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
168
169
|
Log.d('点击支付按钮 ${bloc.productData}');
bloc.add(DoPayEvent(bloc.productData, bloc.curPaymentChannel));
|
4224b3f8
吴启风
feat:支付详情页ui
|
170
171
172
173
174
175
176
177
178
179
180
|
},
child: Image(
width: 125.w,
height: 45.h,
image: AssetImage('btn_pay'.assetPng),
),
),
],
);
},
);
|