diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index e4cacff3..3051a971 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -100,7 +100,7 @@ class _CommunityDetails extends State void initState() { super.initState(); // comunity = widget.arguments["comment"]; - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); businessId = widget.arguments["businessId"]; WidgetsBinding.instance.addObserver(this); commentFocus.addListener(_focusNodeListener); @@ -399,7 +399,7 @@ class _CommunityDetails extends State ///评论列表 _queryMemberCommentList(bool isOnRefresh) async { - if (!isOnRefresh) EasyLoading.show(status: S.current.zhengzaijiazai); + if (!isOnRefresh) EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); if (apiService == null) apiService = ApiService( diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 1730b133..f4b816fc 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -8,7 +8,6 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/home/home_view/discount_zone.dart'; -import 'package:huixiang/home/home_view/home_banner.dart'; import 'package:huixiang/home/home_view/home_recommend_goods.dart'; import 'package:huixiang/home/home_view/top_selling_list.dart'; import 'package:huixiang/home/home_view/union_entry.dart'; @@ -27,7 +26,6 @@ import 'package:huixiang/retrofit/data/goods.dart'; import 'package:huixiang/retrofit/data/goods_category.dart'; import 'package:huixiang/retrofit/data/home_rank.dart'; import 'package:huixiang/retrofit/data/login_info.dart'; -import 'package:huixiang/retrofit/data/msg_stats.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/event_type.dart'; @@ -42,8 +40,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../retrofit/data/user_info.dart'; -import '../utils/flutter_utils.dart'; import '../view_widget/channel_dialog.dart'; +import '../view_widget/custom_image.dart'; import 'home_view/happy_help_farmers.dart'; import 'home_view/shortcut_operation.dart'; @@ -54,7 +52,8 @@ class HomePage extends StatefulWidget { final List firstLoginCouponList; HomePage(Key key, this.changeTab, - {this.invite, this.interviewCouponList, this.firstLoginCouponList}): super(key: key); + {this.invite, this.interviewCouponList, this.firstLoginCouponList}) + : super(key: key); @override State createState() { @@ -64,6 +63,30 @@ class HomePage extends StatefulWidget { class HomePageState extends State with AutomaticKeepAliveClientMixin { ApiService apiService; + final RefreshController refreshController = RefreshController(); + String categoryId; + bool showInvite = false; + bool showNew = false; + + //排序类型枚举:1-自然排序,2-销量,3-价格 + int orderType = 1; + + //是否降序排列 + bool orderDesc = true; + List goods = []; + List gooodsCategorys = []; + List bannerData = []; + List brandData = []; + List
articles = []; + Founder founder; + bool isSigned = false; + int totalMsg = 0; + List coupons = []; + int state = 1; + HomeRank homeRank; + UserInfo userInfo; + dynamic mRaiseMoney = 0; //众筹金余额 + int _loadCount = 0; @override void initState() { @@ -74,8 +97,11 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { setState(() {}); } }); - queryActivity(); - _onRefresh(); + _onRefresh(isFirstIn: true); + if (showInvite) { + inviteShowAlertDialog(widget.invite, widget.interviewCouponList[0]); + showInvite = false; + } if ((widget.invite ?? "") != "" || widget.interviewCouponList != null && @@ -84,7 +110,6 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { //判断新人弹窗 // if (widget.firstLoginCouponList != null && widget.firstLoginCouponList.length > 0) // showNew = true; - } ///邀请成功 @@ -99,18 +124,21 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { } ///活动海报弹窗 - posterShowAlertDialog(ActivityPos activityPos,firstLoginCouponList) { + posterShowAlertDialog(ActivityPos activityPos, firstLoginCouponList) { var today = DateTime.now().day; SharedPreferences.getInstance().then((value) { - if(value.getInt("today")==today && (value.getString("ActivityPosCode") ?? "").contains("${activityPos.code}_${value.getString("userId")};")) + if (value.getInt("today") == today && + (value.getString("ActivityPosCode") ?? "") + .contains("${activityPos.code}_${value.getString("userId")};")) return; - value.setString("ActivityPosCode", "${(value.getString("ActivityPosCode")??"")}${activityPos.code}_${value.getString("userId")};"); + value.setString("ActivityPosCode", + "${(value.getString("ActivityPosCode") ?? "")}${activityPos.code}_${value.getString("userId")};"); value.setInt("today", today); //显示对话框 showDialog( context: context, builder: (BuildContext context) { - return ActivityPoster(activityPos,firstLoginCouponList); + return ActivityPoster(activityPos, firstLoginCouponList); }, ); }); @@ -127,178 +155,111 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { ); } - final SwiperController controller = SwiperController(); - - String categoryId; - int pageNum = 1; - int couponPageNum = 1; - bool showInvite = false; - bool showNew = false; - - //排序类型枚举:1-自然排序,2-销量,3-价格 - int orderType = 1; - - //是否降序排列 - bool orderDesc = true; - List goods = []; - List gooodsCategorys = []; - - List bannerData = []; - List brandData = []; - List
articles = []; - List gooods = []; - Founder founder; - bool isSigned = false; - int totalMsg = 0; - List coupons = []; - int state = 1; - HomeRank homeRank; - UserInfo userInfo; - dynamic mRaiseMoney = 0;//众筹金余额 - - queryHome() async { - // EasyLoading.show(status: S.of(context).zhengzaijiazai); - - final SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService(Dio(), - context: context, token: value.getString('token'), showLoading: false); - - final BaseData brand = - await apiService.queryHomeBrand().catchError((onError) { - SmartDialog.showToast(AppUtils.dioErrorTypeToString(onError.type), - alignment: Alignment.center); - refreshController.refreshFailed(); - }); - if (brand != null && brand.isSuccess) { - brandData.clear(); - brandData.addAll((brand.data["brandList"] as List) - .map((e) => Brand.fromJson(e)) - .toList()); - founder = Founder.fromJson(brand.data["founder"]); - } - - final BaseData> article = await apiService.queryArticle({ - "pageNum": 1, - "pageSize": 3, - "searchKey": "", - "state": 1, - "type": 2 - }).catchError((onError) { - refreshController.refreshFailed(); - }); - articles.clear(); - if (article != null && article.isSuccess) { - articles.addAll(article.data.list); + ///头部banner + queryBanner() async { + try { + BaseData> baseData = await apiService.queryBanner({ + "model": {"type": "HOME_PAGE"}, + }).catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + bannerData = baseData.data.records; + // if (bannerData.length > 0) swiperController.move(0, animation: false); + } + } finally { + addLoadCount(); } + } - final BaseData rank = await apiService.recommendRank().catchError((onError) {}); - if (rank != null && rank.isSuccess) { - homeRank = rank.data; + addLoadCount() { + _loadCount += 1; + if (_loadCount == 6) { + _loadCount = 0; + EasyLoading.dismiss(); + if (refreshController.isRefresh) refreshController.refreshCompleted(); + if (mounted) setState(() {}); } + } - final BaseData> goodsData = await apiService.creditGoods({ - "orderDesc": true, - "orderType": 1, - "pageNum": 1, - "pageSize": 100, - "state": 1 - }).catchError((onError) { - refreshController.refreshFailed(); - }); - if (goodsData != null && goodsData.isSuccess) { - gooods.clear(); - gooods.addAll(goodsData.data.list); + ///推荐排行 + queryRecommendRank() async { + try { + BaseData rank = + await apiService.recommendRank().catchError((onError) {}); + if (rank != null && rank.isSuccess) { + homeRank = rank.data; + } + } finally { + addLoadCount(); } + } - BaseData> dataCategory = - await apiService.goodsCategory({ - "current": 1, - "map": {}, - "model": {"pageNum": 1, "pageSize": 20, "searchKey": ""}, - "order": "descending", - "size": 20, - "sort": "sortOrder" - }).catchError((onError) { - refreshController.loadFailed(); - refreshController.refreshFailed(); - }); - - if (dataCategory != null && - dataCategory.isSuccess && - dataCategory.data != null && - dataCategory.data.records != null && - dataCategory.data.records.length > 0) { - gooodsCategorys.clear(); - gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu)); - gooodsCategorys.addAll(dataCategory.data.records); + ///积分商城商品分類列表 + queryGoodsCategory() async { + try { + BaseData> dataCategory = + await apiService.goodsCategory({ + "current": 1, + "map": {}, + "model": {"pageNum": 1, "pageSize": 20, "searchKey": ""}, + "order": "descending", + "size": 20, + "sort": "sortOrder" + }).catchError((onError) {}); + if (dataCategory != null && + dataCategory.isSuccess && + dataCategory.data != null && + dataCategory.data.records != null && + dataCategory.data.records.length > 0) { + gooodsCategorys.clear(); + gooodsCategorys.add(GoodsCategory(name: S.of(context).quanbu)); + gooodsCategorys.addAll(dataCategory.data.records); + } + } finally { + addLoadCount(); } + } - var param = { - "categoryId": categoryId ?? "", - "orderDesc": orderDesc, - "orderType": orderType, - "pageNum": pageNum, - "pageSize": 100, - "state": 1 - }; - BaseData> pageGoods = - await apiService.creditGoods(param).catchError((onError) { - refreshController.loadFailed(); - refreshController.refreshFailed(); - }); - EasyLoading.dismiss(); - if (pageGoods != null && pageGoods.isSuccess) { - if (pageNum == 1) { - goods.clear(); + ///积分商城商品列表 + queryPointsProductList(bool isRefresh) async { + try { + if (!isRefresh) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + var param = { + "categoryId": categoryId ?? "", + "orderDesc": orderDesc, + "orderType": orderType, + "pageNum": 1, + "pageSize": 100, + "state": 1 + }; + BaseData> pageGoods = + await apiService.creditGoods(param).catchError((onError) {}); + if (pageGoods != null && pageGoods.isSuccess) { + goods = pageGoods.data.list; } - goods.addAll(pageGoods.data.list); - refreshController.refreshCompleted(); - refreshController.loadComplete(); - if (pageGoods.data.pageNum == pageGoods.data.pages) { - refreshController.loadNoData(); - } else { - pageNum += 1; + } finally { + if(isRefresh) + addLoadCount(); + else { + EasyLoading.dismiss(); + setState((){}); } - } else { - refreshController.loadFailed(); - refreshController.refreshFailed(); - } - - final BaseData> baseData = - await apiService.queryBanner({ - "model": {"type": "HOME_PAGE"}, - }).catchError((onError) { - refreshController.refreshFailed(); - }); - if (baseData != null && baseData.isSuccess) { - bannerData.clear(); - bannerData.addAll(baseData.data.records); - refreshController.refreshCompleted(); - if (bannerData.length > 0) controller.move(0, animation: false); - } else { - refreshController.refreshFailed(); } - EasyLoading.dismiss(); - if (showInvite) { - inviteShowAlertDialog(widget.invite, widget.interviewCouponList[0]); - showInvite = false; - } - - //判断新人弹窗 - // if (showNew) { - // newShowAlertDialog(widget.firstLoginCouponList); - // showNew = false; - // } } ///查询会员信息 queryUserBalance() async { - BaseData baseData = - await apiService.queryInfo().catchError((onError) {}); - if (baseData != null && baseData.isSuccess) { - userInfo = baseData.data; - mRaiseMoney = double.tryParse(userInfo.raiseMoney); - if (mounted) setState(() {}); + try { + BaseData baseData = + await apiService.queryInfo().catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + userInfo = baseData.data; + mRaiseMoney = double.tryParse(userInfo.raiseMoney); + } + } finally { + addLoadCount(); } } @@ -326,35 +287,18 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { ///活动弹窗 queryActivity() async { - if (apiService == null) { - SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - showLoading: true - ); - } BaseData baseData = - await apiService.appPopup().catchError((onError) { - }); + await apiService.appPopup().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { - if(baseData.data?.enabled ?? true) - posterShowAlertDialog(baseData.data,widget.firstLoginCouponList); + if (baseData.data?.enabled ?? true) + posterShowAlertDialog(baseData.data, widget.firstLoginCouponList); } } ///核销用户优惠券 queryWiped(memberCouponId) async { - if (apiService == null) { - SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService( - Dio(), - context: context, - token: value.getString("token"), - ); - } - BaseData baseData = await apiService.wiped(memberCouponId).catchError((onError) {}); + BaseData baseData = + await apiService.wiped(memberCouponId).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { SmartDialog.showToast("核销成功", alignment: Alignment.center); } else { @@ -363,6 +307,25 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { } queryCoupon() async { + try { + BaseData> baseData = await apiService.queryCoupon({ + "centre": true, + "pageNum": 1, + "pageSize": 10, + "searchKey": "", + "state": 0 + }).catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + coupons = baseData.data.list; + } + } finally { + addLoadCount(); + } + } + + _onRefresh({bool isFirstIn = false}) async { + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); if (apiService == null) { SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService( @@ -371,39 +334,14 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { token: value.getString("token"), ); } - BaseData> baseData = await apiService.queryCoupon({ - "centre": true, - "pageNum": couponPageNum, - "pageSize": 10, - "searchKey": "", - "state": 0 - }).catchError((onError) { - refreshController.refreshFailed(); - refreshController.loadFailed(); - }); - if (couponPageNum == 1) coupons.clear(); - if (baseData != null && baseData.isSuccess) { - coupons.addAll(baseData.data.list); - refreshController.refreshCompleted(); - refreshController.loadComplete(); - if (baseData.data.pageNum == baseData.data.pages) { - refreshController.loadNoData(); - } else { - couponPageNum += 1; - } - setState(() {}); - } - else { - refreshController.refreshFailed(); - refreshController.loadFailed(); - } - } - - _onRefresh() async{ - await queryHome(); - await queryUserBalance(); + if (isFirstIn) queryActivity(); + queryBanner(); + queryRecommendRank(); + queryGoodsCategory(); + queryPointsProductList(true); + queryUserBalance(); // queryMsgStats(); - await queryCoupon(); + queryCoupon(); } @override @@ -412,8 +350,6 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { if (refreshController != null) refreshController.dispose(); } - final RefreshController refreshController = RefreshController(); - @override Widget build(BuildContext context) { super.build(context); @@ -502,96 +438,90 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), - onRefresh: () { - setState(() {_onRefresh(); - }); - }, + onRefresh: _onRefresh, child: SingleChildScrollView( - physics: NeverScrollableScrollPhysics(), - child: FutureBuilder( - future: queryHome(), - builder: (context, snapshot) { - return Column( - children: [ - ///banner - HomeBanner(bannerData, controller), - - ///吃喝玩 - UnionEntry((int jpIndex) { - widget.changeTab(1,jpIndex); - }), - - ///快捷操作 - ShortcutOperation((int jpIndex) { - widget.changeTab(1,jpIndex); - }), - - ///推广图 - spread(), - - // ///签到 - // SignView(isSigned, (value) { - // setState(() { - // isSigned = value; - // }); - // }), - - ///特惠专区 - if(coupons != null && coupons.length != 0) - DiscountZone(coupons), - - ///特惠专区-推荐商品展示 - if(homeRank != null && homeRank.commodityZone.length != 0) - HomeRecommendGoods(homeRank), - - ///助农专区 - // if(mRaiseMoney != 0) - HappyHelpFarmers(), - - ///福利中心 - WelfareCore(), - - ///吃喝玩商品热销榜 - if(homeRank != null && homeRank.commodityList.length != 0) - TopSellingList(homeRank), - - // ///店铺推荐 - // QuickOrder(), - - // ///超级优惠券 - // CouponView(), - - // ///精选活动 - // FeaturedActivity(), - - // ///积分商城 - // HomeIntegralStore(gooods), - - ///积分商品头Tab - PointsGoodsTitle( - gooodsCategorys, - (orderType, orderDesc) { - this.orderType = orderType; - this.orderDesc = orderDesc; - setState(() {}); - }, - (index) { - categoryId = gooodsCategorys[index].id; - pageNum = 1; - setState(() {}); - }, - ), - - ///积分商品列表 - PointGoods( - goods, - (index) { - _toDetails(index); - }, - ), - ], - );}) - ), + physics: NeverScrollableScrollPhysics(), + child: Column( + children: [ + ///banner + homeBanner(), + + ///吃喝玩 + UnionEntry((int jpIndex) { + widget.changeTab(1, jpIndex); + }), + + ///快捷操作 + ShortcutOperation((int jpIndex) { + widget.changeTab(1, jpIndex); + }), + + ///推广图 + spread(), + + // ///签到 + // SignView(isSigned, (value) { + // setState(() { + // isSigned = value; + // }); + // }), + + ///特惠专区 + if (coupons != null && coupons.length != 0) + DiscountZone(coupons), + + ///特惠专区-推荐商品展示 + if (homeRank != null && + homeRank.commodityZone.length != 0) + HomeRecommendGoods(homeRank), + + ///助农专区 + // if(mRaiseMoney != 0) + HappyHelpFarmers(), + + ///福利中心 + WelfareCore(), + + ///吃喝玩商品热销榜 + if (homeRank != null && + homeRank.commodityList.length != 0) + TopSellingList(homeRank), + + // ///店铺推荐 + // QuickOrder(), + + // ///超级优惠券 + // CouponView(), + + // ///精选活动 + // FeaturedActivity(), + + // ///积分商城 + // HomeIntegralStore(gooods), + + ///积分商品头Tab + PointsGoodsTitle( + gooodsCategorys, + (orderType, orderDesc) { + this.orderType = orderType; + this.orderDesc = orderDesc; + queryPointsProductList(false); + }, + (index) { + categoryId = gooodsCategorys[index].id; + queryPointsProductList(false); + }, + ), + + ///积分商品列表 + PointGoods( + goods, + (index) { + _toDetails(index); + }, + ), + ], + )), ), ), ), @@ -602,7 +532,99 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { ); } - Widget spread(){ + Widget homeBanner() { + return Container( + child: AspectRatio( + aspectRatio: 1.25, + child: bannerData != null && bannerData.isNotEmpty + ? Swiper( + pagination: SwiperPagination( + margin: EdgeInsets.only(bottom: 12.h), + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8, + activeSize: 8, + space: 5, + activeColor: Colors.white, + color: Colors.white.withAlpha(76), + ), + ), + autoplay: true, + duration: 1000, + autoplayDelay: 2000, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + onTap: () { + bannerClick(bannerData[position]); + }, + child: Container( + child: MImage( + bannerData[position].imgUrl, + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.webp", + fadeSrc: "assets/image/default_2_1.webp", + ), + ), + ); + }, + itemCount: bannerData.length, + ) + : Image.asset( + "assets/image/default_2_1.webp", + fit: BoxFit.cover, + ), + ), + ); + } + + /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程,7:门店跳转) + bannerClick(BannerData bannerData) async { + switch (bannerData.contentType) { + case 1: + Navigator.of(context).pushNamed('/router/integral_store_page', + arguments: {"goodsId": bannerData.content}); + break; + case 2: + Navigator.of(context).pushNamed('/router/web_page', arguments: { + "activityId": bannerData.content, + }); + break; + case 3: + Navigator.of(context).pushNamed('/router/web_page', arguments: { + "articleId": bannerData.content, + }); + break; + case 4: + String router = bannerData.content; + // String router = "/router/store_order?{\"id\":\"1512378184161558528\",\"tenant\":\"1188\",\"storeName\":\"农场煮意\"}"; + if (router.contains("?")) { + String params = router.substring(router.indexOf("?") + 1); + Map map = jsonDecode(params); + Navigator.of(context).pushNamed( + router.substring(0, router.indexOf("?")), + arguments: map); + } else { + Navigator.of(context).pushNamed(router); + } + break; + case 5: + Navigator.of(context).pushNamed('/router/class_details', arguments: { + "id": bannerData.content, + }); + break; + case 7: + String params = + bannerData.content.substring(bannerData.content.indexOf("?") + 1); + Map map = jsonDecode(params); + Navigator.of(context).pushNamed( + bannerData.content.substring(0, bannerData.content.indexOf("?")), + arguments: map); + break; + } + } + + Widget spread() { return Container( width: double.infinity, height: 85.h, @@ -618,33 +640,33 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { color: Colors.white.withAlpha(76), ), ), - autoplay:true, + autoplay: true, duration: 1000, autoplayDelay: 2000, itemBuilder: (context, position) { return GestureDetector( - onTap: (){ - if(position == 0){ + onTap: () { + if (position == 0) { Navigator.of(context).pushNamed('/router/invite_friends'); - }else if(position == 1){ + } else if (position == 1) { Navigator.of(context).pushNamed('/router/trading_card_page'); } }, - child:Container( - margin: EdgeInsets.symmetric(horizontal:14.w), + child: Container( + margin: EdgeInsets.symmetric(horizontal: 14.w), child: ClipRRect( - child:Image.asset( + child: Image.asset( spreadItem[position], - width:double.infinity, + width: double.infinity, fit: BoxFit.fill, - height:double.infinity, + height: double.infinity, ), borderRadius: BorderRadius.circular(6.w), ), ), ); }, - itemCount:2, + itemCount: 2, ), ); } @@ -678,20 +700,24 @@ class HomePageState extends State with AutomaticKeepAliveClientMixin { // 新版桌子码跳转 // http://miniscan.lotus-wallet.com/placeorder?tenant_code=1194&table_id=1669609340031467520&store_id=1637659387134738432 var result = await Navigator.of(context).pushNamed('/router/qr_scan'); - if(result.toString().contains("type\":\"coupon")){ + if (result.toString().contains("type\":\"coupon")) { ///活动优惠券赠送弹窗 activityShowAlertDialog(result.toString()); return; - }if(result.toString().contains("type\":\"wiped")){ + } + if (result.toString().contains("type\":\"wiped")) { ///核销券 queryWiped(jsonDecode(result.toString())["memberCouponId"]); return; } // String result = await scanner.scan(); 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 && diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index 22ec8ead..af0a5425 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/lib/home/huixiang_brand_page.dart @@ -44,7 +44,7 @@ class _BrandPage extends State Founder founder; queryHome() async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); final SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService( diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index e3c86fba..4e0d55fe 100644 --- a/lib/home/points_mall_page.dart +++ b/lib/home/points_mall_page.dart @@ -95,7 +95,7 @@ class _PointsMallPage extends State } creditGoods() async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); final SharedPreferences value = await SharedPreferences.getInstance(); client = ApiService(Dio(), diff --git a/lib/home/welfare_exchange.dart b/lib/home/welfare_exchange.dart index 4fa8ecaa..b4ec8b8e 100644 --- a/lib/home/welfare_exchange.dart +++ b/lib/home/welfare_exchange.dart @@ -62,7 +62,7 @@ class _WelfareExchange extends State } queryUser() async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData baseData = await apiService.queryInfo().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { diff --git a/lib/integral/integral_page.dart b/lib/integral/integral_page.dart index 06ae97a7..04f8b83f 100644 --- a/lib/integral/integral_page.dart +++ b/lib/integral/integral_page.dart @@ -191,7 +191,7 @@ class _IntegralPage extends State { SmartDialog.showToast("今日已签到了", alignment: Alignment.center); return; } - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData baseData = await apiService.signIn().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() {}); diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index 67bcc0ee..bc68553f 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -326,7 +326,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { "mobile": mobile, "invite":invite, }; - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData value = await client.memberLogin(param).catchError((error) { print(error.message); SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), alignment: Alignment.center); diff --git a/lib/login/new_login_page.dart b/lib/login/new_login_page.dart index c4d5f9b1..580b4890 100644 --- a/lib/login/new_login_page.dart +++ b/lib/login/new_login_page.dart @@ -61,17 +61,9 @@ class _NewLoginPage extends State { void initState() { super.initState(); isLogin(); - queryChannels(); } queryChannels() async{ - SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); - if (!sharedPreferences.containsKey("isShowPrivacyPolicy") || - !sharedPreferences.getBool("isShowPrivacyPolicy")) { - showAlertDialog(); - return; - } - apiService = ApiService(Dio(), context: context); BaseData baseData = await apiService.appChannels().catchError((error) { print(error.message); SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), @@ -80,7 +72,6 @@ class _NewLoginPage extends State { if (baseData != null && baseData.isSuccess) { channelsList = baseData.data; setState((){}); - EasyLoading.dismiss(); } else { if (baseData?.msg != null) SmartDialog.showToast(baseData.msg, alignment: Alignment.center); @@ -241,7 +232,7 @@ class _NewLoginPage extends State { "areaCode": area, "regChannel":channelName ?? "" }; - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData value = await apiService.memberLogin(param).catchError((error) { print(error.message); SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), @@ -262,11 +253,11 @@ class _NewLoginPage extends State { "interviewCouponList": userInfo.interviewCouponList, "firstLoginCouponList": userInfo.firstLoginCouponList }); - EasyLoading.dismiss(); } else { if (value.msg != null) SmartDialog.showToast(value?.msg, alignment: Alignment.center); } + EasyLoading.dismiss(); } saveUserJson(userJson) { @@ -295,11 +286,10 @@ class _NewLoginPage extends State { sharedPreferences.getString("mobile") == "13800138000"; Navigator.of(context).popAndPushNamed('/router/main_page'); } else { - initController(); - apiService = ApiService(Dio(), context: context); + initController(); isShowLogin = true; - setState(() {}); + queryChannels(); } } diff --git a/lib/mine/scan_web.dart b/lib/mine/scan_web.dart index b738be34..acab322e 100644 --- a/lib/mine/scan_web.dart +++ b/lib/mine/scan_web.dart @@ -26,7 +26,7 @@ class _ScanWeb extends State { super.initState(); result = widget.arguments["result"]; title = widget.arguments["title"]; - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); } @override diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index 798a9c0b..925720ff 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -48,7 +48,7 @@ class _OrderDetailPage extends State { super.initState(); jumpState = widget.arguments["jumpState"]; SharedPreferences.getInstance().then((value) { - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); apiService = ApiService(Dio(), context: context, token: value.getString("token"),); queryDetails(); diff --git a/lib/retrofit/data/product_show.dart b/lib/retrofit/data/product_show.dart new file mode 100644 index 00000000..c4774b6b --- /dev/null +++ b/lib/retrofit/data/product_show.dart @@ -0,0 +1,749 @@ +/// id : "1484156758195699712" +/// createTime : "2022-01-20 21:32:00" +/// createUser : "1364043181062094848" +/// updateTime : "2022-01-21 18:27:02" +/// updateUser : "1364043181062094848" +/// supplierName : "一心回乡生态农场" +/// storeId : "1460885296764682240" +/// categoryId : "1460889654206136320" +/// groupId : "1484146679266410496" +/// shortName : "【一心回乡】三益米 筋道绵润、鲜稻尝鲜;自留种老品种,非转基因种子" +/// productName : "三益米1kg" +/// sellDesc : "" +/// productCode : "PRO202201202132000000000000001" +/// weight : "0" +/// applyPrice : "39.00" +/// price : "24.00" +/// vipPrice : null +/// stock : -13 +/// sellCount : 19 +/// needLogistics : 1 +/// oversold : 1 +/// organic : 0 +/// status : 1 +/// posShow : true +/// subscribeParam : null +/// isRaise : false +/// productType : 0 +/// productNumber : 1 +/// setMeal : 1 +/// attrStyle : 0 +/// detail : "" +/// isDelete : 0 +/// printerFlag : "DEFAULT" +/// materials : null +/// materialId : null +/// details : "" +/// thumbnailImg : "" +/// info : "" +/// buyCount : 12 +/// sellCountLimit : 0 +/// stockRecoveryTime : null +/// isAddPurchase : null +/// limitNum : 0 +/// rankId : "0" +/// happyBean : 0 +/// imgs : ["https://pos.upload.lotus-wallet.com/1179/2022/01/243f54db-2dc8-4a9b-9ccc-09fc7a4e2a2e.jpg"] +/// productSkuList : [{"id":"1484156758229254144","createTime":"2022-01-20 21:32:00","createUser":"1364043181062094848","updateTime":"2022-01-20 21:32:00","updateUser":"1364043181062094848","storeId":"1460885296764682240","skuCode":"P202201202132002","skuNameStr":"","productId":"1484156758195699712","skuPrice":"24.00","applyPrice":"39.00","vipPrice":"24.00","packagingFee":"0.00","skuImg":null,"skuStock":-13,"autoRenewSkuStock":0,"deliveries":0,"ticketType":"","ticketWipedTimeTemplateId":null,"takeType":null,"ticketDays":"0","ticketExpireTime":"23:59:59","sort":50,"setMeal":"","productSetMeals":null,"weight":0.0,"volume":0.0,"isDelete":0,"material":null,"version":0,"skuTickets":null,"ticketStyle":""}] + +class ProductShow { + ProductShow({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String supplierName, + String storeId, + String categoryId, + String groupId, + String shortName, + String productName, + String sellDesc, + String productCode, + String weight, + String applyPrice, + String price, + dynamic vipPrice, + num stock, + num sellCount, + num needLogistics, + num oversold, + num organic, + num status, + bool posShow, + dynamic subscribeParam, + bool isRaise, + num productType, + num productNumber, + num setMeal, + num attrStyle, + String detail, + num isDelete, + String printerFlag, + dynamic materials, + dynamic materialId, + String details, + String thumbnailImg, + String info, + num buyCount, + num sellCountLimit, + dynamic stockRecoveryTime, + dynamic isAddPurchase, + num limitNum, + String rankId, + num happyBean, + List imgs, + List productSkuList,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _supplierName = supplierName; + _storeId = storeId; + _categoryId = categoryId; + _groupId = groupId; + _shortName = shortName; + _productName = productName; + _sellDesc = sellDesc; + _productCode = productCode; + _weight = weight; + _applyPrice = applyPrice; + _price = price; + _vipPrice = vipPrice; + _stock = stock; + _sellCount = sellCount; + _needLogistics = needLogistics; + _oversold = oversold; + _organic = organic; + _status = status; + _posShow = posShow; + _subscribeParam = subscribeParam; + _isRaise = isRaise; + _productType = productType; + _productNumber = productNumber; + _setMeal = setMeal; + _attrStyle = attrStyle; + _detail = detail; + _isDelete = isDelete; + _printerFlag = printerFlag; + _materials = materials; + _materialId = materialId; + _details = details; + _thumbnailImg = thumbnailImg; + _info = info; + _buyCount = buyCount; + _sellCountLimit = sellCountLimit; + _stockRecoveryTime = stockRecoveryTime; + _isAddPurchase = isAddPurchase; + _limitNum = limitNum; + _rankId = rankId; + _happyBean = happyBean; + _imgs = imgs; + _productSkuList = productSkuList; +} + + ProductShow.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _supplierName = json['supplierName']; + _storeId = json['storeId']; + _categoryId = json['categoryId']; + _groupId = json['groupId']; + _shortName = json['shortName']; + _productName = json['productName']; + _sellDesc = json['sellDesc']; + _productCode = json['productCode']; + _weight = json['weight']; + _applyPrice = json['applyPrice']; + _price = json['price']; + _vipPrice = json['vipPrice']; + _stock = json['stock']; + _sellCount = json['sellCount']; + _needLogistics = json['needLogistics']; + _oversold = json['oversold']; + _organic = json['organic']; + _status = json['status']; + _posShow = json['posShow']; + _subscribeParam = json['subscribeParam']; + _isRaise = json['isRaise']; + _productType = json['productType']; + _productNumber = json['productNumber']; + _setMeal = json['setMeal']; + _attrStyle = json['attrStyle']; + _detail = json['detail']; + _isDelete = json['isDelete']; + _printerFlag = json['printerFlag']; + _materials = json['materials']; + _materialId = json['materialId']; + _details = json['details']; + _thumbnailImg = json['thumbnailImg']; + _info = json['info']; + _buyCount = json['buyCount']; + _sellCountLimit = json['sellCountLimit']; + _stockRecoveryTime = json['stockRecoveryTime']; + _isAddPurchase = json['isAddPurchase']; + _limitNum = json['limitNum']; + _rankId = json['rankId']; + _happyBean = json['happyBean']; + _imgs = json['imgs'] != null ? json['imgs'].cast() : []; + if (json['productSkuList'] != null) { + _productSkuList = []; + json['productSkuList'].forEach((v) { + _productSkuList.add(ProductSkuList.fromJson(v)); + }); + } + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _supplierName; + String _storeId; + String _categoryId; + String _groupId; + String _shortName; + String _productName; + String _sellDesc; + String _productCode; + String _weight; + String _applyPrice; + String _price; + dynamic _vipPrice; + num _stock; + num _sellCount; + num _needLogistics; + num _oversold; + num _organic; + num _status; + bool _posShow; + dynamic _subscribeParam; + bool _isRaise; + num _productType; + num _productNumber; + num _setMeal; + num _attrStyle; + String _detail; + num _isDelete; + String _printerFlag; + dynamic _materials; + dynamic _materialId; + String _details; + String _thumbnailImg; + String _info; + num _buyCount; + num _sellCountLimit; + dynamic _stockRecoveryTime; + dynamic _isAddPurchase; + num _limitNum; + String _rankId; + num _happyBean; + List _imgs; + List _productSkuList; +ProductShow copyWith({ String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String supplierName, + String storeId, + String categoryId, + String groupId, + String shortName, + String productName, + String sellDesc, + String productCode, + String weight, + String applyPrice, + String price, + dynamic vipPrice, + num stock, + num sellCount, + num needLogistics, + num oversold, + num organic, + num status, + bool posShow, + dynamic subscribeParam, + bool isRaise, + num productType, + num productNumber, + num setMeal, + num attrStyle, + String detail, + num isDelete, + String printerFlag, + dynamic materials, + dynamic materialId, + String details, + String thumbnailImg, + String info, + num buyCount, + num sellCountLimit, + dynamic stockRecoveryTime, + dynamic isAddPurchase, + num limitNum, + String rankId, + num happyBean, + List imgs, + List productSkuList, +}) => ProductShow( id: id ?? _id, + createTime: createTime ?? _createTime, + createUser: createUser ?? _createUser, + updateTime: updateTime ?? _updateTime, + updateUser: updateUser ?? _updateUser, + supplierName: supplierName ?? _supplierName, + storeId: storeId ?? _storeId, + categoryId: categoryId ?? _categoryId, + groupId: groupId ?? _groupId, + shortName: shortName ?? _shortName, + productName: productName ?? _productName, + sellDesc: sellDesc ?? _sellDesc, + productCode: productCode ?? _productCode, + weight: weight ?? _weight, + applyPrice: applyPrice ?? _applyPrice, + price: price ?? _price, + vipPrice: vipPrice ?? _vipPrice, + stock: stock ?? _stock, + sellCount: sellCount ?? _sellCount, + needLogistics: needLogistics ?? _needLogistics, + oversold: oversold ?? _oversold, + organic: organic ?? _organic, + status: status ?? _status, + posShow: posShow ?? _posShow, + subscribeParam: subscribeParam ?? _subscribeParam, + isRaise: isRaise ?? _isRaise, + productType: productType ?? _productType, + productNumber: productNumber ?? _productNumber, + setMeal: setMeal ?? _setMeal, + attrStyle: attrStyle ?? _attrStyle, + detail: detail ?? _detail, + isDelete: isDelete ?? _isDelete, + printerFlag: printerFlag ?? _printerFlag, + materials: materials ?? _materials, + materialId: materialId ?? _materialId, + details: details ?? _details, + thumbnailImg: thumbnailImg ?? _thumbnailImg, + info: info ?? _info, + buyCount: buyCount ?? _buyCount, + sellCountLimit: sellCountLimit ?? _sellCountLimit, + stockRecoveryTime: stockRecoveryTime ?? _stockRecoveryTime, + isAddPurchase: isAddPurchase ?? _isAddPurchase, + limitNum: limitNum ?? _limitNum, + rankId: rankId ?? _rankId, + happyBean: happyBean ?? _happyBean, + imgs: imgs ?? _imgs, + productSkuList: productSkuList ?? _productSkuList, +); + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get supplierName => _supplierName; + String get storeId => _storeId; + String get categoryId => _categoryId; + String get groupId => _groupId; + String get shortName => _shortName; + String get productName => _productName; + String get sellDesc => _sellDesc; + String get productCode => _productCode; + String get weight => _weight; + String get applyPrice => _applyPrice; + String get price => _price; + dynamic get vipPrice => _vipPrice; + num get stock => _stock; + num get sellCount => _sellCount; + num get needLogistics => _needLogistics; + num get oversold => _oversold; + num get organic => _organic; + num get status => _status; + bool get posShow => _posShow; + dynamic get subscribeParam => _subscribeParam; + bool get isRaise => _isRaise; + num get productType => _productType; + num get productNumber => _productNumber; + num get setMeal => _setMeal; + num get attrStyle => _attrStyle; + String get detail => _detail; + num get isDelete => _isDelete; + String get printerFlag => _printerFlag; + dynamic get materials => _materials; + dynamic get materialId => _materialId; + String get details => _details; + String get thumbnailImg => _thumbnailImg; + String get info => _info; + num get buyCount => _buyCount; + num get sellCountLimit => _sellCountLimit; + dynamic get stockRecoveryTime => _stockRecoveryTime; + dynamic get isAddPurchase => _isAddPurchase; + num get limitNum => _limitNum; + String get rankId => _rankId; + num get happyBean => _happyBean; + List get imgs => _imgs; + List get productSkuList => _productSkuList; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['supplierName'] = _supplierName; + map['storeId'] = _storeId; + map['categoryId'] = _categoryId; + map['groupId'] = _groupId; + map['shortName'] = _shortName; + map['productName'] = _productName; + map['sellDesc'] = _sellDesc; + map['productCode'] = _productCode; + map['weight'] = _weight; + map['applyPrice'] = _applyPrice; + map['price'] = _price; + map['vipPrice'] = _vipPrice; + map['stock'] = _stock; + map['sellCount'] = _sellCount; + map['needLogistics'] = _needLogistics; + map['oversold'] = _oversold; + map['organic'] = _organic; + map['status'] = _status; + map['posShow'] = _posShow; + map['subscribeParam'] = _subscribeParam; + map['isRaise'] = _isRaise; + map['productType'] = _productType; + map['productNumber'] = _productNumber; + map['setMeal'] = _setMeal; + map['attrStyle'] = _attrStyle; + map['detail'] = _detail; + map['isDelete'] = _isDelete; + map['printerFlag'] = _printerFlag; + map['materials'] = _materials; + map['materialId'] = _materialId; + map['details'] = _details; + map['thumbnailImg'] = _thumbnailImg; + map['info'] = _info; + map['buyCount'] = _buyCount; + map['sellCountLimit'] = _sellCountLimit; + map['stockRecoveryTime'] = _stockRecoveryTime; + map['isAddPurchase'] = _isAddPurchase; + map['limitNum'] = _limitNum; + map['rankId'] = _rankId; + map['happyBean'] = _happyBean; + map['imgs'] = _imgs; + if (_productSkuList != null) { + map['productSkuList'] = _productSkuList.map((v) => v.toJson()).toList(); + } + return map; + } + +} + +/// id : "1484156758229254144" +/// createTime : "2022-01-20 21:32:00" +/// createUser : "1364043181062094848" +/// updateTime : "2022-01-20 21:32:00" +/// updateUser : "1364043181062094848" +/// storeId : "1460885296764682240" +/// skuCode : "P202201202132002" +/// skuNameStr : "" +/// productId : "1484156758195699712" +/// skuPrice : "24.00" +/// applyPrice : "39.00" +/// vipPrice : "24.00" +/// packagingFee : "0.00" +/// skuImg : null +/// skuStock : -13 +/// autoRenewSkuStock : 0 +/// deliveries : 0 +/// ticketType : "" +/// ticketWipedTimeTemplateId : null +/// takeType : null +/// ticketDays : "0" +/// ticketExpireTime : "23:59:59" +/// sort : 50 +/// setMeal : "" +/// productSetMeals : null +/// weight : 0.0 +/// volume : 0.0 +/// isDelete : 0 +/// material : null +/// version : 0 +/// skuTickets : null +/// ticketStyle : "" + +class ProductSkuList { + ProductSkuList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String storeId, + String skuCode, + String skuNameStr, + String productId, + String skuPrice, + String applyPrice, + String vipPrice, + String packagingFee, + dynamic skuImg, + num skuStock, + num autoRenewSkuStock, + num deliveries, + String ticketType, + dynamic ticketWipedTimeTemplateId, + dynamic takeType, + String ticketDays, + String ticketExpireTime, + num sort, + String setMeal, + dynamic productSetMeals, + num weight, + num volume, + num isDelete, + dynamic material, + num version, + dynamic skuTickets, + String ticketStyle,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _storeId = storeId; + _skuCode = skuCode; + _skuNameStr = skuNameStr; + _productId = productId; + _skuPrice = skuPrice; + _applyPrice = applyPrice; + _vipPrice = vipPrice; + _packagingFee = packagingFee; + _skuImg = skuImg; + _skuStock = skuStock; + _autoRenewSkuStock = autoRenewSkuStock; + _deliveries = deliveries; + _ticketType = ticketType; + _ticketWipedTimeTemplateId = ticketWipedTimeTemplateId; + _takeType = takeType; + _ticketDays = ticketDays; + _ticketExpireTime = ticketExpireTime; + _sort = sort; + _setMeal = setMeal; + _productSetMeals = productSetMeals; + _weight = weight; + _volume = volume; + _isDelete = isDelete; + _material = material; + _version = version; + _skuTickets = skuTickets; + _ticketStyle = ticketStyle; +} + + ProductSkuList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _storeId = json['storeId']; + _skuCode = json['skuCode']; + _skuNameStr = json['skuNameStr']; + _productId = json['productId']; + _skuPrice = json['skuPrice']; + _applyPrice = json['applyPrice']; + _vipPrice = json['vipPrice']; + _packagingFee = json['packagingFee']; + _skuImg = json['skuImg']; + _skuStock = json['skuStock']; + _autoRenewSkuStock = json['autoRenewSkuStock']; + _deliveries = json['deliveries']; + _ticketType = json['ticketType']; + _ticketWipedTimeTemplateId = json['ticketWipedTimeTemplateId']; + _takeType = json['takeType']; + _ticketDays = json['ticketDays']; + _ticketExpireTime = json['ticketExpireTime']; + _sort = json['sort']; + _setMeal = json['setMeal']; + _productSetMeals = json['productSetMeals']; + _weight = json['weight']; + _volume = json['volume']; + _isDelete = json['isDelete']; + _material = json['material']; + _version = json['version']; + _skuTickets = json['skuTickets']; + _ticketStyle = json['ticketStyle']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _storeId; + String _skuCode; + String _skuNameStr; + String _productId; + String _skuPrice; + String _applyPrice; + String _vipPrice; + String _packagingFee; + dynamic _skuImg; + num _skuStock; + num _autoRenewSkuStock; + num _deliveries; + String _ticketType; + dynamic _ticketWipedTimeTemplateId; + dynamic _takeType; + String _ticketDays; + String _ticketExpireTime; + num _sort; + String _setMeal; + dynamic _productSetMeals; + num _weight; + num _volume; + num _isDelete; + dynamic _material; + num _version; + dynamic _skuTickets; + String _ticketStyle; +ProductSkuList copyWith({ String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String storeId, + String skuCode, + String skuNameStr, + String productId, + String skuPrice, + String applyPrice, + String vipPrice, + String packagingFee, + dynamic skuImg, + num skuStock, + num autoRenewSkuStock, + num deliveries, + String ticketType, + dynamic ticketWipedTimeTemplateId, + dynamic takeType, + String ticketDays, + String ticketExpireTime, + num sort, + String setMeal, + dynamic productSetMeals, + num weight, + num volume, + num isDelete, + dynamic material, + num version, + dynamic skuTickets, + String ticketStyle, +}) => ProductSkuList( id: id ?? _id, + createTime: createTime ?? _createTime, + createUser: createUser ?? _createUser, + updateTime: updateTime ?? _updateTime, + updateUser: updateUser ?? _updateUser, + storeId: storeId ?? _storeId, + skuCode: skuCode ?? _skuCode, + skuNameStr: skuNameStr ?? _skuNameStr, + productId: productId ?? _productId, + skuPrice: skuPrice ?? _skuPrice, + applyPrice: applyPrice ?? _applyPrice, + vipPrice: vipPrice ?? _vipPrice, + packagingFee: packagingFee ?? _packagingFee, + skuImg: skuImg ?? _skuImg, + skuStock: skuStock ?? _skuStock, + autoRenewSkuStock: autoRenewSkuStock ?? _autoRenewSkuStock, + deliveries: deliveries ?? _deliveries, + ticketType: ticketType ?? _ticketType, + ticketWipedTimeTemplateId: ticketWipedTimeTemplateId ?? _ticketWipedTimeTemplateId, + takeType: takeType ?? _takeType, + ticketDays: ticketDays ?? _ticketDays, + ticketExpireTime: ticketExpireTime ?? _ticketExpireTime, + sort: sort ?? _sort, + setMeal: setMeal ?? _setMeal, + productSetMeals: productSetMeals ?? _productSetMeals, + weight: weight ?? _weight, + volume: volume ?? _volume, + isDelete: isDelete ?? _isDelete, + material: material ?? _material, + version: version ?? _version, + skuTickets: skuTickets ?? _skuTickets, + ticketStyle: ticketStyle ?? _ticketStyle, +); + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get storeId => _storeId; + String get skuCode => _skuCode; + String get skuNameStr => _skuNameStr; + String get productId => _productId; + String get skuPrice => _skuPrice; + String get applyPrice => _applyPrice; + String get vipPrice => _vipPrice; + String get packagingFee => _packagingFee; + dynamic get skuImg => _skuImg; + num get skuStock => _skuStock; + num get autoRenewSkuStock => _autoRenewSkuStock; + num get deliveries => _deliveries; + String get ticketType => _ticketType; + dynamic get ticketWipedTimeTemplateId => _ticketWipedTimeTemplateId; + dynamic get takeType => _takeType; + String get ticketDays => _ticketDays; + String get ticketExpireTime => _ticketExpireTime; + num get sort => _sort; + String get setMeal => _setMeal; + dynamic get productSetMeals => _productSetMeals; + num get weight => _weight; + num get volume => _volume; + num get isDelete => _isDelete; + dynamic get material => _material; + num get version => _version; + dynamic get skuTickets => _skuTickets; + String get ticketStyle => _ticketStyle; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['storeId'] = _storeId; + map['skuCode'] = _skuCode; + map['skuNameStr'] = _skuNameStr; + map['productId'] = _productId; + map['skuPrice'] = _skuPrice; + map['applyPrice'] = _applyPrice; + map['vipPrice'] = _vipPrice; + map['packagingFee'] = _packagingFee; + map['skuImg'] = _skuImg; + map['skuStock'] = _skuStock; + map['autoRenewSkuStock'] = _autoRenewSkuStock; + map['deliveries'] = _deliveries; + map['ticketType'] = _ticketType; + map['ticketWipedTimeTemplateId'] = _ticketWipedTimeTemplateId; + map['takeType'] = _takeType; + map['ticketDays'] = _ticketDays; + map['ticketExpireTime'] = _ticketExpireTime; + map['sort'] = _sort; + map['setMeal'] = _setMeal; + map['productSetMeals'] = _productSetMeals; + map['weight'] = _weight; + map['volume'] = _volume; + map['isDelete'] = _isDelete; + map['material'] = _material; + map['version'] = _version; + map['skuTickets'] = _skuTickets; + map['ticketStyle'] = _ticketStyle; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/data/store.dart b/lib/retrofit/data/store.dart index 1dd45b68..e94cc87a 100644 --- a/lib/retrofit/data/store.dart +++ b/lib/retrofit/data/store.dart @@ -1,8 +1,7 @@ - import 'package:huixiang/retrofit/data/coupon_vo.dart'; +import 'package:huixiang/retrofit/data/product_show.dart'; import 'package:huixiang/retrofit/data/store_type.dart'; - class Store { Store(); @@ -38,81 +37,94 @@ class Store { CouponVo couponVO; dynamic deliveryInfo; String businessType; + String businessService; + List productShow; StoreType posType; - factory Store.fromJson(Map json) => Store() - ..id = json['id'] as String - ..createTime = json['createTime'] as String - ..createUser = json['createUser'] as String - ..updateTime = json['updateTime'] as String - ..updateUser = json['updateUser'] as String - ..tenantCode = json['tenantCode'] as String - ..useErp = json['useErp'] as bool - ..openStartTime = json['openStartTime'] as String - ..openEndTime = json['openEndTime'] as String - ..perCapitaConsumption = json['perCapitaConsumption'] as String - ..storeName = json['storeName'] as String - ..distance = (json['distance'] as num)?.toDouble() - ..logo = json['logo'] as String - ..facade = json['facade'] as String - ..shipAddress = json['shipAddress'] as String - ..remark = json['remark'] - ..mobile = json['mobile'] as String - ..longitude = json['longitude'] as String - ..latitude = json['latitude'] as String - ..refundAddress = json['refundAddress'] - ..refundTel = json['refundTel'] - ..refundContact = json['refundContact'] - ..isAutoSendRefundAddress = json['isAutoSendRefundAddress'] as int - ..province = json['province'] as String - ..city = json['city'] as String - ..district = json['district'] as String - ..address = json['address'] as String - ..headName = json['headName'] as String - ..headMobile = json['headMobile'] as String - ..deliveryInfo = json['deliveryInfo'] - ..businessType = json['businessType'] as String - ..couponVO = json['couponVO'] == null ? null : CouponVo.fromJson(json['couponVO']) - ..posType = json['posType'] == null - ? null - : StoreType.fromJson(json['posType'] as Map); - - Map toJson() => { - 'id': this.id, - 'createTime': this.createTime, - 'createUser': this.createUser, - 'updateTime': this.updateTime, - 'updateUser': this.updateUser, - 'tenantCode': this.tenantCode, - 'useErp': this.useErp, - 'openStartTime': this.openStartTime, - 'openEndTime': this.openEndTime, - 'perCapitaConsumption': this.perCapitaConsumption, - 'storeName': this.storeName, - 'distance': this.distance, - 'logo': this.logo, - 'facade': this.facade, - 'shipAddress': this.shipAddress, - 'remark': this.remark, - 'mobile': this.mobile, - 'longitude': this.longitude, - 'latitude': this.latitude, - 'refundAddress': this.refundAddress, - 'refundTel': this.refundTel, - 'refundContact': this.refundContact, - 'isAutoSendRefundAddress': this.isAutoSendRefundAddress, - 'province': this.province, - 'city': this.city, - 'district': this.district, - 'address': this.address, - 'headName': this.headName, - 'headMobile': this.headMobile, - 'deliveryInfo': this.deliveryInfo, - 'businessType': this.businessType, - 'couponVO': this.couponVO != null ? this.couponVO.toJson() : null, - 'posType': this.posType, - }; + factory Store.fromJson(Map json) => + Store() + ..id = json['id'] as String + ..createTime = json['createTime'] as String + ..createUser = json['createUser'] as String + ..updateTime = json['updateTime'] as String + ..updateUser = json['updateUser'] as String + ..tenantCode = json['tenantCode'] as String + ..useErp = json['useErp'] as bool + ..openStartTime = json['openStartTime'] as String + ..openEndTime = json['openEndTime'] as String + ..perCapitaConsumption = json['perCapitaConsumption'] as String + ..storeName = json['storeName'] as String + ..distance = (json['distance'] as num)?.toDouble() + ..logo = json['logo'] as String + ..facade = json['facade'] as String + ..shipAddress = json['shipAddress'] as String + ..remark = json['remark'] + ..mobile = json['mobile'] as String + ..longitude = json['longitude'] as String + ..latitude = json['latitude'] as String + ..refundAddress = json['refundAddress'] + ..refundTel = json['refundTel'] + ..refundContact = json['refundContact'] + ..isAutoSendRefundAddress = json['isAutoSendRefundAddress'] as int + ..province = json['province'] as String + ..city = json['city'] as String + ..district = json['district'] as String + ..address = json['address'] as String + ..headName = json['headName'] as String + ..headMobile = json['headMobile'] as String + ..deliveryInfo = json['deliveryInfo'] + ..businessType = json['businessType'] as String + ..businessService = json['businessService'] as String + ..couponVO = json['couponVO'] == null ? null : CouponVo.fromJson( + json['couponVO']) + ..productShow = (json['productShow'] as List) + ?.map((e) => + e == null ? null : ProductShow.fromJson(e as Map)) + ?.toList() + ..posType = json['posType'] == null + ? null + : StoreType.fromJson(json['posType'] as Map); + Map toJson() => + { + 'id': this.id, + 'createTime': this.createTime, + 'createUser': this.createUser, + 'updateTime': this.updateTime, + 'updateUser': this.updateUser, + 'tenantCode': this.tenantCode, + 'useErp': this.useErp, + 'openStartTime': this.openStartTime, + 'openEndTime': this.openEndTime, + 'perCapitaConsumption': this.perCapitaConsumption, + 'storeName': this.storeName, + 'distance': this.distance, + 'logo': this.logo, + 'facade': this.facade, + 'shipAddress': this.shipAddress, + 'remark': this.remark, + 'mobile': this.mobile, + 'longitude': this.longitude, + 'latitude': this.latitude, + 'refundAddress': this.refundAddress, + 'refundTel': this.refundTel, + 'refundContact': this.refundContact, + 'isAutoSendRefundAddress': this.isAutoSendRefundAddress, + 'province': this.province, + 'city': this.city, + 'district': this.district, + 'address': this.address, + 'headName': this.headName, + 'headMobile': this.headMobile, + 'deliveryInfo': this.deliveryInfo, + 'businessType': this.businessType, + 'businessService': this.businessService, + 'couponVO': this.couponVO != null ? this.couponVO.toJson() : null, + 'productShow': this.productShow.map((e) => e.toJson()).toList(), + 'posType': this.posType, + }; } + + diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index ac89ea53..6415e490 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -26,7 +26,7 @@ import 'data/shopping_home_config.dart'; part 'min_api.g.dart'; -const localBaseUrl = "http://192.168.10.15:8765/app/";///本地 +const localBaseUrl = "http://app-api.test.yixinhuixiang.com/app/";///本地 // const localBaseUrl = "http://pos-test.api.lotus-wallet.com/app/";///测试 const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线上 @@ -49,7 +49,7 @@ abstract class MinApiService { headers["tenant"] = tenant; } if (storeId != null && storeId != "") { - headers["store_id"] = storeId; + headers["store-id"] = storeId; } headers["Environment"] = "app"; dio.options = BaseOptions( @@ -67,7 +67,7 @@ abstract class MinApiService { debugPrint("headers = ${options.headers}"); if (showLoading && !EasyLoading.isShow) { //是否显示loading - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); } if (options.data is FormData) { debugPrint("params data = FormData"); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 6fbd44d8..4a602f8e 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -67,17 +67,11 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -const localBaseUrl = "http://platform-api.test.yixinhuixiang.com/app/"; - -///本地 +const localBaseUrl = "http://platform-api.test.yixinhuixiang.com/app/";///本地 // const localBaseUrl = "http://platform.test.api.lotus-wallet.com/app/";///测试 -const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/"; - -///线上 - -const ipBaseUrl = "https://api.ooomn.com"; +const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线上 -///ip +const ipBaseUrl = "https://api.ooomn.com";///ip @RestApi(baseUrl: localBaseUrl) abstract class ApiService { @@ -110,7 +104,7 @@ abstract class ApiService { debugPrint("headers = ${options.headers}"); if (showLoading && !EasyLoading.isShow) { //是否显示loading - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); } if (options.data is FormData) { debugPrint("params data = FormData"); diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 32506277..4e59be99 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -592,7 +592,7 @@ class _ApiService implements ApiService { data: _data); final value = BaseData>.fromJson( _result.data, - (json) => (json as List) + (json) => ((json??"") == "")?null:(json as List) .map((i) => Store.fromJson(i as Map)) .toList()); return value; diff --git a/lib/setting/account_security_page.dart b/lib/setting/account_security_page.dart index bb9e859d..50ee2cf4 100644 --- a/lib/setting/account_security_page.dart +++ b/lib/setting/account_security_page.dart @@ -26,7 +26,7 @@ class _AccountSecurityPage extends State { @override void initState() { super.initState(); - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); SharedPreferences.getInstance().then((value) => { apiService = ApiService(Dio(), context: context, token: value.getString("token"),), diff --git a/lib/setting/treaty_page.dart b/lib/setting/treaty_page.dart index a3c2ec26..cd44bac6 100644 --- a/lib/setting/treaty_page.dart +++ b/lib/setting/treaty_page.dart @@ -23,7 +23,7 @@ class _TreatyPage extends State { @override void initState() { super.initState(); - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); // if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); // if (Platform.isIOS) WebView.platform = CupertinoWebView(); } diff --git a/lib/setting/user_service_page.dart b/lib/setting/user_service_page.dart index 83e6e9d7..95c1316c 100644 --- a/lib/setting/user_service_page.dart +++ b/lib/setting/user_service_page.dart @@ -25,7 +25,7 @@ class _UserServicePage extends State with WidgetsBindingObserve void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); if (Platform.isIOS) WebView.platform = CupertinoWebView(); } diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index b68d529a..9aef543d 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -228,7 +228,7 @@ class _Settlement extends State { payChannel, tableId) async { try { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData baseData = await minService.getOrderInfo({ "addressId": addressId, @@ -329,7 +329,7 @@ class _Settlement extends State { ///查看订单详情 queryOrderDetails(id) async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); BaseData baseData = await minService.getOrderDetails({ "id": pageType != null ? widget.arguments["orderId"] : id ?? parentId, }).catchError((error) {}); @@ -632,7 +632,7 @@ class _Settlement extends State { print("error: $error"); }); if (baseData != null && baseData.isSuccess) { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); placeOrder = true; this.downOrder = DownOrder.fromJson(baseData.data); querySettlement(); diff --git a/lib/store/shop_details_page.dart b/lib/store/shop_details_page.dart index c2285615..51731ef2 100644 --- a/lib/store/shop_details_page.dart +++ b/lib/store/shop_details_page.dart @@ -94,7 +94,7 @@ class _ShopDetailsPage extends State { /// 查询店铺信息 queryStoreInfo() async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); SharedPreferences value = await SharedPreferences.getInstance(); if (apiService == null) apiService = ApiService( @@ -321,7 +321,7 @@ class _ShopDetailsPage extends State { ///选规格 _queryMiNiDetail(String id, int count) async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); if (count < 0) { shopCarGoods.shoppingCartSkuItemList.forEach((element) { if (element.productId == id) { diff --git a/lib/store/shopping/activity_prefecture_details.dart b/lib/store/shopping/activity_prefecture_details.dart index c3d645ed..743cb5af 100644 --- a/lib/store/shopping/activity_prefecture_details.dart +++ b/lib/store/shopping/activity_prefecture_details.dart @@ -95,7 +95,7 @@ class _ActivityPrefectureDetails extends State { /// 小程序登录 minLogin(SharedPreferences shared) async { - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); apiService = ApiService( Dio(), context: context, diff --git a/lib/store/shopping/shopping_goods_details.dart b/lib/store/shopping/shopping_goods_details.dart index 970ef188..60e8fb5e 100644 --- a/lib/store/shopping/shopping_goods_details.dart +++ b/lib/store/shopping/shopping_goods_details.dart @@ -116,7 +116,7 @@ class _ShoppingGoodsDetails extends State { /// 小程序登录 minLogin(SharedPreferences shared) async { - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); apiService = ApiService( Dio(), context: context, diff --git a/lib/store/shopping/shopping_mall_home.dart b/lib/store/shopping/shopping_mall_home.dart index b761fedf..0de56f71 100644 --- a/lib/store/shopping/shopping_mall_home.dart +++ b/lib/store/shopping/shopping_mall_home.dart @@ -55,7 +55,7 @@ class _ShoppingMallHome extends State /// 小程序登录 minLogin(SharedPreferences shared) async { - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); apiService = ApiService( Dio(), context: context, diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index feb7a4fd..357649ce 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -97,7 +97,7 @@ class _StoreOrderPage extends State /// 小程序登录 minLogin(SharedPreferences shared) async { - EasyLoading.show(status: S.of(context).zhengzaijiazai); + EasyLoading.show(status: S.of(context).zhengzaijiazai,maskType: EasyLoadingMaskType.black); apiService = ApiService( Dio(), context: context, @@ -754,7 +754,7 @@ class _StoreOrderPage extends State ///选规格 _queryMiNiDetail(String id, int count) async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); if (count < 0) { shopCarGoods.shoppingCartSkuItemList.forEach((element) async { if (element.productId == id) { diff --git a/lib/store/store_view/product_sku.dart b/lib/store/store_view/product_sku.dart index 45144057..08902b3e 100644 --- a/lib/store/store_view/product_sku.dart +++ b/lib/store/store_view/product_sku.dart @@ -244,7 +244,7 @@ class _ProductSku extends State { false) == false) { _isTapEd = true; - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); await widget.reduce(widget.miNiDetail, selectSkus); } count -= 1; @@ -275,7 +275,7 @@ class _ProductSku extends State { false) == false) { _isTapEd = true; - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); if (count == 1 && realCount == 0) await widget.addShopCar( widget.miNiDetail, selectSkus, 2); diff --git a/lib/union/union_list.dart b/lib/union/union_list.dart index b00e8b0b..439610b0 100644 --- a/lib/union/union_list.dart +++ b/lib/union/union_list.dart @@ -2,11 +2,14 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; +import 'package:flutter_bmflocation/flutter_bmflocation.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/store.dart'; import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; @@ -14,10 +17,12 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:shimmer/shimmer.dart'; import '../retrofit/data/base_data.dart'; +import '../retrofit/data/product_show.dart'; import '../retrofit/retrofit_api.dart'; import '../utils/flutter_utils.dart'; import '../view_widget/classic_header.dart'; import '../view_widget/no_data_view.dart'; +import '../view_widget/round_button.dart'; class UnionList extends StatefulWidget { final String serviceType; @@ -37,6 +42,7 @@ class UnionList extends StatefulWidget { class _UnionList extends State with AutomaticKeepAliveClientMixin { ApiService apiService; List storeList; + BMFCoordinate latLng; final RefreshController _refreshController = RefreshController(); @override @@ -84,7 +90,9 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { controller: _refreshController, enablePullDown: true, enablePullUp: false, - header: MyHeader(color: Colors.white,), + header: MyHeader( + color: Colors.white, + ), physics: BouncingScrollPhysics(), onRefresh: queryStore, child: (storeList == null || storeList.length == 0) @@ -182,6 +190,202 @@ class _UnionList extends State with AutomaticKeepAliveClientMixin { } Widget buildStoreItem(Store store, position) { + return Container( + margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 12.h), + padding: EdgeInsets.all(12.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(6)), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(25), + offset: Offset(0, 1), + blurRadius: 12, + spreadRadius: 0, + ) + ]), + width: double.infinity, + // height: 235.h, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + MImage( + store.facade, + width: 74, + height: 74, + fit: BoxFit.cover, + radius: BorderRadius.circular(6), + errorSrc: "assets/image/default_1.webp", + fadeSrc: "assets/image/default_1.webp", + ), + Container( + decoration: BoxDecoration( + color: Color(0xFF32A060), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(6), + bottomRight: Radius.circular(6), + topRight: Radius.circular(2), + bottomLeft: Radius.circular(2)), + ), + padding: EdgeInsets.symmetric(horizontal: 3.w, vertical: 2.h), + child: Text( + "品牌", + style: TextStyle( + color: Colors.white, + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ) + ], + ), + SizedBox( + width: 12.w, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + store?.storeName ?? "", + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color(0xFF0D0D0D), + fontSize: 14.sp, + fontWeight: MyFontWeight.bold, + ), + ), + SizedBox(height: 6.h), + Row( + children: [ + Text( + S.of(context).ren( + store?.perCapitaConsumption ?? "", + ), + style: TextStyle( + color: Color(0xFF4D4D4D), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + SizedBox(width: 22.w), + Image.asset( + "assets/image/icon_union_location_black.webp", + fit: BoxFit.fill, + height: 12, + width: 12, + ), + SizedBox(width: 4.w), + Text( + (store.distance ?? 0) > 1000 + ? S.of(context).gongli( + ((store.distance ?? 0) / 1000 * 100).toInt() / + 100.0) + : S + .of(context) + .mi(((store.distance ?? 0) * 100).toInt() / 100.0), + style: TextStyle( + color: Color(0xFF4D4D4D), + fontSize: 12.sp, + ), + ), + ], + ), + SizedBox(height: 10.h), + Row( + children: []..addAll( + itemServer(store != null ? store.businessService : "")), + ), + SizedBox(height: store.businessService == ""?40.h:23.h), + if(storeList[position].productShow != null) + Container( + height: 100.h, + child: ListView.builder( + padding: EdgeInsets.zero, + itemCount: (storeList[position].productShow?.length ??0) > 3 ?3:storeList[position].productShow?.length ?? 0, + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + return GestureDetector( + onTap: () {}, + child: unionGoodsItem( + storeList[position].productShow[index]), + ); + }, + ), + ), + ], + )) + ], + ), + ); + } + + ///标签 + List itemServer(String businessService) { + if (businessService == null || businessService == "") return []; + var list = businessService.split(","); + return list + .map((e) => Container( + margin: EdgeInsets.only(right: 8.w), + child: Container( + decoration: BoxDecoration( + color: Color(0xFFF65720), + borderRadius: BorderRadius.circular(1), + ), + padding: EdgeInsets.all(2), + margin: EdgeInsets.only(right: 10.w), + child: Text( + "$e", + style: TextStyle( + color: Colors.white, + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ), + )) + .toList(); + } + + /// + Widget unionGoodsItem(ProductShow productShow) { + return Container( + width: 74.w, + margin: EdgeInsets.only(right: 8.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MImage( + productShow?.imgs[0] ?? "", + width: 74, + height: 74, + fit: BoxFit.cover, + radius: BorderRadius.circular(4), + errorSrc: "assets/image/default_1.webp", + fadeSrc: "assets/image/default_1.webp", + ), + Padding(padding:EdgeInsets.only(top: 8.h), + child: Text( + productShow?.productName ?? "", + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color(0xFFA29E9E), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ),), + ], + ), + ); + } + + //旧ui + Widget buildStoreItems(Store store, position) { return Container( margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 12.h), decoration: BoxDecoration( diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 5d80f3cb..edb2ae17 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -15,6 +15,7 @@ import 'package:huixiang/union/union_list.dart'; import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -54,8 +55,13 @@ class UnionPageState extends State super.dispose(); WidgetsBinding.instance.removeObserver(this); if (Location.getInstance() != null && - Location.getInstance().aMapFlutterLocation != null) - Location.getInstance().aMapFlutterLocation.stopLocation(); + Location + .getInstance() + .aMapFlutterLocation != null) + Location + .getInstance() + .aMapFlutterLocation + .stopLocation(); } @override @@ -63,8 +69,14 @@ class UnionPageState extends State super.didChangeMetrics(); WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { - print("object: ${MediaQuery.of(context).viewInsets.bottom}"); - if (MediaQuery.of(context).viewInsets.bottom == 0) { + print("object: ${MediaQuery + .of(context) + .viewInsets + .bottom}"); + if (MediaQuery + .of(context) + .viewInsets + .bottom == 0) { if (isKeyBoardShow) { isKeyBoardShow = false; //关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题 @@ -92,25 +104,37 @@ class UnionPageState extends State } startLocation() async { - Location.getInstance().startLocation(context, (BaiduLocation result) async { - if (result != null && - result.latitude != null && - result.longitude != null) { - print("location: $result"); - latLng = BMFCoordinate(result.latitude, result.longitude); - latLng = await BMFCalculateUtils.coordConvert( - coordinate: latLng, - fromType: BMF_COORD_TYPE.BD09LL, - toType: BMF_COORD_TYPE.COMMON); - await saveLatLng(latLng, result.province, result.city, result.district); - print("union: Location result ${latLng.latitude} " - "${latLng.longitude}"); - Location.getInstance().stopLocation(); - } else { - await getLatLng(); - } - loadFinish(showLoading: false); - }); + bool powerFlag = false; + try { + powerFlag = await Location.getInstance().startLocation(context, + (BaiduLocation result) async { + if (result != null && + result.latitude != null && + result.longitude != null) { + print("location: $result"); + latLng = BMFCoordinate(result.latitude, result.longitude); + latLng = await BMFCalculateUtils.coordConvert( + coordinate: latLng, + fromType: BMF_COORD_TYPE.BD09LL, + toType: BMF_COORD_TYPE.COMMON); + await saveLatLng( + latLng, result.province, result.city, result.district); + print("union: Location result ${latLng.latitude} " + "${latLng.longitude}"); + Location.getInstance().stopLocation(); + } else { + await getLatLng(); + } + loadFinish(showLoading: false); + }); + } finally { + if (!powerFlag) { + if (await Permission.locationWhenInUse.status.isGranted) { + startLocation(); + } else + loadFinish(showLoading: false); + } + } } saveLatLng(BMFCoordinate latLng, province, city, district) async { @@ -135,7 +159,7 @@ class UnionPageState extends State } queryIpInfo() async { - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); ApiService apiIpService = ApiService(Dio(), context: context, isIp: true); IpData baseData = await apiIpService.getIpInfo().catchError((onError) {}); if (baseData != null) { @@ -145,7 +169,7 @@ class UnionPageState extends State } loadFinish({bool showLoading = true}) { - if (showLoading) EasyLoading.show(status: S.current.zhengzaijiazai); + if (showLoading) EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); _allKey = [GlobalKey(), GlobalKey(), GlobalKey(), GlobalKey()]; setState(() {}); } @@ -221,10 +245,18 @@ class UnionPageState extends State indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: [ - MyTab(text: S.of(context).quanbu), - MyTab(text: S.of(context).chi), - MyTab(text: S.of(context).he), - MyTab(text: S.of(context).wan), + MyTab(text: S + .of(context) + .quanbu), + MyTab(text: S + .of(context) + .chi), + MyTab(text: S + .of(context) + .he), + MyTab(text: S + .of(context) + .wan), ], ), ), @@ -254,7 +286,10 @@ class UnionPageState extends State ], ), padding: - EdgeInsets.only(top: MediaQuery.of(context).padding.top + 17.h), + EdgeInsets.only(top: MediaQuery + .of(context) + .padding + .top + 17.h), decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, diff --git a/lib/view_widget/channel_dialog.dart b/lib/view_widget/channel_dialog.dart index 9e133439..9b235dd9 100644 --- a/lib/view_widget/channel_dialog.dart +++ b/lib/view_widget/channel_dialog.dart @@ -28,7 +28,7 @@ class _ChannelDialog extends State { @override void initState() { super.initState(); - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); queryChannels(); } diff --git a/lib/vip/user_vip_service_page.dart b/lib/vip/user_vip_service_page.dart index 29a2d908..038ec2d9 100644 --- a/lib/vip/user_vip_service_page.dart +++ b/lib/vip/user_vip_service_page.dart @@ -25,7 +25,7 @@ class _UserVipServicePage extends State with WidgetsBindingO void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); - EasyLoading.show(status: S.current.zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai,maskType: EasyLoadingMaskType.black); if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); if (Platform.isIOS) WebView.platform = CupertinoWebView(); }