Browse Source

商品详情ui更改;(页面滑动时加购物车按钮置顶,购买数量及金额,未添加商品时也显示)

wr_2024_invoice
wurong 6 months ago
parent
commit
e732f4dd7a
  1. 475
      lib/store/shop_details_page.dart

475
lib/store/shop_details_page.dart

@ -65,6 +65,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
int numberOfPeople = 0;
int index;
bool isSetMeal;
int scIndex = 0;
@override
void initState() {
@ -72,6 +73,18 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
id = widget.arguments["id"];
storeId = widget.arguments["storeId"];
isSetMeal = widget.arguments["isSetMeal"] ?? false;
scrollController.addListener(() {
print(scrollController.offset);
if(scIndex == 0 && scrollController.offset > 400){
setState(() {
scIndex = 1;
});
}else if(scIndex == 1 && scrollController.offset <= 400){
setState(() {
scIndex = 0;
});
}
});
// SharedPreferences.getInstance().then((value) {
// String minToken = value.getString("minToken");
// String tenant = value.getString("tenant");
@ -92,9 +105,16 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
buildCount();
}
@override
void dispose() {
super.dispose();
refreshController.dispose();
}
///
queryStoreInfo() async {
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
EasyLoading.show(
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
SharedPreferences value = await SharedPreferences.getInstance();
if (apiService == null)
apiService = ApiService(
@ -321,7 +341,8 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
///
_queryMiNiDetail(String id, int count) async {
EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black);
EasyLoading.show(
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black);
if (count < 0) {
shopCarGoods.shoppingCartSkuItemList.forEach((element) {
if (element.productId == id) {
@ -605,186 +626,308 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
body: Stack(
children: [
Expanded(
child: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
setState(() {
_onRefresh();
});
},
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: Container(
child: SingleChildScrollView(
Column(
children: [
Expanded(
child: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
setState(() {
_onRefresh();
});
},
physics: BouncingScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildProduct(),
SizedBox(
height: 16.h,
),
Container(
width: double.infinity,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 14.w, top: 16.h),
child: Text(
"商品详情",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF000000),
scrollController: scrollController,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildProduct(),
SizedBox(
height: 16.h,
),
Container(
width: double.infinity,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 14.w, top: 16.h),
child: Text(
"商品详情",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF000000),
),
),
),
),
SizedBox(
height: 14.h,
),
Container(
color: Colors.white,
child: Html(
data: miNiDetail?.details ?? "",
style: {
'body': Style(
backgroundColor: Colors.white,
SizedBox(
height: 14.h,
),
Container(
color: Colors.white,
child: Html(
data: miNiDetail?.details ?? "",
style: {
'body': Style(
backgroundColor: Colors.white,
padding: EdgeInsets.all(0),
margin: EdgeInsets.all(0)),
'p': Style(
margin: EdgeInsets.all(0),
padding: EdgeInsets.all(0),
margin: EdgeInsets.all(0)),
'p': Style(
margin: EdgeInsets.all(0),
padding: EdgeInsets.all(0),
),
},
customImageRenders: {
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
return Container();
},
),
},
),
},
customImageRenders: {
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
return Container();
},
),
},
),
),
),
],
),
)
],
Container(
color: Colors.white,
child: Html(
data: miNiDetail?.details ?? "",
style: {
'body': Style(
backgroundColor: Colors.white,
padding: EdgeInsets.all(0),
margin: EdgeInsets.all(0)),
'p': Style(
margin: EdgeInsets.all(0),
padding: EdgeInsets.all(0),
),
},
customImageRenders: {
networkSourceMatcher(): networkImageRender(
loadingWidget: () {
return Container();
},
),
},
),
),
],
),
)
],
),
),
),
flex: 1,
),
),
flex: 1,
),
if (count() != 0)
Stack(
alignment: Alignment.bottomLeft,
children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 14),
height: 45.h,
// color: Color(0xFFFAFAFA),
decoration: BoxDecoration(
color: Color(0xFF383A38),
borderRadius: BorderRadius.circular(100),
// if (count() != 0)
Stack(
alignment: Alignment.bottomLeft,
children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 14),
height: 45.h,
// color: Color(0xFFFAFAFA),
decoration: BoxDecoration(
color: Color(0xFF383A38),
borderRadius: BorderRadius.circular(100),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 45.w,
),
Text.rich(
TextSpan(children: [
TextSpan(
text: "",
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFFFFFFFF),
fontWeight: MyFontWeight.bold),
),
TextSpan(
text: shopCarGoods != null
? shopCarGoods.cartSum
: "0.0",
style: TextStyle(
fontSize: 20.sp,
color: Color(0xFFFFFFFF),
fontFamily: 'JDZhengHT',
fontWeight: MyFontWeight.medium),
),
]),
),
Spacer(),
GestureDetector(
onTap: () {
toDownOrder();
},
child: RoundButton(
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.bold,
backgroup: Color(0xFF32A060),
radius: 100,
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
),
),
],
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
Stack(
children: [
SizedBox(
width: 45.w,
),
Text.rich(
TextSpan(children: [
TextSpan(
text: "",
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFFFFFFFF),
fontWeight: MyFontWeight.bold),
),
TextSpan(
text: shopCarGoods != null
? shopCarGoods.cartSum
: "0.0",
style: TextStyle(
fontSize: 20.sp,
color: Color(0xFFFFFFFF),
fontFamily: 'JDZhengHT',
fontWeight: MyFontWeight.medium),
),
]),
),
Spacer(),
GestureDetector(
InkWell(
onTap: () {
toDownOrder();
if (count() != 0) showShoppingCart();
},
child: RoundButton(
width: 103.w,
height: 54.h,
text: S.current.jiesuan,
textColor: Colors.white,
fontWeight: MyFontWeight.bold,
backgroup: Color(0xFF32A060),
radius: 100,
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
child: Image.asset(
"assets/image/shopping_bag.webp",
width: 66,
height: 66,
fit: BoxFit.fitWidth,
),
),
if (count() != 0)
Positioned(
right: 5,
// top: 14,
child: RoundButton(
width: 17.w,
height: 17.h,
text: "${count()}",
textColor: Colors.white,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFF65720),
fontSize: 12.sp,
radius: 100,
),
),
],
),
),
Stack(
children: [
InkWell(
onTap: () {
if (count() != 0) showShoppingCart();
},
child: Image.asset(
"assets/image/shopping_bag.webp",
width: 66,
height: 66,
fit: BoxFit.fitWidth,
),
],
),
SizedBox(
height: 30.h,
)
],
),
if (scIndex == 1)
Container(
color: Colors.white,
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 10.h,
left: 14.w,
right: 14.w,
bottom: 10.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
miNiDetail?.price ?? "",
style: TextStyle(
fontSize: 24.sp,
fontFamily: 'JDZhengHT',
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFFF85400),
),
if (count() != 0)
Positioned(
right: 5,
// top: 14,
child: RoundButton(
width: 17.w,
height: 17.h,
text: "${count()}",
textColor: Colors.white,
),
SizedBox(
width: 2.w,
),
Expanded(
child: Text(
miNiDetail?.applyPrice ?? "",
style: TextStyle(
fontSize: 16.sp,
fontFamily: 'JDZhengHT',
decoration: TextDecoration.lineThrough,
fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFF65720),
fontSize: 12.sp,
radius: 100,
color: Color(0xFFA29E9E),
),
)),
GestureDetector(
onTap: () async {
if (storeInfo.posType.code == "NORMALSTORE" &&
tableId == 0) {
showDeleteDialog();
} else if (isSetMeal == true) {
await Navigator.of(context)
.pushNamed('/router/product_meals_sku', arguments: {
"id": id,
"storeId": storeId,
"tableId": tableId
});
queryShopCar().then((value) {
this.shopCarGoods = value;
setState(() {});
});
} else {
_queryMiNiDetail(id, counts);
}
},
child: Container(
width: 92.w,
height: 32.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Color(0xFF32A060),
),
],
),
],
),
SizedBox(
height: 30.h,
)
margin: EdgeInsets.only(bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
"assets/image/goods_shopp.webp",
fit: BoxFit.fill,
width: 18,
height: 18,
),
SizedBox(
width: 2,
),
Text(
((miNiDetail?.subscribeParam?.isEnableSubscribe ??
false) ==
true)
? S.of(context).lijiyuyue
: (isSetMeal ?? false) == true
? "选套餐"
: "加入购物车",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFFFFFFF),
),
),
],
),
),
)
],
),
)
],
),
);
@ -815,6 +958,7 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(scIndex == 0)
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
@ -1359,9 +1503,12 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
//
// http://miniscan.lotus-wallet.com/placeorder?tenant_code=1194&table_id=1669609340031467520&store_id=1637659387134738432
Uri uri = Uri.parse(result);
String tableId = uri.queryParameters["tableId"] ?? uri.queryParameters["table_id"];
String tenantCode = uri.queryParameters["tenantCode"] ?? uri.queryParameters["tenant_code"];
String shopId = uri.queryParameters["shopId"] ?? uri.queryParameters["store_id"];
String tableId =
uri.queryParameters["tableId"] ?? uri.queryParameters["table_id"];
String tenantCode = uri.queryParameters["tenantCode"] ??
uri.queryParameters["tenant_code"];
String shopId =
uri.queryParameters["shopId"] ?? uri.queryParameters["store_id"];
if (tableId != null &&
tableId != "" &&
tenantCode != null &&

Loading…
Cancel
Save