From 8016424596036cfb59f7fb56b69d50687f64a336 Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 12 Oct 2021 15:09:30 +0800 Subject: [PATCH] safety --- lib/retrofit/min_api.dart | 2 +- lib/store/store_order.dart | 545 +++++---------------- lib/store/store_view/product_sku.dart | 293 +++++++++++ lib/store/store_view/shop_car.dart | 179 +++++++ lib/store/store_view/shop_goods.dart | 138 ++++++ lib/store/store_view/store_order_list.dart | 308 ++---------- lib/union/union_details_page.dart | 4 +- 7 files changed, 784 insertions(+), 685 deletions(-) create mode 100644 lib/store/store_view/product_sku.dart create mode 100644 lib/store/store_view/shop_car.dart create mode 100644 lib/store/store_view/shop_goods.dart diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index 0b9296e4..949cc36c 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -115,7 +115,7 @@ abstract class MinApiService { ///小程序查询分组及商品列表 @POST("product/findMiNiGroupList") Future>> findMiNiGroupList( - @Body() Map param,Map header); + @Body() Map param); diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 6480e611..a9d3ac2f 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -12,6 +12,8 @@ import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/store_view/shop_car.dart'; +import 'package:huixiang/store/store_view/shop_goods.dart'; import 'package:huixiang/store/store_view/store_activity.dart'; import 'package:huixiang/store/store_view/store_info.dart'; import 'package:huixiang/store/store_view/store_order_list.dart'; @@ -43,7 +45,7 @@ class _StoreOrderPage extends State MinApiService minService; StoreInfo storeInfo; List activitys; - RefreshController refreshController; + // RefreshController refreshController; List _widgetOptions; ScrollController controller = ScrollController(); @@ -66,7 +68,6 @@ class _StoreOrderPage extends State controller, ), - ///星店活动, StoreActivity( widget.arguments, @@ -88,10 +89,10 @@ class _StoreOrderPage extends State BaseData baseData = await apiService .queryStoreInfo(widget.arguments["id"]) .catchError((error) { - refreshController.refreshFailed(); + // refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - refreshController.refreshCompleted(); + // refreshController.refreshCompleted(); storeInfo = StoreInfo.fromJson(baseData.data); activitys = storeInfo.informationVOPageVO.list .map((e) => Activity.fromJson(e)) @@ -99,8 +100,6 @@ class _StoreOrderPage extends State if (mounted) { setState(() {}); } - } else { - refreshController.refreshFailed(); } } @@ -115,162 +114,147 @@ class _StoreOrderPage extends State bottom: 54.h, child: DefaultTabController( length: 2, - child: SmartRefresher( - controller: refreshController = RefreshController(initialRefresh: false), - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - physics: BouncingScrollPhysics(), - onRefresh: () { - queryStoreInfo(); - }, - child: NestedScrollView( - controller: controller, - dragStartBehavior: DragStartBehavior.start, - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), - sliver: SliverAppBar( - expandedHeight: (storeInfo != null && - storeInfo.couponVOList != null) - ? 425.h - : 365.h, - floating: false, - snap: false, - pinned: true, - stretch: false, - 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, - ), + child: NestedScrollView( + controller: controller, + // physics: BouncingScrollPhysics(), + dragStartBehavior: DragStartBehavior.start, + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + expandedHeight: + (storeInfo != null && storeInfo.couponVOList != null) + ? 425.h : 365.h, + floating: false, + snap: false, + pinned: true, + stretch: false, + 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, ), ), - flexibleSpace: FlexibleSpaceBar( - title: Title( - controller, - storeInfo != null ? storeInfo.storeName : '', - ), - collapseMode: CollapseMode.pin, - stretchModes: [ - StretchMode.zoomBackground, - StretchMode.fadeTitle, - StretchMode.blurBackground, - ], - background: Stack( - children: [ - Positioned( - child: Column( - children: [ - // Image.asset( - // "assets/image/share_image_bg.png", - // fit: BoxFit.cover, - // width: MediaQuery.of(context).size.width, - // height: 180.h, - // ), - buildSwiper(), - Expanded( - child: Container( - color: Colors.transparent, - ), - flex: 1, + ), + flexibleSpace: FlexibleSpaceBar( + title: Title( + controller, + storeInfo != null ? storeInfo.storeName : '', + ), + collapseMode: CollapseMode.pin, + stretchModes: [ + StretchMode.zoomBackground, + StretchMode.fadeTitle, + StretchMode.blurBackground, + ], + background: Stack( + children: [ + Positioned( + child: Column( + children: [ + buildSwiper(), + Expanded( + child: Container( + color: Colors.transparent, ), - ], - ), - top: 0, - bottom: 0, - left: 0, - right: 0, + flex: 1, + ), + ], ), - Positioned( - child: Container( - child: Column( - children: [ - ///门店信息 - StoreInfoView(storeInfo), - - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - (a) {}, - coupon: true, - ), + top: 0, + bottom: 0, + left: 0, + right: 0, + ), + Positioned( + child: Container( + child: Column( + children: [ + ///门店信息 + StoreInfoView(storeInfo), - SizedBox( - height: 8, + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + (a) {}, + coupon: true, ), - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), - ], - ), + SizedBox( + height: 8, + ), + + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), + ], ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, ), - ], - ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, + ), + ], ), - 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.current.diancan), - MyTab(text: S.current.xindianhuodong), - ], + ), + 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.current.diancan), + MyTab(text: S.current.xindianhuodong), + ], ), ), ), ), - ]; - }, - body: TabBarView( - physics: BouncingScrollPhysics(), - children: _widgetOptions, - controller: tabcontroller, - ), + ), + ]; + }, + body: TabBarView( + physics: BouncingScrollPhysics(), + children: _widgetOptions, + controller: tabcontroller, ), ), ), @@ -410,274 +394,14 @@ class _StoreOrderPage extends State backgroundColor: Colors.transparent, builder: (context) { return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - width: double.infinity, - height: MediaQuery.of(context).size.height / 2, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.only( - top: 16, - left: 16, - right: 16, - bottom: 8, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "已选商品", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/delete.png", - width: 22, - height: 22, - ), - ), - ], - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.only( - top: 8, - left: 16, - right: 16, - ), - child: ListView.builder( - itemCount: productLists == null ? 0 : productLists.length, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - // return shoppGoodsItem(); - return GestureDetector( - onTap: () {}, - child: shoppGoodsItem(productLists[position], position), - ); - }, - ), - ), - ), - Stack( - alignment: Alignment.bottomLeft, - children: [ - Container( - height: 54.h, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(8), - offset: Offset(0, -1), - blurRadius: 3, - spreadRadius: 0, - ), - ], - ), - child: Row( - children: [ - Spacer(), - Text( - S.of(context).heji, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, - ), - ), - Text( - "¥19.00", - style: TextStyle( - fontSize: 20.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF32A060), - ), - ), - Spacer(), - 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( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/shopp.png", - width: 88, - height: 88, - ), - ), - Positioned( - right: 15, - top: 14, - child: RoundButton( - width: 17, - height: 17, - text: "1", - textColor: Colors.white, - fontWeight: MyFontWeight.regular, - backgroup: Color(0xFF32A060), - fontSize: 12.sp, - radius: 100, - callback: () { - Navigator.of(context) - .pushNamed('/router/test_page'); - }, - ), - ), - ], - ), - ], - ), - ], - ), - ); + return ShopCar(productLists); }); }, ); } Widget shoppGoodsItem(ProductList pro, position) { - return Container( - padding: EdgeInsets.only(bottom: 10), - child: Row( - children: [ - Image.asset( - "assets/image/default_1.png", - width: 60, - height: 60, - fit: BoxFit.cover, - ), - SizedBox(width: 10), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "手工啵啵奶茶", - style: TextStyle( - color: Colors.black, - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - ), - ), - SizedBox(height: 2), - Row( - children: [ - Text( - "无香精", - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox(width: 10), - Text( - "无香精", - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - ), - ) - ], - ), - SizedBox(height: 6), - Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - "会员价", - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Text( - "¥19.00", - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ) - ], - ), - ], - ), - Spacer(), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/reduce.png", - width: 22, - height: 22, - ), - ), - Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text( - "1", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/add.png", - width: 22, - height: 22, - ), - ), - ], - ), - ], - ), - flex: 1, - ), - ], - ), - ); + return ShopGoods(pro, position); } @override @@ -711,8 +435,7 @@ class _Title extends State { if (alphaProgress <= 1) { alphatemp = 1; } else if (alphaProgress <= alphaHeight) { - alphatemp = - (((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0; + alphatemp = (((alphaHeight - alphaProgress) / alphaHeight) > 0.5) ? 1 : 0; } else { alphatemp = 0; } diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart new file mode 100644 index 00000000..516d6287 --- /dev/null +++ b/lib/store/store_view/product_sku.dart @@ -0,0 +1,293 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/store/store_view/store_order_list.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:huixiang/view_widget/round_button.dart'; + +class ProductSku extends StatefulWidget { + final ProductListBean productListBean; + + ProductSku(this.productListBean); + + @override + State<StatefulWidget> createState() { + return _ProductSku(); + } +} + +class _ProductSku extends State<ProductSku> { + List<testModel> temperatureStoreList = [ + testModel("正常冰"), + testModel("少冰"), + testModel("多冰"), + testModel("去冰") + ]; + List<testModel> sweetnessStoreList = [testModel("正常糖"), testModel("5分糖")]; + int isChoice = 0; + int tempClickIndex = 0; + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.topCenter, + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + ), + width: double.infinity, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MImage( + widget.productListBean.imgPath, + width: 70, + height: 70, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.productListBean.productName, + style: TextStyle( + color: Colors.black, + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, + ), + ), + Padding( + padding: EdgeInsets.only(top: 4, bottom: 7), + child: Text( + "已选:正常冰", + style: TextStyle( + color: Color(0xFF727272), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ), + Row( + children: [ + Text( + S.of(context).huiyuanjia, + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, + ), + ), + Text( + widget.productListBean.applyPrice, + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ) + ], + ), + ], + ), + Spacer(), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/icon_order_cancel.png", + width: 22, + height: 22, + ), + ), + ], + ), + SizedBox( + height: 23, + ), + Text( + "温度", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox( + height: 15, + ), + sweetnessStore( + () { + setState(() { + for (var i = 0; i < temperatureStoreList.length; i++) { + if (tempClickIndex == i) + temperatureStoreList[i].isSelected = true; + else + temperatureStoreList[i].isSelected = false; + } + }); + }, + temperatureStoreList, + ), + SizedBox( + height: 24, + ), + Text( + "甜度", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox( + height: 15, + ), + sweetnessStore( + () { + setState(() { + for (var i = 0; i < sweetnessStoreList.length; i++) { + if (tempClickIndex == i) + sweetnessStoreList[i].isSelected = true; + else + sweetnessStoreList[i].isSelected = false; + } + }); + }, + sweetnessStoreList, + ), + SizedBox( + height: 24, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Text( + "数量", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/reduce.png", + width: 22, + height: 22, + ), + ), + Padding( + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + widget.productListBean.buyNum.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/add.png", + width: 22, + height: 22, + ), + ), + ], + ), + SizedBox( + height: 24, + ), + GestureDetector( + onTap: () {}, + child: RoundButton( + width: double.infinity, + height: 54.h, + text: "加入购物车", + textColor: Colors.white, + fontWeight: MyFontWeight.semi_bold, + radius: 27, + backgroup: Color(0xFF32A060), + fontSize: 16.sp, + // padding: EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), + ); + } + + Widget sweetnessStore(Function fc, List<testModel> arrays) { + return GridView.builder( + itemCount: arrays.length, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + //一行的Widget数量 + crossAxisCount: 4, + //水平子Widget之间间距 + crossAxisSpacing: 6.w, + //垂直子Widget之间间距 + mainAxisSpacing: 12.w, + //垂直单个子Widget之间间距 + childAspectRatio: 3 / 1, + ), + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + tempClickIndex = index; + fc(); + }, + child: sweetnessItem(arrays[index].name, arrays[index].isSelected), + ); + }, + ); + } + + Widget sweetnessItem(String name, bool isCheck) { + return Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + RoundButton( + width: 68.w, + height: 29.h, + text: name, + textColor: !isCheck ? Color(0xFF727272) : Colors.white, + fontWeight: MyFontWeight.regular, + radius: 4, + backgroup: !isCheck ? Color(0xFFE5E5E5) : Color(0xFF32A060), + fontSize: 12.sp, + ), + ], + ), + ); + } +} diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart new file mode 100644 index 00000000..a33710d6 --- /dev/null +++ b/lib/store/store_view/shop_car.dart @@ -0,0 +1,179 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/order_info.dart'; +import 'package:huixiang/store/store_view/shop_goods.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/round_button.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ShopCar extends StatefulWidget { + + final List<ProductList> productLists; + + ShopCar(this.productLists); + + @override + State<StatefulWidget> createState() { + return _ShopCar(); + } + +} + +class _ShopCar extends State<ShopCar> { + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.topCenter, + width: double.infinity, + height: MediaQuery.of(context).size.height / 2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + topRight: Radius.circular(8), + ), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only( + top: 16, + left: 16, + right: 16, + bottom: 8, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "已选商品", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/delete.png", + width: 22, + height: 22, + ), + ), + ], + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.only( + top: 8, + left: 16, + right: 16, + ), + child: ListView.builder( + itemCount: widget.productLists == null ? 0 : widget.productLists.length, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + // return shoppGoodsItem(); + return GestureDetector( + onTap: () {}, + child: ShopGoods(widget.productLists[position], position), + ); + }, + ), + ), + ), + Stack( + alignment: Alignment.bottomLeft, + children: [ + Container( + height: 54.h, + decoration: BoxDecoration( + color: Color(0xFFFAFAFA), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(8), + offset: Offset(0, -1), + blurRadius: 3, + spreadRadius: 0, + ), + ], + ), + child: Row( + children: [ + Spacer(), + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + "¥19.00", + style: TextStyle( + fontSize: 20.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + Spacer(), + 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( + onTap: () { + Navigator.of(context).pop(); + }, + child: Image.asset( + "assets/image/shopp.png", + width: 88, + height: 88, + ), + ), + Positioned( + right: 15, + top: 14, + child: RoundButton( + width: 17, + height: 17, + text: "1", + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + fontSize: 12.sp, + radius: 100, + callback: () { + Navigator.of(context) + .pushNamed('/router/test_page'); + }, + ), + ), + ], + ), + ], + ), + ], + ), + ); + } + +} \ No newline at end of file diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart new file mode 100644 index 00000000..87c09ed8 --- /dev/null +++ b/lib/store/store_view/shop_goods.dart @@ -0,0 +1,138 @@ + + +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/order_info.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ShopGoods extends StatefulWidget { + + final ProductList pro; + final int position; + + ShopGoods(this.pro, this.position); + + @override + State<StatefulWidget> createState() { + return _ShopGoods(); + } + +} + +class _ShopGoods extends State<ShopGoods> { + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.only(bottom: 10), + child: Row( + children: [ + Image.asset( + "assets/image/default_1.png", + width: 60, + height: 60, + fit: BoxFit.cover, + ), + SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "手工啵啵奶茶", + style: TextStyle( + color: Colors.black, + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + ), + ), + SizedBox(height: 2), + Row( + children: [ + Text( + "无香精", + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox(width: 10), + Text( + "无香精", + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 11.sp, + fontWeight: MyFontWeight.regular, + ), + ) + ], + ), + SizedBox(height: 6), + Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + "会员价", + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 13.sp, + fontWeight: MyFontWeight.medium, + ), + ), + Text( + "¥19.00", + style: TextStyle( + color: Color(0xFFFF7A1A), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ) + ], + ), + ], + ), + Spacer(), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/reduce.png", + width: 22, + height: 22, + ), + ), + Padding( + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + "1", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () {}, + child: Image.asset( + "assets/image/add.png", + width: 22, + height: 22, + ), + ), + ], + ), + ], + ), + flex: 1, + ), + ], + ), + ); + } + +} \ No newline at end of file diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 5df93c1f..bd6c05e0 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -7,6 +7,7 @@ import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/store/store_view/product_sku.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; @@ -43,16 +44,8 @@ class testModel { } class _StoreOrderListPage extends State<StoreOrderListPage> { - List<testModel> temperatureStoreList = [ - testModel("正常冰"), - testModel("少冰"), - testModel("多冰"), - testModel("去冰") - ]; - List<testModel> sweetnessStoreList = [testModel("正常糖"), testModel("5分糖")]; + int isSelected = 0; - int isChoice = 0; - int tempClickIndex = 0; ApiService apiService; MinApiService minService; List<FindMiNiGroupList> appletProducts; @@ -83,10 +76,12 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { Map<String, dynamic> minStoreInfo = baseData.data; String minToken = minStoreInfo["token"]; String tenant = widget.arguments["tenant"]; - SharedPreferences.getInstance().then((value) => { - value.setString('minToken', minToken), - value.setString('tenant', tenant), - }); + SharedPreferences.getInstance().then( + (value) => { + value.setString('minToken', minToken), + value.setString('tenant', tenant), + }, + ); minService = MinApiService( Dio(), context: context, @@ -101,12 +96,11 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ///小程序查询分组及商品列表 appletGoods() async { BaseData<List<FindMiNiGroupList>> baseData = - await minService.findMiNiGroupList({ - "id": widget.arguments["id"] - }, { - "store_id": widget.arguments["id"], - "tenant": widget.arguments["tenant"], - }); + await minService.findMiNiGroupList( + { + "id": widget.arguments["id"], + }, + ); if (baseData != null && baseData.isSuccess) { setState(() { appletProducts = baseData.data; @@ -133,6 +127,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { child: ListView.builder( itemCount: appletProducts == null ? 0 : appletProducts.length, controller: controller1, + physics: BouncingScrollPhysics(), padding: EdgeInsets.only(top: 0, bottom: 25), itemBuilder: (context, position) { return orderItem(appletProducts[position], position); @@ -143,7 +138,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { width: MediaQuery.of(context).size.width - 100.w, child: ListView.builder( itemCount: productListBeans == null ? 0 : productListBeans.length, - // controller: widget.controller, + physics: BouncingScrollPhysics(), padding: EdgeInsets.zero, itemBuilder: (context, position) { return goodsItem(productListBeans[position], position); @@ -208,10 +203,12 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { errorSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png", ), - SizedBox(width: 10), + SizedBox( + width: 10, + ), Expanded( child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( productListBean.productName, @@ -221,7 +218,9 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { fontWeight: MyFontWeight.medium, ), ), - SizedBox(height: 2), + SizedBox( + height: 2, + ), Row( children: [ Expanded( @@ -236,10 +235,14 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ), ), ), - SizedBox(width: 10), + SizedBox( + width: 10, + ), ], ), - SizedBox(height: 7), + SizedBox( + height: 7, + ), Row( children: [ Column( @@ -255,8 +258,11 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { fontWeight: MyFontWeight.medium, ), ), + SizedBox( + width: 4, + ), Text( - productListBean.price, + "¥${productListBean.price}", style: TextStyle( color: Color(0xFFFF7A1A), fontSize: 11.sp, @@ -275,9 +281,11 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { fontWeight: MyFontWeight.regular, ), ), - SizedBox(width: 10), + SizedBox( + width: 4, + ), Text( - productListBean.applyPrice, + "¥${productListBean.applyPrice}", style: TextStyle( color: Color(0xFFA29E9E), fontSize: 10.sp, @@ -355,252 +363,10 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { backgroundColor: Colors.transparent, builder: (context) { return StatefulBuilder(builder: (context1, state) { - return Container( - alignment: Alignment.topCenter, - padding: EdgeInsets.only(top: 16, left: 16, right: 16), - width: double.infinity, - decoration: BoxDecoration( - color: Color(0xFFFAFAFA), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - topRight: Radius.circular(8), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MImage( - productListBean.imgPath, - width: 70, - height: 70, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.png", - fadeSrc: "assets/image/default_1.png", - ), - SizedBox(width: 10), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - productListBean.productName, - style: TextStyle( - color: Colors.black, - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Padding( - padding: EdgeInsets.only(top: 4, bottom: 7), - child: Text( - "已选:正常冰", - style: TextStyle( - color: Color(0xFF727272), - fontSize: 11.sp, - fontWeight: MyFontWeight.regular, - ), - ), - ), - Row( - children: [ - Text( - S.of(context).huiyuanjia, - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 13.sp, - fontWeight: MyFontWeight.medium, - ), - ), - Text( - productListBean.applyPrice, - style: TextStyle( - color: Color(0xFFFF7A1A), - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ) - ], - ), - ], - ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Image.asset( - "assets/image/icon_order_cancel.png", - width: 22, - height: 22, - ), - ), - ], - ), - SizedBox( - height: 23, - ), - Text( - "温度", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox( - height: 15, - ), - sweetnessStore(() { - state(() { - for (var i = 0; i < temperatureStoreList.length; i++) { - if (tempClickIndex == i) - temperatureStoreList[i].isSelected = true; - else - temperatureStoreList[i].isSelected = false; - } - }); - }, temperatureStoreList), - SizedBox( - height: 24, - ), - Text( - "甜度", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - ), - SizedBox( - height: 15, - ), - sweetnessStore(() { - state(() { - for (var i = 0; i < sweetnessStoreList.length; i++) { - if (tempClickIndex == i) - sweetnessStoreList[i].isSelected = true; - else - sweetnessStoreList[i].isSelected = false; - } - }); - }, sweetnessStoreList), - SizedBox( - height: 24, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Text( - "数量", - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - ), - )), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/reduce.png", - width: 22, - height: 22, - ), - ), - Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text( - productListBean.buyNum.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 14.sp, - fontWeight: MyFontWeight.medium, - ), - ), - ), - InkWell( - onTap: () {}, - child: Image.asset( - "assets/image/add.png", - width: 22, - height: 22, - ), - ), - ], - ), - SizedBox( - height: 24, - ), - GestureDetector( - onTap: (){}, - child: RoundButton( - width: double.infinity, - height: 54.h, - text: "加入购物车", - textColor: Colors.white, - fontWeight: MyFontWeight.semi_bold, - radius: 27, - backgroup: Color(0xFF32A060), - fontSize: 16.sp, - // padding: EdgeInsets.symmetric(vertical: 5.h), - ), - ), - ], - ), - ); + return ProductSku(productListBean); }); }, ); } - Widget sweetnessStore(Function fc, List<testModel> arrays) { - return GridView.builder( - itemCount: arrays.length, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - //一行的Widget数量 - crossAxisCount: 4, - //水平子Widget之间间距 - crossAxisSpacing: 6.w, - //垂直子Widget之间间距 - mainAxisSpacing: 12.w, - //垂直单个子Widget之间间距 - childAspectRatio: 3 / 1), - itemBuilder: (contetx, index) { - return GestureDetector( - onTap: () { - tempClickIndex = index; - fc(); - }, - child: sweetnessItem(arrays[index].name, arrays[index].isSelected), - ); - }, - ); - } - - Widget sweetnessItem(String name, bool isCheck) { - return Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - RoundButton( - width: 68.w, - height: 29.h, - text: name, - textColor: !isCheck ? Color(0xFF727272) : Colors.white, - fontWeight: MyFontWeight.regular, - radius: 4, - backgroup: !isCheck ? Color(0xFFE5E5E5) : Color(0xFF32A060), - fontSize: 12.sp, - ), - ], - ), - ); - } } diff --git a/lib/union/union_details_page.dart b/lib/union/union_details_page.dart index 9846ed31..0dd1def7 100644 --- a/lib/union/union_details_page.dart +++ b/lib/union/union_details_page.dart @@ -204,10 +204,10 @@ class _UnionDetailsPage extends State<UnionDetailsPage> { printMin() async { String miniAppId = storeInfo.mini.miniAppId; - debugPrint("print isExistsApp: ${await Min.isExistsApp(miniAppId)}"); + debugPrint("print isExistsApp: ${await Min.isExistsApp(miniAppId)}"); debugPrint("print getAppBasePath: ${await Min.getAppBasePath(miniAppId)}"); debugPrint("print currentPageUrl: ${await Min.currentPageUrl()}"); - debugPrint("print runingAppid: ${await Min.runingAppid()}"); + debugPrint("print runingAppid: ${await Min.runingAppid()}"); } _loginMin() async {