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 numberOfPeople = 0;
int index; int index;
bool isSetMeal; bool isSetMeal;
int scIndex = 0;
@override @override
void initState() { void initState() {
@ -72,6 +73,18 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
id = widget.arguments["id"]; id = widget.arguments["id"];
storeId = widget.arguments["storeId"]; storeId = widget.arguments["storeId"];
isSetMeal = widget.arguments["isSetMeal"] ?? false; 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) { // SharedPreferences.getInstance().then((value) {
// String minToken = value.getString("minToken"); // String minToken = value.getString("minToken");
// String tenant = value.getString("tenant"); // String tenant = value.getString("tenant");
@ -92,9 +105,16 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
buildCount(); buildCount();
} }
@override
void dispose() {
super.dispose();
refreshController.dispose();
}
/// ///
queryStoreInfo() async { 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(); SharedPreferences value = await SharedPreferences.getInstance();
if (apiService == null) if (apiService == null)
apiService = ApiService( apiService = ApiService(
@ -321,7 +341,8 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
/// ///
_queryMiNiDetail(String id, int count) async { _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) { if (count < 0) {
shopCarGoods.shoppingCartSkuItemList.forEach((element) { shopCarGoods.shoppingCartSkuItemList.forEach((element) {
if (element.productId == id) { if (element.productId == id) {
@ -605,186 +626,308 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Column( body: Stack(
children: [ children: [
Expanded( Column(
child: SmartRefresher( children: [
controller: refreshController, Expanded(
enablePullDown: true, child: SmartRefresher(
enablePullUp: false, controller: refreshController,
header: MyHeader(), enablePullDown: true,
footer: CustomFooter( enablePullUp: false,
builder: (context, mode) { header: MyHeader(),
return MyFooter(mode); footer: CustomFooter(
}, builder: (context, mode) {
), return MyFooter(mode);
onRefresh: () { },
setState(() { ),
_onRefresh(); onRefresh: () {
}); setState(() {
}, _onRefresh();
physics: BouncingScrollPhysics(), });
scrollController: scrollController, },
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: Column( scrollController: scrollController,
mainAxisAlignment: MainAxisAlignment.start, child: SingleChildScrollView(
crossAxisAlignment: CrossAxisAlignment.start, physics: BouncingScrollPhysics(),
children: [ child: Column(
buildProduct(), mainAxisAlignment: MainAxisAlignment.start,
SizedBox( crossAxisAlignment: CrossAxisAlignment.start,
height: 16.h, children: [
), buildProduct(),
Container( SizedBox(
width: double.infinity, height: 16.h,
color: Colors.white, ),
child: Column( Container(
mainAxisAlignment: MainAxisAlignment.start, width: double.infinity,
crossAxisAlignment: CrossAxisAlignment.start, color: Colors.white,
children: [ child: Column(
Padding( mainAxisAlignment: MainAxisAlignment.start,
padding: EdgeInsets.only(left: 14.w, top: 16.h), crossAxisAlignment: CrossAxisAlignment.start,
child: Text( children: [
"商品详情", Padding(
style: TextStyle( padding: EdgeInsets.only(left: 14.w, top: 16.h),
fontSize: 15.sp, child: Text(
fontWeight: MyFontWeight.semi_bold, "商品详情",
color: Color(0xFF000000), style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF000000),
),
), ),
), ),
), SizedBox(
SizedBox( height: 14.h,
height: 14.h, ),
), Container(
Container( color: Colors.white,
color: Colors.white, child: Html(
child: Html( data: miNiDetail?.details ?? "",
data: miNiDetail?.details ?? "", style: {
style: { 'body': Style(
'body': Style( backgroundColor: Colors.white,
backgroundColor: Colors.white, padding: EdgeInsets.all(0),
margin: EdgeInsets.all(0)),
'p': Style(
margin: EdgeInsets.all(0),
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
margin: EdgeInsets.all(0)), ),
'p': Style( },
margin: EdgeInsets.all(0), customImageRenders: {
padding: EdgeInsets.all(0), 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,
), ),
), // if (count() != 0)
flex: 1, Stack(
), alignment: Alignment.bottomLeft,
if (count() != 0) children: [
Stack( Container(
alignment: Alignment.bottomLeft, margin: EdgeInsets.symmetric(horizontal: 14),
children: [ height: 45.h,
Container( // color: Color(0xFFFAFAFA),
margin: EdgeInsets.symmetric(horizontal: 14), decoration: BoxDecoration(
height: 45.h, color: Color(0xFF383A38),
// color: Color(0xFFFAFAFA), borderRadius: BorderRadius.circular(100),
decoration: BoxDecoration( ),
color: Color(0xFF383A38), child: Row(
borderRadius: BorderRadius.circular(100), 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( Stack(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox( InkWell(
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: () { onTap: () {
toDownOrder(); if (count() != 0) showShoppingCart();
}, },
child: RoundButton( child: Image.asset(
width: 103.w, "assets/image/shopping_bag.webp",
height: 54.h, width: 66,
text: S.current.jiesuan, height: 66,
textColor: Colors.white, fit: BoxFit.fitWidth,
fontWeight: MyFontWeight.bold,
backgroup: Color(0xFF32A060),
radius: 100,
fontSize: 16.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),
), ),
), ),
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: [ SizedBox(
InkWell( height: 30.h,
onTap: () { )
if (count() != 0) showShoppingCart(); ],
}, ),
child: Image.asset( if (scIndex == 1)
"assets/image/shopping_bag.webp", Container(
width: 66, color: Colors.white,
height: 66, padding: EdgeInsets.only(
fit: BoxFit.fitWidth, 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( SizedBox(
right: 5, width: 2.w,
// top: 14, ),
child: RoundButton( Expanded(
width: 17.w, child: Text(
height: 17.h, miNiDetail?.applyPrice ?? "",
text: "${count()}", style: TextStyle(
textColor: Colors.white, fontSize: 16.sp,
fontFamily: 'JDZhengHT',
decoration: TextDecoration.lineThrough,
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
backgroup: Color(0xFFF65720), color: Color(0xFFA29E9E),
fontSize: 12.sp,
radius: 100,
), ),
)),
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),
), ),
], margin: EdgeInsets.only(bottom: 8),
), child: Row(
], mainAxisAlignment: MainAxisAlignment.center,
), crossAxisAlignment: CrossAxisAlignment.center,
SizedBox( children: [
height: 30.h, 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, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if(scIndex == 0)
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.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 // http://miniscan.lotus-wallet.com/placeorder?tenant_code=1194&table_id=1669609340031467520&store_id=1637659387134738432
Uri uri = Uri.parse(result); Uri uri = Uri.parse(result);
String tableId = uri.queryParameters["tableId"] ?? uri.queryParameters["table_id"]; String tableId =
String tenantCode = uri.queryParameters["tenantCode"] ?? uri.queryParameters["tenant_code"]; uri.queryParameters["tableId"] ?? uri.queryParameters["table_id"];
String shopId = uri.queryParameters["shopId"] ?? uri.queryParameters["store_id"]; String tenantCode = uri.queryParameters["tenantCode"] ??
uri.queryParameters["tenant_code"];
String shopId =
uri.queryParameters["shopId"] ?? uri.queryParameters["store_id"];
if (tableId != null && if (tableId != null &&
tableId != "" && tableId != "" &&
tenantCode != null && tenantCode != null &&

Loading…
Cancel
Save