Browse Source

充值更改

remove_uniapp
w-R 3 years ago
parent
commit
a598480dbf
  1. BIN
      assets/image/2x/recharge.png
  2. BIN
      assets/image/3x/recharge.png
  3. BIN
      assets/image/recharge.png
  4. 625
      lib/mine/recharge_page.dart

BIN
assets/image/2x/recharge.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

BIN
assets/image/3x/recharge.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
assets/image/recharge.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

625
lib/mine/recharge_page.dart

@ -48,7 +48,7 @@ class _RechargePage extends State<RechargePage> {
}); });
weChatResponseEventHandler.listen((event) async { weChatResponseEventHandler.listen((event) async {
print("payCallback: ${event.errCode}"); print("payCallback: ${event.errCode}");
if(event.errCode == 0){ if (event.errCode == 0) {
Navigator.of(context).pop(); Navigator.of(context).pop();
SmartDialog.showToast("充值成功", alignment: Alignment.center); SmartDialog.showToast("充值成功", alignment: Alignment.center);
} }
@ -59,19 +59,20 @@ class _RechargePage extends State<RechargePage> {
}); });
} }
/// ///
queryBenefitList() async { queryBenefitList() async {
BaseData<List<VipBenefitList>> baseData = await apiService.benefitList().catchError((onError) {}); BaseData<List<VipBenefitList>> baseData =
await apiService.benefitList().catchError((onError) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
setState(() { setState(() {
vipBenefitList.clear(); vipBenefitList.clear();
vipBenefitList.addAll(baseData.data); vipBenefitList.addAll(baseData.data);
vipBenefitList.forEach((element) { vipBenefitList.forEach((element) {
if(element.have && element.config != null && element.code == "RECHARGE"){ if (element.have &&
element.config != null &&
element.code == "RECHARGE") {
discount = double.parse(element.config); discount = double.parse(element.config);
} }
}); });
}); });
} }
@ -81,7 +82,7 @@ class _RechargePage extends State<RechargePage> {
////// //////
queryRuleDetails() async { queryRuleDetails() async {
BaseData<VipRuleDetails> baseData = BaseData<VipRuleDetails> baseData =
await apiService.vipBenefit().catchError((onError) {}); await apiService.vipBenefit().catchError((onError) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
setState(() { setState(() {
vipRuleDetails = baseData.data; vipRuleDetails = baseData.data;
@ -100,266 +101,392 @@ class _RechargePage extends State<RechargePage> {
background: Color(0xFFFFFFFF), background: Color(0xFFFFFFFF),
leadingColor: Colors.black, leadingColor: Colors.black,
), ),
body:Stack( body: Container(
children: [ color: Color(0xFFFFFFFF),
SingleChildScrollView( child: Stack(
physics: BouncingScrollPhysics(), children: [
child: Container( SingleChildScrollView(
child: Column( physics: BouncingScrollPhysics(),
children: [ child: Container(
Container( margin: EdgeInsets.only(left: 16, right: 16),
child: Column(children: [ child: Column(
ItemInputWidget( children: [
S.of(context).qingshuruchongzhijine, Column(
hintText: "",
controller: controller,
padding: EdgeInsets.all(20),
errorText: S.of(context).chongzhizuixiaojine(100),
titleColor: Color(0xFF727272),
errorTextColor: Color(0xFF32A060),
radius: 8,
discount: discount/10,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 27.sp,
color: color,
),
inputLimit: 6,
textInputType: TextInputType.number,
textInputFormatter: FilteringTextInputFormatter.digitsOnly,
onChanged: (value) {
if (value != null &&
value != "" &&
double.tryParse(value) < 100) {
color = Colors.red;
} else {
color = Colors.black;
}
setState(() {});
},
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
if (vipRuleDetails?.recharge != null &&
vipRuleDetails.recharge != "")
Expanded(child:Container(
color: Colors.white,
padding: EdgeInsets.only(left: 8),
child: Html(
data: "注意:${vipRuleDetails?.recharge??""}",
customImageRenders: {
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
return Container();
},
),
},
),
),)
],
),
],),
),
Container(
width: double.infinity,
margin: EdgeInsets.only(
left: 0.w,
right: 0.w,
top: 16.h,
bottom: 4.h,
),
padding: EdgeInsets.only(
left: 20.w,
right: 16.w,
top: 20.h,
bottom: 20.h,
),
decoration: BoxDecoration(
color: Colors.white,
// borderRadius: BorderRadius.circular(4),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
// ItemInputWidget(
// S.of(context).qingshuruchongzhijine,
// hintText: "",
// controller: controller,
// padding: EdgeInsets.all(20),
// errorText: S.of(context).chongzhizuixiaojine(100),
// titleColor: Color(0xFF727272),
// errorTextColor: Color(0xFF32A060),
// radius: 8,
// discount: discount / 10,
// style: TextStyle(
// fontWeight: FontWeight.bold,
// fontSize: 27.sp,
// color: color,
// ),
// inputLimit: 6,
// textInputType: TextInputType.number,
// textInputFormatter:
// FilteringTextInputFormatter.digitsOnly,
// onChanged: (value) {
// if (value != null &&
// value != "" &&
// double.tryParse(value) < 100) {
// color = Colors.red;
// } else {
// color = Colors.black;
// }
// setState(() {});
// },
// ),
Padding( Padding(
padding: EdgeInsets.only(bottom: 16.h), padding: EdgeInsets.only(top: 26, bottom: 28),
child: Text( child: Text(
S.of(context).zhifufangshi, S.of(context).chongzhi,
style: TextStyle( style: TextStyle(
fontSize: 16.sp, fontSize: 28.sp,
color: Colors.black, color: Color(0xFF181818),
fontWeight: FontWeight.bold, fontWeight: MyFontWeight.semi_bold),
),
), ),
), ),
GestureDetector( Row(
onTap: () { children: [
setState(() { Expanded(
checkIndex = 1; child: Text(
}); S.of(context).zhanghuyue,
}, style: TextStyle(
child: Row( fontSize: 15.sp,
mainAxisAlignment: MainAxisAlignment.start, color: Color(0xFF181818),
crossAxisAlignment: CrossAxisAlignment.start, fontWeight: MyFontWeight.semi_bold),
children: [ )),
Image.asset("assets/image/icon_we_chat.webp"), Text.rich(
TextSpan(children: [
TextSpan(
text: "0.00",
style: TextStyle(
fontSize: 26.sp,
color: Color(0xFF181818),
fontWeight: MyFontWeight.semi_bold),
),
TextSpan(
text: "",
style: TextStyle(
fontSize: 15.sp,
color: Color(0xFF181818),
fontWeight: MyFontWeight.semi_bold),
),
]),
),
],
),
SizedBox(height: 28),
rechargeList(),
SizedBox(height:22),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
if (vipRuleDetails?.recharge != null &&
vipRuleDetails.recharge != "")
Expanded( Expanded(
flex: 1, child: Container(
child: Padding( color: Colors.white,
padding: EdgeInsets.only(left: 8.w), child: Html(
child: Text( data: "注意:${vipRuleDetails?.recharge ?? ""}",
S.of(context).weixinzhifu, style:{
style: TextStyle( "html":Style(
fontSize: 14.sp, color: Color(0xFF000000),
color: Color(0xff353535), fontWeight: MyFontWeight.medium,
), )
},
customImageRenders: {
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
return Container();
},
),
},
), ),
), ),
), )
checkView(1), ],
],
),
),
],
),
),
// InkWell(
// onTap: () {
// recharge();
// },
// child: Container(
// // margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 26.h),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// RoundButton(
// width: double.infinity,
// height: 46.h,
// text: S.of(context).querenchongzhi,
// textColor: Colors.white,
// fontSize: 14.sp,
// backgroup: Color(0xff32A060),
// fontWeight: FontWeight.bold,
// ),
// ],
// ),
// ),
// ),
],
),
),
),
Align(alignment: Alignment.bottomCenter,child:
Container(
height: 56.h,
color: Colors.white,
child: Row(
children: [
Expanded(child:Container(
padding:EdgeInsets.only(top: 7.h,left:16),
child:Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
S.of(context).heji,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
Text(
controller.text,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF32A060),
),
), ),
], ],
), ),
if(controller.text != "") Container(
Text.rich( width: double.infinity,
TextSpan( margin: EdgeInsets.only(
children: [ top: 16.h,
TextSpan( bottom: 4.h,
text: "充值", ),
style: TextStyle( padding: EdgeInsets.only(
fontSize:12.sp, top: 20.h,
fontWeight: MyFontWeight.regular, bottom: 20.h,
color: Color(0xFFADADAD), ),
), // decoration: BoxDecoration(
), // color: Colors.white,
TextSpan( // borderRadius: BorderRadius.circular(4),
text:"¥${controller.text}", // ),
style: TextStyle( child: Column(
fontSize: 12.sp, mainAxisAlignment: MainAxisAlignment.spaceAround,
fontWeight: MyFontWeight.regular, crossAxisAlignment: CrossAxisAlignment.start,
color:Color(0xff3541C9), children: [
), Padding(
), padding: EdgeInsets.only(bottom: 16.h),
TextSpan( child: Text(
text: "赠送", S.of(context).zhifufangshi,
style: TextStyle( style: TextStyle(
fontSize:12.sp, fontSize: 16.sp,
fontWeight: MyFontWeight.regular, color: Colors.black,
color: Color(0xFFADADAD), fontWeight: FontWeight.bold,
), ),
), ),
TextSpan( ),
text:"${((double.tryParse(controller.text)??0) - ((double.tryParse(controller.text)??0) * (discount/100))).toStringAsFixed(2)}", GestureDetector(
style: TextStyle( onTap: () {
fontSize: 12.sp, setState(() {
fontWeight: MyFontWeight.regular, checkIndex = 1;
color: Color(0xff3541C9), });
), },
),TextSpan( child: Row(
text: "", mainAxisAlignment: MainAxisAlignment.start,
style: TextStyle( crossAxisAlignment: CrossAxisAlignment.start,
fontSize:12.sp, children: [
fontWeight: MyFontWeight.regular, Image.asset("assets/image/icon_we_chat.webp"),
color: Color(0xFFADADAD), Expanded(
), flex: 1,
child: Padding(
padding: EdgeInsets.only(left: 8.w),
child: Text(
S.of(context).weixinzhifu,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
),
),
),
),
checkView(1),
],
), ),
], ),
), ],
), ),
),
], ],
))
), ),
GestureDetector( ),
onTap: () { ),
recharge(); Align(
}, alignment: Alignment.bottomCenter,
child: RoundButton( child: GestureDetector(
width: 103.w, onTap: (){
height: 54.h, recharge();
text: S.of(context).chongzhi, },
textColor: Colors.white, child: Container(
fontWeight: MyFontWeight.regular, height: 56.h,
backgroup: Color(0xFF32A060), width: double.infinity,
radius: 0, alignment: Alignment.center,
fontSize: 16.sp, decoration: BoxDecoration(
padding: EdgeInsets.symmetric(vertical: 5.h), color: Color(0xFF32A060),
borderRadius: BorderRadius.circular(27),
),
margin: EdgeInsets.only(left: 16,right: 16,bottom: 21),
child: Text(
S.of(context).querenchongzhi,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Colors.white,
),
), ),
), ),
], ),
),
))
],
),
// Container(
// height: 56.h,
// color: Colors.white,
// child: Row(
// children: [
// Expanded(child:Container(
// padding:EdgeInsets.only(top: 7.h,left:16),
// child:Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// Text(
// S.of(context).heji,
// style: TextStyle(
// fontSize: 14.sp,
// fontWeight: MyFontWeight.regular,
// color: Colors.black,
// ),
// ),
// Text(
// controller.text,
// style: TextStyle(
// fontSize: 16.sp,
// fontWeight: MyFontWeight.medium,
// color: Color(0xFF32A060),
// ),
// ),
// ],
// ),
// if(controller.text != "")
// Text.rich(
// TextSpan(
// children: [
// TextSpan(
// text: "充值",
// style: TextStyle(
// fontSize:12.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFFADADAD),
// ),
// ),
// TextSpan(
// text:"¥${controller.text}",
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// color:Color(0xff3541C9),
// ),
// ),
// TextSpan(
// text: "赠送",
// style: TextStyle(
// fontSize:12.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFFADADAD),
// ),
// ),
// TextSpan(
// text:"${((double.tryParse(controller.text)??0) - ((double.tryParse(controller.text)??0) * (discount/100))).toStringAsFixed(2)}",
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xff3541C9),
// ),
// ),TextSpan(
// text: "",
// style: TextStyle(
// fontSize:12.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFFADADAD),
// ),
// ),
// ],
// ),
// ),
// ],
// ))
// ),
// GestureDetector(
// onTap: () {
// recharge();
// },
// child: RoundButton(
// width: 103.w,
// height: 54.h,
// text: S.of(context).chongzhi,
// textColor: Colors.white,
// fontWeight: MyFontWeight.regular,
// backgroup: Color(0xFF32A060),
// radius: 0,
// fontSize: 16.sp,
// padding: EdgeInsets.symmetric(vertical: 5.h),
// ),
// ),
// ],
// ),
// )
)
],
),
),
); );
} }
var checkIndex = 1; var checkIndex = 1;
Widget rechargeList() {
return GridView.builder(
itemCount: 6,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
//Widget数量
crossAxisCount: 3,
//Widget之间间距
crossAxisSpacing:11,
//Widget之间间距
mainAxisSpacing: 0,
childAspectRatio: 1.5,
),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {},
child: rechargeItem(),
);
},
);
}
Widget rechargeItem() {
return Stack(
alignment: Alignment.bottomRight,
children: [
Container(
alignment: Alignment.center,
height: 69.h,
decoration: BoxDecoration(
color: Color(0xFFFAFAFA),
// color: Color(0x2432A060),
borderRadius: BorderRadius.circular(4),
),
// margin: EdgeInsets.only(right: 11,bottom: 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"100元",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF868686),
fontWeight: MyFontWeight.medium,
fontSize: 21.sp,
),
),
SizedBox(height:2,),
Text(
"实际到账:120元",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF868686),
fontWeight: MyFontWeight.regular,
fontSize:12.sp,
),
),
],
),
),
Image.asset(
"assets/image/recharge.png",
width: 20,
height:20,
),
],
);
}
Widget checkView(var index) { Widget checkView(var index) {
return Container( return Container(
padding: EdgeInsets.only(right: 16.w), padding: EdgeInsets.only(right: 16.w),
@ -389,16 +516,17 @@ class _RechargePage extends State<RechargePage> {
return; return;
} }
if(Platform.isAndroid){ if (Platform.isAndroid) {
if (!(await Min.isInitialize())) { if (!(await Min.isInitialize())) {
// app的充值支付使用同一个WXPayEntryActivity回调 // app的充值支付使用同一个WXPayEntryActivity回调
// getPackage空指针 // getPackage空指针
// //
await Min.initialize(); await Min.initialize();
}} }
}
BaseData<dynamic> baseData = BaseData<dynamic> baseData = await apiService.recharge(
await apiService.recharge({"amount": amount, "rechargeType": 2}).catchError((error) {}); {"amount": amount, "rechargeType": 2}).catchError((error) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
WxPay wxPay = WxPay.fromJson(baseData.data); WxPay wxPay = WxPay.fromJson(baseData.data);
await registerWxApi( await registerWxApi(
@ -415,8 +543,7 @@ class _RechargePage extends State<RechargePage> {
timeStamp: int.tryParse(wxPay.timeStamp), timeStamp: int.tryParse(wxPay.timeStamp),
sign: wxPay.sign, sign: wxPay.sign,
); );
} } else {
else{
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
} }
} }

Loading…
Cancel
Save