From 8cd428fd63e0ab253ce93cb961108960f4dc54c2 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 11 Oct 2021 16:49:15 +0800 Subject: [PATCH] safety --- lib/store/store_order.dart | 92 ++++-- lib/store/store_view/store_order_list.dart | 76 ++--- lib/union/union_view/store_info.dart | 338 ++++++++++----------- 3 files changed, 280 insertions(+), 226 deletions(-) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 7d4d4566..464cad3d 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -3,9 +3,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/activity.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/retrofit/data/user_entity.dart'; @@ -26,12 +28,8 @@ import 'package:shared_preferences/shared_preferences.dart'; class StoreOrderPage extends StatefulWidget { final Map arguments; - final List activitys; - final StoreInfo storeInfo; - final List productList; - - StoreOrderPage({this.arguments, this.activitys, this.storeInfo,this.productList}); + StoreOrderPage({this.arguments}); @override State createState() { @@ -40,11 +38,12 @@ class StoreOrderPage extends StatefulWidget { } class _StoreOrderPage extends State - with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin */ { + with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { TabController tabcontroller; ApiService apiService; MinApiService minService; StoreInfo storeInfo; + List activitys; RefreshController refreshController; List _widgetOptions; @@ -62,12 +61,16 @@ class _StoreOrderPage extends State _widgetOptions = [ StoreOrderListPage( - widget.arguments, widget.activitys, storeInfo, controller), + widget.arguments, + activitys, + storeInfo, + controller, + ), ///星店活动, StoreActivity( widget.arguments, - widget.activitys, + activitys, ), ]; @@ -82,7 +85,6 @@ class _StoreOrderPage extends State context: context, token: value.getString('token'), ); - BaseData baseData = await apiService .queryStoreInfo(widget.arguments["id"]) .catchError((error) { @@ -91,6 +93,9 @@ class _StoreOrderPage extends State if (baseData != null && baseData.isSuccess) { refreshController.refreshCompleted(); storeInfo = StoreInfo.fromJson(baseData.data); + activitys = storeInfo.informationVOPageVO.list + .map((e) => Activity.fromJson(e)) + .toList(); if (mounted) { setState(() {}); } @@ -127,7 +132,8 @@ class _StoreOrderPage extends State (BuildContext context, bool innerBoxIsScrolled) { return [ SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), sliver: SliverAppBar( expandedHeight: (storeInfo != null && storeInfo.couponVOList != null) @@ -168,12 +174,13 @@ class _StoreOrderPage extends State Positioned( child: Column( children: [ - Image.asset( - "assets/image/share_image_bg.png", - fit: BoxFit.cover, - width: MediaQuery.of(context).size.width, - height: 180.h, - ), + // 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, @@ -360,6 +367,45 @@ class _StoreOrderPage extends State ); } + Widget buildSwiper() { + return Container( + width: double.infinity, + height: 180.h, + child: Swiper( + pagination: SwiperPagination( + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8.w, + activeSize: 8.w, + space: 5.w, + activeColor: Colors.white, + color: Colors.white.withAlpha(76), + ), + ), + itemBuilder: (context, position) { + return Container( + margin: EdgeInsets.only(left: 10.w, right: 10.w), + child: MImage( + (storeInfo != null && + storeInfo.bannerList != null && + position < storeInfo.bannerList.length) + ? storeInfo.bannerList[position].imgUrl + : "", + fit: BoxFit.cover, + radius: BorderRadius.circular(4), + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + ); + }, + itemCount: (storeInfo != null && storeInfo.bannerList != null) + ? storeInfo.bannerList.length + : 1), + ); + } + + List productLists = []; + ///购物车弹窗 showShoppingCart() { showModalBottomSheet( @@ -420,14 +466,13 @@ class _StoreOrderPage extends State right: 16, ), child: ListView.builder( - itemCount: widget.productList == null ? 0 : widget.productList.length, + itemCount: productLists == null ? 0 : productLists.length, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { // return shoppGoodsItem(); return GestureDetector( - onTap: () { - }, - child: shoppGoodsItem(widget.productList[position], position), + onTap: () {}, + child: shoppGoodsItem(productLists[position], position), ); }, ), @@ -638,8 +683,8 @@ class _StoreOrderPage extends State ); } -// @override -// bool get wantKeepAlive => true; + @override + bool get wantKeepAlive => true; } class Title extends StatefulWidget { @@ -669,7 +714,8 @@ 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/store_order_list.dart b/lib/store/store_view/store_order_list.dart index b1d9f1e9..8ccca1f5 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -25,7 +25,11 @@ class StoreOrderListPage extends StatefulWidget { final ScrollController controller; StoreOrderListPage( - this.arguments, this.activitys, this.storeInfo, this.controller); + this.arguments, + this.activitys, + this.storeInfo, + this.controller, + ); @override State<StatefulWidget> createState() { @@ -76,16 +80,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { context: context, token: value.getString('token'), ); - apiService.minLogin(widget.arguments["id"]) - .catchError((onError){}).then((baseData) { + apiService + .minLogin(widget.arguments["id"]) + .catchError((onError) {}) + .then((baseData) { if (baseData != null && baseData.isSuccess) { 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), - }); + value.setString('minToken', minToken), + value.setString('tenant', tenant), + }); minService = MinApiService( Dio(), context: context, @@ -98,17 +104,14 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { } ///小程序查询分组及商品列表 - appletGoods() async{ - BaseData<List<FindMiNiGroupList>> baseData = await minService.findMiNiGroupList({ - "id":widget.arguments["id"] - },{ - "store_id":widget.arguments["id"], - "tenant":"1175" - }); + appletGoods() async { + BaseData<List<FindMiNiGroupList>> baseData = await minService + .findMiNiGroupList({"id": widget.arguments["id"]}, + {"store_id": widget.arguments["id"], "tenant": "1175"}); if (baseData != null && baseData.isSuccess) { setState(() { appletProducts = baseData.data; - if(appletProducts.length > 0) + if (appletProducts.length > 0) productListBeans = appletProducts[0].productList; }); } @@ -119,7 +122,8 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { return Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height - (kToolbarHeight + 38 + 54.h), - margin: EdgeInsets.only(top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight)), + margin: EdgeInsets.only( + top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight)), child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, @@ -131,7 +135,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { controller: controller1, padding: EdgeInsets.zero, itemBuilder: (context, position) { - return orderItem(appletProducts[position],position); + return orderItem(appletProducts[position], position); }, ), ), @@ -154,14 +158,14 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ScrollController controller1 = ScrollController(); ScrollController controller2 = ScrollController(); - Widget orderItem(FindMiNiGroupList findMiNiGroupList,int index) { + Widget orderItem(FindMiNiGroupList findMiNiGroupList, int index) { return Container( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: [ GestureDetector( - onTap:() { + onTap: () { setState(() { isSelected = index; productListBeans = findMiNiGroupList.productList; @@ -189,17 +193,17 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ); } - Widget goodsItem(ProductListBean productListBean,position) { + Widget goodsItem(ProductListBean productListBean, position) { return Container( color: Colors.white, - padding: EdgeInsets.only(right: 16.w, bottom: 10.h,top:10.h), + padding: EdgeInsets.only(right: 16.w, bottom: 10.h, top: 10.h), child: Row( children: [ SizedBox(width: 12.w), - MImage( + MImage( productListBean != null ? productListBean.imgPath : "", width: 70, - height:70, + height: 70, fit: BoxFit.cover, errorSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png", @@ -220,17 +224,18 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { SizedBox(height: 2), Row( children: [ - Expanded(child: Text( - productListBean.shortName, - overflow: TextOverflow.ellipsis, - maxLines: 2, - style: TextStyle( - color: Color(0xFF4C4C4C), - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, + Expanded( + child: Text( + productListBean.shortName, + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + color: Color(0xFF4C4C4C), + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + ), ), - ), ), - + ), SizedBox(width: 10), ], ), @@ -272,7 +277,7 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ), SizedBox(width: 10), Text( - productListBean.price, + productListBean.price, style: TextStyle( color: Color(0xFFA29E9E), fontSize: 10.sp, @@ -339,6 +344,10 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ); } + List<ProductListBean> shopCarList() { + return productListBeans; + } + ///选规格弹窗 showStoreSelector() { showModalBottomSheet( @@ -591,5 +600,4 @@ class _StoreOrderListPage extends State<StoreOrderListPage> { ), ); } - } diff --git a/lib/union/union_view/store_info.dart b/lib/union/union_view/store_info.dart index 9b222f7c..b193b4ba 100644 --- a/lib/union/union_view/store_info.dart +++ b/lib/union/union_view/store_info.dart @@ -177,175 +177,175 @@ class _StoreInfos extends State<StoreInfos> { ], ), ); - return AspectRatio( - aspectRatio: 1, - child: Container( - margin: EdgeInsets.fromLTRB(16, 20, 16, 8), - padding: EdgeInsets.fromLTRB(10, 20, 10, 14), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(25), - offset: Offset(0, 1), - blurRadius: 12, - spreadRadius: 0, - ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AspectRatio( - aspectRatio: 1.8, - child: buildSwiper(), - ), - Expanded( - child: Container( - margin: EdgeInsets.only( - left: 10.w, - right: 10.w, - top: 16.h, - ), - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - child: Container( - alignment: - Alignment.centerLeft, - child: Text( - widget.storeInfo != null - ? widget.storeInfo.storeName - : "", - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - color: Colors.black, - fontWeight: MyFontWeight.medium, - ), - ), - ), - ), - Text( - S.of(context).ren( - widget.storeInfo != null - ? widget.storeInfo - .perCapitaConsumption - : "", - ), - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF353535), - ), - ), - ], - ), - Text( - widget.storeInfo != null - ? widget.storeInfo.address - : "", - maxLines: 2, - textAlign: TextAlign.justify, - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - Row( - children: itemServer( - widget.storeInfo != null - ? widget.storeInfo.businessService - : "", - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: Text( - S.of(context).yingyeshijian(widget.storeInfo == - null - ? "" - : (widget.storeInfo.openStartTime == - null && - widget.storeInfo - .openEndTime == - null) - ? S.of(context).quantian - : "${widget.storeInfo.openStartTime.substring(0, widget.storeInfo.openStartTime.lastIndexOf(":"))} " - "- ${widget.storeInfo.openEndTime.substring(0, widget.storeInfo.openEndTime.lastIndexOf(":"))}"), - style: TextStyle( - color: Color(0xFF353535), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), - ), - ), - SizedBox( - width: 16.w, - ), - InkWell( - onTap: () { - if (widget.storeInfo == null || - widget.storeInfo.latitude == - null || - widget.storeInfo.longitude == - null || - widget.storeInfo.latitude == "" || - widget.storeInfo.longitude == "") - return; - Navigator.of(context).pushNamed( - '/router/location_map', - arguments: { - "lat": widget.storeInfo.latitude, - "lng": - widget.storeInfo.longitude, - "storeName": - widget.storeInfo.storeName, - }); - }, - child: Image.asset( - "assets/image/icon_union_location.png", - width: 24.w, - height: 24.h, - ), - ), - SizedBox( - width: 16.w, - ), - InkWell( - onTap: () { - showCallMobile(); - }, - child: Image.asset( - "assets/image/icon_union_call.png", - width: 24, - height: 24, - ), - ), - ], - ), - ], - ), - ), - flex: 1, - ), - ], - ), - ), - ); + // return AspectRatio( + // aspectRatio: 1, + // child: Container( + // margin: EdgeInsets.fromLTRB(16, 20, 16, 8), + // padding: EdgeInsets.fromLTRB(10, 20, 10, 14), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(8), + // boxShadow: [ + // BoxShadow( + // color: Colors.black.withAlpha(25), + // offset: Offset(0, 1), + // blurRadius: 12, + // spreadRadius: 0, + // ), + // ], + // ), + // child: Column( + // mainAxisAlignment: MainAxisAlignment.spaceAround, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // AspectRatio( + // aspectRatio: 1.8, + // child: buildSwiper(), + // ), + // Expanded( + // child: Container( + // margin: EdgeInsets.only( + // left: 10.w, + // right: 10.w, + // top: 16.h, + // ), + // child: Column( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // Row( + // children: [ + // Expanded( + // child: Container( + // alignment: + // Alignment.centerLeft, + // child: Text( + // widget.storeInfo != null + // ? widget.storeInfo.storeName + // : "", + // overflow: TextOverflow.ellipsis, + // style: TextStyle( + // fontSize: 16.sp, + // color: Colors.black, + // fontWeight: MyFontWeight.medium, + // ), + // ), + // ), + // ), + // Text( + // S.of(context).ren( + // widget.storeInfo != null + // ? widget.storeInfo + // .perCapitaConsumption + // : "", + // ), + // overflow: TextOverflow.ellipsis, + // style: TextStyle( + // fontSize: 14.sp, + // fontWeight: MyFontWeight.regular, + // color: Color(0xFF353535), + // ), + // ), + // ], + // ), + // Text( + // widget.storeInfo != null + // ? widget.storeInfo.address + // : "", + // maxLines: 2, + // textAlign: TextAlign.justify, + // style: TextStyle( + // color: Color(0xFF353535), + // fontWeight: MyFontWeight.regular, + // fontSize: 12.sp, + // ), + // ), + // Row( + // children: itemServer( + // widget.storeInfo != null + // ? widget.storeInfo.businessService + // : "", + // ), + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.end, + // children: [ + // Expanded( + // child: Text( + // S.of(context).yingyeshijian(widget.storeInfo == + // null + // ? "" + // : (widget.storeInfo.openStartTime == + // null && + // widget.storeInfo + // .openEndTime == + // null) + // ? S.of(context).quantian + // : "${widget.storeInfo.openStartTime.substring(0, widget.storeInfo.openStartTime.lastIndexOf(":"))} " + // "- ${widget.storeInfo.openEndTime.substring(0, widget.storeInfo.openEndTime.lastIndexOf(":"))}"), + // style: TextStyle( + // color: Color(0xFF353535), + // fontWeight: MyFontWeight.regular, + // fontSize: 12.sp, + // ), + // ), + // ), + // SizedBox( + // width: 16.w, + // ), + // InkWell( + // onTap: () { + // if (widget.storeInfo == null || + // widget.storeInfo.latitude == + // null || + // widget.storeInfo.longitude == + // null || + // widget.storeInfo.latitude == "" || + // widget.storeInfo.longitude == "") + // return; + // Navigator.of(context).pushNamed( + // '/router/location_map', + // arguments: { + // "lat": widget.storeInfo.latitude, + // "lng": + // widget.storeInfo.longitude, + // "storeName": + // widget.storeInfo.storeName, + // }); + // }, + // child: Image.asset( + // "assets/image/icon_union_location.png", + // width: 24.w, + // height: 24.h, + // ), + // ), + // SizedBox( + // width: 16.w, + // ), + // InkWell( + // onTap: () { + // showCallMobile(); + // }, + // child: Image.asset( + // "assets/image/icon_union_call.png", + // width: 24, + // height: 24, + // ), + // ), + // ], + // ), + // ], + // ), + // ), + // flex: 1, + // ), + // ], + // ), + // ), + // ); } Widget buildSwiper() {