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';
|
4224b3f8
吴启风
feat:支付详情页ui
|
11
12
13
14
15
16
17
18
|
import 'bloc.dart';
import 'event.dart';
import 'state.dart';
Widget buildRadioOption({
required int value,
required ImageProvider icon,
required String text,
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
19
20
|
required bool isSelected,
required ValueChanged onSelect,
|
4224b3f8
吴启风
feat:支付详情页ui
|
21
|
}) {
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
return
GestureDetector(
onTap: () {
onSelect(value);
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image(image: icon, width: 25.0.w, height: 25.0.h, fit: BoxFit.contain),
const SizedBox(width: 10.0),
Expanded(
child: Text(
text,
style: TextStyle(color: const Color(0xFF333333), fontSize: 12.5.sp),
),
),
Image(
image: isSelected
? AssetImage('checked'.assetPng)
: AssetImage('unchecked'.assetPng),
width: 22.0.w,
height: 22.0.h,
),
],
|
4224b3f8
吴启风
feat:支付详情页ui
|
46
|
),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
47
48
|
);
|
4224b3f8
吴启风
feat:支付详情页ui
|
49
50
51
|
}
class ShoppingPage extends StatelessWidget {
|
07599105
吴启风
feat:商品列表请求&路由
|
52
53
54
|
const ShoppingPage({super.key, this.productEntity});
final ProductEntity? productEntity;
|
4224b3f8
吴启风
feat:支付详情页ui
|
55
56
57
58
59
|
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (BuildContext context) =>
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
60
|
ShoppingBloc(productEntity)..add(InitEvent()),
|
4224b3f8
吴启风
feat:支付详情页ui
|
61
62
63
64
65
66
|
child: _ShoppingView(),
);
}
}
class _ShoppingView extends StatelessWidget {
|
4224b3f8
吴启风
feat:支付详情页ui
|
67
68
69
|
@override
Widget build(BuildContext context) {
final bloc = BlocProvider.of<ShoppingBloc>(context);
|
4224b3f8
吴启风
feat:支付详情页ui
|
70
71
|
return BlocListener<ShoppingBloc, ShoppingState>(
listener: (context, state) {
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
72
73
74
|
if (state is PaySuccessState) {
Navigator.pop(context);
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
75
76
|
},
child: Scaffold(
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
77
|
appBar: WEAppBar(
|
4224b3f8
吴启风
feat:支付详情页ui
|
78
|
//标题传进来的
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
79
|
titleText: bloc.productData?.name ?? '',
|
4224b3f8
吴启风
feat:支付详情页ui
|
80
81
82
83
84
85
86
|
),
body: Container(
margin: const EdgeInsets.only(left: 80.0, top: 28.0, right: 56.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CachedNetworkImage(
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
87
|
imageUrl: bloc.productData?.detailPicUrl ?? '',
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
88
89
90
91
92
|
imageBuilder: (context, imageProvider) => Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
|
4224b3f8
吴启风
feat:支付详情页ui
|
93
|
),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
94
95
96
97
98
|
borderRadius: BorderRadius.circular(5.0),
),
),
placeholder: (context, url) =>
const CircularProgressIndicator(),
|
4224b3f8
吴启风
feat:支付详情页ui
|
99
100
101
102
103
|
// errorWidget: (context, url, error) => const Icon(Icons.error),
height: 210.0.h,
width: 210.0.w,
),
const SizedBox(width: 35.5),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
104
|
Expanded(child: _paymentWidget())
|
4224b3f8
吴启风
feat:支付详情页ui
|
105
106
107
|
],
),
),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
108
109
|
),
);
|
4224b3f8
吴启风
feat:支付详情页ui
|
110
111
112
|
}
}
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
113
|
Widget _paymentWidget() => BlocBuilder<ShoppingBloc, ShoppingState>(
|
4224b3f8
吴启风
feat:支付详情页ui
|
114
115
116
117
118
|
builder: (context, state) {
final bloc = BlocProvider.of<ShoppingBloc>(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
RichText(
text: TextSpan(
children: [
TextSpan(
text: '套餐价格:',
style:
TextStyle(color: const Color(0xFF333333), fontSize: 16.5.sp)
),
TextSpan(
text: '¥${bloc.productData?.price ?? ''}',
style:
TextStyle(color: const Color(0xFFE5262A), fontSize: 16.5.sp)
),
]
),
),
const SizedBox(height: 14.5),
Text(
'套餐名称:${bloc.productData?.name}',
style:
TextStyle(color: const Color(0xFF333333), fontSize: 16.sp),
maxLines: 2,
),
const SizedBox(height: 14.5),
|
4224b3f8
吴启风
feat:支付详情页ui
|
143
|
Container(
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
144
|
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 10.h),
|
4224b3f8
吴启风
feat:支付详情页ui
|
145
146
147
148
149
150
151
152
|
decoration: BoxDecoration(
image: DecorationImage(
image: ImageUtil.getImageProviderOnDefault(
AssetsConst.bgUserInformationText),
fit: BoxFit.fill)),
child: const Text('支付方式选择',
style: TextStyle(
color: Color(0xFF333333),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
153
|
fontSize: 12.5,
|
4224b3f8
吴启风
feat:支付详情页ui
|
154
155
|
fontFamily: 'PingFangSC-Regular')),
),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
156
|
const SizedBox(height: 18.0),
|
4224b3f8
吴启风
feat:支付详情页ui
|
157
158
159
160
|
buildRadioOption(
value: PaymentChannel.wechatPay.payChannelType,
icon: AssetImage('weixin'.assetPng),
text: PaymentChannel.wechatPay.payChannelName,
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
161
162
163
|
isSelected: bloc.curPaymentChannel.payChannelType == PaymentChannel.wechatPay.payChannelType,
onSelect: (newValue) {
bloc.add(ChangePaymentChannelEvent(PaymentChannel.wechatPay));
|
4224b3f8
吴启风
feat:支付详情页ui
|
164
165
|
},
),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
166
|
const SizedBox(height: 15.0),
|
4224b3f8
吴启风
feat:支付详情页ui
|
167
168
169
170
|
buildRadioOption(
value: PaymentChannel.aliPay.payChannelType,
icon: AssetImage('zhifubao'.assetPng),
text: PaymentChannel.aliPay.payChannelName,
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
171
172
|
isSelected: bloc.curPaymentChannel.payChannelType == PaymentChannel.aliPay.payChannelType,
onSelect: (newValue) {
|
2879454a
吴启风
feat:调通支付宝支付&游戏列表页
|
173
|
bloc.add(ChangePaymentChannelEvent(PaymentChannel.aliPay));
|
4224b3f8
吴启风
feat:支付详情页ui
|
174
175
|
},
),
|
ad37b653
吴启风
feat:1、完成微信支付;2、商...
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
const SizedBox(height: 20.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RichText(
text: TextSpan(
children: [
const TextSpan(
text: '需支付:',
style:
TextStyle(color: Color(0xFF333333), fontSize: 12.5, fontFamily: 'PingFangSC-Regular')
),
TextSpan(
text: '¥${bloc.productData?.price ?? ''}',
style:
TextStyle(color: const Color(0xFFE7383B), fontSize: 41.sp, fontFamily: 'PingFangSC-Regular')
),
]
),
),
// 确认支付按钮
GestureDetector(
onTap: () {
bloc.add(DoPayEvent(bloc.productData, bloc.curPaymentChannel));
},
child: Image(
width: 105.w,
height: 45.h,
image: AssetImage('btn_pay'.assetPng),
),
)
],
|
4224b3f8
吴启风
feat:支付详情页ui
|
208
209
210
211
212
|
),
],
);
},
);
|