You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
240 lines
7.8 KiB
240 lines
7.8 KiB
import 'dart:convert'; |
|
|
|
import 'package:dio/dio.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/generated/l10n.dart'; |
|
import 'package:huixiang/data/base_data.dart'; |
|
import 'package:huixiang/data/user_info.dart'; |
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:huixiang/view_widget/border_text.dart'; |
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
class ExchangeOrderSuccessPage extends StatefulWidget { |
|
final Map<String, dynamic>? arguments; |
|
|
|
ExchangeOrderSuccessPage({this.arguments}); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _ExchangeOrderSuccessPage(); |
|
} |
|
} |
|
|
|
class _ExchangeOrderSuccessPage extends State<ExchangeOrderSuccessPage> { |
|
int price = 0; |
|
ApiService? apiService; |
|
int happyBeanPrice= 0; |
|
@override |
|
void initState() { |
|
super.initState(); |
|
price = double.parse((widget.arguments?["points"] ?? "0").toString()).toInt() - |
|
double.parse((widget.arguments?["price"] ?? "0").toString()).toInt(); |
|
happyBeanPrice = double.parse((widget.arguments?["happyBean"] ?? "0").toString()).toInt() - |
|
double.parse((widget.arguments?["happyBeanPrice"] ?? "0").toString()).toInt(); |
|
|
|
UserInfo userInfo; |
|
SharedPreferences.getInstance().then((value){ |
|
apiService = ApiService(Dio(), context: context, token: value.getString("token")); |
|
String? user = value.getString('user'); |
|
if (user?.isEmpty ?? true) { |
|
userInfo = UserInfo.fromJson(jsonDecode(user!)); |
|
userInfo.points = "$price"; |
|
userInfo.happyBean = "$happyBeanPrice"; |
|
value.setString('user', jsonEncode(userInfo.toJson())); |
|
} |
|
}); |
|
|
|
setState(() {}); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Scaffold( |
|
appBar: MyAppBar( |
|
title: S.of(context).zhifuxiangqing, |
|
titleColor: Colors.black, |
|
titleSize: 18.sp, |
|
background: Color(0xFFFAFAFA), |
|
leadingColor: Colors.black, |
|
), |
|
body: Container( |
|
alignment: Alignment.center, |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
SizedBox( |
|
height: 46.h, |
|
), |
|
Image.asset( |
|
"assets/image/icon_order_success.webp", |
|
width: 76.w, |
|
height: 76.h, |
|
fit: BoxFit.contain, |
|
), |
|
SizedBox( |
|
height: 16.h, |
|
), |
|
Text( |
|
S.of(context).duihuanchenggong, |
|
style: TextStyle( |
|
color: Color(0xFF353535), |
|
fontSize: 21.sp, |
|
fontWeight: MyFontWeight.semi_bold), |
|
), |
|
SizedBox( |
|
height:45.h, |
|
), |
|
Text( |
|
"${widget.arguments?["realPay"]}".contains("消费印章") ? |
|
"消费印章" : ("${widget.arguments?["realPay"]}".contains(S.of(context).jifen) ? S.of(context).xiaofeijifen : "消费金额"), |
|
style: TextStyle( |
|
color: Color(0xFF727272), |
|
fontSize: 14.sp, |
|
), |
|
), |
|
SizedBox( |
|
height: 5.h, |
|
), |
|
Text( |
|
widget.arguments?["realPay"] ?? "", |
|
style: TextStyle( |
|
color: Color(0xFF32A060), |
|
fontSize: 21.sp, |
|
fontWeight: MyFontWeight.bold, |
|
), |
|
), |
|
SizedBox( |
|
height: 34.h, |
|
), |
|
Row( |
|
children: [ |
|
Expanded( |
|
child: Column( |
|
children: [ |
|
Text( |
|
"可用印章", |
|
style: TextStyle( |
|
color: Color(0xFF727272), |
|
fontSize: 14.sp, |
|
), |
|
), |
|
SizedBox( |
|
height: 14.h, |
|
), |
|
Text( |
|
"$happyBeanPrice", |
|
style: TextStyle( |
|
color: Colors.black, |
|
fontSize: 21.sp, |
|
fontWeight: MyFontWeight.regular, |
|
), |
|
), |
|
], |
|
), |
|
flex: 1, |
|
), |
|
Container( |
|
width: 1.w, |
|
height: 53.h, |
|
color: Color(0xFFD8D8D8), |
|
margin: EdgeInsets.only(top: 18.h, bottom: 7.h), |
|
), |
|
Expanded( |
|
child: Column( |
|
children: [ |
|
Text( |
|
S.of(context).keyongjifen, |
|
style: TextStyle( |
|
color: Color(0xFF727272), |
|
fontSize: 14.sp, |
|
), |
|
), |
|
SizedBox( |
|
height: 14.h, |
|
), |
|
Text( |
|
"$price", |
|
style: TextStyle( |
|
color: Colors.black, |
|
fontSize: 21.sp, |
|
fontWeight: MyFontWeight.regular, |
|
), |
|
), |
|
], |
|
), |
|
flex: 1, |
|
), |
|
], |
|
), |
|
SizedBox( |
|
height: 40.h, |
|
), |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
mainAxisSize: MainAxisSize.max, |
|
children: [ |
|
SizedBox( |
|
width: 16.w, |
|
), |
|
Expanded( |
|
child: InkWell( |
|
onTap: () { |
|
Navigator.of(context).pop(); |
|
}, |
|
child: BorderText( |
|
text: S.of(context).jixuduihuan, |
|
textColor: Color(0xFF32A060), |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
borderColor: Color(0xFF32A060), |
|
borderWidth: 1, |
|
padding: EdgeInsets.only(top: 12.h, bottom: 12.h), |
|
), |
|
), |
|
flex: 1, |
|
), |
|
SizedBox( |
|
width: 16.w, |
|
), |
|
// Expanded( |
|
// child: InkWell( |
|
// onTap: () { |
|
// receiveToCard(); |
|
// }, |
|
// child: RoundButton( |
|
// text: S.of(context).lingqudaokabao, |
|
// textColor: Colors.white, |
|
// backgroup: Color(0xFF32A060), |
|
// radius: 4, |
|
// fontWeight: MyFontWeight.semi_bold, |
|
// fontSize: 16.sp, |
|
// padding: EdgeInsets.only(top: 12.h, bottom: 12.h), |
|
// ), |
|
// ), |
|
// flex: 1, |
|
// ), |
|
// SizedBox( |
|
// width: 16.w, |
|
// ), |
|
], |
|
) |
|
], |
|
), |
|
), |
|
); |
|
} |
|
|
|
receiveToCard() async { |
|
BaseData? baseData = await apiService?.receiveToCard("${widget.arguments?["id"]}"); |
|
if(baseData?.isSuccess ?? false) { |
|
await Navigator.of(context).pushNamed('/router/mine_card'); |
|
Navigator.of(context).pop(); |
|
} |
|
} |
|
|
|
}
|
|
|