Browse Source

safety

master
fmk 3 years ago
parent
commit
5ea6c2d462
  1. 1128
      lib/settlement/settlement.dart
  2. 165
      lib/settlement/settlement_view/activity.dart
  3. 173
      lib/settlement/settlement_view/activity_coupon_remarks.dart
  4. 268
      lib/settlement/settlement_view/coupon.dart
  5. 357
      lib/settlement/settlement_view/distribution.dart
  6. 150
      lib/settlement/settlement_view/edit_phone.dart
  7. 156
      lib/settlement/settlement_view/pay_method.dart
  8. 174
      lib/settlement/settlement_view/settlement_activity.dart
  9. 166
      lib/settlement/settlement_view/settlement_coupon.dart
  10. 51
      lib/settlement/settlement_view/settlement_order_commodity.dart
  11. 24
      lib/store/store_order.dart
  12. 14
      lib/utils/flutter_utils.dart
  13. 52
      lib/utils/location.dart

1128
lib/settlement/settlement.dart

File diff suppressed because it is too large Load Diff

165
lib/settlement/settlement_view/activity.dart

@ -0,0 +1,165 @@
import 'package:flutter/material.dart';
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/icon_text.dart';
import 'package:huixiang/view_widget/round_button.dart';
class ActivityWidget extends StatefulWidget {
final PromotionInfoListBean promotionInfoListBean;
final StoreInfo storeInfo;
final int index;
final Function() callback;
ActivityWidget(this.promotionInfoListBean, this.storeInfo, this.index, { this.callback, });
@override
State<StatefulWidget> createState() {
return _ActivityWidget();
}
}
class _ActivityWidget extends State<ActivityWidget> {
@override
Widget build(BuildContext context) {
return Container(
height: 177,
width: double.infinity,
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: Column(
children: [
Expanded(
child: Row(
children: [
MImage(
widget.promotionInfoListBean != null
? widget.promotionInfoListBean.image
: "",
fit: BoxFit.cover,
aspectRatio: 1,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
),
SizedBox(
width: 12.w,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.promotionInfoListBean != null
? (widget.promotionInfoListBean.name ?? "")
: "",
style: TextStyle(
fontWeight: MyFontWeight.medium,
fontSize: 14.sp,
color: Colors.black,
),
),
Text(
widget.promotionInfoListBean != null
? (widget.promotionInfoListBean.description ?? "")
: "",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF727272),
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
),
),
SizedBox(
height: 8.w,
),
IconText(
"全场通用",
leftIcon: Icons.circle,
iconColor: Color(0xFF32A060),
iconSize: 6,
textStyle: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF181818),
),
),
IconText(
widget.promotionInfoListBean != null
? ("${widget.promotionInfoListBean.activityStartTime.split(" ")[0].replaceAll("-", ".")}-${widget.promotionInfoListBean.activityEndTime.split(" ")[0].replaceAll("-", ".")}")
: "",
leftIcon: Icons.circle,
iconColor: Color(0xFF32A060),
iconSize: 6,
textStyle: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF181818),
),
),
],
),
),
],
),
flex: 1,
),
SizedBox(
height: 12.w,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"*优惠券与活动不可同时选择",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFACACAC),
),
),
if (widget.promotionInfoListBean != null &&
widget.promotionInfoListBean.canPartake)
RoundButton(
text: "选择活动",
textColor: Colors.white,
padding: EdgeInsets.symmetric(
vertical: 4,
horizontal: 8,
),
backgroup: Color(0xFF32A060),
radius: 12,
callback: widget.callback,
)
else
Text(
"条件未达",
style: TextStyle(
color: Color(0xFF868686),
fontWeight: MyFontWeight.medium,
fontSize: 12.sp,
),
),
],
),
],
),
);
}
}

173
lib/settlement/settlement_view/activity_coupon_remarks.dart

@ -0,0 +1,173 @@
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ActivityCouponRemarks extends StatefulWidget {
final Function() couponCart;
final Function() activityCart;
final CouponListBean couponListBean;
final PromotionInfoListBean promotion;
final int couponCount;
ActivityCouponRemarks(
this.couponCart,
this.activityCart,
this.couponListBean,
this.promotion,
this.couponCount,
);
@override
State<StatefulWidget> createState() {
return _ActivityCouponRemarks();
}
}
class _ActivityCouponRemarks extends State<ActivityCouponRemarks> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
height: 122.h,
margin: EdgeInsets.only(
left: 16,
right: 16,
top: 15,
),
padding: EdgeInsets.only(
left: 16,
right: 16,
top: 14,
bottom: 14,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onTap: () {
widget.activityCart();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
S.of(context).huodong,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Text(
widget.promotion == null ? "*优惠券与活动不可同时选择" : widget.promotion.name,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
SizedBox(
height: 13,
),
InkWell(
onTap: () {
widget.couponCart();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
S.of(context).youhuiquan,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Text(
(widget.couponListBean == null)
? ("未使用优惠券")
: widget.couponListBean.promotionName,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
),
SizedBox(
height: 13,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: Text(
S.of(context).beizhu,
style: TextStyle(
fontWeight: MyFontWeight.regular,
fontSize: 14.sp,
color: Color(0xFF353535),
),
),
),
Text(
"口味、面包硬度等",
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF353535),
fontWeight: MyFontWeight.semi_bold,
),
),
Icon(
Icons.keyboard_arrow_right,
size: 16,
),
],
),
],
),
);
}
}

268
lib/settlement/settlement_view/coupon.dart

@ -0,0 +1,268 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/separator.dart';
class CouponWidget extends StatefulWidget {
final CouponListBean couponList;
final StoreInfo storeInfo;
final bool selected;
CouponWidget(
this.couponList,
this.storeInfo, {
this.selected = false,
});
@override
State<StatefulWidget> createState() {
return _CouponWidget();
}
}
class _CouponWidget extends State<CouponWidget> {
@override
Widget build(BuildContext context) {
return Container(
height: 170,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(top: 14.h, bottom: 8.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Text(
"¥",
style: TextStyle(
fontSize: 22.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xff32A060),
),
),
SizedBox(
height: 4.h,
),
Text(
"${double.tryParse(widget.couponList.discountAmount).toInt()}",
style: TextStyle(
fontSize: 40.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xff32A060),
),
),
],
),
),
Text(
S
.of(context)
.manyuankeyong(widget.couponList.fullAmount),
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xff32A060),
),
),
],
),
flex: 1,
),
Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
border: Border.all(
width: 1,
color: Color(0xFFFF7A1A),
style: BorderStyle.solid,
),
),
child: Text(
S.of(context).shangjiaquan,
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFFFF7A1A),
),
),
),
SizedBox(
width: 8.w,
),
Expanded(
child: Text(
widget.storeInfo.storeName,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xff353535),
),
),
flex: 1,
),
],
),
Text(
widget.couponList.promotionName,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff727272),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
S.of(context).quanchangtongyong,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
),
),
if (widget.couponList.usable)
Container(
margin: EdgeInsets.only(right: 23.w),
child: GestureDetector(
onTap: () {
Navigator.of(context).pop(widget.couponList);
},
child: Image.asset(
widget.selected
? "assets/image/icon_radio_unselected.png"
: "assets/image/icon_radio_selected.png",
width: 24,
height: 24,
),
),
),
],
),
],
),
),
],
),
),
flex: (widget.couponList?.isEx ?? false) ? 97 : 97,
),
Container(
padding: EdgeInsets.symmetric(horizontal: 23.w),
child: MySeparator(
width: 5.w,
height: 1.h,
color: Color(0xFF353535),
),
),
Expanded(
flex: (widget.couponList?.isEx ?? false) ? 56 : 42,
child: Container(
margin: EdgeInsets.symmetric(
horizontal: 23.w,
vertical: 8.h,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
S.of(context).xiangqing,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10.sp,
),
),
GestureDetector(
child: Icon(
(!(widget.couponList?.isEx ?? false))
? Icons.keyboard_arrow_down
: Icons.keyboard_arrow_up,
color: Colors.black,
size: 18,
), //
onTap: () {
setState(() {
widget.couponList.isEx =
!(widget.couponList.isEx ?? false);
});
},
),
],
),
if (widget.couponList?.isEx ?? false)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
S.of(context).shiyongriqi,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10.sp,
),
),
Text(
(widget.couponList.useStartTime == null &&
widget.couponList.useEndTime == null)
? S.of(context).quantian
: "${widget.couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${widget.couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10.sp,
),
),
],
),
],
),
),
),
],
),
);
}
}

357
lib/settlement/settlement_view/distribution.dart

@ -0,0 +1,357 @@
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/address.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/utils/location.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class DistributionMode extends StatefulWidget {
final Function(
String addressId,
int isTake,
String memberCouponId,
int orderId,
String promotionId,
) queryOrderInfo;
final Function(int selectedBtn) queryAddress;
final StoreInfo storeInfo;
final Address address;
DistributionMode(
this.queryOrderInfo, this.queryAddress, this.storeInfo, this.address);
@override
State<StatefulWidget> createState() {
return _DistributionMode();
}
}
class _DistributionMode extends State<DistributionMode> {
List<String> addressBgs = [
"assets/svg/dingdan_ziqu.svg",
"assets/svg/dingdan_waimai.svg",
"assets/svg/dingdan_wuliu.svg",
];
BMFCoordinate myLatLng;
String distance = "0";
int selectedBtn = 0;
@override
void initState() {
super.initState();
startLocation();
}
///
void startLocation() async {
Location.getInstance()
.aMapFlutterLocation
.onResultCallback()
.listen((event) {
if (event != null &&
event["latitude"] != null &&
event["longitude"] != null) {
print("location: $event");
if (event["latitude"] is String && event["longitude"] is String) {
myLatLng = BMFCoordinate(double.tryParse(event["latitude"]),
double.tryParse(event["longitude"]));
} else {
myLatLng = BMFCoordinate(event["latitude"], event["longitude"]);
}
calculate();
Location.getInstance().stopLocation();
}
});
Location.getInstance().prepareLoc();
Location.getInstance().startLocation(context);
}
calculate() async {
BMFCoordinate bmfCoordinate = BMFCoordinate(
double.tryParse(widget.storeInfo.latitude),
double.tryParse(widget.storeInfo.longitude),
);
distance = await AppUtils.calculateDistance(bmfCoordinate, myLatLng);
setState(() {});
}
@override
Widget build(BuildContext context) {
return Container(
height: 143.h,
margin: EdgeInsets.only(
left: 16,
right: 16,
top: 10,
),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
color: Color(0x80FFFFFF),
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
child: SvgPicture.asset(
addressBgs[selectedBtn],
width: double.infinity,
height: double.infinity,
fit: BoxFit.fill,
),
),
Column(
children: [
Container(
height: 50.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
selectedBtn = 0;
widget.queryOrderInfo(
null, selectedBtn, null, 0, null);
},
child: Container(
height: 50.h,
alignment: Alignment.center,
child: Text(
S.of(context).daodianziqu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
),
),
),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
selectedBtn = 1;
widget.queryAddress(selectedBtn);
},
child: Container(
height: 50.h,
alignment: Alignment.center,
child: Text(
S.of(context).waimaipeisong,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
),
),
),
Expanded(
flex: 1,
child: GestureDetector(
onTap: () {
SmartDialog.showToast("该功能暂未开放!",
alignment: Alignment.center);
},
child: Container(
height: 50.h,
alignment: Alignment.center,
child: Text(
S.of(context).kuaidiwuliu,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),
),
),
),
],
),
),
selectedBtn == 0
? Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16, right: 16, top: 15),
child: Column(
children: [
Row(
children: [
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
Text(
widget.storeInfo != null
? (widget.storeInfo.storeName ?? "")
: "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
height: 6,
),
Text(
widget.storeInfo != null
? widget.storeInfo.address
: "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
),
],
),
),
SizedBox(
width: 18,
),
Stack(
alignment: Alignment.center,
children: [
Column(
children: [
Image.asset(
"assets/image/map.png",
height: 61.h,
width: 61.w,
),
],
),
Column(
children: [
RoundButton(
width: 41.w,
height: 13,
text: distance.length > 3
? "${distance}km"
: "距离您${distance}km",
textColor: Color(0xFF34A262),
fontWeight: MyFontWeight.semi_bold,
radius: 7.5,
backgroup: Colors.white,
fontSize: 7.sp,
),
Image.asset(
"assets/image/landmark.png",
height: 24.h,
width: 24.w,
),
],
),
],
),
],
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
),
],
),
)
: Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16, right: 16, top: 15),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/icon_permission_location.png",
height: 24.h,
width: 24.w,
),
Text(
"张先生",
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
width: 13,
),
Expanded(
child: Text(
"12309090909",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
),
),
InkWell(
onTap: () {
setState(() {
Navigator.of(context).popAndPushNamed(
'/router/manage_address_page');
});
},
child: Icon(
Icons.keyboard_arrow_right,
size: 24,
),
),
],
),
Padding(
padding: EdgeInsets.only(top: 4, left: 25),
child: Text(
"武昌区中国铁建凯德1818蓝调步行街中北路109附33门牌号05",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF727272),
),
),
),
],
),
),
],
),
],
),
);
}
}

150
lib/settlement/settlement_view/edit_phone.dart

@ -0,0 +1,150 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/utils/flutter_utils.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class EditPhoneWidget extends StatefulWidget {
final StoreInfo storeInfo;
final Function(String headMobile) mobileChange;
EditPhoneWidget(this.storeInfo, this.mobileChange);
@override
State<StatefulWidget> createState() {
return _EditPhoneWidget();
}
}
class _EditPhoneWidget extends State<EditPhoneWidget> {
bool isEdit = false;
TextEditingController _vc;
@override
void initState() {
// TODO: implement initState
super.initState();
_vc = TextEditingController(
text: widget.storeInfo != null ? widget.storeInfo.headMobile : "");
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(
left: 16,
right: 16,
),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0x0D000000),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8),
),
padding: EdgeInsets.symmetric(
horizontal: 12.w,
vertical: 15.h,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
S.of(context).yuliudianhua,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4C4C4C),
),
),
SizedBox(
width: 50,
),
Expanded(
child: isEdit
? Container(
height: 25.h,
alignment: Alignment.centerRight,
child: TextField(
controller: _vc,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF4C4C4C),
),
textAlign: TextAlign.right,
textAlignVertical: TextAlignVertical.center,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
errorBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
hintText: "",
hintStyle: TextStyle(
fontSize: 10.sp,
color: Color(0xFFA29E9E),
),
),
textInputAction: TextInputAction.next,
inputFormatters: [LengthLimitingTextInputFormatter(11)],
cursorColor: Colors.grey,
),
)
: Container(
height: 25.h,
alignment: Alignment.centerRight,
child: Text(
widget.storeInfo != null
? widget.storeInfo.headMobile
: "",
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF4C4C4C),
),
),
),
),
GestureDetector(
onTap: () {
String mobile = _vc.text;
if (mobile != null && AppUtils.isPhone(mobile)) {
widget.mobileChange(mobile);
widget.storeInfo.headMobile = mobile;
}
setState(() {
this.isEdit = !this.isEdit;
});
},
child: Container(
padding: EdgeInsets.all(8),
child: isEdit
? Icon(
Icons.check,
size: 14.w,
color: Color(0xFF32A060),
)
: Image.asset(
"assets/image/pen.png",
height: 14.h,
width: 14.w,
),
),
),
],
),
);
}
}

156
lib/settlement/settlement_view/pay_method.dart

@ -0,0 +1,156 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/utils/font_weight.dart';
class PayMethod extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _PayMethod();
}
}
class _PayMethod extends State<PayMethod> {
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
margin: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 12.h,
bottom: 4.h,
),
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 20.h,
bottom: 20.h,
),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Color(0x000000).withAlpha(25),
offset: Offset(0, 1),
blurRadius: 12.0,
),
],
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: Text(
S.of(context).zhifufangshi,
style: TextStyle(
fontSize: 16.sp,
color: Colors.black,
fontWeight: MyFontWeight.regular,
),
),
),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 1;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(1),
Text(
S.of(context).pingtaiyue,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,),
),
],
),
),
SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 2;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(2),
Text(
S.of(context).dianpuyue,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
),
SizedBox(
height: 10,
),
GestureDetector(
onTap: () {
setState(() {
checkIndex = 3;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
checkView(3),
Spacer(),
Image.asset("assets/image/icon_we_chat.png"),
Padding(
padding: EdgeInsets.only(left: 8.w),
child: Text(
S.of(context).weixinzhifu,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xff353535),
fontWeight: MyFontWeight.semi_bold,
),
),
),
],
),
),
],
),
);
}
var checkIndex = 1;
Widget checkView(var index) {
return Container(
padding: EdgeInsets.only(right: 16.w),
alignment: Alignment.center,
child: Image.asset(
checkIndex != index
? "assets/image/icon_radio_unselected.png"
: "assets/image/icon_radio_selected.png",
width: 15.w,
height: 15.h,
),
);
}
}

174
lib/settlement/settlement_view/settlement_activity.dart

@ -0,0 +1,174 @@
import 'package:flutter/material.dart';
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/settlement/settlement_view/activity.dart';
import 'package:huixiang/settlement/settlement_view/coupon.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class SettlementActivity extends StatefulWidget {
final StoreInfo storeInfo;
final SettleOrderInfo settleOrderInfo;
SettlementActivity(this.settleOrderInfo, this.storeInfo);
@override
State<StatefulWidget> createState() {
return _SettlementActivity();
}
}
class _SettlementActivity extends State<SettlementActivity> {
List<PromotionInfoListBean> promotionInfoCan = [];
List<PromotionInfoListBean> promotionInfoNo = [];
@override
void initState() {
super.initState();
promotionInfoCan.clear();
promotionInfoNo.clear();
if (widget.settleOrderInfo != null &&
widget.settleOrderInfo.promotionInfoList != null &&
widget.settleOrderInfo.promotionInfoList.length > 0) {
widget.settleOrderInfo.promotionInfoList.forEach((element) {
if (element.canPartake) {
promotionInfoCan.add(element);
} else {
promotionInfoNo.add(element);
}
});
setState(() {});
}
}
@override
Widget build(BuildContext context) {
return StatefulBuilder(
builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
width: double.infinity,
height: MediaQuery.of(context).size.height / 3 * 2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
"可参加的活动(${promotionInfoCan.length})",
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Image.asset(
"assets/image/cancel.png",
width: 24,
height: 24,
),
),
],
),
),
Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
),
child: ListView.builder(
itemCount: (promotionInfoCan == null ||
promotionInfoCan.length == 0)
? 0
: promotionInfoCan.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return ActivityWidget(
promotionInfoCan[position],
widget.storeInfo,
position,
callback: (){
Navigator.of(context).pop(promotionInfoCan[position]);
},
);
},
),
),
if (promotionInfoNo != null || promotionInfoNo.length > 0)
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Text(
"不可参加的活动",
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
if (promotionInfoNo != null || promotionInfoNo.length > 0)
Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
),
child: ListView.builder(
itemCount: (promotionInfoNo == null ||
promotionInfoNo.length == 0)
? 0
: promotionInfoNo.length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return ActivityWidget(
promotionInfoNo[position],
widget.storeInfo,
position,
);
},
),
),
],
),
),
);
},
);
}
}

166
lib/settlement/settlement_view/settlement_coupon.dart

@ -0,0 +1,166 @@
import 'package:flutter/material.dart';
import 'package:huixiang/retrofit/data/settleOrderInfo.dart';
import 'package:huixiang/retrofit/data/store_info.dart';
import 'package:huixiang/settlement/settlement_view/coupon.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class SettlementCoupon extends StatefulWidget {
final StoreInfo storeInfo;
final SettleOrderInfo settleOrderInfo;
final CouponListBean couponBean;
SettlementCoupon(
this.settleOrderInfo,
this.storeInfo, {
this.couponBean,
});
@override
State<StatefulWidget> createState() {
return _SettlementCoupon();
}
}
class _SettlementCoupon extends State<SettlementCoupon> {
List<CouponListBean> couponCan = [];
List<CouponListBean> couponNo = [];
@override
void initState() {
super.initState();
couponCan.clear();
couponNo.clear();
if (widget.settleOrderInfo != null &&
widget.settleOrderInfo.couponList != null &&
widget.settleOrderInfo.couponList.length > 0) {
widget.settleOrderInfo.couponList.forEach((element) {
if (element.usable) {
couponCan.add(element);
} else {
couponNo.add(element);
}
});
setState(() {});
}
}
@override
Widget build(BuildContext context) {
return StatefulBuilder(
builder: (context1, state) {
return Container(
alignment: Alignment.topCenter,
width: double.infinity,
height: MediaQuery.of(context).size.height / 3 * 2,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
"可用优惠券(${couponCan.length})",
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
InkWell(
onTap: () {
Navigator.of(context).pop();
},
child: Image.asset(
"assets/image/cancel.png",
width: 24,
height: 24,
),
),
],
),
),
Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
),
child: ListView.builder(
itemCount: couponCan == null ? 0 : couponCan.length,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return CouponWidget(
couponCan[position],
widget.storeInfo,
selected: widget.couponBean == couponCan[position],
);
},
),
),
if (couponNo != null || couponNo.length > 0)
Container(
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 8,
),
child: Text(
"不可用优惠券",
style: TextStyle(
color: Color(0xFF000000),
fontSize: 14.sp,
fontWeight: MyFontWeight.medium,
),
),
),
if (couponNo != null || couponNo.length > 0)
Container(
padding: EdgeInsets.only(
top: 8,
left: 16,
right: 16,
),
child: ListView.builder(
itemCount: couponNo == null ? 0 : couponNo.length,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return CouponWidget(
couponNo[position],
widget.storeInfo,
);
},
),
),
],
),
),
);
},
);
}
}

51
lib/settlement/settlement_view/settlement_order_commodity.dart

@ -12,7 +12,7 @@ class SettlementOrderCommodity extends StatefulWidget {
final SettleOrderInfo settleOrderInfo;
SettlementOrderCommodity(this.isTakeOut,this.settleOrderInfo);
SettlementOrderCommodity(this.isTakeOut, this.settleOrderInfo);
@override
State<StatefulWidget> createState() {
@ -68,8 +68,9 @@ class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
if (widget.settleOrderInfo == null) return [];
List<Widget> widgets = [];
if (widget.settleOrderInfo != null) {
widgets.addAll(
widget.settleOrderInfo.orderProductList.map((e) => commodityItem(e)).toList());
widgets.addAll(widget.settleOrderInfo.orderProductList
.map((e) => commodityItem(e))
.toList());
}
widgets.add(SizedBox(height: 20.h));
@ -81,8 +82,7 @@ class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
? S.of(context).peisongfei
: S.of(context).yunfei,
"",
"+${widget.settleOrderInfo?.postAge??"0"}"
));
"+${widget.settleOrderInfo?.postAge ?? "0"}"));
}
widgets.add(Container(
@ -101,7 +101,6 @@ class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
}
Widget commodityItem(OrderProductListBean productList) {
return Container(
margin: EdgeInsets.only(top: 8.h, bottom: 8.h),
child: Row(
@ -153,8 +152,8 @@ class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
Expanded(
flex: 1,
child: Text(
productList.weight != null
? "${productList.weight}kg"
productList.skuNameStr != null
? "${productList.skuNameStr ?? ""}"
: "",
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -315,19 +314,34 @@ class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
? widget.settleOrderInfo.orderProductList.length
: "0"),
style: TextStyle(
fontSize: 10.sp,
color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.semi_bold),
fontSize: 10.sp,
color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.semi_bold,
),
),
flex: 1,
),
Container(
child: Text(
"已优惠:¥${widget.settleOrderInfo.discountAmount}",
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF7B7B7B),
fontWeight: MyFontWeight.medium,
),
),
),
SizedBox(
width: 15.w,
),
Container(
child: Text(
S.of(context).jiesuanjine,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF353535),
fontWeight: MyFontWeight.semi_bold),
fontSize: 12.sp,
color: Color(0xFF353535),
fontWeight: MyFontWeight.semi_bold,
),
),
),
SizedBox(
@ -337,10 +351,11 @@ class _SettlementOrderCommodity extends State<SettlementOrderCommodity> {
totalPrice(),
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold),
)
fontSize: 14.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.semi_bold,
),
),
],
),
);

24
lib/store/store_order.dart

@ -25,6 +25,7 @@ import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import 'package:huixiang/view_widget/receive_success.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -239,7 +240,7 @@ class _StoreOrderPage extends State<StoreOrderPage>
storeInfo.couponVOList != null)
UnionCoupon(
storeInfo,
(a) {},
_receiveCoupon,
coupon: true,
),
@ -315,7 +316,6 @@ class _StoreOrderPage extends State<StoreOrderPage>
shopCarGoods,
controller,
_queryMiNiDetail,
// _productListResult,
_fc,
),
@ -416,6 +416,26 @@ class _StoreOrderPage extends State<StoreOrderPage>
);
}
///
_receiveCoupon(couponId) async {
BaseData baseData = await apiService.receiveCoupon(couponId);
if (baseData != null && baseData.isSuccess) {
queryStoreInfo();
showAlertDialog();
}
}
///
showAlertDialog() {
//
showDialog(
context: context,
builder: (BuildContext context) {
return ReceiveSuccess();
},
);
}
///
int count() {
if (shopCarGoods == null ||

14
lib/utils/flutter_utils.dart

@ -8,6 +8,14 @@ import 'package:path_provider/path_provider.dart';
class AppUtils {
///线
static Future<String> calculateDistance(BMFCoordinate bmfCoordinate, BMFCoordinate myLatLng) async {
double mi = await BMFCalculateUtils.getLocationDistance(bmfCoordinate, myLatLng);
NumberFormat numberFormat = NumberFormat("#.#");
return "${numberFormat.format(mi / 1000)}";
}
static Future<BMFCoordinate> coordConvert(BMFCoordinate latLng) async {
return BMFCalculateUtils.coordConvert(
coordinate: latLng,
@ -15,6 +23,12 @@ class AppUtils {
toType: BMF_COORD_TYPE.COMMON);
}
static bool isPhone(mobile) {
RegExp exp = RegExp(
r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$');
return exp.hasMatch(mobile);
}
static double textScale(context) {
double textScaleFactor = MediaQuery.of(context).textScaleFactor;
// print("textScaleFactor: $textScaleFactor");

52
lib/utils/location.dart

@ -1,6 +1,3 @@
import 'dart:io';
import 'package:android_intent_plus/android_intent.dart';
@ -11,7 +8,6 @@ import 'package:huixiang/view_widget/request_permission.dart';
import 'package:permission_handler/permission_handler.dart';
class Location {
static Location _instance;
Location._internal() {
@ -74,8 +70,7 @@ class Location {
}
void stopLocation() {
if (aMapFlutterLocation != null)
aMapFlutterLocation.stopLocation();
if (aMapFlutterLocation != null) aMapFlutterLocation.stopLocation();
}
enableLocation(context) {
@ -87,8 +82,8 @@ class Location {
S.of(context).nindingweigongnengweikaiqi,
S.of(context).weilexiangnintuijianfujindemendianxinxi,
S.of(context).dakaidingwei,
(result) async {
if(result) {
(result) async {
if (result) {
final AndroidIntent intent = AndroidIntent(
action: 'action_location_source_settings',
package: "com.zsw.huixiang");
@ -104,29 +99,24 @@ class Location {
requestDialog(context) {
showCupertinoDialog(
context: context,
builder: (context) {
return RequestPermission(
"assets/image/icon_permission_location_bg.png",
S.of(context).nindingweiquanxianweiyunxu,
S.of(context).weilexiangnintuijianfujindemendianxinxi,
S.of(context).kaiqiquanxian,
(result) async {
if (result) {
await openAppSettings();
if (await Permission.location.isGranted) {
startLocation(context);
}
context: context,
builder: (context) {
return RequestPermission(
"assets/image/icon_permission_location_bg.png",
S.of(context).nindingweiquanxianweiyunxu,
S.of(context).weilexiangnintuijianfujindemendianxinxi,
S.of(context).kaiqiquanxian,
(result) async {
if (result) {
await openAppSettings();
if (await Permission.location.isGranted) {
startLocation(context);
}
},
heightRatioWithWidth: 0.82,
);
});
}
},
heightRatioWithWidth: 0.82,
);
},
);
}
}

Loading…
Cancel
Save