|
|
|
@ -32,6 +32,7 @@ import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
|
|
|
|
|
|
|
|
|
|
class UnionPage extends StatefulWidget { |
|
|
|
|
final int initialIndex; |
|
|
|
|
|
|
|
|
|
UnionPage(Key key, this.initialIndex) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -98,7 +99,8 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
if (tabController == null) |
|
|
|
|
tabController = TabController(length: 4, vsync: this,initialIndex: widget.initialIndex); |
|
|
|
|
tabController = TabController( |
|
|
|
|
length: 4, vsync: this, initialIndex: widget.initialIndex); |
|
|
|
|
// tabController?.addListener(() { |
|
|
|
|
// startLocation(); |
|
|
|
|
// }); |
|
|
|
@ -116,16 +118,18 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
|
|
|
|
|
RefreshController tabRefresh() { |
|
|
|
|
RefreshController tempRef; |
|
|
|
|
if (tabController.index == 0) tempRef = refreshController; |
|
|
|
|
else if (tabController.index == 1) tempRef = refreshController1; |
|
|
|
|
else if (tabController.index == 2) tempRef = refreshController2; |
|
|
|
|
if (tabController.index == 0) |
|
|
|
|
tempRef = refreshController; |
|
|
|
|
else if (tabController.index == 1) |
|
|
|
|
tempRef = refreshController1; |
|
|
|
|
else if (tabController.index == 2) |
|
|
|
|
tempRef = refreshController2; |
|
|
|
|
else if (tabController.index == 3) tempRef = refreshController3; |
|
|
|
|
return tempRef; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
startLocation(bool isOnRefresh) async { |
|
|
|
|
if(!isOnRefresh) |
|
|
|
|
EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
|
if (!isOnRefresh) EasyLoading.show(status: S.current.zhengzaijiazai); |
|
|
|
|
Location.getInstance() |
|
|
|
|
.aMapFlutterLocation |
|
|
|
|
.onResultCallback() |
|
|
|
@ -157,21 +161,20 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
event["province"], |
|
|
|
|
event["city"], |
|
|
|
|
event["district"], |
|
|
|
|
editingController.text,-1); |
|
|
|
|
editingController.text, |
|
|
|
|
-1); |
|
|
|
|
if (_mapController != null) |
|
|
|
|
_mapController.updateMapOptions(BMFMapOptions( |
|
|
|
|
center: value, |
|
|
|
|
zoomLevel: 15, |
|
|
|
|
)); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
getLatLng(); |
|
|
|
|
// EasyLoading.dismiss(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Location.getInstance().prepareLoc(); |
|
|
|
|
Location.getInstance().startLocation(context).then((value) { |
|
|
|
|
if (!value) { |
|
|
|
@ -211,7 +214,8 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
value.getString("province"), |
|
|
|
|
value.getString("city"), |
|
|
|
|
value.getString("district"), |
|
|
|
|
editingController.text,-1), |
|
|
|
|
editingController.text, |
|
|
|
|
-1), |
|
|
|
|
setState(() { |
|
|
|
|
if (_mapController != null) { |
|
|
|
|
_mapController.updateMapOptions(BMFMapOptions( |
|
|
|
@ -234,7 +238,8 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
List<Store> storeList2; |
|
|
|
|
List<Store> storeList3; |
|
|
|
|
|
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,int index) async { |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey, |
|
|
|
|
int index) async { |
|
|
|
|
if (apiService == null) { |
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
apiService = ApiService( |
|
|
|
@ -254,31 +259,38 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
? "" |
|
|
|
|
: ((tabController.index == 1 && index == -1) || index == 1 |
|
|
|
|
? "EATSTORE" |
|
|
|
|
: ((tabController.index == 2 && index == -1) || index == 2 ? "DRINKSTORE" : "HAPPYSTORE")), |
|
|
|
|
: ((tabController.index == 2 && index == -1) || index == 2 |
|
|
|
|
? "DRINKSTORE" |
|
|
|
|
: "HAPPYSTORE")), |
|
|
|
|
}).catchError((error) { |
|
|
|
|
if(index == -1) |
|
|
|
|
tabRefresh().refreshFailed(); |
|
|
|
|
if (index == -1) tabRefresh().refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
if (index == -1 && storeList == null) { |
|
|
|
|
if (tabController.index != 0) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,0); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 0); |
|
|
|
|
if (tabController.index != 1) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,1); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 1); |
|
|
|
|
if (tabController.index != 2) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,2); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 2); |
|
|
|
|
if (tabController.index != 3) |
|
|
|
|
queryStore(latitude, longitude, province, city, district, searchKey,3); |
|
|
|
|
} |
|
|
|
|
if ((tabController.index == 0 && index == -1) || index == 0) storeList = baseData.data; |
|
|
|
|
else if ((tabController.index == 1 && index == -1) || index == 1) storeList1 = baseData.data; |
|
|
|
|
else if ((tabController.index == 2 && index == -1) || index == 2) storeList2 = baseData.data; |
|
|
|
|
else if ((tabController.index == 3 && index == -1) || index == 3) storeList3 = baseData.data; |
|
|
|
|
if(index == -1) |
|
|
|
|
tabRefresh().refreshCompleted(); |
|
|
|
|
queryStore( |
|
|
|
|
latitude, longitude, province, city, district, searchKey, 3); |
|
|
|
|
} |
|
|
|
|
if ((tabController.index == 0 && index == -1) || index == 0) |
|
|
|
|
storeList = baseData.data; |
|
|
|
|
else if ((tabController.index == 1 && index == -1) || index == 1) |
|
|
|
|
storeList1 = baseData.data; |
|
|
|
|
else if ((tabController.index == 2 && index == -1) || index == 2) |
|
|
|
|
storeList2 = baseData.data; |
|
|
|
|
else if ((tabController.index == 3 && index == -1) || index == 3) |
|
|
|
|
storeList3 = baseData.data; |
|
|
|
|
if (index == -1) tabRefresh().refreshCompleted(); |
|
|
|
|
} else { |
|
|
|
|
if(index == -1) |
|
|
|
|
tabRefresh().refreshFailed(); |
|
|
|
|
if (index == -1) tabRefresh().refreshFailed(); |
|
|
|
|
} |
|
|
|
|
EasyLoading.dismiss(); |
|
|
|
|
setState(() {}); |
|
|
|
@ -302,6 +314,11 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
brightness: Brightness.light, |
|
|
|
|
titleChild: PreferredSize( |
|
|
|
|
preferredSize: Size(double.infinity, 38.h), |
|
|
|
|
child: Theme( |
|
|
|
|
data: ThemeData( |
|
|
|
|
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 |
|
|
|
|
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 |
|
|
|
|
), |
|
|
|
|
child: TabBar( |
|
|
|
|
controller: tabController, |
|
|
|
|
isScrollable: true, |
|
|
|
@ -327,15 +344,23 @@ class UnionPageState extends State<UnionPage>
|
|
|
|
|
MyTab(text: "喝"), |
|
|
|
|
MyTab(text: "玩"), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
)), |
|
|
|
|
body: TabBarView( |
|
|
|
|
controller: tabController, |
|
|
|
|
children: [ |
|
|
|
|
UnionList(refreshController, storeList,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController1, storeList1,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController2, storeList2,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController3, storeList3,(){startLocation(true);}), |
|
|
|
|
UnionList(refreshController, storeList, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
UnionList(refreshController1, storeList1, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
UnionList(refreshController2, storeList2, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
UnionList(refreshController3, storeList3, () { |
|
|
|
|
startLocation(true); |
|
|
|
|
}), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|