w-R 3 years ago
parent
commit
91be0a76fb
  1. 4
      lib/retrofit/retrofit_api.dart
  2. 129
      lib/store/shopping/shopping_cart/shopping_cart_page.dart

4
lib/retrofit/retrofit_api.dart

@ -91,8 +91,8 @@ abstract class ApiService {
headers["Environment"] = "app";
}
dio.options = BaseOptions(
connectTimeout: 60000,
receiveTimeout: 60000,
connectTimeout: 15000,
receiveTimeout: 15000,
headers: headers,
responseType: ResponseType.json,
);

129
lib/store/shopping/shopping_cart/shopping_cart_page.dart

@ -16,8 +16,6 @@ import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ShoppingCartPage extends StatefulWidget {
final String minToken;
@ -26,6 +24,7 @@ class ShoppingCartPage extends StatefulWidget {
final StoreInfo storeInfo;
ShoppingCartPage(this.minToken, this.storeId, this.tenant, this.storeInfo);
@override
State<StatefulWidget> createState() {
return _ShoppingCartPage();
@ -45,7 +44,6 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
bool topIndex = false;
bool isAllSelect = false;
@override
void initState() {
super.initState();
@ -80,8 +78,7 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
///
queryShopCar() async {
if(widget.minToken == null)
return;
if (widget.minToken == null) return;
if (minService == null)
minService = MinApiService(
Dio(),
@ -114,8 +111,7 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
cartSkuItem.selected = selected;
shopCarTemp["selected"] = selected;
shopCarTemp["shoppingCartSkuItemList"] = [cartSkuItem.toJson()];
BaseData baseDate =
await minService.shoppingCartSingle(shopCarTemp);
BaseData baseDate = await minService.shoppingCartSingle(shopCarTemp);
if (baseDate.isSuccess) {
setState(() {
queryShopCar();
@ -156,7 +152,8 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
child: Container(
alignment: Alignment.center,
margin: EdgeInsets.only(right: 12.w),
child: Text(!topIndex ? "管理" :S.of(context).quxiao,
child: Text(
!topIndex ? "管理" : S.of(context).quxiao,
style: TextStyle(
fontSize: 18.sp,
fontWeight: MyFontWeight.semi_bold,
@ -225,30 +222,35 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
onTap: () {
setState(() {
isAllSelect = !isAllSelect;
shopCarGoods[0].shoppingCartSkuItemList.forEach((element) {
shopCarGoods[0]
.shoppingCartSkuItemList
.forEach((element) {
element.selected = isAllSelect ? 1 : 0;
shopCartAdd(element, 0, element.selected);
});
});
},
child: Image.asset(
isAllSelect ? "assets/image/icon_radio_selected.webp" :
"assets/image/icon_radio_unselected.webp",
isAllSelect
? "assets/image/icon_radio_selected.webp"
: "assets/image/icon_radio_unselected.webp",
width: 16,
height: 16,
),
),
SizedBox(width: 5.w),
Expanded(child: Text(
Expanded(
child: Text(
"全选",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFA29E9E),
),
),),
!topIndex ?
Row(
),
),
!topIndex
? Row(
children: [
Text.rich(
TextSpan(
@ -262,14 +264,15 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
),
),
TextSpan(
text:((shopCarGoods?.length??0) > 0) ? (shopCarGoods[0]?.cartSum ?? "") : "",
text: ((shopCarGoods?.length ?? 0) > 0)
? (shopCarGoods[0]?.cartSum ?? "")
: "",
style: TextStyle(
fontSize: 20.sp,
fontWeight: MyFontWeight.semi_bold,
color: Color(0xFF32A060),
),
),
],
),
),
@ -302,10 +305,11 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
color: Colors.white,
),
),
),),
),
),
],
):
GestureDetector(
)
: GestureDetector(
onTap: () {
clearShopCar();
},
@ -336,7 +340,6 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
),
),
),
],
),
),
@ -353,11 +356,13 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
text: "目前暂无商品,要快去买点好吃的哦~",
fontSize: 16.sp,
margin: EdgeInsets.only(top: 150.h),
):
Container(
)
: Container(
margin: EdgeInsets.only(bottom: 50.h),
child: ListView.builder(
itemCount:((shopCarGoods?.length ?? 0) > 0) ? (shopCarGoods[0]?.shoppingCartSkuItemList?.length ?? 0) : 0,
itemCount: ((shopCarGoods?.length ?? 0) > 0)
? (shopCarGoods[0]?.shoppingCartSkuItemList?.length ?? 0)
: 0,
shrinkWrap: true,
padding: EdgeInsets.only(
top: 8.h,
@ -366,8 +371,7 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
physics: BouncingScrollPhysics(),
itemBuilder: (context, position) {
return InkWell(
onTap: () {
},
onTap: () {},
child: cartGoodsItem(position),
);
}),
@ -397,13 +401,19 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
GestureDetector(
onTap: () {
setState(() {
shopCarGoods[0].shoppingCartSkuItemList[index].selected = (shopCarGoods[0].shoppingCartSkuItemList[index].selected == 0) ? 1 : 0;
shopCartAdd(shopCarGoods[0].shoppingCartSkuItemList[index],0,shopCarGoods[0].shoppingCartSkuItemList[index].selected);
shopCarGoods[0].shoppingCartSkuItemList[index].selected =
(shopCarGoods[0].shoppingCartSkuItemList[index].selected ==
0)
? 1
: 0;
shopCartAdd(shopCarGoods[0].shoppingCartSkuItemList[index], 0,
shopCarGoods[0].shoppingCartSkuItemList[index].selected);
});
},
child: Image.asset(
(shopCarGoods[0].shoppingCartSkuItemList[index].selected==1) ? "assets/image/icon_radio_selected.webp" :
"assets/image/icon_radio_unselected.webp",
(shopCarGoods[0].shoppingCartSkuItemList[index].selected == 1)
? "assets/image/icon_radio_selected.webp"
: "assets/image/icon_radio_unselected.webp",
width: 16,
height: 16,
),
@ -419,14 +429,18 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
fadeSrc: "assets/image/default_1.webp",
),
SizedBox(width: 10.w),
Expanded(child:
Container(
height:81.h,child:Column(
Expanded(
child: Container(
height: 81.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
shopCarGoods[0].shoppingCartSkuItemList[index]?.productName ?? "",
shopCarGoods[0]
.shoppingCartSkuItemList[index]
?.productName ??
"",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@ -437,7 +451,8 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
),
// SizedBox(height: 5.h),
Text(
shopCarGoods[0].shoppingCartSkuItemList[index]?.skuName ?? "",
shopCarGoods[0].shoppingCartSkuItemList[index]?.skuName ??
"",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.medium,
@ -449,7 +464,8 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:Text.rich(
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
@ -461,7 +477,10 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
),
),
TextSpan(
text:shopCarGoods[0].shoppingCartSkuItemList[index]?.skuPrice ?? "",
text: shopCarGoods[0]
.shoppingCartSkuItemList[index]
?.skuPrice ??
"",
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
@ -473,12 +492,22 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,children: [
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkWell(
onTap: () {
setState(() {
if(shopCarGoods[0].shoppingCartSkuItemList[index].buyNum > 1)
shopCartAdd(shopCarGoods[0].shoppingCartSkuItemList[index],-1,shopCarGoods[0].shoppingCartSkuItemList[index].selected);
if (shopCarGoods[0]
.shoppingCartSkuItemList[index]
.buyNum >
1)
shopCartAdd(
shopCarGoods[0]
.shoppingCartSkuItemList[index],
-1,
shopCarGoods[0]
.shoppingCartSkuItemList[index]
.selected);
});
},
child: Image.asset(
@ -491,7 +520,11 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
width: 30,
alignment: Alignment.center,
child: Text(
shopCarGoods[0].shoppingCartSkuItemList[index]?.buyNum.toString() ?? 0,
shopCarGoods[0]
.shoppingCartSkuItemList[index]
?.buyNum
.toString() ??
0,
style: TextStyle(
color: Colors.black,
fontSize: 14.sp,
@ -502,7 +535,13 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
InkWell(
onTap: () {
setState(() {
shopCartAdd(shopCarGoods[0].shoppingCartSkuItemList[index],1,shopCarGoods[0].shoppingCartSkuItemList[index].selected);
shopCartAdd(
shopCarGoods[0]
.shoppingCartSkuItemList[index],
1,
shopCarGoods[0]
.shoppingCartSkuItemList[index]
.selected);
});
},
child: Image.asset(
@ -511,11 +550,13 @@ class _ShoppingCartPage extends State<ShoppingCartPage>
height: 22,
),
),
],)
],
)
],
),
],
)),),
)),
),
],
),
);

Loading…
Cancel
Save