Browse Source

safety

master
fmk 3 years ago
parent
commit
2ebf20808f
  1. 5
      lib/address/address_map_page.dart
  2. 18
      lib/home/activity_list_page.dart
  3. 81
      lib/home/home_page.dart
  4. 65
      lib/home/huixiang_brand_page.dart
  5. 93
      lib/home/points_mall_page.dart
  6. 2
      lib/integral/integral_detailed_page.dart
  7. 12
      lib/integral/integral_page.dart
  8. 7
      lib/login/login_page.dart
  9. 4
      lib/main.dart
  10. 17
      lib/main_page.dart
  11. 59
      lib/mine/mine_page.dart
  12. 31
      lib/mine/mine_vip_level_page.dart
  13. 37
      lib/order/order_history_page.dart
  14. 7
      lib/order/store_selector_page.dart
  15. 17
      lib/retrofit/retrofit_api.dart
  16. 3
      lib/union/store_details_page.dart
  17. 144
      lib/union/union_details_page.dart
  18. 54
      lib/union/union_page.dart
  19. 8
      lib/utils/location.dart
  20. 65
      lib/view_widget/classic_header.dart
  21. 14
      pubspec.lock
  22. 3
      pubspec.yaml

5
lib/address/address_map_page.dart

@ -15,6 +15,7 @@ import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart';
import 'package:flutter_bmflocation/bdmap_location_flutter_plugin.dart';
import 'package:flutter_bmflocation/flutter_baidu_location_android_option.dart';
import 'package:flutter_bmflocation/flutter_baidu_location_ios_option.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/address.dart';
@ -199,10 +200,10 @@ class _AddressMapPage extends State<AddressMapPage> {
if (await Permission.location.isPermanentlyDenied) {
requestDialog();
} else if (await Permission.location.isGranted) {
SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai, animationDurationTemp: Duration(seconds: 1));
EasyLoading.show(status: S.of(context).zhengzaijiazai);
aMapFlutterLocation.startLocation();
Future.delayed(Duration(seconds: 6), () {
SmartDialog.dismiss();
EasyLoading.dismiss();
});
} else if (await Permission.location.isUndetermined) {
await Permission.location.request();

18
lib/home/activity_list_page.dart

@ -30,11 +30,6 @@ class _ActivityListPage extends State<ActivityListPage>
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
queryActivity(),
});
eventBus.on<EventType>().listen((event) {
if (event.type < 3) {
@ -46,6 +41,8 @@ class _ActivityListPage extends State<ActivityListPage>
List<Activity> activityList;
queryActivity() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(), context: context, token: value.getString('token'));
BaseData<PageInfo<Activity>> baseData = await apiService.informationList({
"pageNum": 1,
"pageSize": 10,
@ -57,9 +54,7 @@ class _ActivityListPage extends State<ActivityListPage>
});
if (baseData != null && baseData.isSuccess) {
_refreshController.refreshCompleted();
setState(() {
activityList = baseData.data.list;
});
}
}
@ -88,7 +83,10 @@ class _ActivityListPage extends State<ActivityListPage>
},
),
onRefresh: queryActivity,
child: ListView.builder(
child: FutureBuilder(
future: queryActivity(),
builder: (context, snapshot) {
return ListView.builder(
itemCount: activityList == null ? 0 : activityList.length,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
@ -121,7 +119,9 @@ class _ActivityListPage extends State<ActivityListPage>
),
);
},
),
);
},
)
),
),
);

81
lib/home/home_page.dart

@ -1,6 +1,7 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
@ -46,14 +47,6 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: false),
queryHome(),
});
eventBus.on<EventType>().listen((event) {
if (event.type < 3) {
setState(() {});
@ -84,9 +77,13 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
Founder founder;
queryHome() async {
SmartDialog.showLoading(
msg: S.of(context).zhengzaijiazai,
animationDurationTemp: Duration(seconds: 1));
// SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
EasyLoading.show(status: S.of(context).zhengzaijiazai);
final SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(Dio(), context: context,
token: value.getString('token'), showLoading: false);
BaseData<PageInfo<BannerData>> baseData = await apiService.queryBanner({
"model": {"type": "HOME_PAGE"},
}).catchError((onError) {
@ -95,10 +92,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
if (baseData != null && baseData.isSuccess) {
bannerData.clear();
bannerData.addAll(baseData.data.records);
setState(() {
if (bannerData.length > 0)
controller.move(0, animation: false);
});
if (bannerData.length > 0) controller.move(0, animation: false);
}
BaseData brand = await apiService.queryHomeBrand().catchError((onError) {
@ -137,10 +131,10 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
gooods.clear();
gooods.addAll(goodsData.data.list);
}
SmartDialog.dismiss();
// SmartDialog.dismiss();
EasyLoading.dismiss();
if (baseData != null && baseData.isSuccess) {
refreshController.refreshCompleted();
if (mounted) setState(() {});
} else {
refreshController.refreshFailed();
}
@ -167,7 +161,10 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
onRefresh: queryHome,
child: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Column(
child: FutureBuilder(
future: queryHome(),
builder: (context, snapshot) {
return Column(
children: [
banner(),
SizedBox(
@ -303,6 +300,8 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
),
// integralStore(),
],
);
},
),
),
),
@ -597,14 +596,14 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
return Container(
height: 90.h,
margin: EdgeInsets.only(bottom: 18.h),
child: ListView.builder(
padding: EdgeInsets.only(left: 10.w, right: 10.w),
scrollDirection: Axis.horizontal,
child: Swiper(
physics: BouncingScrollPhysics(),
viewportFraction: 0.32,
scale: 0.7,
itemBuilder: (context, position) {
return Container(
height: 60.h,
width: 120.w,
// height: 60.h,
// width: 120.w,
margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h),
decoration: BoxDecoration(
color: Colors.white,
@ -630,6 +629,38 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
itemCount:
(brandData != null && brandData.length > 0) ? brandData.length : 0,
),
// child: ListView.builder(
// padding: EdgeInsets.only(left: 10.w, right: 10.w),
// scrollDirection: Axis.horizontal,
// physics: BouncingScrollPhysics(),
// itemBuilder: (context, position) {
// return Container(
// height: 60.h,
// width: 120.w,
// margin: EdgeInsets.symmetric(horizontal: 3.w, vertical: 15.h),
// decoration: BoxDecoration(
// color: Colors.white,
// boxShadow: [
// BoxShadow(
// color: Colors.black.withAlpha(37),
// offset: Offset(0, 2),
// blurRadius: 5,
// spreadRadius: 0,
// )
// ],
// borderRadius: BorderRadius.circular(8),
// ),
// child: MImage(
// brandData != null ? brandData[position].image : "",
// radius: BorderRadius.circular(8),
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_2_1.png",
// fadeSrc: "assets/image/default_2_1.png",
// ),
// );
// },
// itemCount: (brandData != null && brandData.length > 0) ? brandData.length : 0,
// ),
);
}
@ -673,7 +704,9 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
),
);
},
itemCount: (bannerData != null && bannerData.length > 0) ? bannerData.length : 1,
itemCount: (bannerData != null && bannerData.length > 0)
? bannerData.length
: 1,
),
),
);

65
lib/home/huixiang_brand_page.dart

@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/image_render.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
@ -32,7 +33,9 @@ class BrandPage extends StatefulWidget {
class _BrandPage extends State<BrandPage>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
ScrollController scrollController = ScrollController();
final ScrollController scrollController = ScrollController();
final RefreshController refreshController = RefreshController();
ApiService apiService;
List<Brand> brands = [];
@ -40,11 +43,19 @@ class _BrandPage extends State<BrandPage>
List<GlobalKey> globaKeys = [];
List<BannerData> bannerData = [];
// List<String> brandText = [];
var isShowMore = false;
queryHome() async {
BaseData<BrandData> baseData = await apiService.queryHome().catchError((error) {
Future 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);
BaseData<BrandData> baseData = await apiService.queryHome().catchError((
error) {
refreshController.refreshFailed();
});
BaseData<PageInfo<BannerData>> banner = await apiService.queryBanner({
@ -55,9 +66,7 @@ class _BrandPage extends State<BrandPage>
bannerData.clear();
bannerData.addAll(banner.data.records);
BaseData brand = await apiService.queryHomeBrand().catchError((onError) {
refreshController.refreshFailed();
}).catchError((onError) {
BaseData brand = await apiService.queryHomeBrand().catchError((error) {
refreshController.refreshFailed();
});
if (brand != null && brand.isSuccess) {
@ -69,30 +78,27 @@ class _BrandPage extends State<BrandPage>
brands.forEach((element) {
globaKeys.add(GlobalKey());
});
setState(() {});
} else {
refreshController.refreshFailed();
}
EasyLoading.dismiss();
if (baseData != null && baseData.isSuccess) {
refreshController.refreshCompleted();
brandData = baseData.data;
setState(() {});
} else {
refreshController.refreshFailed();
}
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
}
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
queryHome(),
});
eventBus.on<EventType>().listen((event) {
print("object: BrandPage");
if (event.type < 3) {
@ -101,14 +107,15 @@ class _BrandPage extends State<BrandPage>
});
}
RefreshController refreshController = RefreshController();
@override
Widget build(BuildContext context) {
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,
),
@ -132,8 +139,14 @@ class _BrandPage extends State<BrandPage>
child: Container(
color: Color(0xFFF7F7F7),
margin: EdgeInsets.only(top: 16.h),
child: Column(
child: FutureBuilder(
future: queryHome(),
builder: (context, snapshot) {
//ConnectionState
return Column(
children: homeChildItem(),
);
},
),
),
),
@ -260,7 +273,9 @@ class _BrandPage extends State<BrandPage>
),
),
TextSpan(
text: " ${S.of(context).jituanchuangbanren}",
text: " ${S
.of(context)
.jituanchuangbanren}",
style: TextStyle(
fontSize: 10.sp,
color: Colors.black,
@ -293,7 +308,9 @@ class _BrandPage extends State<BrandPage>
mainAxisSize: MainAxisSize.max,
children: [
Text(
S.of(context).gengduo,
S
.of(context)
.gengduo,
style: TextStyle(
fontSize: 12.sp,
color: Colors.black,
@ -353,7 +370,9 @@ class _BrandPage extends State<BrandPage>
height: 40.h,
),
Text(
S.of(context).linian,
S
.of(context)
.linian,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,

93
lib/home/points_mall_page.dart

@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
@ -58,31 +59,16 @@ class _PointsMallPage extends State<PointsMallPage>
void initState() {
super.initState();
refreshUserInfo();
eventBus.on<EventType>().listen((event) {
if (event.type < 3) {
setState(() {});
}
if (event.type == 3) {
refreshUserInfo();
creditGoods();
}
});
}
refreshUserInfo() {
if (mounted)
SharedPreferences.getInstance().then((value) => {
client = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: false),
SmartDialog.showLoading(msg: S.current.zhengzaijiazai),
creditGoods(categoryId),
queryUser(),
});
}
int pageNum = 1;
//1-2-3-
@ -103,7 +89,6 @@ class _PointsMallPage extends State<PointsMallPage>
if (banner != null) {
bannerData.clear();
bannerData.addAll(banner.data.records);
setState(() {});
}
BaseData<UserInfo> baseData = await client.queryInfo();
@ -112,11 +97,18 @@ class _PointsMallPage extends State<PointsMallPage>
SharedPreferences.getInstance().then((value) => {
value.setString('user', jsonEncode(baseData.data)),
});
setState(() {});
}
}
creditGoods(categoryId) async {
creditGoods() async {
EasyLoading.show(status: S.current.zhengzaijiazai);
final SharedPreferences value = await SharedPreferences.getInstance();
client = ApiService(Dio(),
context: context, token: value.getString('token'), showLoading: false);
await queryUser();
BaseData<PageInfo<GoodsCategory>> dataCategory =
await client.goodsCategory({
"current": 1,
@ -149,13 +141,12 @@ class _PointsMallPage extends State<PointsMallPage>
_refreshController.loadFailed();
_refreshController.refreshFailed();
});
SmartDialog.dismiss();
EasyLoading.dismiss();
if (baseData != null && baseData.isSuccess) {
if (pageNum == 1) {
goods.clear();
}
goods.addAll(baseData.data.list);
setState(() {
_refreshController.refreshCompleted();
_refreshController.loadComplete();
if (baseData.data.pageNum == baseData.data.pages) {
@ -163,7 +154,6 @@ class _PointsMallPage extends State<PointsMallPage>
} else {
pageNum += 1;
}
});
} else {
_refreshController.loadFailed();
_refreshController.refreshFailed();
@ -174,26 +164,12 @@ class _PointsMallPage extends State<PointsMallPage>
_refresh() {
pageNum = 1;
SmartDialog.showLoading(msg: S.current.zhengzaijiazai);
creditGoods(categoryId);
queryUser();
creditGoods();
}
@override
Widget build(BuildContext context) {
super.build(context);
List<DropdownMenuItem<String>> sortItems = [];
sortString.forEach((element) {
sortItems.add(DropdownMenuItem(
value: element,
child: Text(
element,
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
color: Color(0xff353535)),
)));
});
return SmartRefresher(
enablePullDown: true,
enablePullUp: true,
@ -208,13 +184,15 @@ class _PointsMallPage extends State<PointsMallPage>
controller: _refreshController,
onRefresh: _refresh,
onLoading: () {
SmartDialog.showLoading(msg: S.current.zhengzaijiazai);
creditGoods(categoryId);
creditGoods();
},
child: SingleChildScrollView(
child: Container(
color: Color(0xFFFAFAFA),
child: Column(
child: FutureBuilder(
future: creditGoods(),
builder: (context, snapshot) {
return Column(
children: [
banner(),
userItem(),
@ -223,20 +201,34 @@ class _PointsMallPage extends State<PointsMallPage>
imgPath: "assets/image/icon_points_mall.png",
moreText: _itemText,
moreType: 1,
items: sortItems,
items: sortString
.map((e) => DropdownMenuItem(
value: e,
child: Text(
e,
style: TextStyle(
fontSize: 12.sp,
fontWeight: FontWeight.w500,
color: Color(0xff353535)),
),
),
)
.toList(),
onChanged: _sortChange,
),
Container(
alignment: Alignment.centerLeft,
child: DefaultTabController(
length: gooodsCategorys == null ? 0 : gooodsCategorys.length,
length: gooodsCategorys == null
? 0
: gooodsCategorys.length,
child: TabBar(
isScrollable: true,
//
indicatorColor: Color(0xff39B54A),
labelColor: Color(0xff32A060),
labelStyle:
TextStyle(fontSize: 14.sp, fontWeight: FontWeight.bold),
labelStyle: TextStyle(
fontSize: 14.sp, fontWeight: FontWeight.bold),
unselectedLabelStyle: TextStyle(
fontSize: 14.sp,
fontWeight: FontWeight.w400,
@ -254,7 +246,7 @@ class _PointsMallPage extends State<PointsMallPage>
onTap: (index) {
categoryId = gooodsCategorys[index].id;
pageNum = 1;
creditGoods(categoryId);
creditGoods();
},
),
),
@ -274,7 +266,8 @@ class _PointsMallPage extends State<PointsMallPage>
mainAxisSpacing: 16.w,
//Widget宽高比例 0.59
childAspectRatio: 166 /
(281 / 2 + (281 / 2) * AppUtils.textScale(context)),
(281 / 2 +
(281 / 2) * AppUtils.textScale(context)),
),
itemBuilder: (contetx, index) {
return GestureDetector(
@ -285,8 +278,9 @@ class _PointsMallPage extends State<PointsMallPage>
);
})
],
),
),
);
},
)),
),
);
}
@ -323,8 +317,7 @@ class _PointsMallPage extends State<PointsMallPage>
orderDesc = false;
break;
}
SmartDialog.showLoading(msg: S.current.zhengzaijiazai);
creditGoods(categoryId);
creditGoods();
setState(() {
_itemText = item;
});

2
lib/integral/integral_detailed_page.dart

@ -62,7 +62,7 @@ class _IntegralDetailedPage extends State<IntegralDetailedPage>
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), token: value.getString("token")),
apiService = ApiService(Dio(), context: context, token: value.getString("token")),
userInfo = UserInfo.fromJson(jsonDecode(value.getString('user'))),
queryDetail("bill_cate_point_get"),
});

12
lib/integral/integral_page.dart

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/generated/l10n.dart';
@ -43,9 +44,7 @@ class _IntegralPage extends State<IntegralPage> {
token: value.getString("token"),
showLoading: false);
userinfo = UserInfo.fromJson(jsonDecode(value.getString("user")));
SmartDialog.showLoading(
msg: S.of(context).zhengzaijiazai,
animationDurationTemp: Duration(seconds: 1));
EasyLoading.show(status: S.of(context).zhengzaijiazai);
querySignInfo();
});
}
@ -67,7 +66,8 @@ class _IntegralPage extends State<IntegralPage> {
.indexWhere((element) => element.id == userinfo.memberRankVo.id) +
1);
}
SmartDialog.dismiss(closeType: 3);
// SmartDialog.dismiss(closeType: 3);
EasyLoading.dismiss();
if (baseData != null && baseData.isSuccess) {
signInfo = baseData.data;
setState(() {});
@ -508,7 +508,7 @@ class _IntegralPage extends State<IntegralPage> {
SmartDialog.showToast("今日已签到了", alignment: Alignment.center);
return;
}
SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
EasyLoading.show(status: S.of(context).zhengzaijiazai);
BaseData baseData = await apiService.signIn();
if (baseData != null && baseData.isSuccess) {
querySignInfo();
@ -516,7 +516,7 @@ class _IntegralPage extends State<IntegralPage> {
widget: SignInWidget("${signInfo.signInList.length + 1}",
"${signInfo.rewardList[signInfo.signInList.length]}"));
} else {
SmartDialog.dismiss();
EasyLoading.dismiss();
}
}

7
lib/login/login_page.dart

@ -3,6 +3,7 @@ import 'dart:convert';
import 'dart:io';
import 'dart:ui';
import 'package:flutter/gestures.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
@ -68,7 +69,7 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
sharedPreferences.getString("token") != "") {
Navigator.of(context).popAndPushNamed('/router/main_page');
} else {
client = ApiService(Dio());
client = ApiService(Dio(), context: context);
isShowLogin = true;
setState(() {});
}
@ -274,13 +275,13 @@ class _MyLoginPageState extends State<LoginPage> with TickerProviderStateMixin {
"capcha": code,
"mobile": mobile,
};
SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai);
EasyLoading.show(status: S.of(context).zhengzaijiazai);
BaseData value = await client.memberLogin(param).catchError((error) {
print(error);
SmartDialog.showToast("$error", alignment: Alignment.center);
});
Future.delayed(Duration(seconds: 2), () {
SmartDialog.dismiss();
EasyLoading.dismiss();
if (value.isSuccess) {
saveUserJson(value.data);
eventBus.fire(EventType(3));

4
lib/main.dart

@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bmflocation/bdmap_location_flutter_plugin.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/address/address_map_page.dart';
import 'package:huixiang/address/edit_address_page.dart';
@ -167,6 +168,8 @@ class MyApp extends StatelessWidget {
supportedLocales: S.delegate.supportedLocales,
home: (isFirst ?? true) ? GuidePage() : LoginPage(),
// home: MainPage(),
//EasyLoading.init();
builder: EasyLoading.init(
builder: (context, widget) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
@ -175,6 +178,7 @@ class MyApp extends StatelessWidget {
child: FlutterSmartDialog(child: widget),
);
},
),
onGenerateRoute: (settings) {
final String name = settings.name;
final Function pageContentBuilder = routers[name];

17
lib/main_page.dart

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:io';
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/home/huixiang_brand_page.dart';
import 'package:huixiang/home/main_home_page.dart';
@ -57,6 +58,20 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
super.initState();
WidgetsBinding.instance.addObserver(this);
EasyLoading.instance
..indicatorType = EasyLoadingIndicatorType.circle
// ..indicatorType = EasyLoadingIndicatorType.wave
// ..indicatorType = EasyLoadingIndicatorType.threeBounce
..loadingStyle = EasyLoadingStyle.dark
..indicatorSize = 35.0
..backgroundColor = Colors.white
..progressColor = Colors.green
..progressWidth = 3.0
..userInteractions = false
..dismissOnTap = false;
pushRoute();
_widgetOptions = <Widget>[
@ -189,7 +204,7 @@ class _MainPage extends State<MainPage> with WidgetsBindingObserver {
}
}
PageController pageController = PageController(initialPage: 1);
final PageController pageController = PageController(initialPage: 1);
@override
Widget build(BuildContext context) {

59
lib/mine/mine_page.dart

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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/main.dart';
@ -28,6 +29,10 @@ class MinePage extends StatefulWidget {
class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
ApiService apiService;
UserInfo userinfo;
int rankLevel = 1;
List<Rank> ranks = [];
final RefreshController _refreshController = RefreshController();
_toUserInfo() async {
SharedPreferences shared = await SharedPreferences.getInstance();
@ -63,43 +68,30 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
@override
void initState() {
super.initState();
refreshUserInfo();
eventBus.on<EventType>().listen((event) {
print("EventType: ${event.type}");
if (event.type < 3) {
setState(() {});
}
if (event.type == 3) {
refreshUserInfo();
queryUserInfo();
}
});
}
refreshUserInfo() {
if (mounted)
SharedPreferences.getInstance().then(
(value) => {
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: false),
queryUserInfo() async {
EasyLoading.show(status: S.of(context).zhengzaijiazai);
final SharedPreferences value = await SharedPreferences.getInstance();
if (value.containsKey('user') &&
value.getString('user') != null &&
value.getString('user') != "")
{
userinfo = UserInfo.fromJson(jsonDecode(value.getString('user'))),
},
queryUserInfo()
},
);
value.getString('user') != "") {
userinfo = UserInfo.fromJson(jsonDecode(value.getString('user')));
}
apiService = ApiService(Dio(), context: context,
token: value.getString('token'), showLoading: false);
UserInfo userinfo;
int rankLevel = 1;
List<Rank> ranks = [];
queryUserInfo() async {
SmartDialog.showLoading(msg: S.of(context).zhengzaijiazai, animationDurationTemp: Duration(seconds: 1));
BaseData<List<Rank>> rankData = await apiService.rankList();
if (rankData != null && rankData.isSuccess) {
ranks.clear();
@ -126,12 +118,9 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
} else {
_refreshController.refreshFailed();
}
SmartDialog.dismiss();
if (mounted) setState(() {});
EasyLoading.dismiss();
}
RefreshController _refreshController = RefreshController();
@override
Widget build(BuildContext context) {
super.build(context);
@ -152,7 +141,10 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
child: Stack(
alignment: Alignment.centerRight,
children: [
Column(
FutureBuilder(
future: queryUserInfo(),
builder: (context, snapshot) {
return Column(
children: [
Container(
margin: EdgeInsets.only(right: 16.w),
@ -210,6 +202,8 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
});
});
},
child: Hero(
tag: "vip",
child: MineVipView(
rankLevel,
curLevel: rankLevel,
@ -220,14 +214,17 @@ class _MinePage extends State<MinePage> with AutomaticKeepAliveClientMixin {
userinfo.memberRankVo != null)
? userinfo.memberRankVo.rankOrigin
: 0,
createTime:
(userinfo != null) ? userinfo.createTime : "",
createTime: (userinfo != null)
? userinfo.createTime
: "",
),
),
),
orderOrCard(),
mineList(context),
],
),
);
}),
// buildNotice(),
],
),

31
lib/mine/mine_vip_level_page.dart

@ -1,4 +1,3 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@ -68,23 +67,41 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
child: Column(
children: [
Container(
height: 224.h ,
height: 224.h,
child: Swiper(
viewportFraction: 0.95,
loop: false,
physics: BouncingScrollPhysics(),
controller: controller,
itemBuilder: (context, position) {
if (widget.arguments["rankLevel"] == (position + 1) || !(ranks != null && ranks.isNotEmpty)) {
return Hero(
tag: "vip",
child: MineVipView(
!(ranks != null && ranks.isNotEmpty) ? widget.arguments["rankLevel"] : position + 1,
curLevel: widget.arguments["rankLevel"],
padding: 6.w,
rank: !(ranks != null && ranks.isNotEmpty) ? 0 : widget.arguments["points"],
rankMax: !(ranks != null && ranks.isNotEmpty) ? 0 : (position < (ranks.length - 1))
? ranks[position + 1].rankOrigin
: ranks[position].rankOrigin,
createTime: widget.arguments["createTime"],
),
);
} else {
return MineVipView(
position + 1,
curLevel: widget.arguments["rankLevel"],
padding: 6.w,
rank: widget.arguments["points"],
rankMax: (position < (ranks.length - 1)) ? ranks[position + 1].rankOrigin : ranks[position].rankOrigin,
rankMax: (position < (ranks.length - 1))
? ranks[position + 1].rankOrigin
: ranks[position].rankOrigin,
createTime: widget.arguments["createTime"],
);
}
},
itemCount: (ranks != null && ranks.isNotEmpty) ? ranks.length : 0,
itemCount: (ranks != null && ranks.isNotEmpty) ? ranks.length : 1,
),
),
Container(
@ -181,9 +198,11 @@ class _MineVipLevelPage extends State<MineVipLevelPage> {
children: ranks != null
? ranks.map((e) {
return levelItem(
e, ranks[ranks.indexOf(e)].rankOrigin,
e,
ranks[ranks.indexOf(e)].rankOrigin,
ranks.indexOf(e) == (ranks.length - 1)
? 0 : ranks[ranks.indexOf(e) + 1].rankOrigin);
? 0
: ranks[ranks.indexOf(e) + 1].rankOrigin);
}).toList()
: [],
),

37
lib/order/order_history_page.dart

@ -201,7 +201,7 @@ class _OrderHistoryList extends State<OrderHistoryList>
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(), token: value.getString("token")),
apiService = ApiService(Dio(), context: context, token: value.getString("token")),
queryOrder(),
});
}
@ -219,7 +219,8 @@ class _OrderHistoryList extends State<OrderHistoryList>
blurRadius: 12,
spreadRadius: 0,
)
]),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
@ -430,23 +431,35 @@ class _OrderHistoryList extends State<OrderHistoryList>
orderInfo.refundStatus,
orderInfo.dayFlowCode, (type) {
if (type == 0) {
String storeId =
(orderInfo != null && orderInfo.storeVO != null)
String storeId = (orderInfo != null &&
orderInfo.storeVO != null)
? (orderInfo.storeVO.id ?? "")
: "";
aginOrder(storeId);
} else if (type == 1) {
SmartDialog.show(widget: Tips((){
SmartDialog.show(
widget: Tips(
() {
SmartDialog.dismiss();
}, text: "暂不支持此功能",));
},
text: "暂不支持此功能",
));
} else if (type == 2) {
SmartDialog.show(widget: Tips((){
SmartDialog.show(
widget: Tips(
() {
SmartDialog.dismiss();
}, text: "暂不支持此功能",));
},
text: "暂不支持此功能",
));
} else if (type == 3) {
SmartDialog.show(widget: Tips((){
SmartDialog.show(
widget: Tips(
() {
SmartDialog.dismiss();
}, text: "暂不支持此功能",));
},
text: "暂不支持此功能",
));
} else if (type == 4) {
Navigator.of(context).pushNamed(
'/router/logistics_information_page',
@ -473,8 +486,8 @@ class _OrderHistoryList extends State<OrderHistoryList>
}
aginOrder(storeId) {
Navigator.of(context).pushNamed('/router/union_detail_page',
arguments: {"id": storeId});
Navigator.of(context)
.pushNamed('/router/union_detail_page', arguments: {"id": storeId});
}
String totalPrice(orderInfo) {

7
lib/order/store_selector_page.dart

@ -7,6 +7,7 @@ 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/bdmap_location_flutter_plugin.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/base_data.dart';
@ -119,12 +120,10 @@ class _StoreSelectorPage extends State<StoreSelectorPage> {
if (await Permission.location.isPermanentlyDenied) {
requestDialog();
} else if (await Permission.location.isGranted) {
SmartDialog.showLoading(
msg: S.of(context).zhengzaijiazai,
animationDurationTemp: Duration(seconds: 1));
EasyLoading.show(status: S.of(context).zhengzaijiazai);
aMapFlutterLocation.startLocation();
Future.delayed(Duration(seconds: 6), () {
SmartDialog.dismiss();
EasyLoading.dismiss();
});
} else if (await Permission.location.isUndetermined) {
await Permission.location.request();

17
lib/retrofit/retrofit_api.dart

@ -5,6 +5,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.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/activity.dart';
@ -70,9 +71,10 @@ abstract class ApiService {
debugPrint("method = ${options.method.toString()}");
debugPrint("url = ${options.uri.toString()}");
debugPrint("headers = ${options.headers}");
if (showLoading) {
if (showLoading && !EasyLoading.isShow) {
//loading
SmartDialog.showLoading(msg: S.current.zhengzaijiazai);
// SmartDialog.showLoading(msg: S.current.zhengzaijiazai);
EasyLoading.show(status: S.of(context).zhengzaijiazai);
}
if (options.data is FormData) {
debugPrint("params data = FormData");
@ -81,8 +83,10 @@ abstract class ApiService {
}
debugPrint("params queryParameters = ${options.queryParameters}");
}, onResponse: (Response response) {
if (showLoading) {
SmartDialog.dismiss();
if (showLoading && EasyLoading.isShow) {
// SmartDialog.dismiss();
EasyLoading.dismiss();
}
debugPrint("\n====================== 响应数据开始 =====================");
debugPrint("code = ${response.statusCode}");
@ -112,8 +116,9 @@ abstract class ApiService {
}
debugPrint("======================= 响应数据结束 =======================\n");
}, onError: (DioError e) {
if (showLoading) {
SmartDialog.dismiss();
// SmartDialog.dismiss();
if (EasyLoading.isShow) {
EasyLoading.dismiss();
}
debugPrint("\n=======================错误响应数据 ========================");
debugPrint("type = ${e.type}");

3
lib/union/store_details_page.dart

@ -283,7 +283,8 @@ class _StoreDetailsPage extends State<StoreDetailsPage>
});
if (baseData != null && baseData.isSuccess) {
commentTextController.text = "";
queryMemberCommentList();
await queryMemberCommentList();
toComment();
}
}

144
lib/union/union_details_page.dart

@ -5,6 +5,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:huixiang/generated/l10n.dart';
@ -49,21 +50,14 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
refreshController.dispose();
}
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token')),
queryStoreInfo(),
});
}
StoreInfo storeInfo;
List<Activity> activitys;
queryStoreInfo() async {
final SharedPreferences value = await SharedPreferences.getInstance();
apiService =
ApiService(Dio(), context: context, token: value.getString('token'));
BaseData baseData = await apiService
.queryStoreInfo(widget.arguments["id"])
.catchError((error) {
@ -75,25 +69,27 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
activitys = storeInfo.informationVOPageVO.list
.map((e) => Activity.fromJson(e))
.toList();
if (mounted) setState(() {});
} else {
refreshController.refreshFailed();
}
}
RefreshController refreshController = RefreshController();
final RefreshController refreshController = RefreshController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
background: Color(0xFFF7F7F7),
title: storeInfo == null ? "" : storeInfo.storeName,
title: storeInfo == null ? widget.arguments["storeName"] : storeInfo.storeName,
titleColor: Colors.black87,
titleSize: 18.sp,
leadingColor: Colors.black,
),
body: Column(
body: FutureBuilder(
future: queryStoreInfo(),
builder: (context, snapshot) {
return Column(
children: [
Expanded(
child: SmartRefresher(
@ -114,7 +110,7 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
padding: EdgeInsets.fromLTRB(10, 20, 10, 14),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(8)),
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
@ -159,7 +155,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
),
Expanded(
child: Container(
alignment: Alignment.centerRight,
alignment:
Alignment.centerRight,
child: Text(
S.of(context).ren(
storeInfo != null
@ -192,7 +189,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
Row(
children: itemServer(
storeInfo != null
? storeInfo.businessService : "",
? storeInfo.businessService
: "",
),
),
Row(
@ -203,8 +201,14 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
children: [
Expanded(
child: Text(
S.of(context).yingyeshijian(storeInfo == null
? "" : (storeInfo.openStartTime == null && storeInfo.openEndTime == null)
S.of(context).yingyeshijian(storeInfo ==
null
? ""
: (storeInfo.openStartTime ==
null &&
storeInfo
.openEndTime ==
null)
? S.of(context).quantian
: "${storeInfo.openStartTime.substring(0, storeInfo.openStartTime.lastIndexOf(":"))} "
"- ${storeInfo.openEndTime.substring(0, storeInfo.openEndTime.lastIndexOf(":"))}"),
@ -221,8 +225,10 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
InkWell(
onTap: () {
if (storeInfo == null ||
storeInfo.latitude == null ||
storeInfo.longitude == null ||
storeInfo.latitude ==
null ||
storeInfo.longitude ==
null ||
storeInfo.latitude == "" ||
storeInfo.longitude == "")
return;
@ -230,7 +236,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
'/router/location_map',
arguments: {
"lat": storeInfo.latitude,
"lng": storeInfo.longitude,
"lng":
storeInfo.longitude,
"storeName":
storeInfo.storeName,
});
@ -347,6 +354,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
),
),
],
);
},
),
);
}
@ -793,9 +802,8 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
? activitys[position].coverImg
: "",
aspectRatio: 2.2,
radius: BorderRadius.only(
topRight: Radius.circular(8),
topLeft: Radius.circular(8),
radius: BorderRadius.vertical(
top: Radius.circular(8),
),
fit: BoxFit.cover,
errorSrc: "assets/image/default_2_1.png",
@ -911,26 +919,12 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
);
}
//{"uid":"1412687522458238976",
// "userInfo":{"headimg":"https:\/\/pos.upload.gznl.top\/admin\/2021\/07\/4ed055e5-5341-4080-a6f0-fe97c62d078f.jpg",
// "balance":null,
// "money":"0.00",
// "phone":"13800138000",
// "isBind":true,
// "nickname":"你这橘子洋气呀"
// },
// "baseURL":"https:\/\/pos-test.api.lotus-wallet.com\/app\/",
// "shopId":"1344490596986781696",
// "tenantCode":"1177",
// "position":"30.554638,114.34394500000002",
// "token":"Bearer eyJ0eXAiOiJKc29uV2ViVG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX3R5cGUiOiJNSU5JIiwibmFtZSI6IiIsInRva2VuX3R5cGUiOiJ0b2tlbiIsInVzZXJpZCI6IjE0MTI2ODc1MjI0NTgyMzg5NzYiLCJhY2NvdW50IjoiIiwiZXhwIjoxNjI2Nzk1Nzc0LCJuYmYiOjE2MjY3NjY5NzR9.cggcx_vqTozKS-z9uygjV4uA2yHQ4eWssMAngd2c-i0"}
printMin() async {
String miniAppId = storeInfo.mini.miniAppId;
print("print isExistsApp: ${await Min.isExistsApp(miniAppId)}");
print("print getAppBasePath: ${await Min.getAppBasePath(miniAppId)}");
print("print currentPageUrl: ${await Min.currentPageUrl()}");
print("print runingAppid: ${await Min.runingAppid()}");
// print("print getAppVersionInfo: ${await Min.getAppVersionInfo(miniAppId)}");
debugPrint("print isExistsApp: ${await Min.isExistsApp(miniAppId)}");
debugPrint("print getAppBasePath: ${await Min.getAppBasePath(miniAppId)}");
debugPrint("print currentPageUrl: ${await Min.currentPageUrl()}");
debugPrint("print runingAppid: ${await Min.runingAppid()}");
}
_loginMin() async {
@ -1008,67 +1002,20 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
});
}
Function state;
double progressValue = 0;
String downText = "正在下载中...";
downloadWgt(appid, savePath) async {
downText = S.of(context).zhengzaixiazaizhong;
showCupertinoDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return Material(
type: MaterialType.transparency,
child: StatefulBuilder(builder: (context, status) {
state = status;
return Center(
child: Container(
width: 130.w,
height: 130.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 40.h,
width: 40.w,
child: CircularProgressIndicator(
value: progressValue,
backgroundColor: Colors.yellow,
color: Colors.blue,
valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
),
),
Text(
downText,
style: TextStyle(
color: Colors.black,
fontSize: 16.sp,
fontWeight: FontWeight.bold,
),
),
],
),
),
);
}),
);
});
Response response = await Dio()
.download(storeInfo.mini.miniDownloadUrl, savePath,
onReceiveProgress: (progress, max) {
progressValue = progress.toDouble() / max.toDouble();
// print("print progressValue: $progressValue");
state(() {});
EasyLoading.showProgress(progressValue, status: downText);
});
if (response.statusCode == 200) {
downText = "下载完成";
EasyLoading.showProgress(progressValue, status: downText);
SharedPreferences.getInstance().then((value) {
value.setStringList(
"miniAppid",
@ -1077,15 +1024,12 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
: [])
..add(appid));
});
state(() {});
Future.delayed(Duration(seconds: 1), () {
if (Navigator.canPop(context)) {
Navigator.of(context).pop();
}
});
} else {
print("print 下载失败");
}
Future.delayed(Duration(seconds: 1), () {
EasyLoading.dismiss();
});
}
List<Widget> itemServer(String businessService) {
@ -1112,7 +1056,7 @@ class _UnionDetailsPage extends State<UnionDetailsPage> {
showCallMobile() {
showCupertinoModalPopup(
context: context,
builder: (contetx) {
builder: (context) {
return CupertinoActionSheet(
title: Text(S.of(context).bodadianhua),
actions: [

54
lib/union/union_page.dart

@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart';
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.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/main.dart';
@ -34,8 +35,12 @@ class UnionPage extends StatefulWidget {
class _UnionPage extends State<UnionPage>
with AutomaticKeepAliveClientMixin, WidgetsBindingObserver {
RefreshController refreshController =
final RefreshController refreshController =
RefreshController(initialRefresh: false);
ApiService apiService;
bool isKeyBoardShow = false;
BMFCoordinate latLng;
@override
void dispose() {
@ -46,8 +51,6 @@ class _UnionPage extends State<UnionPage>
refreshController.dispose();
}
bool isKeyBoardShow = false;
@override
void didChangeMetrics() {
super.didChangeMetrics();
@ -67,18 +70,13 @@ class _UnionPage extends State<UnionPage>
});
}
ApiService apiService;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
Location.getInstance()
.aMapFlutterLocation
.onResultCallback()
.listen((event) {
print("value: ");
Location.getInstance().aMapFlutterLocation
.onResultCallback().listen((event) {
if (event != null &&
event["latitude"] != null &&
event["longitude"] != null) {
@ -114,6 +112,8 @@ class _UnionPage extends State<UnionPage>
zoomLevel: 15,
));
});
} else {
EasyLoading.dismiss();
}
});
@ -126,13 +126,19 @@ class _UnionPage extends State<UnionPage>
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();
}
});
}
BMFCoordinate latLng;
saveLatLng(BMFCoordinate latLng, province, city, district) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString("latitude", "${latLng.latitude}");
@ -195,11 +201,11 @@ class _UnionPage extends State<UnionPage>
}).catchError((error) {
refreshController.refreshFailed();
});
SmartDialog.dismiss();
EasyLoading.dismiss();
if (baseData != null && baseData.isSuccess) {
storeList = baseData.data;
refreshController.refreshCompleted();
if (mounted) setState(() {});
setState(() {});
} else {
refreshController.refreshFailed();
}
@ -250,11 +256,7 @@ class _UnionPage extends State<UnionPage>
physics: BouncingScrollPhysics(),
header: MyHeader(),
onRefresh: () {
print(
"object: ${Location.getInstance().aMapFlutterLocation == null}");
Location.getInstance().startLocation(context).then((value) {
refreshController.refreshCompleted();
});
startLocation();
},
child: ListView.builder(
itemCount: storeList == null ? 0 : storeList.length,
@ -265,8 +267,12 @@ class _UnionPage extends State<UnionPage>
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/union_detail_page',
arguments: {"id": storeList[position].id});
Navigator.of(context).pushNamed(
'/router/union_detail_page',
arguments: {
"id": storeList[position].id,
"storeName": storeList[position].storeName
});
},
child: buildStoreItem(storeList[position], position),
);
@ -276,7 +282,7 @@ class _UnionPage extends State<UnionPage>
}
BMFMapController _mapController;
TextEditingController editingController = TextEditingController();
final TextEditingController editingController = TextEditingController();
void onMapCreated(BMFMapController controller) {
_mapController = controller;
@ -302,9 +308,7 @@ class _UnionPage extends State<UnionPage>
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
Location.getInstance().startLocation(context).then((value) {
refreshController.refreshCompleted();
});
startLocation();
},
controller: editingController,
cursorHeight: 30.h,

8
lib/utils/location.dart

@ -48,17 +48,20 @@ class Location {
});
}
Future<void> startLocation(context) async {
Future<bool> startLocation(context) async {
if (!(await Permission.locationWhenInUse.serviceStatus.isEnabled)) {
enableLocation(context);
return;
return false;
}
if (await Permission.location.isPermanentlyDenied) {
requestDialog(context);
return false;
} else if (await Permission.location.isGranted) {
aMapFlutterLocation.startLocation();
return true;
} else if (await Permission.location.isUndetermined) {
await Permission.location.request();
return false;
} else {
if (Platform.isIOS) {
//
@ -66,6 +69,7 @@ class Location {
} else {
await Permission.location.request();
}
return false;
}
}

65
lib/view_widget/classic_header.dart

@ -7,30 +7,33 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'
hide RefreshIndicator, RefreshIndicatorState;
import 'package:flutter/services.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/view_widget/rotate_container.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:rive/rive.dart';
class MyHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
// return CustomHeader();
return MyClassicHeader(
completeIcon: const Icon(Icons.done, color: Color(0xFF32A060)),
refreshStyle: RefreshStyle.Follow,
completeText: S.of(context).shuaxinchenggong,
failedText: S.of(context).shuaxinshibai,
refreshingText: S.of(context).shuaxinzhong,
releaseText: S.of(context).shifangshuaxin,
idleText: S.of(context).xialashuaxin,
completeTextStyle: TextStyle(color: Color(0xFF32A060)),
refreshingIcon: RotateContainer(
rotated: true,
child: Image.asset(
"assets/image/icon_header_loading.png",
width: 24,
height: 24,
iconPos: IconPosition.left,
completeTextStyle: TextStyle(
color: Color(0xFF32A060),
),
completeIcon: Icon(
Icons.done,
color: Color(0xFF32A060),
),
refreshingIcon: SpinKitCircle(
color: Colors.grey,
size: 24.w,
),
);
}
@ -44,14 +47,11 @@ class CustomHeader extends RefreshIndicator {
}
class _CustomHeader extends RefreshIndicatorState<CustomHeader> {
FlareControls flareController = FlareControls();
Artboard _riveArtboard;
RiveAnimationController _controllerIdle;
@override
void initState() {
super.initState();
@ -72,7 +72,6 @@ class _CustomHeader extends RefreshIndicatorState<CustomHeader> {
@override
Widget buildContent(BuildContext context, RefreshStatus mode) {
if (_controllerIdle != null) {
if (mode == RefreshStatus.idle) {
_controllerIdle.isActive = false;
@ -213,21 +212,29 @@ class _ClassicHeaderState extends RefreshIndicatorState<MyClassicHeader> {
Widget buildContent(BuildContext context, RefreshStatus mode) {
Widget textWidget = _buildText(mode);
Widget iconWidget = _buildIcon(mode);
List<Widget> children = <Widget>[iconWidget, textWidget];
final Widget container = Wrap(
spacing: widget.spacing,
textDirection: widget.iconPos == IconPosition.left
? TextDirection.ltr
: TextDirection.rtl,
direction: widget.iconPos == IconPosition.bottom ||
widget.iconPos == IconPosition.top
? Axis.vertical
: Axis.horizontal,
crossAxisAlignment: WrapCrossAlignment.center,
verticalDirection: widget.iconPos == IconPosition.bottom
? VerticalDirection.up
: VerticalDirection.down,
alignment: WrapAlignment.center,
List<Widget> children = <Widget>[
iconWidget,
SizedBox(
width: 10,
),
textWidget
];
final Widget container = Row(
// spacing: widget.spacing,
// textDirection: widget.iconPos == IconPosition.left
// ? TextDirection.ltr
// : TextDirection.rtl,
// direction: widget.iconPos == IconPosition.bottom ||
// widget.iconPos == IconPosition.top
// ? Axis.vertical
// : Axis.horizontal,
// crossAxisAlignment: WrapCrossAlignment.center,
// verticalDirection: widget.iconPos == IconPosition.bottom
// ? VerticalDirection.up
// : VerticalDirection.down,
// alignment: WrapAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: children,
);
return widget.outerBuilder != null

14
pubspec.lock

@ -328,6 +328,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.3"
flutter_easyloading:
dependency: "direct main"
description:
name: flutter_easyloading
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
flutter_html:
dependency: "direct main"
description:
@ -375,6 +382,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.6"
flutter_spinkit:
dependency: "direct main"
description:
name: flutter_spinkit
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.0"
flutter_staggered_grid_view:
dependency: "direct main"
description:

3
pubspec.yaml

@ -86,6 +86,9 @@ dependencies:
sharesdk_plugin: ^1.3.0
flutter_spinkit: ^5.0.0
flutter_easyloading: ^3.0.0
rive: ^0.6.8
flare_flutter: ^3.0.2

Loading…
Cancel
Save