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.
381 lines
13 KiB
381 lines
13 KiB
import 'package:flutter/cupertino.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/generated/l10n.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:huixiang/retrofit/data/rank.dart'; |
|
import 'package:huixiang/retrofit/data/user_info.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:huixiang/view_widget/login_tips_dialog.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
class MineVipEntry extends StatelessWidget { |
|
int vipLevel; |
|
int curLevel; |
|
final int rankMax; |
|
final int rank; |
|
final String createTime; |
|
final String tag; |
|
final double padding; |
|
final UserInfo userInfo; |
|
final List<Rank> ranks; |
|
|
|
MineVipEntry( |
|
{this.vipLevel = 1, |
|
this.ranks, |
|
this.tag, |
|
this.userInfo, |
|
this.padding = 16, |
|
this.curLevel = 1, |
|
this.rankMax = 0, |
|
this.rank = 0, |
|
this.createTime = ""}); |
|
|
|
String topLeft = ""; |
|
String levelText = "普卡用户"; |
|
Color logoColor = Color(0xFFCACACA); |
|
Color levelTextColor = Color(0xFFCACACA); |
|
Color levelTextBackdrop = Color(0xFFFFF8EC); |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
if (userInfo != null && |
|
userInfo.memberRankVo != null && |
|
ranks != null && |
|
ranks.length > 0) { |
|
curLevel = (ranks |
|
.indexWhere((element) => element.id == userInfo.memberRankVo.id) + |
|
1); |
|
vipLevel = curLevel; |
|
} |
|
|
|
if (curLevel == vipLevel) { |
|
topLeft = S.of(context).dangqiandengji; |
|
} else if (vipLevel < curLevel) { |
|
topLeft = S.of(context).shangyidengji; |
|
} else { |
|
topLeft = S.of(context).zanweikaitong; |
|
} |
|
switch (vipLevel) { |
|
case 2: |
|
{ |
|
levelText = ranks[1].rankName; |
|
logoColor = Color(int.parse( |
|
(ranks[1].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextColor = Color(int.parse( |
|
(ranks[1].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextBackdrop = Color(int.parse( |
|
(ranks[1].color ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
break; |
|
} |
|
case 3: |
|
{ |
|
levelText = ranks[2].rankName; |
|
logoColor = Color(int.parse( |
|
(ranks[2].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextColor = Color(int.parse( |
|
(ranks[2].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextBackdrop = Color(int.parse( |
|
(ranks[2].color ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
break; |
|
} |
|
case 4: |
|
{ |
|
levelText = ranks[3].rankName; |
|
logoColor = Color(int.parse( |
|
(ranks[3].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextColor = Color(int.parse( |
|
(ranks[3].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextBackdrop = Color(int.parse( |
|
(ranks[3].color ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
break; |
|
} |
|
case 5: |
|
{ |
|
levelText = ranks[4].rankName; |
|
logoColor = Color(int.parse( |
|
(ranks[4].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextColor = Color(int.parse( |
|
(ranks[4].textColor ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
levelTextBackdrop = Color(int.parse( |
|
(ranks[4].color ?? "").replaceAll("#", "FF"), |
|
radix: 16)); |
|
break; |
|
} |
|
} |
|
|
|
Widget widget = userInfo.memberRankVo.rankName != null |
|
? Container( |
|
height: 20.h, |
|
width: double.infinity, |
|
child: Row( |
|
children: [ |
|
Container( |
|
height: double.infinity, |
|
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 4.h), |
|
decoration: BoxDecoration( |
|
color: logoColor, |
|
borderRadius: BorderRadius.only( |
|
topLeft: Radius.circular(4), |
|
bottomLeft: Radius.circular(4), |
|
), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Color(0x08213303).withAlpha(12), |
|
offset: Offset(0, 2), |
|
blurRadius: 4, |
|
spreadRadius: 0, |
|
), |
|
], |
|
), |
|
child: Image.asset( |
|
"assets/image/mine_vip_logo.webp", |
|
fit: BoxFit.cover, |
|
// width: 13.w, |
|
// height: 11.h, |
|
), |
|
), |
|
Container( |
|
height: double.infinity, |
|
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 3.h), |
|
decoration: BoxDecoration( |
|
color: levelTextBackdrop, |
|
borderRadius: BorderRadius.only( |
|
topRight: Radius.circular(4), |
|
bottomRight: Radius.circular(4), |
|
), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Color(0x08213303).withAlpha(12), |
|
offset: Offset(0, 2), |
|
blurRadius: 4, |
|
spreadRadius: 0, |
|
), |
|
], |
|
), |
|
child: Row( |
|
children: [ |
|
Text( |
|
levelText, |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
color: levelTextColor, |
|
fontSize: 10.sp, |
|
fontWeight: MyFontWeight.regular, |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/icon_right.webp", |
|
fit: BoxFit.cover, |
|
width: 8, |
|
height: 8, |
|
color: levelTextColor, |
|
), |
|
], |
|
), |
|
) |
|
], |
|
), |
|
) |
|
: Container( |
|
height: 20.h, |
|
width: double.infinity, |
|
child: Row( |
|
children: [ |
|
Container( |
|
height: double.infinity, |
|
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 4.h), |
|
decoration: BoxDecoration( |
|
color: Color(0xFFCACACA), |
|
borderRadius: BorderRadius.only( |
|
topLeft: Radius.circular(4), |
|
bottomLeft: Radius.circular(4), |
|
), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Color(0x08213303).withAlpha(12), |
|
offset: Offset(0, 2), |
|
blurRadius: 4, |
|
spreadRadius: 0, |
|
), |
|
], |
|
), |
|
child: Image.asset( |
|
"assets/image/mine_vip_logo.webp", |
|
fit: BoxFit.cover, |
|
// width: 13.w, |
|
// height: 11.h, |
|
), |
|
), |
|
Container( |
|
height: double.infinity, |
|
padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 3.h), |
|
decoration: BoxDecoration( |
|
color: Color(0xFFFFF8EC), |
|
borderRadius: BorderRadius.only( |
|
topRight: Radius.circular(4), |
|
bottomRight: Radius.circular(4), |
|
), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Color(0x08213303).withAlpha(12), |
|
offset: Offset(0, 2), |
|
blurRadius: 4, |
|
spreadRadius: 0, |
|
), |
|
], |
|
), |
|
child: Row( |
|
children: [ |
|
Text( |
|
"开通会员", |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
color: Color(0xFFCACACA), |
|
fontSize: 10.sp, |
|
fontWeight: MyFontWeight.regular, |
|
), |
|
), |
|
Image.asset( |
|
"assets/image/icon_right.webp", |
|
fit: BoxFit.cover, |
|
width: 8, |
|
height: 8, |
|
color: Color(0xFFCACACA), |
|
), |
|
], |
|
), |
|
) |
|
], |
|
), |
|
); |
|
// Container( |
|
// width: double.infinity, |
|
// padding: EdgeInsets.only(top: 12.h, bottom: 22.h, left: 12.w, right: 12.w), |
|
// margin: EdgeInsets.only(top: 23.h,left: 13.5.w,right: 13.5.w,bottom:15.h), |
|
// decoration: BoxDecoration( |
|
// color: Color(0xFF3D3D5D), |
|
// borderRadius: BorderRadius.circular(6), |
|
// boxShadow: [ |
|
// BoxShadow( |
|
// color: Colors.black.withAlpha(12), |
|
// offset: Offset(0, 3), |
|
// blurRadius: 14, |
|
// spreadRadius: 0, |
|
// ) |
|
// ], |
|
// ), |
|
// child: Column( |
|
// mainAxisAlignment: MainAxisAlignment.start, |
|
// crossAxisAlignment: CrossAxisAlignment.start, |
|
// children: [ |
|
// Row( |
|
// children: [ |
|
// Image.asset( |
|
// "assets/image/vip_logo.webp", |
|
// width: 24, |
|
// height: 24, |
|
// ), |
|
// SizedBox( |
|
// width: 5.w, |
|
// ), |
|
// Expanded( |
|
// child: Text( |
|
// levelText, |
|
// style: TextStyle( |
|
// fontSize: 16.sp, |
|
// fontWeight: MyFontWeight.semi_bold, |
|
// color: Color(0xFFFFEAD2)), |
|
// )), |
|
// Container( |
|
// padding: EdgeInsets.fromLTRB(9.w, 4.h, 8.w, 4.h), |
|
// decoration: BoxDecoration( |
|
// color: Color(0xFFFFECD2), |
|
// borderRadius: BorderRadius.circular(10), |
|
// ), |
|
// child: Text( |
|
// S.of(context).chakanquanyi, |
|
// style: TextStyle( |
|
// fontSize: 12.sp, |
|
// fontWeight: MyFontWeight.semi_bold, |
|
// color: Color(0xFF92755D), |
|
// ), |
|
// ), |
|
// ) |
|
// ], |
|
// ), |
|
// SizedBox( |
|
// height: 16.h, |
|
// ), |
|
// Container( |
|
// height: 4.h, |
|
// child: ClipRRect( |
|
// borderRadius: BorderRadius.circular(6.5), |
|
// child: LinearProgressIndicator( |
|
// value: rankMax > (rank ?? 0) |
|
// ? ((vipLevel < curLevel) |
|
// ? rankMax / rankMax |
|
// : (rank ?? 0) / rankMax) |
|
// : 0, |
|
// backgroundColor: Color(0xFF222233), |
|
// color: Color(0xFFFFECD2), |
|
// ), |
|
// ), |
|
// ), |
|
// SizedBox( |
|
// height: 8.h, |
|
// ), |
|
// Text( |
|
// rank > rankMax |
|
// ? S.of(context).dangqiandengji |
|
// : "消费金额¥${rank.toStringAsFixed(2).toString()} 距${S.of(context).xiayidengji}还需¥${(rankMax - (rank ?? 0)).toStringAsFixed(2)}", |
|
// style: TextStyle( |
|
// color: Color(0xFFFFEAD2), |
|
// fontWeight: MyFontWeight.light, |
|
// fontFamily: 'JDZhengHT', |
|
// fontSize: 14.sp, |
|
// ), |
|
// ) |
|
// ], |
|
// )); |
|
|
|
return GestureDetector( |
|
onTap: () { |
|
if (userInfo != null) { |
|
SharedPreferences.getInstance().then((value) { |
|
if (value.getString("token") == null || |
|
value.getString("token") == "") { |
|
LoginTipsDialog().show(context); |
|
return; |
|
} |
|
// Navigator.of(context) |
|
// .pushNamed('/router/mine_vip_level_page', arguments: { |
|
// "rankLevel": curLevel, |
|
// "createTime": (userInfo != null) ? "${userInfo.createTime}" : "", |
|
// "points": (userInfo != null) ? int.tryParse(userInfo.points) : 0, |
|
// }); |
|
Navigator.of(context) |
|
.pushNamed('/router/mine_vip_core', arguments: { |
|
"rankLevel": curLevel, |
|
"userInfo": userInfo, |
|
"createTime": (userInfo != null) ? "${userInfo.createTime}" : "", |
|
"expendAmount": |
|
double.tryParse(userInfo?.expendAmount ?? "0").toInt(), |
|
}); |
|
}); |
|
} |
|
}, |
|
child: widget, |
|
); |
|
} |
|
}
|
|
|