Browse Source

充值更改;

remove_uniapp
w-R 3 years ago
parent
commit
be9c1e8ce2
  1. 6
      lib/message/system_details.dart
  2. 52
      lib/mine/mine_view/wallet_coupon_view.dart
  3. 107
      lib/mine/recharge_page.dart
  4. 78
      lib/retrofit/data/recharge_list.dart
  5. 9
      lib/retrofit/retrofit_api.dart
  6. 23
      lib/retrofit/retrofit_api.g.dart
  7. 14
      lib/utils/flutter_utils.dart

6
lib/message/system_details.dart

@ -365,10 +365,10 @@ class _SystemDetails extends State<SystemDetails> {
children: [
Image.asset(
(message.typed == 1)
? "assets/image/icon_system_message.png"
? "assets/image/icon_system_message.webp"
: (message.typed == 2)
? "assets/image/icon_system_message.png"
: "assets/image/c_z.png",
? "assets/image/icon_system_message.webp"
: "assets/image/c_z.webp",
width: 24.w,
height: 24.h,
),

52
lib/mine/mine_view/wallet_coupon_view.dart

@ -31,59 +31,7 @@ class _WalletCoupon extends State<WalletCoupon> {
),
],
),
child: (Theme.of(context).platform == TargetPlatform.android)
? GestureDetector(
onTap: () {
SharedPreferences.getInstance().then((value) {
if (value.getString("token") == null ||
value.getString("token") == "") {
LoginTipsDialog().show(context);
return;
}
Navigator.of(context).pushNamed('/router/roll_center_page');
});
},
child: Row(
children: [
Image.asset(
"assets/image/icon_mine_invoice_assistant.webp",
width: 48.h,
height: 48.h,
),
SizedBox(
width: 12.w,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
S.of(context).lingquanzhongxin,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
color: Color(0xFF353535),
),
),
SizedBox(
height: 3,
),
Text(
"联盟下单享不停、海量优惠券等你来领!",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 12.sp,
color: Color(0xFF7B7B7B),
),
),
],
),
)
],
))
: Row(
children: [
Expanded(
flex: 1,

107
lib/mine/recharge_page.dart

@ -9,10 +9,13 @@ 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/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_rule_details.dart';
import 'package:huixiang/retrofit/data/wx_pay.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/min.dart';
import 'package:huixiang/view_widget/item_input_widget.dart';
@ -35,6 +38,10 @@ class _RechargePage extends State<RechargePage> {
List<VipBenefitList> vipBenefitList = [];
Color color = Colors.black;
double discount = 100;
List<RechargeList> rechargeA;
int selectIndex = 0;
UserInfo userInfo;
dynamic mBalance;
@override
void initState() {
@ -45,11 +52,13 @@ class _RechargePage extends State<RechargePage> {
context: context, token: value.getString("token"), pay: true);
queryBenefitList();
queryRuleDetails();
queryRechargeList();
queryUserBalance();
});
weChatResponseEventHandler.listen((event) async {
print("payCallback: ${event.errCode}");
if (event.errCode == 0) {
Navigator.of(context).pop();
queryUserBalance();
SmartDialog.showToast("充值成功", alignment: Alignment.center);
}
// else{
@ -79,6 +88,16 @@ class _RechargePage extends State<RechargePage> {
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 {
BaseData<VipRuleDetails> baseData =
@ -91,6 +110,25 @@ class _RechargePage extends State<RechargePage> {
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
Widget build(BuildContext context) {
return Scaffold(
@ -168,7 +206,7 @@ class _RechargePage extends State<RechargePage> {
Text.rich(
TextSpan(children: [
TextSpan(
text: "0.00",
text: "$mBalance",
style: TextStyle(
fontSize: 26.sp,
color: Color(0xFF181818),
@ -199,12 +237,6 @@ class _RechargePage extends State<RechargePage> {
color: Colors.white,
child: Html(
data: "注意:${vipRuleDetails?.recharge ?? ""}",
style:{
"html":Style(
color: Color(0xFF000000),
fontWeight: MyFontWeight.medium,
)
},
customImageRenders: {
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
@ -418,7 +450,7 @@ class _RechargePage extends State<RechargePage> {
Widget rechargeList() {
return GridView.builder(
itemCount: 6,
itemCount: rechargeA == null ? 0 : rechargeA.length,
shrinkWrap: true,
physics: BouncingScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
@ -432,23 +464,27 @@ class _RechargePage extends State<RechargePage> {
),
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {},
child: rechargeItem(),
onTap: () {
setState(() {
selectIndex = index;
});
},
child: rechargeItem(rechargeA[index],index),
);
},
);
}
Widget rechargeItem() {
return Stack(
Widget rechargeItem(RechargeList rechargeA,index) {
return Container(
child: Stack(
alignment: Alignment.bottomRight,
children: [
Container(
alignment: Alignment.center,
height: 69.h,
decoration: BoxDecoration(
color: Color(0xFFFAFAFA),
// color: Color(0x2432A060),
color: selectIndex == index ?Color(0x2432A060) : Color(0xFFFAFAFA),
borderRadius: BorderRadius.circular(4),
),
// margin: EdgeInsets.only(right: 11,bottom: 16),
@ -457,34 +493,35 @@ class _RechargePage extends State<RechargePage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"100",
"${AppUtils.calculateDouble(double.tryParse(rechargeA.rechargeMoney)??0)}",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF868686),
fontWeight: MyFontWeight.medium,
fontSize: 21.sp,
fontSize:18.sp,
),
),
SizedBox(height:2,),
Text(
"实际到账:120元",
"实际到账:${AppUtils.calculateDouble((double.tryParse(rechargeA.rechargeMoney)??0) + (double.tryParse(rechargeA.giftdMoney)??0) +((double.tryParse(rechargeA.rechargeMoney)??0) - ((double.tryParse(rechargeA.rechargeMoney)??0) * (discount/100))))}",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFF868686),
fontWeight: MyFontWeight.regular,
fontSize:12.sp,
fontSize:10.sp,
),
),
],
),
),
if(selectIndex == index)
Image.asset(
"assets/image/recharge.png",
width: 20,
height:20,
),
],
);
));
}
Widget checkView(var index) {
@ -502,19 +539,19 @@ class _RechargePage extends State<RechargePage> {
}
recharge() async {
String money = controller.text;
if (money == null || money == "") {
SmartDialog.showToast(S.of(context).qingshuruchongzhijine,
alignment: Alignment.center);
return;
}
int amount = int.tryParse(money);
if (checkIndex == 1) {
if (amount < 100) {
SmartDialog.showToast(S.of(context).chongzhizuixiaojine(100),
alignment: Alignment.center);
return;
}
// String money = controller.text;
// if (money == null || money == "") {
// SmartDialog.showToast(S.of(context).qingshuruchongzhijine,
// alignment: Alignment.center);
// return;
// }
// int amount = int.tryParse(money);
// if (checkIndex == 1) {
// if (amount < 100) {
// SmartDialog.showToast(S.of(context).chongzhizuixiaojine(100),
// alignment: Alignment.center);
// return;
// }
if (Platform.isAndroid) {
if (!(await Min.isInitialize())) {
@ -526,7 +563,7 @@ class _RechargePage extends State<RechargePage> {
}
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) {
WxPay wxPay = WxPay.fromJson(baseData.data);
await registerWxApi(
@ -547,5 +584,5 @@ class _RechargePage extends State<RechargePage> {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
}
// }
}

78
lib/retrofit/data/recharge_list.dart

@ -0,0 +1,78 @@
/// id : "1494622230208839681"
/// rechargeMoney : "100.00"
/// giftdMoney : "0.00"
/// gitfdCouponId : null
/// tenantCode : "admin"
/// createTime : "2022-03-23 10:53:37"
/// isDeleted : 0
/// rechargeType : 0
/// remark : "充充充"
class RechargeList {
RechargeList({
String id,
String rechargeMoney,
String giftdMoney,
dynamic gitfdCouponId,
String tenantCode,
String createTime,
int isDeleted,
int rechargeType,
String remark,}){
_id = id;
_rechargeMoney = rechargeMoney;
_giftdMoney = giftdMoney;
_gitfdCouponId = gitfdCouponId;
_tenantCode = tenantCode;
_createTime = createTime;
_isDeleted = isDeleted;
_rechargeType = rechargeType;
_remark = remark;
}
RechargeList.fromJson(dynamic json) {
_id = json['id'];
_rechargeMoney = json['rechargeMoney'];
_giftdMoney = json['giftdMoney'];
_gitfdCouponId = json['gitfdCouponId'];
_tenantCode = json['tenantCode'];
_createTime = json['createTime'];
_isDeleted = json['isDeleted'];
_rechargeType = json['rechargeType'];
_remark = json['remark'];
}
String _id;
String _rechargeMoney;
String _giftdMoney;
dynamic _gitfdCouponId;
String _tenantCode;
String _createTime;
int _isDeleted;
int _rechargeType;
String _remark;
String get id => _id;
String get rechargeMoney => _rechargeMoney;
String get giftdMoney => _giftdMoney;
dynamic get gitfdCouponId => _gitfdCouponId;
String get tenantCode => _tenantCode;
String get createTime => _createTime;
int get isDeleted => _isDeleted;
int get rechargeType => _rechargeType;
String get remark => _remark;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = _id;
map['rechargeMoney'] = _rechargeMoney;
map['giftdMoney'] = _giftdMoney;
map['gitfdCouponId'] = _gitfdCouponId;
map['tenantCode'] = _tenantCode;
map['createTime'] = _createTime;
map['isDeleted'] = _isDeleted;
map['rechargeType'] = _rechargeType;
map['remark'] = _remark;
return map;
}
}

9
lib/retrofit/retrofit_api.dart

@ -43,6 +43,7 @@ import 'data/message.dart';
import 'data/msg_stats.dart';
import 'data/page.dart';
import 'data/rank.dart';
import 'data/recharge_list.dart';
import 'data/second_card_list.dart';
import 'data/sign_info.dart';
import 'data/social_info.dart';
@ -63,8 +64,8 @@ part 'retrofit_api.g.dart';
// const base_url = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
// const baseUrl = "http://platform.prod.kunqi.lotus-wallet.com/app/"; ///222
const base_url = "http://192.168.10.236:8766/app/"; ///
const baseUrl = "http://192.168.10.236:8766/app/"; ///
const base_url = "http://192.168.10.236:8776/app/"; ///
const baseUrl = "http://192.168.10.236:8776/app/"; ///
// const base_url = "http://192.168.10.37:8766/app/";
// const baseUrl = "http://192.168.10.37:8766/app/";
@ -218,6 +219,10 @@ abstract class ApiService {
@POST("/wallet/recharge")
Future<BaseData<dynamic>> recharge(@Body() Map<String, dynamic> param);
///
@GET("/wallet/rechargeAct")
Future<BaseData<List<RechargeList>>> rechargeAct();
///
@GET("/coupon/receive?couponId={couponId}")
Future<BaseData> receiveCoupon(@Path("couponId") String couponId);

23
lib/retrofit/retrofit_api.g.dart

@ -9,7 +9,7 @@ part of 'retrofit_api.dart';
class _ApiService implements ApiService {
_ApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'http://192.168.10.236:8766/app/';
baseUrl ??= 'http://192.168.10.236:8776/app/';
}
final Dio _dio;
@ -298,6 +298,27 @@ class _ApiService implements ApiService {
return value;
}
@override
Future<BaseData<List<RechargeList>>> rechargeAct() async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>('/wallet/rechargeAct',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<List<RechargeList>>.fromJson(
_result.data,
(json) => (json as List<dynamic>)
.map<RechargeList>((i) => RechargeList.fromJson(i as Map<String, dynamic>))
.toList());
return value;
}
@override
Future<BaseData<dynamic>> receiveCoupon(couponId) async {
ArgumentError.checkNotNull(couponId, 'couponId');

14
lib/utils/flutter_utils.dart

@ -15,6 +15,20 @@ class AppUtils {
return "${numberFormat.format(mi / 1000)}";
}
static String trimEnd(String resString,String char){
while(resString.endsWith(char)){
resString = resString.substring(0,resString.length - 1);
}
return resString;
}
////
static String calculateDouble(double res){
String resString = res.toStringAsFixed(2);
resString = trimEnd(resString, "0");
resString = trimEnd(resString, ".");
return resString;
}
static Future<BMFCoordinate> coordConvert(BMFCoordinate latLng) async {
return BMFCalculateUtils.coordConvert(

Loading…
Cancel
Save