|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
|
import 'package:flutter_html/flutter_html.dart'; |
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
import 'package:fluwx/fluwx.dart'; |
|
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/vip_benefit_list.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/vip_rule_details.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/wx_pay.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/utils/min.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/item_input_widget.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
@ -23,10 +28,11 @@ class RechargePage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _RechargePage extends State<RechargePage> { |
|
|
|
|
ApiService apiService; |
|
|
|
|
|
|
|
|
|
TextEditingController controller = TextEditingController(); |
|
|
|
|
|
|
|
|
|
VipRuleDetails vipRuleDetails; |
|
|
|
|
List<VipBenefitList> vipBenefitList = []; |
|
|
|
|
Color color = Colors.black; |
|
|
|
|
double discount = 100; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
@ -35,9 +41,42 @@ class _RechargePage extends State<RechargePage> {
|
|
|
|
|
SharedPreferences.getInstance().then((value) { |
|
|
|
|
apiService = ApiService(Dio(), |
|
|
|
|
context: context, token: value.getString("token"), pay: true); |
|
|
|
|
queryBenefitList(); |
|
|
|
|
queryRuleDetails(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///会员权益列表 |
|
|
|
|
queryBenefitList() async { |
|
|
|
|
BaseData<List<VipBenefitList>> baseData = await apiService.benefitList().catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
vipBenefitList.clear(); |
|
|
|
|
vipBenefitList.addAll(baseData.data); |
|
|
|
|
vipBenefitList.forEach((element) { |
|
|
|
|
if(element.have && element.config != null && element.code == "RECHARGE"){ |
|
|
|
|
discount = double.parse(element.config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///会员权益介绍/规则/说明/储值说明 |
|
|
|
|
queryRuleDetails() async { |
|
|
|
|
BaseData<VipRuleDetails> baseData = |
|
|
|
|
await apiService.vipBenefit().catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
vipRuleDetails = baseData.data; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Scaffold( |
|
|
|
@ -48,137 +87,217 @@ class _RechargePage extends State<RechargePage> {
|
|
|
|
|
background: Color(0xFFFFFFFF), |
|
|
|
|
leadingColor: Colors.black, |
|
|
|
|
), |
|
|
|
|
body: SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
ItemInputWidget( |
|
|
|
|
S.of(context).qingshuruchongzhijine, |
|
|
|
|
hintText: "", |
|
|
|
|
controller: controller, |
|
|
|
|
padding: EdgeInsets.all(20), |
|
|
|
|
errorText: S.of(context).chongzhizuixiaojine(10), |
|
|
|
|
titleColor: Color(0xFF727272), |
|
|
|
|
errorTextColor: Color(0xFF32A060), |
|
|
|
|
radius: 8, |
|
|
|
|
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) < 10) { |
|
|
|
|
color = Colors.red; |
|
|
|
|
} else { |
|
|
|
|
color = Colors.black; |
|
|
|
|
} |
|
|
|
|
setState(() {}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
margin: EdgeInsets.only( |
|
|
|
|
left: 20.w, |
|
|
|
|
right: 20.w, |
|
|
|
|
top: 12.h, |
|
|
|
|
bottom: 4.h, |
|
|
|
|
), |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
left: 20.w, |
|
|
|
|
right: 16.w, |
|
|
|
|
top: 20.h, |
|
|
|
|
bottom: 20.h, |
|
|
|
|
), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Color(0x000000).withAlpha(25), |
|
|
|
|
offset: Offset(0, 1), |
|
|
|
|
blurRadius: 12.0, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
color: Colors.white, |
|
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(bottom: 16.h), |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).zhifufangshi, |
|
|
|
|
body:Stack( |
|
|
|
|
children: [ |
|
|
|
|
SingleChildScrollView( |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
child: Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
child: Column(children: [ |
|
|
|
|
ItemInputWidget( |
|
|
|
|
S.of(context).qingshuruchongzhijine, |
|
|
|
|
hintText: "", |
|
|
|
|
controller: controller, |
|
|
|
|
padding: EdgeInsets.all(20), |
|
|
|
|
errorText: S.of(context).chongzhizuixiaojine(0.1), |
|
|
|
|
titleColor: Color(0xFF727272), |
|
|
|
|
errorTextColor: Color(0xFF32A060), |
|
|
|
|
radius: 8, |
|
|
|
|
discount: discount/10, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
color: Colors.black, |
|
|
|
|
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) < 10) { |
|
|
|
|
color = Colors.red; |
|
|
|
|
} else { |
|
|
|
|
color = Colors.black; |
|
|
|
|
} |
|
|
|
|
setState(() {}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
checkIndex = 1; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
Row( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset("assets/image/icon_we_chat.png"), |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
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(); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
checkView(1), |
|
|
|
|
),) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
],), |
|
|
|
|
), |
|
|
|
|
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( |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Color(0x000000).withAlpha(25), |
|
|
|
|
offset: Offset(0, 1), |
|
|
|
|
blurRadius: 12.0, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
color: Colors.white, |
|
|
|
|
// borderRadius: BorderRadius.circular(4), |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(bottom: 16.h), |
|
|
|
|
child: Text( |
|
|
|
|
S.of(context).zhifufangshi, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
color: Colors.black, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
checkIndex = 1; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Image.asset("assets/image/icon_we_chat.png"), |
|
|
|
|
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), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
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, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
// 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: 54.h, |
|
|
|
|
color: Colors.white, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Spacer(), |
|
|
|
|
Padding(padding: EdgeInsets.only(top: 7,right: 16), |
|
|
|
|
child:Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
S.of(context).heji, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
controller.text == "" ? "" :(double.parse(controller.text) * (discount/100)).toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
)), |
|
|
|
|
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), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -207,8 +326,8 @@ class _RechargePage extends State<RechargePage> {
|
|
|
|
|
} |
|
|
|
|
int amount = int.tryParse(money); |
|
|
|
|
if (checkIndex == 1) { |
|
|
|
|
if (amount < 10) { |
|
|
|
|
SmartDialog.showToast(S.of(context).chongzhizuixiaojine(10), |
|
|
|
|
if (amount < 0.001) { |
|
|
|
|
SmartDialog.showToast(S.of(context).chongzhizuixiaojine(0.001), |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -220,10 +339,10 @@ class _RechargePage extends State<RechargePage> {
|
|
|
|
|
// await Min.initialize(); |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
BaseData<WxPay> baseData = |
|
|
|
|
BaseData<dynamic> baseData = |
|
|
|
|
await apiService.recharge({"amount": amount, "rechargeType": 2}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
WxPay wxPay = baseData.data; |
|
|
|
|
WxPay wxPay = WxPay.fromJson(baseData.data); |
|
|
|
|
await registerWxApi( |
|
|
|
|
appId: wxPay.appId, |
|
|
|
|
doOnAndroid: true, |
|
|
|
@ -240,8 +359,19 @@ class _RechargePage extends State<RechargePage> {
|
|
|
|
|
); |
|
|
|
|
weChatResponseEventHandler.listen((event) async { |
|
|
|
|
print("payCallback: ${event.errCode}"); |
|
|
|
|
if(event.errCode == 0){ |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
SmartDialog.showToast("充值成功", alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
SmartDialog.showToast("充值失败", alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|