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.

932 lines
29 KiB

3 years ago
import 'dart:convert';
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';
3 years ago
import 'package:flutter_easyloading/flutter_easyloading.dart';
3 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
3 years ago
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
3 years ago
import 'package:flutter_swiper/flutter_swiper.dart';
3 years ago
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/activity.dart';
3 years ago
import 'package:huixiang/retrofit/data/base_data.dart';
3 years ago
import 'package:huixiang/retrofit/data/miNiDetail.dart';
3 years ago
import 'package:huixiang/retrofit/data/shoppingCart.dart';
3 years ago
import 'package:huixiang/retrofit/data/store_info.dart';
3 years ago
import 'package:huixiang/retrofit/min_api.dart';
3 years ago
import 'package:huixiang/retrofit/retrofit_api.dart';
3 years ago
import 'package:huixiang/store/store_view/people_num.dart';
3 years ago
import 'package:huixiang/store/store_view/product_sku.dart';
3 years ago
import 'package:huixiang/store/store_view/shop_car.dart';
3 years ago
import 'package:huixiang/store/store_view/store_activity.dart';
3 years ago
import 'package:huixiang/store/store_view/store_info.dart';
3 years ago
import 'package:huixiang/store/store_view/store_order_list.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/custom_image.dart';
3 years ago
import 'package:huixiang/view_widget/my_tab.dart';
3 years ago
import 'package:huixiang/view_widget/receive_success.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 {
3 years ago
final Map<String, dynamic> arguments;
3 years ago
3 years ago
StoreOrderPage({this.arguments});
3 years ago
@override
State<StatefulWidget> createState() {
return _StoreOrderPage();
}
}
3 years ago
class _StoreOrderPage extends State<StoreOrderPage>
3 years ago
with TickerProviderStateMixin {
3 years ago
TabController tabcontroller;
ApiService apiService;
3 years ago
MinApiService minService;
3 years ago
StoreInfo storeInfo;
3 years ago
List<Activity> activitys;
3 years ago
StoreOrderListPage storeOrderListPage;
3 years ago
3 years ago
ScrollController controller = ScrollController();
3 years ago
ShoppingCart shopCarGoods;
3 years ago
int tableId = 0;
3 years ago
String parentId = "";
String parentCode = "";
3 years ago
String tenant = "";
String storeId = "";
int numberOfPeople = 0;
3 years ago
///小程序token
String minToken;
3 years ago
3 years ago
@override
void initState() {
super.initState();
3 years ago
tableId = widget.arguments["tableId"] ?? 0;
3 years ago
tenant = widget.arguments["tenant"];
storeId = widget.arguments["id"];
debugPrint(
"store_param tableId:$tableId tenant:$tenant storeId:$storeId");
3 years ago
if (tabcontroller == null)
tabcontroller = TabController(
length: 2,
vsync: this,
);
3 years ago
3 years ago
SharedPreferences.getInstance().then((value) {
minLogin(value);
});
3 years ago
}
3 years ago
/// 小程序登录
3 years ago
minLogin(SharedPreferences shared) async {
3 years ago
EasyLoading.show(status: S.of(context).zhengzaijiazai);
3 years ago
apiService = ApiService(
Dio(),
context: context,
3 years ago
token: shared.getString('token'),
3 years ago
showLoading: false,
3 years ago
);
3 years ago
apiService.minLogin(storeId).catchError((onError) {
debugPrint(onError);
}).then((baseData) {
3 years ago
if (baseData != null && baseData.isSuccess) {
Map<String, dynamic> minStoreInfo = baseData.data;
3 years ago
minToken = minStoreInfo["token"];
queryStoreInfo();
3 years ago
SharedPreferences.getInstance().then(
3 years ago
(value) => {
3 years ago
value.setString('minToken', minToken),
value.setString('tenant', tenant),
3 years ago
value.setString('storeId', storeId),
3 years ago
},
);
minService = MinApiService(
Dio(),
context: context,
token: minToken,
tenant: tenant,
3 years ago
storeId: storeId,
3 years ago
showLoading: false,
3 years ago
);
3 years ago
queryMemberInfo();
3 years ago
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
3 years ago
if (tableId > 0) {
3 years ago
getParentInfo();
3 years ago
}
3 years ago
EasyLoading.dismiss();
3 years ago
}
});
}
3 years ago
queryMemberInfo() async {
BaseData baseData = await minService.memberInfo()
.catchError((error){debugPrint(error);});
if (baseData != null && baseData.isSuccess) {
SharedPreferences.getInstance().then(
(value) => {
value.setString('minMember', jsonEncode(baseData.data)),
},
);
}
}
3 years ago
///获取父订单(火锅订单加菜前调用)
getParentInfo() async {
3 years ago
BaseData baseData = await minService.getParentInfo("$tableId")
.catchError((error) {debugPrint(error);});
3 years ago
if (baseData != null && baseData.isSuccess) {
3 years ago
if (baseData.data != null) {
3 years ago
parentId = baseData.data["id"];
parentCode = baseData.data["parentCode"];
} else {
///TODO: 没有父订单,
queryStoreInfo1();
}
}
3 years ago
}
///获取桌子信息
queryStoreInfo1() async {
BaseData baseData = await minService.queryStoreInfo1({
"getCoupon": true,
"storeId": storeId,
"tableId": tableId,
}).catchError((error) {
debugPrint(error);
});
if (baseData != null && baseData.isSuccess) {
StoreInfo storeInfo = StoreInfo.fromJson(baseData.data);
if (storeInfo.storeTable != null) {
showPeopleNum(storeInfo.storeTable.tableName);
}
}
}
3 years ago
/// 查询店铺信息
3 years ago
queryStoreInfo() async {
3 years ago
BaseData baseData = await apiService.queryStoreInfo(storeId).catchError((error) {
3 years ago
debugPrint(error);
});
3 years ago
if (baseData != null && baseData.isSuccess) {
storeInfo = StoreInfo.fromJson(baseData.data);
3 years ago
activitys = storeInfo.informationVOPageVO.list
.map((e) => Activity.fromJson(e))
.toList();
3 years ago
if (mounted) {
setState(() {});
}
}
3 years ago
EasyLoading.dismiss();
3 years ago
}
3 years ago
RefreshController refreshController;
3 years ago
bool dialogShowing = false;
3 years ago
3 years ago
@override
Widget build(BuildContext context) {
3 years ago
return WillPopScope(
onWillPop: () async {
if (dialogShowing) {
debugPrint("ssssasdadsasdadasd");
SmartDialog.dismiss();
return false;
} else {
return true;
}
},
3 years ago
child: Container(
color: Colors.white,
child: Stack(
children: [
Positioned(
left: 0,
right: 0,
top: 0,
bottom: 54.h,
child: NestedScrollView(
controller: controller,
dragStartBehavior: DragStartBehavior.start,
physics: BouncingScrollPhysics(),
headerSliverBuilder: (BuildContext context, bool innerScrolled) {
return [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
sliver: SliverAppBar(
expandedHeight:
(storeInfo != null && storeInfo.couponVOList != null)
? 470.h
: 365.h,
floating: false,
snap: false,
pinned: true,
stretch: false,
brightness: Brightness.light,
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
),
3 years ago
),
3 years ago
flexibleSpace: FlexibleSpaceBar(
title: Title(
controller,
storeInfo != null ? storeInfo.storeName : '',
),
collapseMode: CollapseMode.pin,
stretchModes: [
StretchMode.zoomBackground,
StretchMode.fadeTitle,
StretchMode.blurBackground,
],
background: Container(
color: Colors.white,
child: Stack(
children: [
Positioned(
3 years ago
child: Column(
children: [
3 years ago
buildSwiper(),
Expanded(
child: Container(
color: Colors.transparent,
3 years ago
),
3 years ago
flex: 1,
),
],
),
top: 0,
bottom: 0,
left: 0,
right: 0,
),
Positioned(
child: Container(
child: Column(
children: [
///门店信息
StoreInfoView(storeInfo),
3 years ago
3 years ago
///门店对应优惠券
if (storeInfo != null &&
storeInfo.couponVOList != null)
UnionCoupon(
storeInfo,
_receiveCoupon,
coupon: true,
),
3 years ago
3 years ago
if (storeInfo == null ||
storeInfo.couponVOList == null)
SizedBox(
height: 8,
),
///门店对应VIP信息
Vip(storeInfo, () {}, false),
],
),
3 years ago
),
3 years ago
top: 110.h,
bottom: 0,
left: 0,
right: 0,
3 years ago
),
3 years ago
],
),
3 years ago
),
3 years ago
),
3 years ago
backgroundColor: Color(0x33FAFAFA),
centerTitle: false,
elevation: 0,
bottom: PreferredSize(
preferredSize: Size(
MediaQuery.of(context).size.width,
38,
),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
width: MediaQuery.of(context).size.width,
child: TabBar(
controller: tabcontroller,
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: S.of(context).diancan),
MyTab(text: S.of(context).xindianhuodong),
],
3 years ago
),
3 years ago
),
3 years ago
),
),
),
3 years ago
];
},
body: TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
///点餐
StoreOrderListPage(
widget.arguments,
activitys,
storeInfo,
shopCarGoods,
controller,
minToken,
tenant,
_queryMiNiDetail,
),
3 years ago
3 years ago
///星店活动,
StoreActivity(
widget.arguments,
activitys,
),
],
controller: tabcontroller,
),
), /*SmartRefresher(
3 years ago
controller: refreshController =
RefreshController(initialRefresh: false),
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
physics: BouncingScrollPhysics(),
onRefresh: () {
queryStoreInfo();
},
child:
),*/
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,
),
3 years ago
),
3 years ago
Text(
"${shopCarGoods != null ? shopCarGoods.cartSum : "0.0"}",
style: TextStyle(
fontSize: 20.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF32A060),
),
3 years ago
),
3 years ago
Spacer(),
GestureDetector(
onTap: () {
toDownOrder();
},
child: RoundButton(
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
radius: 0,
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
),
),
],
),
),
Stack(
children: [
InkWell(
3 years ago
onTap: () {
3 years ago
showShoppingCart();
3 years ago
},
3 years ago
child: Image.asset(
"assets/image/shopp.png",
width: 88,
height: 88,
fit: BoxFit.fitWidth,
),
),
Positioned(
right: 15,
top: 14,
3 years ago
child: RoundButton(
3 years ago
width: 17,
height: 17,
text: "${count()}",
3 years ago
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFF32A060),
3 years ago
fontSize: 12.sp,
radius: 100,
3 years ago
),
),
],
),
3 years ago
],
),
3 years ago
),
3 years ago
],
),
3 years ago
),
3 years ago
);
}
3 years ago
///领取优惠券
_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();
},
);
}
3 years ago
///显示选择人数的弹窗
3 years ago
showPeopleNum(String tableName) async {
var people = await showDialog(
context: context,
3 years ago
barrierDismissible: false,
3 years ago
builder: (context) {
return PeopleNumView(tableName);
},
);
if (people != null && people > 0) {
setState(() {
this.numberOfPeople = people;
});
3 years ago
} else {
Navigator.of(context).pop();
3 years ago
}
}
3 years ago
///计算个数
int count() {
if (shopCarGoods == null ||
shopCarGoods.shoppingCartSkuItemList == null ||
shopCarGoods.shoppingCartSkuItemList.length == 0) return 0;
int count = 0;
shopCarGoods.shoppingCartSkuItemList.forEach((element) {
count += element.buyNum;
});
return count;
}
///去下单结算页面
3 years ago
toDownOrder() async {
3 years ago
int num = count();
3 years ago
if (parentId == null || parentId == "") {
if (num == 0) {
SmartDialog.showToast("请先选择您要购买的商品!~");
return;
}
3 years ago
}
3 years ago
3 years ago
await Navigator.of(context).pushNamed(
3 years ago
'/router/settlement',
arguments: {
"storeInfo": storeInfo,
3 years ago
"tableId": tableId,
"parentCode": parentCode,
"parentId": parentId,
3 years ago
"shoppingCart": shopCarGoods,
3 years ago
"numberOfPeople": numberOfPeople,
3 years ago
},
);
3 years ago
if(tableId >0){
getParentInfo();
}
3 years ago
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
3 years ago
}
3 years ago
Widget buildSwiper() {
return Container(
width: double.infinity,
height: 180.h,
child: Swiper(
3 years ago
pagination: SwiperPagination(
alignment: Alignment.bottomCenter,
builder: DotSwiperPaginationBuilder(
size: 8.w,
activeSize: 8.w,
space: 5.w,
activeColor: Colors.white,
color: Colors.white.withAlpha(76),
3 years ago
),
3 years ago
),
itemBuilder: (context, position) {
return Container(
child: MImage(
(storeInfo != null &&
storeInfo.bannerList != null &&
position < storeInfo.bannerList.length)
? storeInfo.bannerList[position].imgUrl
: "",
fit: BoxFit.cover,
radius: BorderRadius.zero,
errorSrc: "assets/image/default_2_1.png",
fadeSrc: "assets/image/default_2_1.png",
),
);
},
itemCount: (storeInfo != null && storeInfo.bannerList != null)
? storeInfo.bannerList.length
: 1,
),
3 years ago
);
}
3 years ago
/// 购物车的key,用于刷新UI
3 years ago
GlobalKey shopCartKey = GlobalKey();
3 years ago
///购物车弹窗
showShoppingCart() {
3 years ago
queryShopCar().then((value) {
3 years ago
this.shopCarGoods = value;
3 years ago
dialogShowing = true;
SmartDialog.show(
widget: ShopCar(
shopCartKey,
this.shopCarGoods,
clearShopCar,
toDownOrder,
shopCartAdd,
shopCartReduce,
),
onDismiss: () {
dialogShowing = false;
3 years ago
},
3 years ago
alignmentTemp: Alignment.bottomCenter,
3 years ago
);
});
3 years ago
}
3 years ago
///清空购物车
3 years ago
clearShopCar() async {
BaseData<bool> baseData = await minService.clearShoppingCart();
if (baseData.isSuccess) {
3 years ago
shopCarGoods = null;
3 years ago
setState(() {});
}
3 years ago
}
3 years ago
///选规格
_queryMiNiDetail(String id,int count) async {
3 years ago
EasyLoading.show(status: S.current.zhengzaijiazai);
3 years ago
BaseData<MiNiDetail> baseData = await minService.miNiDetail(id).catchError((error){});
3 years ago
if (baseData != null && baseData.isSuccess) {
showStoreSelector(baseData.data, id,count);
3 years ago
}
}
3 years ago
///选规格弹窗
showStoreSelector(MiNiDetail miNiDetail, String id,int count) async {
if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1
&& miNiDetail.attrList[0].attrValueList.length == 1) {
_addShopCar(miNiDetail, [], count);
3 years ago
} else {
EasyLoading.dismiss();
dialogShowing = true;
SmartDialog.show(
3 years ago
widget: ProductSku(
3 years ago
miNiDetail,
shopCarGoods,
id,
_addShopCar,
add,
reduce,
3 years ago
),
onDismiss: () {
dialogShowing = false;
},
3 years ago
alignmentTemp: Alignment.bottomCenter,
);
}
3 years ago
}
3 years ago
///添加购物车
3 years ago
Future _addShopCar(MiNiDetail miNiDetail, selectSkus, int count) async {
3 years ago
ProductSkuVOListBean productSku;
if (selectSkus!= null && selectSkus.length == 0) {
productSku = miNiDetail.productSkuVOList.first;
} else {
productSku = miNiDetail.productSkuVOList.firstWhere((element) {
bool gg = true;
selectSkus.forEach((element1) {
if (element.skuNameStr.indexOf(element1) < 0) {
gg = false;
return gg;
}
});
return gg;
3 years ago
});
3 years ago
}
3 years ago
if (productSku == null) return;
String skuId = productSku.id;
3 years ago
String skuValue = selectSkus
.toString()
.replaceAll("[", "")
.replaceAll("]", "")
.replaceAll(",", "");
3 years ago
if (miNiDetail != null) {
3 years ago
BaseData<List<ShoppingCart>> baseDate = await minService.addShoppingCart({
"storeId": storeInfo.id,
"storeName": storeInfo.storeName ?? "",
3 years ago
"numberOfPeople": numberOfPeople,
"tableId": tableId,
3 years ago
"parentId": parentId,
"parentCode": parentCode,
3 years ago
"shoppingCartSkuItemList": [
{
3 years ago
"buyNum": count,
"id": skuId,
"productId": miNiDetail.id,
"productName": miNiDetail.productName,
"skuName": skuValue,
3 years ago
"storeId": storeInfo.id,
3 years ago
"skuPrice": productSku.skuPrice,
3 years ago
"skuStock": productSku.skuStock,
3 years ago
"tableId": tableId,
3 years ago
},
3 years ago
],
});
3 years ago
EasyLoading.dismiss();
3 years ago
if (baseDate != null && baseDate.isSuccess) {
3 years ago
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
3 years ago
}
}
}
///查询购物车
3 years ago
Future<ShoppingCart> queryShopCar() async {
3 years ago
BaseData<List<ShoppingCart>> baseDate =
await minService.getShoppingCart(tableId);
3 years ago
if (baseDate != null &&
baseDate.isSuccess &&
baseDate.data != null &&
baseDate.data.length > 0) {
return baseDate.data[0];
3 years ago
} else {
3 years ago
return null;
3 years ago
}
3 years ago
}
3 years ago
///购物车➕1
3 years ago
Future<ShoppingCart> shopCartAdd(
ShoppingCartSkuItemListBean cartSkuItem) async {
3 years ago
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
cartSkuItem.buyNum += 1;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
3 years ago
BaseData<List<ShoppingCart>> baseDate =
await minService.shoppingCartSingle(shopCarTemp);
3 years ago
if (baseDate.isSuccess) {
3 years ago
this.shopCarGoods = await queryShopCar();
if (shopCartKey != null) {
shopCartKey.currentState.setState(() {});
}
setState(() {});
3 years ago
}
3 years ago
return this.shopCarGoods;
3 years ago
}
///购物车➖1
3 years ago
Future<ShoppingCart> shopCartReduce(
ShoppingCartSkuItemListBean cartSkuItem) async {
3 years ago
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
cartSkuItem.buyNum -= 1;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
3 years ago
BaseData<List<ShoppingCart>> baseDate =
await minService.shoppingCartSingle(shopCarTemp);
3 years ago
if (baseDate.isSuccess) {
3 years ago
this.shopCarGoods = await queryShopCar();
if (shopCartKey != null) {
shopCartKey.currentState.setState(() {});
}
setState(() {});
3 years ago
}
3 years ago
return this.shopCarGoods;
3 years ago
}
///商品➕1
add(MiNiDetail miNiDetail, selectSkus) async {
3 years ago
ProductSkuVOListBean productSku =
miNiDetail.productSkuVOList.firstWhere((element) {
3 years ago
return skuY(element, selectSkus);
});
if (productSku == null) return;
String skuId = productSku.id;
if (shopCarGoods == null) {
await _addShopCar(miNiDetail, selectSkus, 2);
return;
}
3 years ago
int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList
.indexWhere((element) => skuId == element.id);
3 years ago
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
3 years ago
shopCarGoods.tableId = "$tableId";
3 years ago
if (shopSkuIndex >= 0) {
shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum += 1;
3 years ago
ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods
.shoppingCartSkuItemList
.firstWhere((element) => skuId == element.id);
3 years ago
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
} else {
await _addShopCar(miNiDetail, selectSkus, 2);
return;
}
3 years ago
BaseData<List<ShoppingCart>> baseDate =
await minService.shoppingCartSingle(shopCarTemp);
3 years ago
if (baseDate.isSuccess) {
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
}
}
///商品➖1
reduce(MiNiDetail miNiDetail, selectSkus) async {
3 years ago
ProductSkuVOListBean productSku =
miNiDetail.productSkuVOList.firstWhere((element) {
3 years ago
return skuY(element, selectSkus);
});
if (productSku == null) return;
String skuId = productSku.id;
if (shopCarGoods == null) {
await _addShopCar(miNiDetail, selectSkus, 2);
return;
}
3 years ago
ShoppingCartSkuItemListBean shopSkuItem = shopCarGoods
.shoppingCartSkuItemList
.firstWhere((element) => skuId == element.skuId);
int shopSkuIndex = shopCarGoods.shoppingCartSkuItemList
.indexWhere((element) => skuId == element.skuId);
3 years ago
if (shopSkuItem != null) {
if (shopSkuItem.buyNum > 1) {
shopCarGoods.shoppingCartSkuItemList[shopSkuIndex].buyNum -= 1;
}
} else {
await _addShopCar(miNiDetail, selectSkus, 2);
return;
}
3 years ago
shopCarGoods.tableId = "$tableId";
3 years ago
Map<String, dynamic> shopCarTemp = shopCarGoods.toJson();
3 years ago
ShoppingCartSkuItemListBean cartSkuItem = shopCarGoods
.shoppingCartSkuItemList
.firstWhere((element) => skuId == element.id);
3 years ago
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
3 years ago
BaseData<List<ShoppingCart>> baseDate =
await minService.shoppingCartSingle(shopCarTemp);
3 years ago
if (baseDate.isSuccess) {
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
}
}
bool skuY(ProductSkuVOListBean productSku, selectSkus) {
bool gg = true;
selectSkus.forEach((element1) {
if (productSku.skuNameStr.indexOf(element1) < 0) {
gg = false;
return gg;
}
});
return gg;
3 years ago
}
3 years ago
}
3 years ago
class Title extends StatefulWidget {
final ScrollController controller;
final String title;
Title(this.controller, this.title);
@override
State<StatefulWidget> createState() {
return _Title();
}
}
class _Title extends State<Title> {
double alpha = 0;
@override
void initState() {
super.initState();
widget.controller.addListener(() {
double maxScrollExtent = widget.controller.position.maxScrollExtent;
double alphaHeight = (kToolbarHeight) / 2;
double alphaProgress = maxScrollExtent - widget.controller.offset;
double alphatemp = 0;
if (alphaProgress <= 1) {
alphatemp = 1;
} else if (alphaProgress <= alphaHeight) {
3 years ago
alphatemp =
(((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0;
3 years ago
} else {
alphatemp = 0;
}
if (alpha != alphatemp && mounted) {
alpha = alphatemp;
3 years ago
print("object: $alpha");
3 years ago
setState(() {});
}
});
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 38),
child: Text(
widget.title ?? "",
style: TextStyle(
color: Colors.black.withOpacity(alpha),
fontWeight: FontWeight.bold,
fontSize: 18.sp,
),
),
);
}
}