|
|
@ -9,10 +9,13 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import 'package:fluwx/fluwx.dart'; |
|
|
|
import 'package:fluwx/fluwx.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/retrofit/data/recharge_list.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/retrofit/data/user_info.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/vip_benefit_list.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/vip_benefit_list.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/vip_rule_details.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/vip_rule_details.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/wx_pay.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/wx_pay.dart'; |
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
import 'package:huixiang/utils/min.dart'; |
|
|
|
import 'package:huixiang/utils/min.dart'; |
|
|
|
import 'package:huixiang/view_widget/item_input_widget.dart'; |
|
|
|
import 'package:huixiang/view_widget/item_input_widget.dart'; |
|
|
@ -35,6 +38,10 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
List<VipBenefitList> vipBenefitList = []; |
|
|
|
List<VipBenefitList> vipBenefitList = []; |
|
|
|
Color color = Colors.black; |
|
|
|
Color color = Colors.black; |
|
|
|
double discount = 100; |
|
|
|
double discount = 100; |
|
|
|
|
|
|
|
List<RechargeList> rechargeA; |
|
|
|
|
|
|
|
int selectIndex = 0; |
|
|
|
|
|
|
|
UserInfo userInfo; |
|
|
|
|
|
|
|
dynamic mBalance; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
void initState() { |
|
|
@ -45,11 +52,13 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
context: context, token: value.getString("token"), pay: true); |
|
|
|
context: context, token: value.getString("token"), pay: true); |
|
|
|
queryBenefitList(); |
|
|
|
queryBenefitList(); |
|
|
|
queryRuleDetails(); |
|
|
|
queryRuleDetails(); |
|
|
|
|
|
|
|
queryRechargeList(); |
|
|
|
|
|
|
|
queryUserBalance(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
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(); |
|
|
|
queryUserBalance(); |
|
|
|
SmartDialog.showToast("充值成功", alignment: Alignment.center); |
|
|
|
SmartDialog.showToast("充值成功", alignment: Alignment.center); |
|
|
|
} |
|
|
|
} |
|
|
|
// else{ |
|
|
|
// else{ |
|
|
@ -79,6 +88,16 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
EasyLoading.dismiss(); |
|
|
|
EasyLoading.dismiss(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryUserBalance() async { |
|
|
|
|
|
|
|
BaseData<UserInfo> baseData = |
|
|
|
|
|
|
|
await apiService.queryInfo().catchError((onError) {}); |
|
|
|
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
|
|
|
userInfo = baseData.data; |
|
|
|
|
|
|
|
mBalance = double.tryParse(userInfo?.money ?? "0"); |
|
|
|
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///会员权益介绍/规则/说明/储值说明 |
|
|
|
///会员权益介绍/规则/说明/储值说明 |
|
|
|
queryRuleDetails() async { |
|
|
|
queryRuleDetails() async { |
|
|
|
BaseData<VipRuleDetails> baseData = |
|
|
|
BaseData<VipRuleDetails> baseData = |
|
|
@ -91,6 +110,25 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
EasyLoading.dismiss(); |
|
|
|
EasyLoading.dismiss(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///充值列表 |
|
|
|
|
|
|
|
queryRechargeList() async { |
|
|
|
|
|
|
|
if (apiService == null) { |
|
|
|
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
|
|
|
apiService = ApiService( |
|
|
|
|
|
|
|
Dio(), |
|
|
|
|
|
|
|
context: context, |
|
|
|
|
|
|
|
token: value.getString("token"), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BaseData<List<RechargeList>> baseData = await apiService.rechargeAct().catchError((onError) {}); |
|
|
|
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
rechargeA = baseData.data; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Scaffold( |
|
|
|
return Scaffold( |
|
|
@ -168,7 +206,7 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
Text.rich( |
|
|
|
Text.rich( |
|
|
|
TextSpan(children: [ |
|
|
|
TextSpan(children: [ |
|
|
|
TextSpan( |
|
|
|
TextSpan( |
|
|
|
text: "0.00", |
|
|
|
text: "$mBalance", |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 26.sp, |
|
|
|
fontSize: 26.sp, |
|
|
|
color: Color(0xFF181818), |
|
|
|
color: Color(0xFF181818), |
|
|
@ -199,12 +237,6 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
color: Colors.white, |
|
|
|
color: Colors.white, |
|
|
|
child: Html( |
|
|
|
child: Html( |
|
|
|
data: "注意:${vipRuleDetails?.recharge ?? ""}", |
|
|
|
data: "注意:${vipRuleDetails?.recharge ?? ""}", |
|
|
|
style:{ |
|
|
|
|
|
|
|
"html":Style( |
|
|
|
|
|
|
|
color: Color(0xFF000000), |
|
|
|
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
customImageRenders: { |
|
|
|
customImageRenders: { |
|
|
|
networkSourceMatcher(): networkImageRender( |
|
|
|
networkSourceMatcher(): networkImageRender( |
|
|
|
loadingWidget: () { |
|
|
|
loadingWidget: () { |
|
|
@ -418,7 +450,7 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
|
|
|
|
|
|
|
|
Widget rechargeList() { |
|
|
|
Widget rechargeList() { |
|
|
|
return GridView.builder( |
|
|
|
return GridView.builder( |
|
|
|
itemCount: 6, |
|
|
|
itemCount: rechargeA == null ? 0 : rechargeA.length, |
|
|
|
shrinkWrap: true, |
|
|
|
shrinkWrap: true, |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
@ -432,59 +464,64 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
), |
|
|
|
), |
|
|
|
itemBuilder: (context, index) { |
|
|
|
itemBuilder: (context, index) { |
|
|
|
return GestureDetector( |
|
|
|
return GestureDetector( |
|
|
|
onTap: () {}, |
|
|
|
onTap: () { |
|
|
|
child: rechargeItem(), |
|
|
|
setState(() { |
|
|
|
|
|
|
|
selectIndex = index; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
child: rechargeItem(rechargeA[index],index), |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget rechargeItem() { |
|
|
|
Widget rechargeItem(RechargeList rechargeA,index) { |
|
|
|
return Stack( |
|
|
|
return Container( |
|
|
|
|
|
|
|
child: Stack( |
|
|
|
alignment: Alignment.bottomRight, |
|
|
|
alignment: Alignment.bottomRight, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
Container( |
|
|
|
alignment: Alignment.center, |
|
|
|
alignment: Alignment.center, |
|
|
|
height: 69.h, |
|
|
|
height: 69.h, |
|
|
|
decoration: BoxDecoration( |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Color(0xFFFAFAFA), |
|
|
|
color: selectIndex == index ?Color(0x2432A060) : Color(0xFFFAFAFA), |
|
|
|
// color: Color(0x2432A060), |
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
borderRadius: BorderRadius.circular(4), |
|
|
|
), |
|
|
|
), |
|
|
|
// margin: EdgeInsets.only(right: 11,bottom: 16), |
|
|
|
// margin: EdgeInsets.only(right: 11,bottom: 16), |
|
|
|
child: Column( |
|
|
|
child: Column( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
"${AppUtils.calculateDouble(double.tryParse(rechargeA.rechargeMoney)??0)}元", |
|
|
|
"100元", |
|
|
|
textAlign: TextAlign.center, |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFF868686), |
|
|
|
color: Color(0xFF868686), |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
fontSize:18.sp, |
|
|
|
fontSize: 21.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height:2,), |
|
|
|
SizedBox(height:2,), |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
"实际到账:${AppUtils.calculateDouble((double.tryParse(rechargeA.rechargeMoney)??0) + (double.tryParse(rechargeA.giftdMoney)??0) +((double.tryParse(rechargeA.rechargeMoney)??0) - ((double.tryParse(rechargeA.rechargeMoney)??0) * (discount/100))))}元", |
|
|
|
"实际到账:120元", |
|
|
|
textAlign: TextAlign.center, |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFF868686), |
|
|
|
color: Color(0xFF868686), |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
fontSize:10.sp, |
|
|
|
fontSize:12.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
if(selectIndex == index) |
|
|
|
Image.asset( |
|
|
|
Image.asset( |
|
|
|
"assets/image/recharge.png", |
|
|
|
"assets/image/recharge.png", |
|
|
|
width: 20, |
|
|
|
width: 20, |
|
|
|
height:20, |
|
|
|
height:20, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
); |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget checkView(var index) { |
|
|
|
Widget checkView(var index) { |
|
|
@ -502,19 +539,19 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
recharge() async { |
|
|
|
recharge() async { |
|
|
|
String money = controller.text; |
|
|
|
// String money = controller.text; |
|
|
|
if (money == null || money == "") { |
|
|
|
// if (money == null || money == "") { |
|
|
|
SmartDialog.showToast(S.of(context).qingshuruchongzhijine, |
|
|
|
// SmartDialog.showToast(S.of(context).qingshuruchongzhijine, |
|
|
|
alignment: Alignment.center); |
|
|
|
// alignment: Alignment.center); |
|
|
|
return; |
|
|
|
// return; |
|
|
|
} |
|
|
|
// } |
|
|
|
int amount = int.tryParse(money); |
|
|
|
// int amount = int.tryParse(money); |
|
|
|
if (checkIndex == 1) { |
|
|
|
// if (checkIndex == 1) { |
|
|
|
if (amount < 100) { |
|
|
|
// if (amount < 100) { |
|
|
|
SmartDialog.showToast(S.of(context).chongzhizuixiaojine(100), |
|
|
|
// SmartDialog.showToast(S.of(context).chongzhizuixiaojine(100), |
|
|
|
alignment: Alignment.center); |
|
|
|
// alignment: Alignment.center); |
|
|
|
return; |
|
|
|
// return; |
|
|
|
} |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
if (Platform.isAndroid) { |
|
|
|
if (Platform.isAndroid) { |
|
|
|
if (!(await Min.isInitialize())) { |
|
|
|
if (!(await Min.isInitialize())) { |
|
|
@ -526,7 +563,7 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BaseData<dynamic> baseData = await apiService.recharge( |
|
|
|
BaseData<dynamic> baseData = await apiService.recharge( |
|
|
|
{"amount": amount, "rechargeType": 2}).catchError((error) {}); |
|
|
|
{"amount": 0,"rechargeActId":rechargeA[selectIndex].id, "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( |
|
|
@ -547,5 +584,5 @@ class _RechargePage extends State<RechargePage> { |
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|