Browse Source

Merge branch 'master' into dev

# Conflicts:
#	lib/union/union_view/union_coupon.dart
master
w-R 3 years ago
parent
commit
ac96c74f00
  1. 2
      lib/main.dart
  2. 3
      lib/retrofit/data/store_info.dart
  3. 244
      lib/store/store_order.dart
  4. 166
      lib/store/store_view/store_info.dart
  5. 2
      lib/union/union_details_page.dart
  6. 45
      lib/union/union_page.dart
  7. 8
      lib/union/union_view/store_info.dart
  8. 99
      lib/union/union_view/union_coupon.dart

2
lib/main.dart

@ -52,6 +52,7 @@ import 'package:huixiang/setting/help_feedback_page.dart';
import 'package:huixiang/setting/permission_setting_page.dart';
import 'package:huixiang/setting/setting_page.dart';
import 'package:huixiang/setting/treaty_page.dart';
import 'package:huixiang/store/store_order.dart';
import 'package:huixiang/union/location_map_page.dart';
import 'package:huixiang/web/web_page.dart';
@ -277,6 +278,7 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/router/location_map': (context, {arguments}) => LocationMap(arguments: arguments),
'/router/qr_scan': (context, {arguments}) => QrCodeScanPage(),
'/router/qr_share': (context, {arguments}) => QrSharePage(),
'/router/store_order': (context, {arguments}) => StoreOrderPage(arguments: arguments),
// '/router/hot_article_details_page': (context, {arguments}) => HotArticleDetailsPage(),
// '/router/ui_test': (context, {arguments}) => UITest(),
};

3
lib/retrofit/data/store_info.dart

@ -17,6 +17,7 @@ class StoreInfo {
DeliveryInfo deliveryInfo;
String district;
String headMobile;
String tel;
String headName;
String id;
num isAutoSendRefundAddress;
@ -67,6 +68,7 @@ class StoreInfo {
: DeliveryInfo.fromJson(json['deliveryInfo'] as Map<String, dynamic>)
..district = json['district'] as String
..headMobile = json['headMobile'] as String
..tel = json['tel'] as String
..headName = json['headName'] as String
..id = json['id'] as String
..isVip = json['isVip']
@ -115,6 +117,7 @@ class StoreInfo {
'deliveryInfo': this.deliveryInfo.toJson(),
'district': this.district,
'headMobile': this.headMobile,
'tel': this.tel,
'headName': this.headName,
'id': this.id,
'isAutoSendRefundAddress': this.isAutoSendRefundAddress,

244
lib/store/store_order.dart

@ -0,0 +1,244 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
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';
import 'package:huixiang/union/union_view/union_coupon.dart';
import 'package:huixiang/union/union_view/vip.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
class StoreOrderPage extends StatefulWidget {
final Map arguments;
StoreOrderPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _StoreOrderPage();
}
}
class _StoreOrderPage extends State<StoreOrderPage>
with TickerProviderStateMixin/*, AutomaticKeepAliveClientMixin */{
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();
}
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: DefaultTabController(
length: 2,
child: SmartRefresher(
controller: refreshController =
RefreshController(initialRefresh: false),
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
physics: BouncingScrollPhysics(),
onRefresh: () {
queryStoreInfo();
},
child: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
sliver: SliverAppBar(
title: Text(
"百年川椒",
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18.sp,
),
),
expandedHeight: (storeInfo != null && storeInfo.couponVOList != null) ? 425.h : 365.h,
floating: false,
snap: false,
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,
),
),
),
pinned: true,
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: [
///
StoreInfoView(),
///
if (storeInfo != null && storeInfo.couponVOList != null)
UnionCoupon(
storeInfo,
(a) {},
coupon: true,
),
///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),
labelPadding: EdgeInsets.only(left: 8.w, right: 8.w),
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: [
MyTab(text: "点单"),
MyTab(text: "星店活动"),
],
),
),
),
),
),
];
},
body: TabBarView(
physics: BouncingScrollPhysics(),
children: [
Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
),
Container(
color: Colors.white,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
)
],
controller: tabcontroller,
),
),
),
),
),
Container(
height: 50.h,
color: Colors.blue,
),
],
);
}
// @override
// bool get wantKeepAlive => true;
}

166
lib/store/store_view/store_info.dart

@ -0,0 +1,166 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/round_button.dart';
class StoreInfoView extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _StoreInfoView();
}
}
class _StoreInfoView extends State<StoreInfoView> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 5.h,
bottom: 6.h,
),
height: 138.h,
padding: EdgeInsets.all(12.w),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.w),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
offset: Offset(0, 3),
blurRadius: 3,
spreadRadius: 0,
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Row(
children: [
Expanded(
child: Column(
children: [
Container(
alignment: Alignment.centerLeft,
child: Text(
"百年川椒",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 18.sp,
color: Colors.black,
fontWeight: MyFontWeight.medium,
),
),
),
Row(
children: [
Text(
S.of(context).ren("1"),
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
),
SizedBox(
width: 20.w,
),
]..addAll(itemServer("11,22")),
),
Text(
"地址:武昌区楚河汉界第一街区万达总部国际C座对面",
maxLines: 2,
textAlign: TextAlign.justify,
style: TextStyle(
color: Color(0xFF353535),
fontWeight: MyFontWeight.regular,
fontSize: 12.sp,
),
),
],
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
),
),
Image.asset(
"assets/image/icon_vip_name.png",
width: 70.w,
height: 70.w,
)
],
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
),
flex: 1,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Text(
S.of(context).yingyeshijian("10:00-22:00"),
style: TextStyle(
color: Color(0xFF353535),
fontWeight: MyFontWeight.regular,
fontSize: 12.sp,
),
),
),
SizedBox(
width: 16.w,
),
InkWell(
onTap: () {},
child: Image.asset(
"assets/image/icon_union_location.png",
width: 24.w,
height: 24.h,
),
),
SizedBox(
width: 16.w,
),
InkWell(
onTap: () {},
child: Image.asset(
"assets/image/icon_union_call.png",
width: 24,
height: 24,
),
),
],
),
],
),
);
}
List<Widget> itemServer(String businessService) {
if (businessService == null || businessService == "") return [];
var list = businessService.split(",");
return list
.map((e) => Container(
margin: EdgeInsets.only(right: 8.w),
child: RoundButton(
height: 14.h * AppUtils.textScale(context),
text: "$e",
backgroup: Color(0xFFFF7A1A),
padding: EdgeInsets.only(
left: 2.w,
right: 2.w,
),
fontSize: 10.sp,
textColor: Colors.white,
),
))
.toList();
}
}

2
lib/union/union_details_page.dart

@ -339,7 +339,7 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
} else {
print("print 下载失败");
}
Future.delayed(Duration(seconds: 1), () {
Future.delayed(Duration(seconds: 1), (){
EasyLoading.dismiss();
});
}

45
lib/union/union_page.dart

@ -34,8 +34,8 @@ class UnionPage extends StatefulWidget {
class _UnionPage extends State<UnionPage>
with AutomaticKeepAliveClientMixin, WidgetsBindingObserver {
final RefreshController refreshController = RefreshController(initialRefresh: false);
final RefreshController refreshController =
RefreshController(initialRefresh: false);
ApiService apiService;
bool isKeyBoardShow = false;
BMFCoordinate latLng;
@ -44,11 +44,11 @@ class _UnionPage extends State<UnionPage>
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
if (Location.getInstance() != null && Location.getInstance().aMapFlutterLocation != null)
if (Location.getInstance() != null &&
Location.getInstance().aMapFlutterLocation != null)
Location.getInstance().aMapFlutterLocation.stopLocation();
if (refreshController != null)
refreshController.dispose();
if (refreshController != null) refreshController.dispose();
}
@override
@ -88,8 +88,10 @@ class _UnionPage extends State<UnionPage>
startLocation() async {
EasyLoading.show(status: S.current.zhengzaijiazai);
Location.getInstance().aMapFlutterLocation
.onResultCallback().listen((event) {
Location.getInstance()
.aMapFlutterLocation
.onResultCallback()
.listen((event) {
if (event != null &&
event["latitude"] != null &&
event["longitude"] != null) {
@ -108,10 +110,8 @@ class _UnionPage extends State<UnionPage>
this.latLng = value;
saveLatLng(
value, event["province"], event["city"], event["district"]);
print(
"union: Location result ${value.latitude} "
"${value.longitude}",
);
print("union: Location result ${value.latitude} "
"${value.longitude}");
Location.getInstance().stopLocation();
queryStore(
"${value.latitude}",
@ -152,13 +152,16 @@ class _UnionPage extends State<UnionPage>
getLatLng() async {
SharedPreferences.getInstance().then(
(value) => {
apiService = ApiService(Dio(), context: context,
token: value.getString('token'), showLoading: false),
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: false),
if (value.containsKey("latitude") &&
value.containsKey("longitude") &&
value.containsKey("province") &&
value.containsKey("city") &&
value.containsKey("district")) {
value.containsKey("district"))
{
latLng = BMFCoordinate(double.tryParse(value.getString("latitude")),
double.tryParse(value.getString("longitude"))),
queryStore(
@ -265,12 +268,20 @@ class _UnionPage extends State<UnionPage>
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
// Navigator.of(context).pushNamed(
// '/router/union_detail_page',
// arguments: {
// "id": storeList[position].id,
// "storeName": storeList[position].storeName
// });
Navigator.of(context).pushNamed(
'/router/union_detail_page',
'/router/store_order',
arguments: {
"id": storeList[position].id,
"storeName": storeList[position].storeName
});
},
);
},
child: buildStoreItem(storeList[position], position),
);
@ -300,7 +311,7 @@ class _UnionPage extends State<UnionPage>
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
),
],
),
child: TextField(

8
lib/union/union_view/store_info.dart

@ -413,12 +413,12 @@ class _StoreInfos extends State<StoreInfos> {
title: Text(S.of(context).bodadianhua),
actions: [
if (widget.storeInfo != null &&
widget.storeInfo.headMobile != null &&
widget.storeInfo.headMobile != "")
widget.storeInfo.tel != null &&
widget.storeInfo.tel != "")
CupertinoActionSheetAction(
child: Text(widget.storeInfo.headMobile),
child: Text(widget.storeInfo.tel),
onPressed: () {
callMobile(widget.storeInfo.headMobile);
callMobile(widget.storeInfo.tel);
Navigator.of(context).pop();
},
isDefaultAction: true,

99
lib/union/union_view/union_coupon.dart

@ -1,7 +1,3 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
@ -12,55 +8,60 @@ import 'package:huixiang/view_widget/round_button.dart';
import 'package:huixiang/view_widget/separator.dart';
class UnionCoupon extends StatefulWidget {
final StoreInfo storeInfo;
final bool coupon;
final Function(String id) receiveCoupon;
UnionCoupon(this.storeInfo, this.receiveCoupon);
UnionCoupon(this.storeInfo, this.receiveCoupon, {this.coupon = false});
@override
State<StatefulWidget> createState() {
return _UnionCoupon();
}
}
class _UnionCoupon extends State<UnionCoupon> {
@override
Widget build(BuildContext context) {
return Column(
return (widget.coupon != null &&
widget.coupon &&
(widget.storeInfo != null && widget.storeInfo.couponVOList != null))
? buildCoupon()
: Column(
children: [
// Container(
// margin: EdgeInsets.only(top: 10.h, bottom: 10.h),
// child: ItemTitle(
// text: S.of(context).youhuiquan,
// imgPath: "assets/image/icon_union_coupons.png",
// ),
// ),
(widget.storeInfo != null && widget.storeInfo.couponVOList != null)
Container(
margin: EdgeInsets.only(top: 10.h, bottom: 10.h),
child: ItemTitle(
text: S.of(context).youhuiquan,
imgPath: "assets/image/icon_union_coupons.png",
),
),
(widget.storeInfo != null &&
widget.storeInfo.couponVOList != null)
? buildCoupon()
: Container(
width: double.infinity,
height: 0.h,
height: 50.h,
alignment: Alignment.center,
// child: Text(
// S.of(context).zanwuyouhuiquankelingqu,
// style: TextStyle(
// fontSize: 14.sp,
// fontWeight: MyFontWeight.semi_bold,
// color: Color(0xFFA0A0A0),
// ),
// ),
child: Text(
S.of(context).zanwuyouhuiquankelingqu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFA0A0A0),
),
),
),
],
);
}
Widget buildCoupon() {
return Container(
height: 109.h,
child: ListView.builder(
itemCount: (widget.storeInfo != null && widget.storeInfo.couponVOList != null)
itemCount:
(widget.storeInfo != null && widget.storeInfo.couponVOList != null)
? widget.storeInfo.couponVOList.length
: 0,
physics: BouncingScrollPhysics(parent: PageScrollPhysics()),
@ -96,8 +97,8 @@ class _UnionCoupon extends State<UnionCoupon> {
TextSpan(
text: (widget.storeInfo != null &&
widget.storeInfo.couponVOList != null &&
widget.storeInfo
.couponVOList[position].bizType ==
widget.storeInfo.couponVOList[position]
.bizType ==
1)
? "¥"
: "",
@ -110,13 +111,16 @@ class _UnionCoupon extends State<UnionCoupon> {
TextSpan(
text: (widget.storeInfo != null &&
widget.storeInfo.couponVOList != null &&
widget.storeInfo
.couponVOList[position].bizType ==
widget.storeInfo.couponVOList[position]
.bizType ==
1)
? "${double.tryParse(widget.storeInfo.couponVOList[position].discountAmount).toInt()}"
: (widget.storeInfo != null &&
widget.storeInfo.couponVOList != null &&
widget.storeInfo.couponVOList[position]
widget.storeInfo.couponVOList !=
null &&
widget
.storeInfo
.couponVOList[position]
.bizType ==
5)
? S.of(context).duihuanquan
@ -156,8 +160,8 @@ class _UnionCoupon extends State<UnionCoupon> {
Text(
(widget.storeInfo != null &&
widget.storeInfo.couponVOList != null)
? widget.storeInfo
.couponVOList[position].couponName
? widget.storeInfo.couponVOList[position]
.couponName
: "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
@ -174,15 +178,18 @@ class _UnionCoupon extends State<UnionCoupon> {
.bizType ==
1
? S.of(context).manlijiandaijinquan(
double.tryParse(widget.storeInfo
double.tryParse(widget
.storeInfo
.couponVOList[position]
.fullAmount)
.toInt(),
double.tryParse(widget.storeInfo
double.tryParse(widget
.storeInfo
.couponVOList[position]
.discountAmount)
.toInt())
: S.of(context).quanchangzhe(widget.storeInfo
: S.of(context).quanchangzhe(widget
.storeInfo
.couponVOList[position]
.discountPercent))
: "",
@ -199,7 +206,9 @@ class _UnionCoupon extends State<UnionCoupon> {
widget.storeInfo.couponVOList !=
null &&
// widget.storeInfo.couponVOList[position].useStartTime != null &&
widget.storeInfo.couponVOList[position]
widget
.storeInfo
.couponVOList[position]
.useEndTime !=
null)
// ? "${widget.storeInfo.couponVOList[position].useStartTime.replaceAll("-", ".").split(" ")[0]}-${widget.storeInfo.couponVOList[position].useEndTime.replaceAll("-", ".").split(" ")[0]}"
@ -221,7 +230,9 @@ class _UnionCoupon extends State<UnionCoupon> {
onTap: () {
if (widget.storeInfo != null &&
widget.storeInfo.couponVOList != null &&
widget.storeInfo.couponVOList[position].status == 0) {
widget.storeInfo.couponVOList[position]
.status ==
0) {
widget.receiveCoupon(
widget.storeInfo.couponVOList[position].id);
}
@ -231,14 +242,16 @@ class _UnionCoupon extends State<UnionCoupon> {
child: RoundButton(
text: (widget.storeInfo != null &&
widget.storeInfo.couponVOList != null &&
widget.storeInfo.couponVOList[position].status >
widget.storeInfo.couponVOList[position]
.status >
0)
? S.of(context).yilingqu
: S.of(context).lingqu,
textColor: Colors.white,
backgroup: (widget.storeInfo != null &&
widget.storeInfo.couponVOList != null &&
widget.storeInfo.couponVOList[position].status >
widget.storeInfo.couponVOList[position]
.status >
0)
? Colors.grey
: Color(0xFF32A060),
@ -259,6 +272,4 @@ class _UnionCoupon extends State<UnionCoupon> {
),
);
}
}
Loading…
Cancel
Save