From 044677b931e04806db4f01ab78909ca5e70e4698 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 30 Aug 2021 19:01:27 +0800 Subject: [PATCH] safety --- lib/home/points_mall_page.dart | 2 +- lib/integral/integral_page.dart | 72 +++++++------ lib/mine/vip_card_page.dart | 170 +++++++++++++++++------------- lib/mine/vip_detail_page.dart | 27 +++-- lib/utils/location.dart | 3 +- lib/utils/painter_bg.dart | 2 + lib/view_widget/custom_image.dart | 2 +- 7 files changed, 160 insertions(+), 118 deletions(-) diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index f46de496..869cbe81 100644 --- a/lib/home/points_mall_page.dart +++ b/lib/home/points_mall_page.dart @@ -245,7 +245,7 @@ class _PointsMallPage extends State onTap: (index) { categoryId = gooodsCategorys[index].id; pageNum = 1; - creditGoods(); + setState(() {});; }, ), ), diff --git a/lib/integral/integral_page.dart b/lib/integral/integral_page.dart index 52e84226..360ba9b7 100644 --- a/lib/integral/integral_page.dart +++ b/lib/integral/integral_page.dart @@ -132,12 +132,13 @@ class _IntegralPage extends State { Widget integralTask() { return Container( - width: double.infinity, + width: MediaQuery.of(context).size.width - 32, + height: 300.h, margin: EdgeInsets.all(16), padding: EdgeInsets.fromLTRB(10.w, 20.h, 10.w, 20.h), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(8)), + borderRadius: BorderRadius.circular(8), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(12), @@ -162,9 +163,8 @@ class _IntegralPage extends State { ), ), ), - Container( - child: AspectRatio( - aspectRatio: 1.5, + Expanded( + child: Container( child: Swiper( loop: false, physics: BouncingScrollPhysics(), @@ -190,7 +190,8 @@ class _IntegralPage extends State { (signInfo.taskList.length % 3 > 0 ? 1 : 0))) : 1), ), - ), + flex: 1, + ) ], ), ); @@ -293,10 +294,10 @@ class _IntegralPage extends State { backgroup: task.limitDay == (task.complateNum ?? task.conplateNum) ? Color(0xFFA0A0A0) : Color(0xFF32A060), - radius: 12, + radius: 12.w, fontSize: 14.sp, fontWeight: FontWeight.bold, - padding: EdgeInsets.fromLTRB(12.w, 4.h, 12.w, 4.h), + padding: EdgeInsets.symmetric(vertical: 4.h, horizontal: 12.w), ), ], ), @@ -306,7 +307,7 @@ class _IntegralPage extends State { Widget signInItem(position) { if (position == 6) { return Container( - padding: EdgeInsets.all(6), + padding: EdgeInsets.all(4), decoration: BoxDecoration( color: Color(0xFFF0F0F2), borderRadius: BorderRadius.circular(4), @@ -317,7 +318,7 @@ class _IntegralPage extends State { children: [ Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( @@ -328,11 +329,9 @@ class _IntegralPage extends State { fontWeight: MyFontWeight.medium, ), ), - SizedBox( - height: 10.h, - ), Container( alignment: Alignment.center, + height: 30.h, child: Text( S.of(context).shenmijifendali, style: TextStyle( @@ -342,6 +341,14 @@ class _IntegralPage extends State { ), ), ), + Text( + "", + style: TextStyle( + color: Color(0xFF353535), + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), ], ), flex: 1, @@ -350,8 +357,8 @@ class _IntegralPage extends State { alignment: Alignment.center, child: Image.asset( "assets/image/icon_gold_blessing.png", - width: 59, - height: 59, + width: 59.w, + height: 59.h, ), ), ], @@ -388,8 +395,8 @@ class _IntegralPage extends State { alignment: Alignment.center, child: Image.asset( "assets/image/icon_gold_coin.png", - width: 30, - height: 30, + width: 30.w, + height: 30.h, ), ), Container( @@ -404,13 +411,14 @@ class _IntegralPage extends State { ? "+${signInfo.rewardList[position]}" : "+10", style: TextStyle( - color: (signInfo != null && - signInfo.signInList != null && - signInfo.signInList.length > position) - ? Colors.white - : Color(0xFF727272), - fontSize: 12.sp, - fontWeight: MyFontWeight.regular), + color: (signInfo != null && + signInfo.signInList != null && + signInfo.signInList.length > position) + ? Colors.white + : Color(0xFF727272), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), ), ), ], @@ -424,7 +432,7 @@ class _IntegralPage extends State { return Container( width: double.infinity, margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h), - padding: EdgeInsets.fromLTRB(20.w, 20.h, 20.w, 20.h), + padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), @@ -467,9 +475,9 @@ class _IntegralPage extends State { crossAxisCount: 4, shrinkWrap: true, itemCount: 7, - mainAxisSpacing: 8.h, - crossAxisSpacing: 18.w, - padding: EdgeInsets.only(bottom: 32.h), + mainAxisSpacing: 8, + crossAxisSpacing: 18, + padding: EdgeInsets.only(bottom: 32), physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return signInItem(position); @@ -483,8 +491,8 @@ class _IntegralPage extends State { child: Container( alignment: Alignment.center, child: RoundButton( - width: 106, - height: 34, + width: 106.w, + height: 34.h, text: (signInfo != null && signInfo.todayHasSignin) ? S.of(context).yiqiandao : S.of(context).lijiqiandao, @@ -494,8 +502,8 @@ class _IntegralPage extends State { : Color(0xFF32A060), fontSize: 16.sp, fontWeight: MyFontWeight.regular, - padding: EdgeInsets.fromLTRB(16.w, 6.h, 16.w, 6.h), - radius: 4, + padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 6.h), + radius: 4.w, ), ), ), diff --git a/lib/mine/vip_card_page.dart b/lib/mine/vip_card_page.dart index d66e9ddf..5b793ff4 100644 --- a/lib/mine/vip_card_page.dart +++ b/lib/mine/vip_card_page.dart @@ -32,7 +32,8 @@ class _VipCardPage extends State { _refreshController = RefreshController(); SharedPreferences.getInstance().then((value) { - apiService = ApiService(Dio(), context: context, token: value.getString("token")); + apiService = + ApiService(Dio(), context: context, token: value.getString("token")); queryVipCard(); }); } @@ -40,7 +41,8 @@ class _VipCardPage extends State { List coupons = []; queryVipCard() async { - BaseData> baseData = await apiService.vipList({}).catchError((error) { + BaseData> baseData = + await apiService.vipList({}).catchError((error) { _refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { @@ -70,24 +72,27 @@ class _VipCardPage extends State { controller: _refreshController, onRefresh: queryVipCard, physics: BouncingScrollPhysics(), - child: (coupons != null && coupons.length > 0) ? ListView.builder( - padding: EdgeInsets.symmetric(vertical: 8.h), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - Navigator.of(context).pushNamed('/router/vip_details_page', - arguments: {"id": coupons[position].id}); - }, - child: vipCardItem(coupons[position]), - ); - }, - itemCount: coupons != null ? coupons.length : 0, - ) : NoDataView( - isShowBtn: false, - text: "还没有会员卡~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h), - ), + child: (coupons != null && coupons.length > 0) + ? ListView.builder( + padding: EdgeInsets.symmetric(vertical: 8.h), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed( + '/router/vip_details_page', + arguments: {"id": coupons[position].id}); + }, + child: vipCardItem(coupons[position]), + ); + }, + itemCount: coupons != null ? coupons.length : 0, + ) + : NoDataView( + isShowBtn: false, + text: "还没有会员卡~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h), + ), ), ), ); @@ -107,18 +112,19 @@ class _VipCardPage extends State { Widget vipCardItem(VipCard vipCard) { return Container( - margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w, 8.h), + margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.w), - color: Colors.white, - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ],), + borderRadius: BorderRadius.circular(8.w), + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + ), child: Stack( children: [ Positioned( @@ -144,7 +150,9 @@ class _VipCardPage extends State { Row( children: [ MImage( - (vipCard?.storeList?.length ?? 0) > 0 ? vipCard.storeList[0].logo : "", + (vipCard?.storeList?.length ?? 0) > 0 + ? vipCard.storeList[0].logo + : "", width: 54, height: 54, fit: BoxFit.cover, @@ -185,16 +193,18 @@ class _VipCardPage extends State { ], ), Text.rich( - TextSpan(children: [ - TextSpan( - text:S.of(context).huiyuanka, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Colors.black, + TextSpan( + children: [ + TextSpan( + text: S.of(context).huiyuanka, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), ), - ), - ],), + ], + ), textDirection: TextDirection.ltr, ), ], @@ -214,16 +224,18 @@ class _VipCardPage extends State { size: 24, ), Text.rich( - TextSpan(children: [ - TextSpan( - text:S.of(context).chakanxiangqing, - style: TextStyle( - fontSize: 12.sp, - fontWeight: FontWeight.bold, - color: Colors.black, + TextSpan( + children: [ + TextSpan( + text: S.of(context).chakanxiangqing, + style: TextStyle( + fontSize: 12.sp, + fontWeight: FontWeight.bold, + color: Colors.black, + ), ), - ), - ],), + ], + ), ), ], ), @@ -237,41 +249,47 @@ class _VipCardPage extends State { Expanded( flex: 1, child: Text.rich( - TextSpan(children: [ + TextSpan( + children: [ + TextSpan( + text: "No.${vipCard.id}", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ), + ), + Text.rich( + TextSpan( + children: [ TextSpan( - text: "No.${vipCard.id}", + text: S.of(context).youxiaoqixian, style: TextStyle( - fontSize: 14.sp, + fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: Colors.black, + color: Color(0Xff353535), ), ), - ],), + ], ), ), Text.rich( - TextSpan(children: [ - TextSpan( - text: S.of(context).youxiaoqixian, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0Xff353535), - ), - ), - ],), - ), - Text.rich( - TextSpan(children: [ - TextSpan( - text: S.of(context).changqiyouxiao, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0Xff353535), + TextSpan( + children: [ + TextSpan( + text: S.of(context).changqiyouxiao, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0Xff353535), + ), ), - ), - ],), + ], + ), ), ], ), diff --git a/lib/mine/vip_detail_page.dart b/lib/mine/vip_detail_page.dart index d1d76aea..db2c544b 100644 --- a/lib/mine/vip_detail_page.dart +++ b/lib/mine/vip_detail_page.dart @@ -1,6 +1,7 @@ import 'package:barcode_widget/barcode_widget.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/order_info.dart'; @@ -43,6 +44,11 @@ class _VipDetailPage extends State { vipDetail("", ""); + startLocation(); + } + + startLocation() async { + EasyLoading.show(status: S.current.zhengzaijiazai); Location.getInstance() .aMapFlutterLocation .onResultCallback() @@ -50,15 +56,18 @@ class _VipDetailPage extends State { if (event != null && event["latitude"] != null && event["longitude"] != null) { - SharedPreferences.getInstance().then((value) { - apiService = ApiService(Dio(), - context: context, token: value.getString("token")); - vipDetail(event["latitude"], event["longitude"]); - }); + vipDetail(event["latitude"], event["longitude"]); + } else { + EasyLoading.dismiss(); } }); Location.getInstance().prepareLoc(); - Location.getInstance().startLocation(context); + Location.getInstance().startLocation(context).then((value) { + if (!value) { + EasyLoading.dismiss(); + refreshController.refreshFailed(); + } + }); } VipCard vipCard; @@ -66,6 +75,9 @@ class _VipDetailPage extends State { int current = 1; vipDetail(latitude, longitude) async { + final SharedPreferences value = await SharedPreferences.getInstance(); + if(apiService == null) + apiService = ApiService(Dio(), context: context, token: value.getString("token")); BaseData baseData = await apiService.vipDetail({ "id": widget.arguments["id"], "latitude": "$latitude", @@ -74,10 +86,11 @@ class _VipDetailPage extends State { if (baseData != null && baseData.isSuccess) { vipCard = baseData.data; refreshController.loadComplete(); - setState(() {}); } else { refreshController.loadFailed(); } + print("object:object"); + setState(() {}); } @override diff --git a/lib/utils/location.dart b/lib/utils/location.dart index 70e6eda7..75a6c0cd 100644 --- a/lib/utils/location.dart +++ b/lib/utils/location.dart @@ -74,7 +74,8 @@ class Location { } void stopLocation() { - aMapFlutterLocation.stopLocation(); + if (aMapFlutterLocation != null) + aMapFlutterLocation.stopLocation(); } enableLocation(context) { diff --git a/lib/utils/painter_bg.dart b/lib/utils/painter_bg.dart index d1a7f4bf..07661da5 100644 --- a/lib/utils/painter_bg.dart +++ b/lib/utils/painter_bg.dart @@ -15,6 +15,7 @@ class BgPainter extends CustomPainter { void paint(Canvas canvas, Size size) { Path path = Path(); + //移动到点 P0点 也是曲线的起点 path.lineTo(0, 0); path.lineTo(size.width, 0); @@ -23,6 +24,7 @@ class BgPainter extends CustomPainter { path.close(); Paint paint = Paint() + ..isAntiAlias = true ..color = bgColor ..style = PaintingStyle.fill; diff --git a/lib/view_widget/custom_image.dart b/lib/view_widget/custom_image.dart index 1eccbb72..589216a1 100644 --- a/lib/view_widget/custom_image.dart +++ b/lib/view_widget/custom_image.dart @@ -13,7 +13,7 @@ class MImage extends StatelessWidget { final BoxFit fit; final bool isCircle; - double scaleIndex = 2.5; + double scaleIndex = 3.5; MImage( this.src, {