|
|
|
import 'package:barcode_widget/barcode_widget.dart';
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/order_info.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/page.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/vip_card.dart';
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
import 'package:huixiang/utils/painter_bg.dart';
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_footer.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
class VipDetailPage extends StatefulWidget {
|
|
|
|
final Map<String, dynamic> arguments;
|
|
|
|
|
|
|
|
VipDetailPage({this.arguments});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _VipDetailPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _VipDetailPage extends State<VipDetailPage> {
|
|
|
|
ApiService apiService;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
refreshController.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
SharedPreferences.getInstance().then((value) {
|
|
|
|
apiService =
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token"));
|
|
|
|
vipDetail();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
VipCard vipCard;
|
|
|
|
List<OrderInfo> orderInfos = [];
|
|
|
|
final RefreshController refreshController = RefreshController();
|
|
|
|
int current = 1;
|
|
|
|
|
|
|
|
vipDetail() async {
|
|
|
|
BaseData baseData = await apiService
|
|
|
|
.vipDetail(widget.arguments["id"])
|
|
|
|
.catchError((onError) {});
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
vipCard = VipCard.fromJson(baseData.data);
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
BaseData order = await apiService.orderList({
|
|
|
|
"current": current,
|
|
|
|
"model": {"status": 0, "storeId": vipCard.storeId},
|
|
|
|
"order": "descending",
|
|
|
|
"size": 10,
|
|
|
|
"sort": "id"
|
|
|
|
});
|
|
|
|
if (order != null && order.isSuccess) {
|
|
|
|
PageInfo pageInfo = PageInfo.fromJson(order.data);
|
|
|
|
if (current == 1) {
|
|
|
|
orderInfos.clear();
|
|
|
|
}
|
|
|
|
orderInfos
|
|
|
|
.addAll(pageInfo.records.map((e) => OrderInfo.fromJson(e)).toList());
|
|
|
|
refreshController.loadComplete();
|
|
|
|
if (current * 10 > int.tryParse(pageInfo.total)) {
|
|
|
|
refreshController.loadNoData();
|
|
|
|
} else {
|
|
|
|
current += 1;
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
} else {
|
|
|
|
refreshController.loadFailed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: MyAppBar(
|
|
|
|
title: S.of(context).huiyuankaxiangqing,
|
|
|
|
titleColor: Colors.white,
|
|
|
|
background: Color(0xFF3A405A),
|
|
|
|
// brightness: Brightness.dark,
|
|
|
|
leadingColor: Colors.white,
|
|
|
|
),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
children: [
|
|
|
|
CustomPaint(
|
|
|
|
painter: BgPainter(
|
|
|
|
bgColor: Color(0xFF3A405A),
|
|
|
|
bezierHeight: 30.h,
|
|
|
|
),
|
|
|
|
child: Container(
|
|
|
|
height: 220.h,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
buildVipCard(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 16.w, top: 35.h, bottom: 16.h),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
S.of(context).shiyongmendian,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 8.w,
|
|
|
|
),
|
|
|
|
Image.asset(
|
|
|
|
"assets/image/icon_shop.png",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: SmartRefresher(
|
|
|
|
controller: refreshController,
|
|
|
|
enablePullDown: false,
|
|
|
|
enablePullUp: true,
|
|
|
|
footer: CustomFooter(
|
|
|
|
builder: (context, mode) {
|
|
|
|
return MyFooter(mode);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
child: ListView.builder(
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {},
|
|
|
|
child: shopItem(orderInfos[position]),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: orderInfos != null ? orderInfos.length : 0,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildVipCard() {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h),
|
|
|
|
height: 220.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/icon_vip_bj.png",
|
|
|
|
fit: BoxFit.fill, //填充剩余空间
|
|
|
|
height: 220.h,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(16.w),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
vipCard != null ? vipCard.storeLogo : "",
|
|
|
|
width: 40.w,
|
|
|
|
height: 40.h,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorSrc: "assets/image/default_1.png",
|
|
|
|
fadeSrc: "assets/image/default_1.png",
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 8.w,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
height: 54.h,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
vipCard != null ? vipCard.storeName : "",
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
Image.asset(
|
|
|
|
"assets/image/icon_vip.png",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: S.of(context).huiyuanka,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
textDirection: TextDirection.ltr,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container(),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 32.w, right: 32.w),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text:
|
|
|
|
"¥ ${vipCard != null ? vipCard.balance : ""}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24.sp,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
'/router/vip_balance',
|
|
|
|
arguments: {"storeId": vipCard.id});
|
|
|
|
},
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: S.of(context).yue,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Icon(
|
|
|
|
Icons.keyboard_arrow_right,
|
|
|
|
color: Colors.black,
|
|
|
|
size: 22.5,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Text.rich(
|
|
|
|
TextSpan(children: [
|
|
|
|
TextSpan(
|
|
|
|
text: "0",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 24.sp,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 5.h,
|
|
|
|
),
|
|
|
|
Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: S.of(context).jifen,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 5.h, bottom: 5.h),
|
|
|
|
child: Text(
|
|
|
|
vipCard != null
|
|
|
|
? "${vipCard.id.substring(0, 4)} "
|
|
|
|
"${vipCard.id.substring(4, 8)} "
|
|
|
|
"${vipCard.id.substring(8, 12)} "
|
|
|
|
"${vipCard.id.substring(12, 16)} "
|
|
|
|
"${vipCard.id.substring(16, vipCard.id.length)}"
|
|
|
|
: "",
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 14.sp,
|
|
|
|
wordSpacing: vipCard == null
|
|
|
|
? 10
|
|
|
|
: (MediaQuery.of(context).size.width - 64.w) /
|
|
|
|
(((vipCard.id.length) * 4)),
|
|
|
|
letterSpacing: vipCard == null
|
|
|
|
? 8
|
|
|
|
: (MediaQuery.of(context).size.width - 64.w) /
|
|
|
|
(((vipCard.id.length) * 4)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
BarcodeWidget(
|
|
|
|
barcode: Barcode.code128(),
|
|
|
|
data: '2673713263236786',
|
|
|
|
height: 30.h,
|
|
|
|
color: Colors.black,
|
|
|
|
drawText: false,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget shopItem(OrderInfo orderInfo) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.all(16.w),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Text(
|
|
|
|
(orderInfo != null) ? orderInfo.storeName : "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed('/router/union_detail_page',
|
|
|
|
arguments: {"id": orderInfo.storeId});
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
"查看",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Icon(
|
|
|
|
Icons.chevron_right,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
size: 16,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 8.h,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"地址:",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Color(0xff353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"楚河汉街第一街区万达总部国际C座对面",
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Color(0xff353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 4.h,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"营业时间:",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Color(0xff353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Text(
|
|
|
|
(orderInfo.storeVO.openStartTime == null &&
|
|
|
|
orderInfo.storeVO.openEndTime == null)
|
|
|
|
? S.of(context).quantian
|
|
|
|
: "${orderInfo.storeVO.openStartTime.substring(0, orderInfo.storeVO.openStartTime.lastIndexOf(":"))}-${orderInfo.storeVO.openEndTime.substring(0, orderInfo.storeVO.openEndTime.lastIndexOf(":"))}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Color(0xff353535),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Text(
|
|
|
|
"3.9km",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
color: Color(0xff868686),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isRemake = true;
|
|
|
|
|
|
|
|
String totalPrice(orderInfo) {
|
|
|
|
if (orderInfo == null) return "";
|
|
|
|
double totalPrice = (double.tryParse(orderInfo.orderSum) +
|
|
|
|
double.tryParse(orderInfo.postFee));
|
|
|
|
if (orderInfo.orderDetail != null &&
|
|
|
|
orderInfo.orderDetail.couponDTO != null) {
|
|
|
|
totalPrice -= double.tryParse(orderInfo.orderDetail.couponDTO.money);
|
|
|
|
}
|
|
|
|
return "$totalPrice";
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Widget> goodsItem(List<ProductList> products) {
|
|
|
|
if (products == null) return [];
|
|
|
|
if (products.length > 3) {
|
|
|
|
products = products.sublist(0, 3);
|
|
|
|
}
|
|
|
|
return products
|
|
|
|
.map(
|
|
|
|
(e) => Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 2.w),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
e.skuImg,
|
|
|
|
width: 75.w,
|
|
|
|
height: 75.h,
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
errorSrc: "assets/image/default_1.png",
|
|
|
|
fadeSrc: "assets/image/default_1.png",
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 4.h,
|
|
|
|
),
|
|
|
|
if (isRemake)
|
|
|
|
Container(
|
|
|
|
width: 75.w,
|
|
|
|
child: Text(
|
|
|
|
e.productName,
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 10.sp,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
}
|