Browse Source

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

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

165
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,7 +626,9 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
body: Stack(
children: [
Column(
children: [
Expanded(
child: SmartRefresher(
@ -625,7 +648,6 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
},
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: Container(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
@ -680,6 +702,29 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
},
),
),
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();
},
),
},
),
),
],
),
)
@ -687,10 +732,9 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
),
),
),
),
flex: 1,
),
if (count() != 0)
// if (count() != 0)
Stack(
alignment: Alignment.bottomLeft,
children: [
@ -787,6 +831,105 @@ class _ShopDetailsPage extends State<ShopDetailsPage> {
)
],
),
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),
),
),
SizedBox(
width: 2.w,
),
Expanded(
child: Text(
miNiDetail?.applyPrice ?? "",
style: TextStyle(
fontSize: 16.sp,
fontFamily: 'JDZhengHT',
decoration: TextDecoration.lineThrough,
fontWeight: MyFontWeight.regular,
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),
),
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