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.
541 lines
19 KiB
541 lines
19 KiB
1 year ago
|
import 'package:dio/dio.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||
|
import 'package:huixiang/utils/font_weight.dart';
|
||
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||
|
|
||
|
import '../../../generated/l10n.dart';
|
||
|
import '../../../retrofit/business_api.dart';
|
||
|
import '../../../retrofit/data/base_data.dart';
|
||
|
import '../../../retrofit/data/phone_query_member_info.dart';
|
||
|
import '../../../utils/business_instance.dart';
|
||
|
import '../../../utils/flutter_utils.dart';
|
||
|
import '../../../view_widget/classic_header.dart';
|
||
|
import '../../../view_widget/custom_image.dart';
|
||
|
import '../../../view_widget/my_footer.dart';
|
||
|
import '../../../view_widget/settlement_tips_dialog.dart';
|
||
|
|
||
|
class MemberDetailsPage extends StatefulWidget {
|
||
|
final Map<String, dynamic> arguments;
|
||
|
|
||
|
MemberDetailsPage({this.arguments});
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _MemberDetailsPage();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _MemberDetailsPage extends State<MemberDetailsPage> {
|
||
|
final RefreshController refreshController = RefreshController();
|
||
|
BusinessApiService businessService;
|
||
|
PhoneQueryMemberInfo phoneQueryMemberInfo;
|
||
|
String networkError = "";
|
||
|
int networkStatus = 0;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
queryMemberPhoneInfo(widget?.arguments["phoneNum"] ?? "");
|
||
|
}
|
||
|
|
||
|
///根据手机号搜索用户信息
|
||
|
queryMemberPhoneInfo(phoneNum, {isShow = true}) async {
|
||
|
try {
|
||
|
if (isShow)
|
||
|
EasyLoading.show(
|
||
|
status: S.current.zhengzaijiazai,
|
||
|
maskType: EasyLoadingMaskType.black);
|
||
|
if (businessService == null) {
|
||
|
businessService = BusinessApiService(Dio(),
|
||
|
context: context,
|
||
|
token: BusinessInstance.instance.businessToken,
|
||
|
tenant: BusinessInstance.instance.businessTenant,
|
||
|
storeId: widget.arguments["storeId"]);
|
||
|
}
|
||
|
BaseData<PhoneQueryMemberInfo> baseData = await businessService
|
||
|
.queryMemberInfo(
|
||
|
{"phoneNum": phoneNum, "isNewUser": false}).catchError((error) {
|
||
|
networkError = AppUtils.dioErrorTypeToString(error.type);
|
||
|
networkStatus = -1;
|
||
|
setState(() {});
|
||
|
refreshController.refreshFailed();
|
||
|
refreshController.loadFailed();
|
||
|
});
|
||
|
if (!mounted) return;
|
||
|
if (baseData != null && baseData.isSuccess) {
|
||
|
phoneQueryMemberInfo = baseData.data;
|
||
|
refreshController.loadComplete();
|
||
|
refreshController.refreshCompleted();
|
||
|
networkStatus = 1;
|
||
|
} else {
|
||
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
|
||
|
refreshController.refreshFailed();
|
||
|
refreshController.loadFailed();
|
||
|
}
|
||
|
} finally {
|
||
|
if (isShow) EasyLoading.dismiss();
|
||
|
setState(() {});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
resizeToAvoidBottomInset: false,
|
||
|
appBar: MyAppBar(
|
||
|
title: "会员详情",
|
||
|
titleColor: Colors.black,
|
||
|
background: Colors.white,
|
||
|
leadingColor: Colors.black,
|
||
|
brightness: Brightness.dark,
|
||
|
),
|
||
|
body:
|
||
|
networkStatus == -1
|
||
|
? noNetwork() :
|
||
|
SmartRefresher(
|
||
|
controller: refreshController,
|
||
|
enablePullDown: true,
|
||
|
enablePullUp: false,
|
||
|
header: MyHeader(
|
||
|
color: Color(0xFF30415B),
|
||
|
),
|
||
|
footer: CustomFooter(
|
||
|
builder: (context, mode) {
|
||
|
return MyFooter(mode);
|
||
|
},
|
||
|
),
|
||
|
onRefresh: () {
|
||
|
queryMemberPhoneInfo(widget?.arguments["phoneNum"] ?? "",isShow: false);
|
||
|
},
|
||
|
physics: BouncingScrollPhysics(),
|
||
|
scrollController: ScrollController(),
|
||
|
child: Container(
|
||
|
padding: EdgeInsets.only(top:15.h,left: 16.w,right: 16.w),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
vipPlate(),
|
||
|
vipFunction(),
|
||
|
vipRecord()
|
||
|
],
|
||
|
))));
|
||
|
}
|
||
|
|
||
|
///会员信息板块
|
||
|
Widget vipPlate() {
|
||
|
return Container(
|
||
|
width: double.infinity,
|
||
|
margin: EdgeInsets.only(bottom: 12.h),
|
||
|
padding: EdgeInsets.only(bottom: 15.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
child: Column(
|
||
|
children: [
|
||
|
Container(
|
||
|
width: double.infinity,
|
||
|
padding: EdgeInsets.only(left: 16.w, bottom: 33.h, top: 13.h),
|
||
|
margin: EdgeInsets.only(bottom: 10.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
gradient: LinearGradient(
|
||
|
begin: Alignment.centerLeft,
|
||
|
end: Alignment.centerRight,
|
||
|
colors: [Color(0xFF30415B), Color(0xFF5171A4)]),
|
||
|
borderRadius: BorderRadius.vertical(
|
||
|
top: Radius.circular(8),
|
||
|
),
|
||
|
),
|
||
|
child: Row(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Container(
|
||
|
width: 52.h,
|
||
|
height: 52.h,
|
||
|
margin: EdgeInsets.only(right: 15.w,),
|
||
|
decoration: BoxDecoration(
|
||
|
borderRadius: BorderRadius.circular(4),
|
||
|
),
|
||
|
child:MImage(
|
||
|
(phoneQueryMemberInfo?.headimg ??
|
||
|
""),
|
||
|
width: double.infinity,
|
||
|
height: double.infinity,
|
||
|
fit: BoxFit.cover,
|
||
|
errorSrc: "assets/image/default_1.webp",
|
||
|
fadeSrc: "assets/image/default_1.webp",
|
||
|
),
|
||
|
),
|
||
|
Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(bottom: 8.h),
|
||
|
child: Text(
|
||
|
"会员名称:${phoneQueryMemberInfo?.nickName ?? ""}",
|
||
|
overflow: TextOverflow.ellipsis,
|
||
|
maxLines: 2,
|
||
|
style: TextStyle(
|
||
|
fontSize: 12.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
)),
|
||
|
Text(
|
||
|
"手机号:${phoneQueryMemberInfo?.phoneNum ?? ""}",
|
||
|
style: TextStyle(
|
||
|
fontSize: 12.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(bottom: 7.h),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Image.asset(
|
||
|
"assets/image/bus_vip_balance.webp",
|
||
|
width: 24.h,
|
||
|
height: 24.h,
|
||
|
fit: BoxFit.fill,
|
||
|
),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(left: 7.w),
|
||
|
child: Text(
|
||
|
"会员余额",
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
color: Color(0xFF252626),
|
||
|
),
|
||
|
))
|
||
|
],
|
||
|
)),
|
||
|
Text(
|
||
|
phoneQueryMemberInfo?.balance ?? "0.00",
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
color: Color(0xFF30415B),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
)),
|
||
|
Expanded(
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(bottom: 7.h),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Image.asset(
|
||
|
"assets/image/bus_coupon.webp",
|
||
|
width: 20.w,
|
||
|
height: 18.h,
|
||
|
fit: BoxFit.fill,
|
||
|
),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(left: 7.w),
|
||
|
child: Text(
|
||
|
"优惠券",
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
color: Color(0xFF252626),
|
||
|
),
|
||
|
))
|
||
|
],
|
||
|
)),
|
||
|
Text(
|
||
|
(phoneQueryMemberInfo?.useableConponList?.length ?? 0)
|
||
|
.toString(),
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
color: Color(0xFF30415B),
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
)),
|
||
|
],
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
///会员功能
|
||
|
Widget vipFunction() {
|
||
|
return Container(
|
||
|
width: double.infinity,
|
||
|
margin: EdgeInsets.only(bottom: 12.h),
|
||
|
padding: EdgeInsets.only(bottom:17.h,top:27.h,),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
child:Row(
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child:GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
Navigator.of(context)
|
||
|
.pushNamed('/router/vip_recharge_page', arguments: {
|
||
|
"storeId": widget.arguments["storeId"] ??"",
|
||
|
});
|
||
|
},
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Padding(padding:EdgeInsets.only(bottom: 12.h),
|
||
|
child: Image.asset(
|
||
|
"assets/image/bus_home_syt.webp",
|
||
|
width: 26.w,
|
||
|
height: 23.h,
|
||
|
fit: BoxFit.fill,
|
||
|
)),
|
||
|
Text(
|
||
|
"会员充值",
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
color: Color(0xFF252626),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
)),
|
||
|
Expanded(
|
||
|
child:GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
if(widget.arguments["storeId"] == "0"){
|
||
|
SmartDialog.show(
|
||
|
widget: SettlementTips(
|
||
|
() {
|
||
|
},
|
||
|
text: "当前为所有门店状态,收银操作时,请将门店切换至要消费的门店!",
|
||
|
color: Color(0xFF30415B),
|
||
|
));
|
||
|
}else{
|
||
|
Navigator.of(context)
|
||
|
.pushNamed('/router/cashier_page', arguments: {
|
||
|
"storeId": widget.arguments["storeId"] ??"",
|
||
|
"phone":widget?.arguments["phoneNum"] ?? ""
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Padding(padding:EdgeInsets.only(bottom: 12.h),
|
||
|
child: Image.asset(
|
||
|
"assets/image/bus_home_hyyetj.webp",
|
||
|
width: 23.h,
|
||
|
height: 23.h,
|
||
|
fit: BoxFit.fill,
|
||
|
)),
|
||
|
Text(
|
||
|
"会员收银",
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
color: Color(0xFF252626),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
))),
|
||
|
Spacer()
|
||
|
// Expanded(
|
||
|
// child:Column(
|
||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||
|
// children: [
|
||
|
// Padding(padding:EdgeInsets.only(bottom: 12.h),
|
||
|
// child: Image.asset(
|
||
|
// "assets/image/bus_vip_cc.webp",
|
||
|
// width: 24.h,
|
||
|
// height: 24.h,
|
||
|
// fit: BoxFit.fill,
|
||
|
// )),
|
||
|
// Text(
|
||
|
// "会员充次",
|
||
|
// style: TextStyle(
|
||
|
// fontSize: 14.sp,
|
||
|
// fontWeight: MyFontWeight.medium,
|
||
|
// color: Color(0xFF252626),
|
||
|
// ),
|
||
|
// ),
|
||
|
// ],
|
||
|
// )),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
///会员消费/充值/充次记录
|
||
|
Widget vipRecord() {
|
||
|
return Container(
|
||
|
width: double.infinity,
|
||
|
margin: EdgeInsets.only(bottom: 12.h),
|
||
|
padding: EdgeInsets.only(bottom:17.h,top:11.h,left: 17.w,right: 16.w),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
child:Column(
|
||
|
children: [
|
||
|
vipRecordText("消费记录"),
|
||
|
Container(
|
||
|
width: double.infinity,
|
||
|
height: 1.h,
|
||
|
color: Color(0xFFEBECEF),
|
||
|
),
|
||
|
vipRecordText("充值记录"),
|
||
|
// Container(
|
||
|
// width: double.infinity,
|
||
|
// height: 1.h,
|
||
|
// color: Color(0xFFEBECEF),
|
||
|
// ),
|
||
|
// vipRecordText("充次记录"),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
Widget vipRecordText(String text){
|
||
|
return GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: (){
|
||
|
Navigator.of(context).pushNamed(
|
||
|
'/router/record_details',
|
||
|
arguments: {
|
||
|
"storeId": widget.arguments["storeId"],
|
||
|
"titleName":text,
|
||
|
"mid":phoneQueryMemberInfo?.sid ??"",
|
||
|
"title":text == "消费记录" ?"bill_tenant_balance":"bill_tenant_balance",
|
||
|
"category":text == "消费记录" ?"bill_cate_buy":"bill_cate_rechange",
|
||
|
});
|
||
|
},
|
||
|
child: Container(
|
||
|
padding: EdgeInsets.symmetric(vertical: 16.h),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Text(
|
||
|
text,
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
)),
|
||
|
Padding(padding: EdgeInsets.only(right: 9.w,),child: Image.asset(
|
||
|
"assets/image/icon_right_z.webp",
|
||
|
width: 16.h,
|
||
|
height: 16.h,
|
||
|
color: Color(0xFF353535),
|
||
|
)),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
///网络错误
|
||
|
Widget noNetwork() {
|
||
|
return Container(
|
||
|
color: Colors.white,
|
||
|
width: double.infinity,
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Text(
|
||
|
networkError.substring(0, networkError.indexOf(",")),
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
color: Color(0xFF0D0D0D),
|
||
|
fontWeight: MyFontWeight.bold),
|
||
|
),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.symmetric(vertical: 10.h),
|
||
|
child: Text(
|
||
|
"请检查网络设置或稍后重试",
|
||
|
style: TextStyle(
|
||
|
fontSize: 12.sp,
|
||
|
color: Color(0xFF7A797F),
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
),
|
||
|
),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: () {
|
||
|
queryMemberPhoneInfo(widget?.arguments["phoneNum"] ?? "");
|
||
|
},
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0xFF30415B),
|
||
|
borderRadius: BorderRadius.circular(15),
|
||
|
),
|
||
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h),
|
||
|
child: Text(
|
||
|
"重试",
|
||
|
style: TextStyle(
|
||
|
fontSize: 14.sp,
|
||
|
color: Colors.white,
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
)),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|