After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 850 B |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 950 B |
After Width: | Height: | Size: 966 B |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 1012 B |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 958 B |
After Width: | Height: | Size: 952 B |
After Width: | Height: | Size: 694 B |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 746 B |
After Width: | Height: | Size: 738 B |
@ -0,0 +1,118 @@
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
import 'package:huixiang/retrofit/data/vip_card_home.dart'; |
||||
import 'package:huixiang/view_widget/classic_header.dart'; |
||||
import 'package:huixiang/vip/vip_view/exclusive_coupon.dart'; |
||||
import 'package:huixiang/vip/vip_view/vip_goods_discount.dart'; |
||||
import 'package:huixiang/vip/vip_view/vip_top.dart'; |
||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
|
||||
import '../retrofit/data/base_data.dart'; |
||||
import '../retrofit/retrofit_api.dart'; |
||||
import '../view_widget/my_appbar.dart'; |
||||
|
||||
|
||||
class VipPage extends StatefulWidget { |
||||
|
||||
VipPage(Key key): super(key: key); |
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _VipPageState(); |
||||
} |
||||
} |
||||
|
||||
class _VipPageState extends State<VipPage> with AutomaticKeepAliveClientMixin { |
||||
final RefreshController _refreshController = RefreshController(); |
||||
ApiService apiService; |
||||
VipCardHome vipHome; |
||||
|
||||
|
||||
@override |
||||
void dispose() { |
||||
super.dispose(); |
||||
if (_refreshController != null) _refreshController.dispose(); |
||||
} |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
queryVipHome(); |
||||
} |
||||
|
||||
queryVipHome() async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
showLoading: true |
||||
); |
||||
} |
||||
BaseData<VipCardHome> baseData = |
||||
await apiService.vipCardIndex().catchError((onError) { |
||||
_refreshController.refreshFailed();}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
vipHome = baseData.data; |
||||
_refreshController.refreshCompleted(); |
||||
}else{ |
||||
_refreshController.refreshFailed(); |
||||
SmartDialog.showToast(baseData.msg ?? "", alignment: Alignment.center); |
||||
} |
||||
} |
||||
|
||||
|
||||
_onRefresh() { |
||||
queryVipHome(); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
super.build(context); |
||||
return Scaffold( |
||||
backgroundColor: Color(0xFFF9FAF7), |
||||
body: Container( |
||||
padding: EdgeInsets.only(bottom: 76.h), |
||||
child: SmartRefresher( |
||||
controller: _refreshController, |
||||
enablePullDown: true, |
||||
enablePullUp: false, |
||||
header: MyHeader(), |
||||
physics: BouncingScrollPhysics(), |
||||
onRefresh: () { |
||||
setState(() { |
||||
_onRefresh(); |
||||
}); |
||||
}, |
||||
child: SingleChildScrollView( |
||||
child: Container( |
||||
child: FutureBuilder( |
||||
future:queryVipHome(), |
||||
builder: (context, snapshot) { |
||||
return Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
VipTop(vipHome), |
||||
|
||||
VipGoodsDiscount(vipHome), |
||||
|
||||
ExclusiveCoupon(), |
||||
], |
||||
); |
||||
}, |
||||
), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
@override |
||||
bool get wantKeepAlive => true; |
||||
} |
@ -0,0 +1,132 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
||||
class ExclusiveCoupon extends StatefulWidget { |
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _ExclusiveCoupon(); |
||||
} |
||||
} |
||||
|
||||
class _ExclusiveCoupon extends State<ExclusiveCoupon> { |
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 40.h), |
||||
width: double.infinity, |
||||
padding: EdgeInsets.all(16.w), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(6.w), |
||||
color: Colors.white, |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Text( |
||||
"专享优惠券", |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
), |
||||
), |
||||
SizedBox( |
||||
height: 10.h, |
||||
), |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Stack( |
||||
alignment: Alignment.bottomCenter, |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/vip_shop_hx.webp", |
||||
width: 100.w, |
||||
height: 120.h, |
||||
fit: BoxFit.fill, |
||||
), |
||||
Padding( |
||||
padding: EdgeInsets.only(bottom: 4.h), |
||||
child: Text( |
||||
"6折饮品券", |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
)), |
||||
SizedBox( |
||||
width: 14.w, |
||||
), |
||||
Expanded( |
||||
child: Stack( |
||||
alignment: Alignment.bottomCenter, |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/vip_shop_qj.webp", |
||||
width: 100.w, |
||||
height: 120.h, |
||||
fit: BoxFit.fill, |
||||
), |
||||
Padding( |
||||
padding: EdgeInsets.only(bottom: 4.h), |
||||
child: Text( |
||||
"7折烘焙券", |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 14.w, |
||||
), |
||||
Expanded( |
||||
child: Stack( |
||||
alignment: Alignment.bottomCenter, |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/vip_shop_hg.webp", |
||||
width:100.w, |
||||
height: 120.h, |
||||
fit: BoxFit.fill, |
||||
), |
||||
Padding( |
||||
padding: EdgeInsets.only(bottom: 4.h), |
||||
child: Text( |
||||
"8折火锅券", |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,208 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
||||
import '../../retrofit/data/vip_card_home.dart'; |
||||
import '../../view_widget/custom_image.dart'; |
||||
|
||||
|
||||
class VipGoodsDiscount extends StatefulWidget { |
||||
final VipCardHome vipCardHome; |
||||
|
||||
VipGoodsDiscount(this.vipCardHome); |
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _VipGoodsDiscount(); |
||||
} |
||||
} |
||||
|
||||
class _VipGoodsDiscount extends State<VipGoodsDiscount> { |
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
margin: EdgeInsets.symmetric(vertical: 25.h,horizontal: 16.w), |
||||
child:Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
if(widget?.vipCardHome!=null) |
||||
(widget?.vipCardHome?.member?.isVip ?? false)? |
||||
Row( |
||||
mainAxisAlignment: MainAxisAlignment.center, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/vip_discount_left.webp", |
||||
width: 21.w, |
||||
height: 39.h, |
||||
fit: BoxFit.fill, |
||||
), |
||||
SizedBox(width: 11.w,), |
||||
Text( |
||||
"回乡VIP卡专享权益", |
||||
style: TextStyle( |
||||
color: Color(0xff32A060), |
||||
fontSize:15.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
), |
||||
), |
||||
SizedBox(width: 11.w,), |
||||
Image.asset( |
||||
"assets/image/vip_discount_right.webp", |
||||
width: 21.w, |
||||
height: 39.h, |
||||
fit: BoxFit.fill, |
||||
), |
||||
],): |
||||
Row( |
||||
mainAxisAlignment: MainAxisAlignment.center, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/vip_lock.webp", |
||||
width: 20, |
||||
height: 20, |
||||
fit: BoxFit.cover, |
||||
), |
||||
SizedBox(width: 2.w,), |
||||
Text( |
||||
"开通回乡VIP卡获取更多权益", |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize:15.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
vipGoodsRecommend(), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget vipGoodsRecommend(){ |
||||
return Container( |
||||
margin: EdgeInsets.only(top: 10.h), |
||||
height: 200.h, |
||||
width: double.infinity, |
||||
padding: EdgeInsets.all(16.w), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(6.w), |
||||
color: Colors.white, |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child:Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Text( |
||||
"会员专享价格", |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize:15.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
), |
||||
), |
||||
SizedBox(height:20.h,), |
||||
vipGoodsRecommendList(), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget vipGoodsRecommendList(){ |
||||
return Container( |
||||
height: 126.h, |
||||
child: ListView.builder( |
||||
scrollDirection: Axis.horizontal, |
||||
physics: BouncingScrollPhysics(), |
||||
itemCount: widget.vipCardHome?.productVips?.length ?? 0, |
||||
itemBuilder: (context, position) { |
||||
return GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context) |
||||
.pushNamed('/router/shop_details_page', arguments: { |
||||
"id": widget?.vipCardHome?.productVips[position].id, |
||||
"storeId": widget?.vipCardHome?.productVips[position].storeId, |
||||
}); |
||||
}, |
||||
child: vipGoodsRecommendItem(widget.vipCardHome.productVips[position]), |
||||
); |
||||
}, |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget vipGoodsRecommendItem(ProductVips productVips){ |
||||
return Container( |
||||
width: 70.w, |
||||
margin: EdgeInsets.only(right:10.w,left:6.w), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
Stack( |
||||
alignment: Alignment.bottomCenter, |
||||
children: [ |
||||
MImage( |
||||
productVips.thumbnailImg ?? "", |
||||
width: 70, |
||||
height: 70, |
||||
fit: BoxFit.cover, |
||||
errorSrc: "assets/image/default_1.webp", |
||||
fadeSrc: "assets/image/default_1.webp", |
||||
), |
||||
if(productVips.vipDiscount != "0.00") |
||||
Container( |
||||
width: 70, |
||||
padding: EdgeInsets.symmetric(vertical:2.h), |
||||
alignment: Alignment.center, |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.only( |
||||
bottomRight: Radius.circular(4.r), |
||||
bottomLeft: Radius.circular(4.r), |
||||
), |
||||
color: Color(0xff32A060), |
||||
), |
||||
child: Text( |
||||
"省${productVips.vipDiscount ?? ""}元", |
||||
style: TextStyle( |
||||
color: Colors.white, |
||||
fontSize:13.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
),), |
||||
), |
||||
], |
||||
), |
||||
Padding(padding:EdgeInsets.only(top:6.h,bottom: 4.h), |
||||
child: Text( |
||||
productVips.productName ?? "", |
||||
maxLines: 1, |
||||
overflow: TextOverflow.ellipsis, |
||||
style: TextStyle( |
||||
color: Color(0xff0D0D0D), |
||||
fontSize:14.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
),), |
||||
), |
||||
Text( |
||||
"¥${productVips.vipPrice ?? ""}", |
||||
style: TextStyle( |
||||
color: Color(0xff0D0D0D), |
||||
fontSize:15.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
),) |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,733 @@
|
||||
import 'dart:io'; |
||||
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
||||
import 'package:fluwx/fluwx.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
import 'package:tobias/tobias.dart'; |
||||
|
||||
import '../../generated/l10n.dart'; |
||||
import '../../retrofit/data/base_data.dart'; |
||||
import '../../retrofit/data/vip_card_home.dart'; |
||||
import '../../retrofit/data/wx_pay.dart'; |
||||
import '../../retrofit/retrofit_api.dart'; |
||||
import '../../utils/flutter_utils.dart'; |
||||
import '../../utils/min.dart'; |
||||
import 'package:tobias/tobias.dart' as tobias; |
||||
|
||||
class VipTop extends StatefulWidget { |
||||
final VipCardHome vipCardHome; |
||||
|
||||
VipTop(this.vipCardHome); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _VipTop(); |
||||
} |
||||
} |
||||
|
||||
class _VipTop extends State<VipTop> { |
||||
int selectIndex = 0; |
||||
ApiService apiService; |
||||
var payType = 1; |
||||
dynamic payListen; |
||||
int stateIndex = 0; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
payListen = weChatResponseEventHandler.listen((event) async { |
||||
print("payCallback: ${event.errCode}"); |
||||
if (event.errCode == 0) { |
||||
SmartDialog.showToast("支付成功", alignment: Alignment.center); |
||||
} else { |
||||
SmartDialog.showToast("支付失败", alignment: Alignment.center); |
||||
return; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
recharge() async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService(Dio(), |
||||
context: context, token: value.getString("token"), showLoading: true); |
||||
} |
||||
BaseData<dynamic> baseData = await apiService.orderVip({ |
||||
"cardId": widget?.vipCardHome?.cards[selectIndex]?.id, |
||||
"type": payType |
||||
}).catchError((error) {}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
if (payType == 1) { |
||||
if (Platform.isAndroid) { |
||||
if (!(await Min.isInitialize())) { |
||||
// 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, |
||||
// 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, |
||||
// 故而在此初始化一下 |
||||
await Min.initialize(); |
||||
} |
||||
} |
||||
WxPay wxPay = WxPay.fromJson(baseData.data); |
||||
await registerWxApi( |
||||
appId: wxPay.appId, |
||||
doOnAndroid: true, |
||||
universalLink: "https://hx.lotus-wallet.com/app/", |
||||
); |
||||
payWithWeChat( |
||||
appId: wxPay.appId, |
||||
partnerId: wxPay.partnerId, |
||||
prepayId: wxPay.prepayId, |
||||
packageValue: wxPay.packageValue, |
||||
nonceStr: wxPay.nonceStr, |
||||
timeStamp: int.tryParse(wxPay.timeStamp), |
||||
sign: wxPay.sign, |
||||
); |
||||
} else { |
||||
tobias.isAliPayInstalled().then((value) => { |
||||
// 判断是否安装了支付宝 |
||||
if (!value) |
||||
{SmartDialog.showToast("请安装支付宝", alignment: Alignment.center)} |
||||
else |
||||
{ |
||||
tobias.aliPay(baseData.data["body"]).then((payRes) { |
||||
if (payRes['resultStatus'] == 9000 || |
||||
payRes['resultStatus'] == '9000') { |
||||
SmartDialog.showToast("支付成功", |
||||
alignment: Alignment.center); |
||||
} else { |
||||
SmartDialog.showToast(payRes['memo'], |
||||
alignment: Alignment.center); |
||||
} |
||||
}) |
||||
} |
||||
}); |
||||
} |
||||
} else { |
||||
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
||||
} |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
child: Column( |
||||
children: [ |
||||
vipCard(), |
||||
SizedBox( |
||||
height: 15.h, |
||||
), |
||||
(!(widget?.vipCardHome?.member?.isVip ?? false) || stateIndex== 1)? |
||||
vipCardList(): |
||||
Padding( |
||||
padding: EdgeInsets.symmetric(horizontal: 16.w), |
||||
child: Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Container( |
||||
alignment: Alignment.center, |
||||
padding: EdgeInsets.symmetric( |
||||
horizontal: 10.w, vertical: 15.h), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(4.w), |
||||
color: Color(0xffffffff), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Text.rich( |
||||
TextSpan( |
||||
children: [ |
||||
TextSpan( |
||||
text: "已享会员权益 ", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
fontSize: 15.sp, |
||||
color: Color(0xff32A060), |
||||
), |
||||
), |
||||
TextSpan( |
||||
text: widget?.vipCardHome?.member?.vipDuration |
||||
.toString() ?? |
||||
"0", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
fontSize: 18.sp, |
||||
color: Color(0xffF96519), |
||||
), |
||||
), |
||||
TextSpan( |
||||
text: " 天", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
fontSize: 15.sp, |
||||
color: Color(0xff32A060), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
textDirection: TextDirection.ltr, |
||||
))), |
||||
SizedBox( |
||||
width: 10.w, |
||||
), |
||||
Expanded( |
||||
child: GestureDetector( |
||||
onTap: () { |
||||
setState(() { |
||||
stateIndex = 1; |
||||
}); |
||||
}, |
||||
child: Container( |
||||
alignment: Alignment.center, |
||||
padding: EdgeInsets.symmetric( |
||||
horizontal: 10.w, vertical: 15.h), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(4.w), |
||||
color: Color(0xffffffff), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Row( |
||||
mainAxisAlignment: MainAxisAlignment.center, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
Text( |
||||
"${(widget?.vipCardHome?.member?.isVipSubscribe ??false) ?"已开通自动续费":"续费回乡VIP"}", |
||||
style: TextStyle( |
||||
color: Color((widget?.vipCardHome?.member?.isVipSubscribe ??false)?0xff3A3936:0xff32A060), |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 6.w, |
||||
), |
||||
Image.asset( |
||||
"${(widget?.vipCardHome?.member?.isVipSubscribe ??false) ? "assets/image/vip_xf.webp":"assets/image/icon_right.webp"}", |
||||
width: 16, |
||||
height: 16, |
||||
fit: BoxFit.fill, |
||||
color: Color(0xff32A060), |
||||
), |
||||
], |
||||
))), |
||||
) |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget vipCard() { |
||||
return Container( |
||||
margin: EdgeInsets.fromLTRB( |
||||
16.w, MediaQuery.of(context).padding.top + 25.h, 16.w, 8.h), |
||||
height: 167.h, |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(8.w), |
||||
color: Colors.white, |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Stack( |
||||
// alignment: Alignment.center, |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/vip_card.webp", |
||||
fit: BoxFit.fill, //填充剩余空间 |
||||
height: 167.h, |
||||
), |
||||
Container( |
||||
padding: EdgeInsets.all(16.w), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
"回乡VIP卡", |
||||
style: TextStyle( |
||||
color: Color(0xff32A060), |
||||
fontSize: 24.sp, |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
), |
||||
)), |
||||
Text( |
||||
widget?.vipCardHome?.member?.nickname ?? "", |
||||
style: TextStyle( |
||||
color: Colors.white, |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
SizedBox( |
||||
height: 15.h, |
||||
), |
||||
if (widget?.vipCardHome?.member?.isVip ?? false) |
||||
Text( |
||||
"有效期至 ${(widget?.vipCardHome?.member?.vipExpire ?? "").substring(0,( widget?.vipCardHome?.member?.vipExpire ?? "").indexOf(" "))}", |
||||
style: TextStyle( |
||||
color: Color(0xffFFFFFF), |
||||
fontSize: 13.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget vipCardList() { |
||||
return Container( |
||||
height: 132.h, |
||||
margin: EdgeInsets.symmetric(horizontal: 14.w), |
||||
child: ListView.builder( |
||||
scrollDirection: Axis.horizontal, |
||||
physics: BouncingScrollPhysics(), |
||||
itemCount: widget?.vipCardHome?.cards?.length ?? 0, |
||||
itemBuilder: (context, position) { |
||||
return GestureDetector( |
||||
onTap: () { |
||||
setState(() { |
||||
selectIndex = position; |
||||
if (widget?.vipCardHome?.cards[selectIndex]?.autoSubscribe ?? |
||||
false) { |
||||
vipTreatyShowBottomSheet(); |
||||
} else { |
||||
vipShowBottomSheet(); |
||||
} |
||||
}); |
||||
}, |
||||
child: vipCardItem(widget?.vipCardHome?.cards[position], position), |
||||
); |
||||
}, |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget vipCardItem(Cards cards, index) { |
||||
return Expanded( |
||||
child: Stack( |
||||
alignment: Alignment.topRight, |
||||
children: [ |
||||
Container( |
||||
height: double.infinity, |
||||
width: 166.w, |
||||
alignment: Alignment.center, |
||||
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 25.h), |
||||
margin: EdgeInsets.only(right: 15.w), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(4.w), |
||||
color: Color(selectIndex == index ? 0xffF0FAF4 : 0xffffffff), |
||||
border: Border.all( |
||||
color: Color(selectIndex == index ? 0xff32A060 : 0xFFEAEAEA), |
||||
width: 2, |
||||
), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Column( |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
"${cards?.duration.toString() ?? ""}天", |
||||
textAlign: TextAlign.center, |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
), |
||||
), |
||||
), |
||||
Expanded( |
||||
child: Text( |
||||
cards?.name ?? "", |
||||
textAlign: TextAlign.center, |
||||
maxLines: 1, |
||||
overflow: TextOverflow.ellipsis, |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 15.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
SizedBox( |
||||
height: 10.h, |
||||
), |
||||
Text( |
||||
"¥${AppUtils.calculateDouble(double.tryParse(cards?.price ?? ""))}", |
||||
textAlign: TextAlign.center, |
||||
style: TextStyle( |
||||
color: Color(0xff32A060), |
||||
fontSize: 36.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
if (cards.autoSubscribe) |
||||
Container( |
||||
padding: EdgeInsets.symmetric(vertical: 4.h, horizontal: 6.w), |
||||
margin: EdgeInsets.only(right: 15.w), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.only( |
||||
topRight: Radius.circular(6.r), |
||||
bottomLeft: Radius.circular(6.r), |
||||
), |
||||
color: Color(0xff32A060), |
||||
), |
||||
child: Text( |
||||
"更优惠", |
||||
style: TextStyle( |
||||
color: Colors.white, |
||||
fontSize: 12.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
) |
||||
], |
||||
)); |
||||
} |
||||
|
||||
///会员卡包月协议弹窗 |
||||
vipTreatyShowBottomSheet() { |
||||
showModalBottomSheet( |
||||
builder: (BuildContext context) { |
||||
return treatyBuildBottomSheetWidget(context); |
||||
}, |
||||
backgroundColor: Colors.transparent, |
||||
barrierColor: Colors.transparent, |
||||
context: context); |
||||
} |
||||
|
||||
Widget treatyBuildBottomSheetWidget(BuildContext context) { |
||||
return Container( |
||||
padding: EdgeInsets.symmetric(vertical: 20.h, horizontal: 14.w), |
||||
height: 127.h, |
||||
decoration: new BoxDecoration( |
||||
color: Colors.white, |
||||
borderRadius: new BorderRadius.only( |
||||
topLeft: const Radius.circular(6.0), |
||||
topRight: const Radius.circular(6.0))), |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Padding( |
||||
padding: EdgeInsets.only(left: 4.w), |
||||
child: Text.rich( |
||||
TextSpan( |
||||
children: [ |
||||
TextSpan( |
||||
text: "开通即默认同意", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 12.sp, |
||||
color: Color(0xff4D4D4D), |
||||
), |
||||
), |
||||
TextSpan( |
||||
text: "《回乡VIP会员卡规则协议》", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 12.sp, |
||||
color: Color(0xff32A060), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
textDirection: TextDirection.ltr, |
||||
), |
||||
), |
||||
GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
vipShowBottomSheet(); |
||||
}, |
||||
child: Container( |
||||
height: 40.h, |
||||
alignment: Alignment.center, |
||||
margin: EdgeInsets.only(top: 26.h), |
||||
padding: EdgeInsets.symmetric(horizontal: 16.w), |
||||
decoration: new BoxDecoration( |
||||
color: Color(0xff32A060), |
||||
borderRadius: BorderRadius.circular(24)), |
||||
child: Text( |
||||
"立刻开通", |
||||
style: TextStyle( |
||||
fontSize: 16.sp, |
||||
height: 1.3.h, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFFFFFFFF), |
||||
), |
||||
), |
||||
), |
||||
) |
||||
], |
||||
)); |
||||
} |
||||
|
||||
///会员卡包月购买弹窗 |
||||
vipShowBottomSheet() { |
||||
showModalBottomSheet( |
||||
builder: (BuildContext context) { |
||||
return StatefulBuilder(builder: ( |
||||
context, |
||||
state, |
||||
) { |
||||
return buildBottomSheetWidget(context, state); |
||||
}); |
||||
}, |
||||
backgroundColor: Colors.transparent, |
||||
context: context); |
||||
} |
||||
|
||||
Widget buildBottomSheetWidget(BuildContext context, state) { |
||||
return Container( |
||||
padding: EdgeInsets.all(16), |
||||
decoration: new BoxDecoration( |
||||
color: Colors.white, |
||||
borderRadius: new BorderRadius.only( |
||||
topLeft: const Radius.circular(8.0), |
||||
topRight: const Radius.circular(8.0))), |
||||
child: Container( |
||||
height: 230.h, |
||||
child: Column( |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
"支付方式", |
||||
textAlign: TextAlign.center, |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 15.sp, |
||||
color: Color(0xff0D0D0D), |
||||
), |
||||
)), |
||||
GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
}, |
||||
child: Icon( |
||||
Icons.clear, |
||||
color: Colors.black, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
GestureDetector( |
||||
onTap: () { |
||||
state(() { |
||||
payType = 1; |
||||
}); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.only( |
||||
left: 14.w, right: 32.w, top: 11.h, bottom: 11.h), |
||||
margin: EdgeInsets.only(top: 17.h), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(4.w), |
||||
color: Color(payType == 1 ? 0xFFF0FAF4 : 0xffF9F9F9), |
||||
border: Border.all( |
||||
color: Color(payType == 1 ? 0xFF32A060 : 0xFFFAFAFA), |
||||
width: payType == 1 ? 2 : 0, |
||||
), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Color(0xffF9F9F9).withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Row( |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/icon_we_chat.webp", |
||||
width: 20, |
||||
fit: BoxFit.fill, |
||||
height: 20, |
||||
), |
||||
SizedBox( |
||||
width: 8.w, |
||||
), |
||||
Text( |
||||
S.of(context).weixinzhifu, |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 15.sp, |
||||
color: Color(0xff0D0D0D), |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 20.w, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
), |
||||
GestureDetector( |
||||
onTap: () { |
||||
state(() { |
||||
payType = 2; |
||||
}); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.only( |
||||
left: 14.w, right: 32.w, top: 11.h, bottom: 11.h), |
||||
margin: EdgeInsets.only(top: 17.h), |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(4.w), |
||||
color: Color(payType == 2 ? 0xFFF0FAF4 : 0xffF9F9F9), |
||||
border: Border.all( |
||||
color: Color(payType == 2 ? 0xFF32A060 : 0xFFFAFAFA), |
||||
width: payType == 2 ? 2 : 0, |
||||
), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Color(0xffF9F9F9).withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Row( |
||||
children: [ |
||||
Image.asset( |
||||
"assets/image/icon_alipay.webp", |
||||
width: 20, |
||||
fit: BoxFit.fill, |
||||
height: 20, |
||||
), |
||||
SizedBox( |
||||
width: 8.w, |
||||
), |
||||
Text( |
||||
"支付宝支付", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 15.sp, |
||||
color: Color(0xff0D0D0D), |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 20.w, |
||||
), |
||||
], |
||||
), |
||||
), |
||||
), |
||||
Container( |
||||
width: double.infinity, |
||||
height: 40.h, |
||||
margin: EdgeInsets.only(top: 30.h), |
||||
decoration: new BoxDecoration( |
||||
color: Color(0xff383A38), |
||||
borderRadius: BorderRadius.circular(24)), |
||||
child: Row( |
||||
children: [ |
||||
SizedBox( |
||||
width: 16.w, |
||||
), |
||||
Expanded( |
||||
child: Text.rich( |
||||
TextSpan( |
||||
children: [ |
||||
TextSpan( |
||||
text: "¥", |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 12.sp, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
TextSpan( |
||||
text: AppUtils.calculateDouble(double.tryParse( |
||||
widget?.vipCardHome?.cards[selectIndex] |
||||
?.price ?? |
||||
"")), |
||||
style: TextStyle( |
||||
fontWeight: MyFontWeight.regular, |
||||
fontSize: 20.sp, |
||||
color: Colors.white, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
textDirection: TextDirection.ltr, |
||||
)), |
||||
GestureDetector( |
||||
onTap: () { |
||||
Navigator.of(context).pop(); |
||||
recharge(); |
||||
}, |
||||
child: Container( |
||||
height: double.infinity, |
||||
alignment: Alignment.center, |
||||
padding: EdgeInsets.symmetric(horizontal: 16.w), |
||||
decoration: new BoxDecoration( |
||||
color: Color(0xff32A060), |
||||
borderRadius: BorderRadius.circular(24)), |
||||
child: Text( |
||||
"立刻支付", |
||||
style: TextStyle( |
||||
fontSize: 16.sp, |
||||
height: 1.3.h, |
||||
fontWeight: MyFontWeight.regular, |
||||
color: Color(0xFFFFFFFF), |
||||
), |
||||
), |
||||
), |
||||
) |
||||
], |
||||
), |
||||
) |
||||
], |
||||
), |
||||
)); |
||||
} |
||||
} |