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.

345 lines
13 KiB

3 years ago
import 'package:dio/dio.dart';
3 years ago
import 'package:flutter/cupertino.dart';
3 years ago
import 'package:flutter/gestures.dart';
3 years ago
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
3 years ago
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity.dart';
3 years ago
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/store/store_view/store_info.dart';
3 years ago
import 'package:huixiang/store/store_view/store_order_page.dart';
3 years ago
import 'package:huixiang/union/union_view/union_coupon.dart';
import 'package:huixiang/union/union_view/vip.dart';
3 years ago
import 'package:huixiang/utils/font_weight.dart';
3 years ago
import 'package:huixiang/view_widget/classic_header.dart';
3 years ago
import 'package:huixiang/view_widget/custom_image.dart';
3 years ago
import 'package:huixiang/view_widget/my_tab.dart';
3 years ago
import 'package:huixiang/view_widget/round_button.dart';
3 years ago
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
class StoreOrderPage extends StatefulWidget {
final Map arguments;
3 years ago
final List<Activity> activitys;
final StoreInfo storeInfo;
3 years ago
3 years ago
StoreOrderPage({this.arguments, this.activitys, this.storeInfo});
3 years ago
@override
State<StatefulWidget> createState() {
return _StoreOrderPage();
}
}
class _StoreOrderPage extends State<StoreOrderPage>
3 years ago
with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin */ {
3 years ago
TabController tabcontroller;
ApiService apiService;
StoreInfo storeInfo;
RefreshController refreshController;
@override
void initState() {
super.initState();
queryStoreInfo();
}
queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString('token'),
);
BaseData baseData = await apiService
.queryStoreInfo(widget.arguments["id"])
.catchError((error) {
refreshController.refreshFailed();
});
if (baseData != null && baseData.isSuccess) {
refreshController.refreshCompleted();
storeInfo = StoreInfo.fromJson(baseData.data);
if (mounted) {
setState(() {});
}
} else {
refreshController.refreshFailed();
}
}
3 years ago
ScrollController controller = ScrollController();
3 years ago
@override
Widget build(BuildContext context) {
3 years ago
return Stack(
3 years ago
children: [
Expanded(
child: DefaultTabController(
length: 2,
child: SmartRefresher(
3 years ago
controller: refreshController =
RefreshController(initialRefresh: false),
3 years ago
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
physics: BouncingScrollPhysics(),
onRefresh: () {
3 years ago
queryStoreInfo();
3 years ago
},
child: NestedScrollView(
3 years ago
controller: controller,
dragStartBehavior: DragStartBehavior.start,
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
3 years ago
return [
SliverOverlapAbsorber(
3 years ago
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
3 years ago
sliver: SliverAppBar(
3 years ago
title: Text(
3 years ago
widget.storeInfo != null
? widget.storeInfo.storeName
: "",
3 years ago
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18.sp,
),
),
3 years ago
expandedHeight: (storeInfo != null &&
storeInfo.couponVOList != null)
? 425.h
: 365.h,
3 years ago
floating: false,
snap: false,
3 years ago
pinned: true,
3 years ago
leading: GestureDetector(
onTap: () {
Navigator.of(context).pop();
},
child: Container(
alignment: Alignment.centerRight,
margin: EdgeInsets.only(left: 10),
padding: EdgeInsets.all(6),
child: Icon(
Icons.arrow_back_ios,
color: Colors.black,
size: 24,
),
),
),
3 years ago
flexibleSpace: FlexibleSpaceBar(
background: Stack(
children: [
Positioned(
child: Column(
children: [
Image.asset(
"assets/image/share_image_bg.png",
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width,
height: 180.h,
),
Expanded(
child: Container(
color: Colors.transparent,
),
flex: 1,
),
],
),
top: 0,
bottom: 0,
left: 0,
right: 0,
),
Positioned(
child: Container(
child: Column(
children: [
///门店信息
3 years ago
StoreInfoView(storeInfo),
3 years ago
///门店对应优惠券
3 years ago
if (storeInfo != null &&
storeInfo.couponVOList != null)
3 years ago
UnionCoupon(
storeInfo,
3 years ago
(a) {},
3 years ago
coupon: true,
),
3 years ago
SizedBox(
height: 8,
),
3 years ago
///门店对应VIP信息
Vip(storeInfo, () {}, false),
],
),
),
top: 110.h,
bottom: 0,
left: 0,
right: 0,
),
],
),
collapseMode: CollapseMode.pin,
),
backgroundColor: Color(0xFFFAFAFA),
centerTitle: false,
elevation: 0,
bottom: PreferredSize(
preferredSize: Size(
MediaQuery.of(context).size.width,
38.h,
),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
width: MediaQuery.of(context).size.width,
child: TabBar(
controller: tabcontroller = TabController(
length: 2,
vsync: this,
),
automaticIndicatorColorAdjustment: true,
isScrollable: true,
indicatorWeight: 1,
indicatorColor: Color(0xFFFAFAFA),
3 years ago
labelPadding:
EdgeInsets.only(left: 8.w, right: 8.w),
3 years ago
indicatorSize: TabBarIndicatorSize.label,
unselectedLabelStyle: TextStyle(
fontSize: 15.sp,
fontWeight: FontWeight.w400,
),
labelStyle: TextStyle(
color: Colors.black,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
labelColor: Colors.black,
tabs: [
3 years ago
MyTab(text: S.current.diancan),
MyTab(text: S.current.xindianhuodong),
3 years ago
],
),
),
),
),
),
];
},
body: TabBarView(
physics: BouncingScrollPhysics(),
children: [
3 years ago
StoreOrderListPage(widget.arguments, widget.activitys, storeInfo, controller),
3 years ago
Container(
3 years ago
color: Colors.black,
3 years ago
width: MediaQuery.of(context).size.width,
3 years ago
),
3 years ago
],
controller: tabcontroller,
),
),
),
),
),
3 years ago
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Stack(
alignment: Alignment.bottomLeft,
children: [
Container(
height: 54.h,
color: Color(0xFFFAFAFA),
child: Row(
children: [
Spacer(),
Text(
S.of(context).heji,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
Text(
"¥19.00",
style: TextStyle(
fontSize: 20.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF32A060),
),
),
Spacer(),
GestureDetector(
3 years ago
onTap: () {
3 years ago
Navigator.of(context).pushNamed(
'/router/settlement',
3 years ago
arguments: {},
3 years ago
);
},
3 years ago
child: RoundButton(
3 years ago
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
),
),
],
),
),
3 years ago
Stack(
children: [
3 years ago
InkWell(
3 years ago
onTap: () {
setState(() {
3 years ago
// showShoppingCart();
3 years ago
});
},
child: Image.asset(
3 years ago
"assets/image/icon_shop.png",
3 years ago
width: 88,
height: 88,
3 years ago
fit: BoxFit.fitWidth,
3 years ago
),
),
Positioned(
right: 15,
top: 14,
child: RoundButton(
width: 17,
height: 17,
text: "1",
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
fontSize: 12.sp,
radius: 100,
// padding: EdgeInsets.symmetric(vertical: 5.h),
),
)
],
),
3 years ago
],
),
)
3 years ago
],
);
}
3 years ago
// @override
// bool get wantKeepAlive => true;
3 years ago
}