From b6247e70bbdd3410904973e06b54e690d5f266de Mon Sep 17 00:00:00 2001 From: fmk Date: Tue, 24 Aug 2021 17:39:42 +0800 Subject: [PATCH] safety --- lib/home/activity_list_page.dart | 4 +- lib/home/home_page.dart | 4 +- lib/home/huixiang_brand_page.dart | 65 ++++++--------- lib/home/points_mall_page.dart | 12 ++- lib/mine/mine_page.dart | 5 +- lib/order/order_detail_page.dart | 123 ++++++++++++++++------------ lib/retrofit/retrofit_api.dart | 10 +++ lib/setting/help_feedback_page.dart | 97 ++++++++++++++++------ lib/union/store_details_page.dart | 54 ++++++------ lib/union/union_details_page.dart | 4 +- lib/union/union_page.dart | 51 ++++++------ 11 files changed, 246 insertions(+), 183 deletions(-) diff --git a/lib/home/activity_list_page.dart b/lib/home/activity_list_page.dart index d050c190..cbb45354 100644 --- a/lib/home/activity_list_page.dart +++ b/lib/home/activity_list_page.dart @@ -82,7 +82,9 @@ class _ActivityListPage extends State return MyFooter(mode); }, ), - onRefresh: queryActivity, + onRefresh: () { + setState(() {}); + }, child: FutureBuilder( future: queryActivity(), builder: (context, snapshot) { diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index f82adf5f..94bb5815 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -158,7 +158,9 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), - onRefresh: queryHome, + onRefresh: (){ + setState(() {}); + }, child: SingleChildScrollView( physics: NeverScrollableScrollPhysics(), child: FutureBuilder( diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index 7b5877bc..1cb7553a 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/lib/home/huixiang_brand_page.dart @@ -33,7 +33,6 @@ class BrandPage extends StatefulWidget { class _BrandPage extends State with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { - final ScrollController scrollController = ScrollController(); final RefreshController refreshController = RefreshController(); @@ -46,18 +45,22 @@ class _BrandPage extends State var isShowMore = false; Future queryHome() async { - EasyLoading.show(status: S - .of(context) - .zhengzaijiazai); + EasyLoading.show(status: S.current.zhengzaijiazai); final SharedPreferences value = await SharedPreferences.getInstance(); - apiService = ApiService(Dio(), context: context, - token: value.getString('token'), showLoading: false); + apiService = ApiService(Dio(), + context: context, token: value.getString('token'), showLoading: false); - BaseData baseData = await apiService.queryHome().catchError(( - error) { + BaseData baseData = + await apiService.queryHome().catchError((error) { refreshController.refreshFailed(); }); + if (baseData != null && baseData.isSuccess) { + brandData = baseData.data; + } else { + refreshController.refreshFailed(); + } + BaseData> banner = await apiService.queryBanner({ "model": {"type": "BRAND_APP"}, }).catchError((error) { @@ -82,17 +85,9 @@ class _BrandPage extends State refreshController.refreshFailed(); } EasyLoading.dismiss(); - if (baseData != null && baseData.isSuccess) { - refreshController.refreshCompleted(); - brandData = baseData.data; - } else { - refreshController.refreshFailed(); - } - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); + refreshController.refreshCompleted(); + print("huixiang_______"); + if(mounted) setState(() {}); } @override @@ -105,6 +100,9 @@ class _BrandPage extends State setState(() {}); } }); + + queryHome(); + } @override @@ -112,10 +110,7 @@ class _BrandPage extends State super.build(context); return Scaffold( appBar: AppBar( - toolbarHeight: 40.h - MediaQuery - .of(context) - .padding - .top, + toolbarHeight: 40.h - MediaQuery.of(context).padding.top, backgroundColor: Colors.white, elevation: 0, ), @@ -139,14 +134,8 @@ class _BrandPage extends State child: Container( color: Color(0xFFF7F7F7), margin: EdgeInsets.only(top: 16.h), - child: FutureBuilder( - future: queryHome(), - builder: (context, snapshot) { - //ConnectionState - return Column( - children: homeChildItem(), - ); - }, + child: Column( + children: homeChildItem(), ), ), ), @@ -265,7 +254,7 @@ class _BrandPage extends State TextSpan(children: [ TextSpan( text: - brandData == null ? "" : brandData.originator, + brandData == null ? "" : brandData.originator, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.sp, @@ -273,9 +262,7 @@ class _BrandPage extends State ), ), TextSpan( - text: " ${S - .of(context) - .jituanchuangbanren}", + text: " ${S.of(context).jituanchuangbanren}", style: TextStyle( fontSize: 10.sp, color: Colors.black, @@ -308,9 +295,7 @@ class _BrandPage extends State mainAxisSize: MainAxisSize.max, children: [ Text( - S - .of(context) - .gengduo, + S.of(context).gengduo, style: TextStyle( fontSize: 12.sp, color: Colors.black, @@ -370,9 +355,7 @@ class _BrandPage extends State height: 40.h, ), Text( - S - .of(context) - .linian, + S.of(context).linian, style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.bold, diff --git a/lib/home/points_mall_page.dart b/lib/home/points_mall_page.dart index f0472dbd..21cee1ff 100644 --- a/lib/home/points_mall_page.dart +++ b/lib/home/points_mall_page.dart @@ -162,11 +162,6 @@ class _PointsMallPage extends State String categoryId; - _refresh() { - pageNum = 1; - creditGoods(); - } - @override Widget build(BuildContext context) { super.build(context); @@ -182,9 +177,12 @@ class _PointsMallPage extends State }, ), controller: _refreshController, - onRefresh: _refresh, + onRefresh: () { + pageNum = 1; + setState(() {}); + }, onLoading: () { - creditGoods(); + setState(() {}); }, child: SingleChildScrollView( child: Container( diff --git a/lib/mine/mine_page.dart b/lib/mine/mine_page.dart index e9ab6439..fb41cb92 100644 --- a/lib/mine/mine_page.dart +++ b/lib/mine/mine_page.dart @@ -136,7 +136,10 @@ class _MinePage extends State with AutomaticKeepAliveClientMixin { enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), - onRefresh: queryUserInfo, + onRefresh: () { + // queryUserInfo + setState(() {}); + }, child: SingleChildScrollView( child: Container( child: Stack( diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index 5a7427ac..9582ca60 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -718,13 +718,8 @@ class _OrderDetailPage extends State { children: [ InkWell( onTap: () { - // showModalBottomSheet( - // context: context, - // builder: (context) { - // return PayInputWidget(); - // }, - // ); if (payStatus == 0) { + orderCancel(); } else if (payStatus < 4) { SmartDialog.show( widget: TextImageWidget( @@ -751,29 +746,32 @@ class _OrderDetailPage extends State { ); } }, - child: Column( - children: [ - Image.asset( - payStatus == 0 - ? "assets/image/icon_order_cancel.png" - : "assets/image/icon_request_refund.png", - width: 24.w, - height: 24.h, - fit: BoxFit.contain, - ), - SizedBox( - height: 8.h, - ), - Text( - payStatus == 0 - ? S.of(context).quxiaodingdan - : S.of(context).shenqingtuikuan, - style: TextStyle( - color: Color(0xFF353535), - fontSize: 12.sp, + child: Container( + padding: EdgeInsets.all(5), + child: Column( + children: [ + Image.asset( + payStatus == 0 + ? "assets/image/icon_order_cancel.png" + : "assets/image/icon_request_refund.png", + width: 24.w, + height: 24.h, + fit: BoxFit.contain, ), - ), - ], + SizedBox( + height: 8.h, + ), + Text( + payStatus == 0 + ? S.of(context).quxiaodingdan + : S.of(context).shenqingtuikuan, + style: TextStyle( + color: Color(0xFF353535), + fontSize: 12.sp, + ), + ), + ], + ), ), ), GestureDetector( @@ -785,32 +783,39 @@ class _OrderDetailPage extends State { (orderInfo != null && orderInfo.storeVO != null) ? (orderInfo.storeVO.id ?? "") : ""; - aginOrder(storeId); + String storeName = + (orderInfo != null && orderInfo.storeVO != null) + ? (orderInfo.storeVO.storeName ?? "") + : ""; + aginOrder(storeId, storeName); } }, - child: Column( - children: [ - Image.asset( - payStatus == 0 - ? "assets/image/icon_order_renminbi.png" - : "assets/image/icon_order_agin.png", - width: 24.w, - height: 24.h, - fit: BoxFit.contain, - ), - SizedBox( - height: 8.h, - ), - Text( - payStatus == 0 - ? S.of(context).jixuzhifu - : S.of(context).zailaiyidan, - style: TextStyle( - color: Color(0xFF32A060), - fontSize: 12.sp, + child: Container( + padding: EdgeInsets.all(5), + child: Column( + children: [ + Image.asset( + payStatus == 0 + ? "assets/image/icon_order_renminbi.png" + : "assets/image/icon_order_agin.png", + width: 24.w, + height: 24.h, + fit: BoxFit.contain, ), - ), - ], + SizedBox( + height: 8.h, + ), + Text( + payStatus == 0 + ? S.of(context).jixuzhifu + : S.of(context).zailaiyidan, + style: TextStyle( + color: Color(0xFF32A060), + fontSize: 12.sp, + ), + ), + ], + ), ), ), ], @@ -830,9 +835,19 @@ class _OrderDetailPage extends State { } } - aginOrder(storeId) { - Navigator.of(context) - .pushNamed('/router/union_detail_page', arguments: {"id": storeId}); + orderCancel() async { + BaseData baseData = await apiService.orderCancel(widget.arguments["id"]); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("订单取消成功"); + Future.delayed(Duration(milliseconds: 300), () { + queryDetails(); + }); + } + } + + aginOrder(storeId, storeName) { + Navigator.of(context).pushNamed('/router/union_detail_page', + arguments: {"id": storeId, "storeName": storeName}); } Widget buildCommodity() { diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index d2d2d0eb..a14d01cc 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -361,4 +361,14 @@ abstract class ApiService { Future> shippingTrace( @Path("shipperCode") String shipperCode, @Path("logisticCode") String logisticCode); + + ///反馈 + @POST("/other/report") + Future> report(@Body() Map map); + + ///取消订单 + @GET("/order/orderCancel?id={id}") + Future> orderCancel(@Path("id") String id); + + } diff --git a/lib/setting/help_feedback_page.dart b/lib/setting/help_feedback_page.dart index 5ea510fa..f6279baf 100644 --- a/lib/setting/help_feedback_page.dart +++ b/lib/setting/help_feedback_page.dart @@ -1,9 +1,15 @@ +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class HelpFeedbackPage extends StatefulWidget { @override @@ -15,6 +21,18 @@ class HelpFeedbackPage extends StatefulWidget { class _HelpFeedbackPage extends State { var _isExpanded = [false, false, false]; + ApiService apiService; + + @override + void initState() { + super.initState(); + + SharedPreferences.getInstance().then((value) { + apiService = ApiService(Dio(), context: context, token: value.getString("token")); + }); + + } + @override Widget build(BuildContext context) { return Scaffold( @@ -119,16 +137,21 @@ class _HelpFeedbackPage extends State { ), flex: 1, ), - Container( - height: 54.h, - alignment: Alignment.center, - color: Color(0xFF32A060), - child: RoundButton( - text: S.of(context).tijiao, - backgroup: Color(0xFF32A060), - textColor: Colors.white, - fontSize: 16.sp, - fontWeight: FontWeight.bold, + InkWell( + onTap: () { + report(); + }, + child: Container( + height: 54.h, + alignment: Alignment.center, + color: Color(0xFF32A060), + child: RoundButton( + text: S.of(context).tijiao, + backgroup: Color(0xFF32A060), + textColor: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.bold, + ), ), ), ], @@ -137,6 +160,25 @@ class _HelpFeedbackPage extends State { ); } + report() async { + var content = editingController.text; + var phone = phoneController.text; + BaseData baseData = await apiService.report({ + "mobile": phone, + "reportContent": content, + }); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("反馈成功"); + Navigator.of(context).pop(); + } else { + SmartDialog.showToast("反馈失败"); + } + } + + final TextEditingController editingController = TextEditingController(); + final TextEditingController phoneController = TextEditingController(); + int textLength = 0; + _feedback() { return Container( width: double.infinity, @@ -161,6 +203,13 @@ class _HelpFeedbackPage extends State { alignment: Alignment.topLeft, child: TextField( maxLines: 5, + controller: editingController, + onChanged: (value) { + setState(() { + textLength = value.length; + }); + }, + maxLength: 50, decoration: InputDecoration( border: InputBorder.none, hintText: S.of(context).fankuilizi, @@ -172,18 +221,18 @@ class _HelpFeedbackPage extends State { ), ), ), - Container( - alignment: Alignment.bottomRight, - padding: EdgeInsets.only(right: 20.w), - child: Text( - "0/50", - style: TextStyle( - fontSize: 14.sp, - fontWeight: FontWeight.w400, - color: Color(0xffA29E9E), - ), - ), - ), + // Container( + // alignment: Alignment.bottomRight, + // padding: EdgeInsets.only(right: 20.w), + // child: Text( + // "$textLength/50", + // style: TextStyle( + // fontSize: 14.sp, + // fontWeight: FontWeight.w400, + // color: Color(0xffA29E9E), + // ), + // ), + // ), ], ), ); @@ -193,7 +242,7 @@ class _HelpFeedbackPage extends State { return Container( width: double.infinity, margin: EdgeInsets.all(16.w), - decoration: new BoxDecoration( + decoration: BoxDecoration( color: Color(0xffffffff), borderRadius: BorderRadius.circular(4.0), boxShadow: [ @@ -211,6 +260,8 @@ class _HelpFeedbackPage extends State { margin: EdgeInsets.fromLTRB(20.w, 0, 20.w, 0), alignment: Alignment.topLeft, child: TextField( + controller: phoneController, + inputFormatters: [LengthLimitingTextInputFormatter(11)], decoration: InputDecoration( border: InputBorder.none, hintText: S.of(context).qingshuruyouxiaoshoujihaoma, diff --git a/lib/union/store_details_page.dart b/lib/union/store_details_page.dart index 284beb1a..d278e59e 100644 --- a/lib/union/store_details_page.dart +++ b/lib/union/store_details_page.dart @@ -475,7 +475,8 @@ class _StoreDetailsPage extends State child: Row( children: [ Text( - S.of(context) + S + .of(context) .pinglun_(commentTotal.toString()), style: TextStyle( fontSize: 16.sp, @@ -519,8 +520,31 @@ class _StoreDetailsPage extends State ), ); }, - ) - else + ), + if (memberList != null && memberList.length > 0) + Container( + height: 63.h, + decoration: BoxDecoration( + color: Color(0xFFF2F2F2), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 2), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + alignment: Alignment.center, + child: Text( + S.of(context).yixiansquanbupinglun, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + ), + ), + ), + if (memberList == null || memberList.length == 0) Container( width: double.infinity, height: 80.h, @@ -965,30 +989,6 @@ class _StoreDetailsPage extends State ), ), ), - if (index == max - 1) - Container( - height: 63.h, - decoration: BoxDecoration( - color: Color(0xffF2F2F2), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 2), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - margin: EdgeInsets.only(top: 30.h), - alignment: Alignment.center, - child: Text( - S.of(context).yixiansquanbupinglun, - style: TextStyle( - fontSize: 14.sp, - color: Color(0xff353535), - ), - ), - ), ], ), ); diff --git a/lib/union/union_details_page.dart b/lib/union/union_details_page.dart index 552e8077..ede3546d 100644 --- a/lib/union/union_details_page.dart +++ b/lib/union/union_details_page.dart @@ -98,7 +98,9 @@ class _UnionDetailsPage extends State { enablePullUp: false, header: MyHeader(), physics: BouncingScrollPhysics(), - onRefresh: queryStoreInfo, + onRefresh: () { + setState(() {}); + }, child: SingleChildScrollView( physics: NeverScrollableScrollPhysics(), child: Column( diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 5e368dad..e5322e7d 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -75,6 +75,19 @@ class _UnionPage extends State super.initState(); WidgetsBinding.instance.addObserver(this); + eventBus.on().listen((event) { + if (event.type < 3) { + setState(() {}); + } + }); + + getLatLng(); + startLocation(); + } + + startLocation() async { + EasyLoading.show(status: S.current.zhengzaijiazai); + Location.getInstance().aMapFlutterLocation .onResultCallback().listen((event) { if (event != null && @@ -88,16 +101,16 @@ class _UnionPage extends State latLng = BMFCoordinate(event["latitude"], event["longitude"]); } BMFCalculateUtils.coordConvert( - coordinate: latLng, - fromType: BMF_COORD_TYPE.BD09LL, - toType: BMF_COORD_TYPE.COMMON) + coordinate: latLng, + fromType: BMF_COORD_TYPE.BD09LL, + toType: BMF_COORD_TYPE.COMMON) .then((value) { this.latLng = value; saveLatLng( value, event["province"], event["city"], event["district"]); print( - "value: ${value.latitude} " - "${value.longitude}", + "union: Location result ${value.latitude} " + "${value.longitude}", ); queryStore( "${value.latitude}", @@ -117,24 +130,11 @@ class _UnionPage extends State } }); - eventBus.on().listen((event) { - print("object: UnionPage"); - if (event.type < 3) { - setState(() {}); - } - }); - - getLatLng(); Location.getInstance().prepareLoc(); - startLocation(); - } - - startLocation() async { - EasyLoading.show(status: S.current.zhengzaijiazai); Location.getInstance().startLocation(context).then((value) { if (!value) { EasyLoading.dismiss(); - refreshController.refreshCompleted(); + refreshController.refreshFailed(); } }); } @@ -151,16 +151,13 @@ class _UnionPage extends State getLatLng() async { SharedPreferences.getInstance().then( (value) => { - apiService = ApiService(Dio(), - context: context, - token: value.getString('token'), - showLoading: false), + apiService = ApiService(Dio(), context: context, + token: value.getString('token'), showLoading: false), if (value.containsKey("latitude") && value.containsKey("longitude") && value.containsKey("province") && value.containsKey("city") && - value.containsKey("district")) - { + value.containsKey("district")) { latLng = BMFCoordinate(double.tryParse(value.getString("latitude")), double.tryParse(value.getString("longitude"))), queryStore( @@ -201,14 +198,14 @@ class _UnionPage extends State }).catchError((error) { refreshController.refreshFailed(); }); - EasyLoading.dismiss(); if (baseData != null && baseData.isSuccess) { storeList = baseData.data; refreshController.refreshCompleted(); - setState(() {}); } else { refreshController.refreshFailed(); } + EasyLoading.dismiss(); + setState(() {}); } @override