Browse Source

联盟板块新ui更改完成;

dev
huixiang_app 1 year ago
parent
commit
b82d328bb2
  1. 2
      assets/map_style/chinese_cities.json
  2. 2
      lib/main.dart
  3. 78
      lib/retrofit/data/ip_data.dart
  4. 85
      lib/retrofit/retrofit_api.dart
  5. 20
      lib/retrofit/retrofit_api.g.dart
  6. 497
      lib/union/union_list.dart
  7. 942
      lib/union/union_page.dart
  8. 382
      lib/union/union_select_city.dart

2
assets/map_style/chinese_cities.json

@ -6,7 +6,7 @@
{"area": "广州"}, {"area": "广州"},
{"area": "成都"}, {"area": "成都"},
{"area": "杭州"}, {"area": "杭州"},
{"area": "南京"}, {"area": "武汉"},
{"area": "重庆"} {"area": "重庆"}
], ],
"A": [ "A": [

2
lib/main.dart

@ -442,5 +442,5 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/router/trading_card_page': (context, {arguments}) => '/router/trading_card_page': (context, {arguments}) =>
TradingCardPage(), TradingCardPage(),
'/router/union_select_city': (context, {arguments}) => '/router/union_select_city': (context, {arguments}) =>
UnionSelectCity(), UnionSelectCity(arguments:arguments),
}; };

78
lib/retrofit/data/ip_data.dart

@ -0,0 +1,78 @@
/// code : 200
/// msg : "success"
/// ip : "27.17.85.129"
/// country : "中国"
/// province : "湖北"
/// city : "武汉市"
/// isp : "电信"
class IpData {
IpData({
num code,
String msg,
String ip,
String country,
String province,
String city,
String isp,}){
_code = code;
_msg = msg;
_ip = ip;
_country = country;
_province = province;
_city = city;
_isp = isp;
}
IpData.fromJson(dynamic json) {
_code = json['code'];
_msg = json['msg'];
_ip = json['ip'];
_country = json['country'];
_province = json['province'];
_city = json['city'];
_isp = json['isp'];
}
num _code;
String _msg;
String _ip;
String _country;
String _province;
String _city;
String _isp;
IpData copyWith({ num code,
String msg,
String ip,
String country,
String province,
String city,
String isp,
}) => IpData( code: code ?? _code,
msg: msg ?? _msg,
ip: ip ?? _ip,
country: country ?? _country,
province: province ?? _province,
city: city ?? _city,
isp: isp ?? _isp,
);
num get code => _code;
String get msg => _msg;
String get ip => _ip;
String get country => _country;
String get province => _province;
String get city => _city;
String get isp => _isp;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['code'] = _code;
map['msg'] = _msg;
map['ip'] = _ip;
map['country'] = _country;
map['province'] = _province;
map['city'] = _city;
map['isp'] = _isp;
return map;
}
}

85
lib/retrofit/retrofit_api.dart

@ -41,6 +41,7 @@ import 'data/headlines_list.dart';
import 'data/headlines_list_details.dart'; import 'data/headlines_list_details.dart';
import 'data/home_rank.dart'; import 'data/home_rank.dart';
import 'data/invitation_list.dart'; import 'data/invitation_list.dart';
import 'data/ip_data.dart';
import 'data/logistics.dart'; import 'data/logistics.dart';
import 'data/member_Infor.dart'; import 'data/member_Infor.dart';
import 'data/member_comment_list.dart'; import 'data/member_comment_list.dart';
@ -66,9 +67,17 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart'; part 'retrofit_api.g.dart';
const localBaseUrl = "http://192.168.10.15:8766/app/";/// const localBaseUrl = "http://platform-api.test.yixinhuixiang.com/app/";
///
// const localBaseUrl = "http://platform.test.api.lotus-wallet.com/app/";/// // const localBaseUrl = "http://platform.test.api.lotus-wallet.com/app/";///
const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";///线 const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/";
///线
const ipBaseUrl = "https://api.ooomn.com";
///ip
@RestApi(baseUrl: localBaseUrl) @RestApi(baseUrl: localBaseUrl)
abstract class ApiService { abstract class ApiService {
@ -78,6 +87,7 @@ abstract class ApiService {
BuildContext context, BuildContext context,
String token, String token,
bool showLoading = false, bool showLoading = false,
bool isIp = false,
bool pay = true, bool pay = true,
}) { }) {
Map<String, dynamic> headers = Map<String, dynamic> headers =
@ -85,6 +95,7 @@ abstract class ApiService {
if (pay) { if (pay) {
headers["Environment"] = "app"; headers["Environment"] = "app";
} }
if (isIp) baseUrl = ipBaseUrl;
dio.options = BaseOptions( dio.options = BaseOptions(
connectTimeout: 60000, connectTimeout: 60000,
receiveTimeout: 60000, receiveTimeout: 60000,
@ -113,14 +124,16 @@ abstract class ApiService {
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
debugPrint("code = ${response.statusCode}"); debugPrint("code = ${response.statusCode}");
p(jsonEncode(response.data));
if (response.request.path != "/creditGoods/list")
p(jsonEncode(response.data));
// debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length * 10); // debugPrint(jsonEncode(response.data), wrapWidth: response.data.toString().length * 10);
Map map = response.data; Map map = response.data;
if (map["code"] != 0) { // if (map["code"] != 0) {
EasyLoading.dismiss(); // EasyLoading.dismiss();
} // }
if (map["code"] == 40005 || map["code"] == 40001) { if (map["code"] == 40005 || map["code"] == 40001) {
if (!LoginTipsDialog().isShow) { if (!LoginTipsDialog().isShow) {
print("show: ${LoginTipsDialog().isShow}"); print("show: ${LoginTipsDialog().isShow}");
@ -166,11 +179,12 @@ abstract class ApiService {
/// ///
@POST("/file/upload") @POST("/file/upload")
@MultiPart() @MultiPart()
Future<BaseData<UploadResult>> upload( Future<BaseData<UploadResult>> upload(@Part(name: "file") File data,
@Part(name: "file") File data, @Part(name: "folderId") int folderId,bool isVideo); @Part(name: "folderId") int folderId, bool isVideo);
/// ///
@GET("https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all") @GET(
"https://restapi.amap.com/v3/place/around?key=542b46afa8e4b88fe1eb3c4d0ba0872f&location={lat},{lng}&keywords={keywords}&offset={size}&page={page}&extensions=all")
Future<dynamic> searchPoi(@Path("lat") String lat, @Path("lng") String lng, Future<dynamic> searchPoi(@Path("lat") String lat, @Path("lng") String lng,
@Path("keywords") String keywords, int size, int page); @Path("keywords") String keywords, int size, int page);
@ -184,7 +198,8 @@ abstract class ApiService {
/// ///
@GET("/auth/sendVerify/{areaCode}/{mobile}") @GET("/auth/sendVerify/{areaCode}/{mobile}")
Future<BaseData> sendVerify(@Path("areaCode") String areaCode, @Path("mobile") String mobile); Future<BaseData> sendVerify(
@Path("areaCode") String areaCode, @Path("mobile") String mobile);
/// ///
@POST("/creditGoods/list") @POST("/creditGoods/list")
@ -298,11 +313,13 @@ abstract class ApiService {
/// ///
@POST("/information/list") @POST("/information/list")
Future<BaseData<PageInfo<Article>>> queryArticle(@Body() Map<String, dynamic> param); Future<BaseData<PageInfo<Article>>> queryArticle(
@Body() Map<String, dynamic> param);
///banner查询 ///banner查询
@POST("/banner/page") @POST("/banner/page")
Future<BaseData<PageInfo<BannerData>>> queryBanner(@Body() Map<String, dynamic> param); Future<BaseData<PageInfo<BannerData>>> queryBanner(
@Body() Map<String, dynamic> param);
/// ///
@GET("/home/brand") @GET("/home/brand")
@ -404,11 +421,13 @@ abstract class ApiService {
/// ///
@POST("/information/trend-list") @POST("/information/trend-list")
Future<BaseData<PageInfo<ComunityComment>>> trendList(@Body() Map<String, dynamic> map); Future<BaseData<PageInfo<ComunityComment>>> trendList(
@Body() Map<String, dynamic> map);
/// / /// /
@POST("/member/follow/list") @POST("/member/follow/list")
Future<BaseData<PageInfo<ListData>>> followList(@Body() Map<String, dynamic> map); Future<BaseData<PageInfo<ListData>>> followList(
@Body() Map<String, dynamic> map);
//// ////
@PUT("/member/follow/{followId}") @PUT("/member/follow/{followId}")
@ -428,11 +447,13 @@ abstract class ApiService {
/// ///
@GET("/course/catalogList/{courseId}") @GET("/course/catalogList/{courseId}")
Future<BaseData<List<Chapter>>> catalogList(@Path("courseId") String courseId); Future<BaseData<List<Chapter>>> catalogList(
@Path("courseId") String courseId);
/// ///
@POST("/course/list") @POST("/course/list")
Future<BaseData<PageInfo<CourseList>>> courseList(@Body() Map<String, dynamic> map); Future<BaseData<PageInfo<CourseList>>> courseList(
@Body() Map<String, dynamic> map);
/// ///
@GET("/course/collectList") @GET("/course/collectList")
@ -440,7 +461,8 @@ abstract class ApiService {
/// ///
@GET("/course/collect/{collectId}") @GET("/course/collect/{collectId}")
Future<BaseData<List<CourseList>>> collect(@Path("collectId") String collectId); Future<BaseData<List<CourseList>>> collect(
@Path("collectId") String collectId);
/// ///
@GET("/course/{id}") @GET("/course/{id}")
@ -452,15 +474,18 @@ abstract class ApiService {
/// APP查询所有成就徽章 /// APP查询所有成就徽章
@POST("/app-memberAchievement/findBadges") @POST("/app-memberAchievement/findBadges")
Future<BaseData<List<VipBadgesList>>> findBadges(@Body() Map<String, dynamic> map); Future<BaseData<List<VipBadgesList>>> findBadges(
@Body() Map<String, dynamic> map);
/// ///
@GET("/app-memberAchievement/getAchievementDetail?achievementCategoryId={achievementCategoryId}") @GET(
Future<BaseData<List<AchievementDetailList>>> getAchievementDetail(@Path("achievementCategoryId") String achievementCategoryId); "/app-memberAchievement/getAchievementDetail?achievementCategoryId={achievementCategoryId}")
Future<BaseData<List<AchievementDetailList>>> getAchievementDetail(
@Path("achievementCategoryId") String achievementCategoryId);
/// ///
@GET("/member/benefitList") @GET("/member/benefitList")
Future<BaseData<List<VipBenefitList>>> benefitList(); Future<BaseData<List<VipBenefitList>>> benefitList();
/// ///
@GET("/home/vipBenefit") @GET("/home/vipBenefit")
@ -480,7 +505,8 @@ abstract class ApiService {
/// ///
@GET("/creditOrder/getAppShippingTrace?orderId={orderId}") @GET("/creditOrder/getAppShippingTrace?orderId={orderId}")
Future<BaseData<Logistics>> getAppShippingTrace(@Path("orderId") String orderId); Future<BaseData<Logistics>> getAppShippingTrace(
@Path("orderId") String orderId);
/// ///
@POST("/member/rankBuy") @POST("/member/rankBuy")
@ -492,11 +518,13 @@ abstract class ApiService {
/// ///
@GET("/information/category/{id}") @GET("/information/category/{id}")
Future<BaseData<HeadlinesListDetails>> headlinesDetails(@Path("id") String id); Future<BaseData<HeadlinesListDetails>> headlinesDetails(
@Path("id") String id);
/// ///
@POST("/member/inviteMemberList") @POST("/member/inviteMemberList")
Future<BaseData<PageInfo<InvitationList>>> inviteMemberList(@Body() Map<String, dynamic> map); Future<BaseData<PageInfo<InvitationList>>> inviteMemberList(
@Body() Map<String, dynamic> map);
/// ///
@GET("/coupon/wiped/{memberCouponId}") @GET("/coupon/wiped/{memberCouponId}")
@ -564,5 +592,10 @@ abstract class ApiService {
/// ///
@GET("/store/storeListByCreditId/{creditGoodsId}") @GET("/store/storeListByCreditId/{creditGoodsId}")
Future<BaseData<List<Store>>> storeListByCreditId(@Path("creditGoodsId") String creditGoodsId); Future<BaseData<List<Store>>> storeListByCreditId(
@Path("creditGoodsId") String creditGoodsId);
///APP门店推广渠道
@GET("/api/ip")
Future<IpData> getIpInfo();
} }

20
lib/retrofit/retrofit_api.g.dart

@ -2109,6 +2109,26 @@ class _ApiService implements ApiService {
return value; return value;
} }
@override
Future<IpData> getIpInfo() async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'/api/ip',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = IpData.fromJson(
_result.data,
);
return value;
}
@override @override
Future<BaseData<dynamic>> orderVip(param) async { Future<BaseData<dynamic>> orderVip(param) async {
ArgumentError.checkNotNull(param, 'param'); ArgumentError.checkNotNull(param, 'param');

497
lib/union/union_list.dart

@ -1,28 +1,32 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.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/generated/l10n.dart';
import 'package:huixiang/retrofit/data/store.dart'; import 'package:huixiang/retrofit/data/store.dart';
import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/border_text.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/request_permission.dart';
import 'package:huixiang/view_widget/round_button.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
import '../retrofit/data/base_data.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/no_data_view.dart';
class UnionList extends StatefulWidget { class UnionList extends StatefulWidget {
final RefreshController refreshController; final String serviceType;
final List<Store> storeList; final BMFCoordinate latLng;
final Function onRefresh; final String searchKey;
final Function queryStore; final String city;
UnionList(this.refreshController,this.storeList,this.onRefresh,this.queryStore);
UnionList(Key key, this.serviceType, this.latLng, this.searchKey, this.city)
: super(key: key);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -30,89 +34,105 @@ class UnionList extends StatefulWidget {
} }
} }
class _UnionList extends State<UnionList> { class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
final TextEditingController editingController = TextEditingController(); ApiService apiService;
List<Store> storeList;
final RefreshController _refreshController = RefreshController();
@override
bool get wantKeepAlive => true;
@override
void initState() {
super.initState();
queryStore();
}
queryStore() async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
}
BaseData<List<Store>> baseData = await apiService.queryStore({
"city": widget.city ?? "",
// "district": district,
// "province": province,
"latitude": (widget.latLng?.latitude ?? "").toString(),
"longitude": (widget.latLng?.longitude ?? "").toString(),
if (widget.searchKey != "") "searchKey": widget.searchKey,
"serviceType": widget.serviceType,
"exchange": false,
}).catchError((error) {
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type),
alignment: Alignment.center);
});
if (baseData != null && baseData.isSuccess) {
storeList = baseData.data;
}
_refreshController.refreshCompleted();
EasyLoading.dismiss();
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return SmartRefresher(
children: [ controller: _refreshController,
// buildSearchItem(), enablePullDown: true,
Container( enablePullUp: false,
height: MediaQuery.of(context).size.height - header: MyHeader(color: Colors.white,),
103.h - physics: BouncingScrollPhysics(),
MediaQuery.of(context).padding.top, onRefresh: queryStore,
child: SmartRefresher( child: (storeList == null || storeList.length == 0)
controller: widget.refreshController, ? NoDataView(
enablePullUp: false, src: "assets/image/di_zhi.webp",
enablePullDown: true, isShowBtn: false,
physics: BouncingScrollPhysics(), text: "暂无店铺列表~",
header: MyHeader(), fontSize: 16.sp,
onRefresh: widget.onRefresh, margin: EdgeInsets.only(top: 120.h),
child: (widget.storeList == null || widget.storeList.length == 0) )
? NoDataView( : ListView.builder(
src:"assets/image/di_zhi.webp", itemCount: storeList.length,
isShowBtn: false, padding: EdgeInsets.only(
text: "暂无店铺列表~", top: 8.h,
fontSize: 16.sp, bottom: 100.h,
margin: EdgeInsets.only(top: 120.h), ),
):ListView.builder( itemBuilder: (context, position) {
itemCount:widget.storeList == null ? 0 : widget.storeList.length, return InkWell(
padding: EdgeInsets.only( onTap: () {
top: 8.h, {
bottom: 100.h, /* + (375.h - 88.h) + 4.h*/ Navigator.of(context).pushNamed(
), '/router/store_order',
physics: NeverScrollableScrollPhysics(), arguments: {
itemBuilder: (context, position) { "id": storeList[position].id,
return InkWell( "tenant": storeList[position].tenantCode,
onTap: () { "storeName": storeList[position].storeName,
// if (widget.storeList[position].posType.code == "NORMALSTORE") { "distance": storeList[position].distance
// showDeleteDialog(); },
// } );
// else }
// if ( widget.storeList[position].storeName == "一心回乡商城") { },
// Navigator.of(context).pushNamed( child: buildStoreItem(storeList[position], position),
// '/router/shopping_mall_home', );
// arguments: { },
// "type": 0, ),
// "id": widget.storeList[position].id,
// "tenant": widget.storeList[position].tenantCode,
// "storeName": widget.storeList[position].storeName
// },
// );
// }
// else
{
Navigator.of(context).pushNamed(
'/router/store_order',
arguments: {
"id": widget.storeList[position].id,
"tenant": widget.storeList[position].tenantCode,
"storeName": widget.storeList[position].storeName,
"distance":widget.storeList[position].distance
},
);
}
},
child:
buildStoreItem(widget.storeList[position], position),
);
})),
)
],
); );
} }
Widget sm(){ Widget sm() {
return Container( return Container(
margin:EdgeInsets.symmetric(horizontal: 14.w,vertical: 8.h), margin: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h),
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
height: 223.h, height: 223.h,
child:Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Shimmer.fromColors( Shimmer.fromColors(
@ -124,19 +144,25 @@ class _UnionList extends State<UnionList> {
height: 140.h, height: 140.h,
), ),
), ),
Padding(padding: EdgeInsets.only(left: 6.w,bottom: 5.h,top: 12.h), Padding(
child: Shimmer.fromColors( padding: EdgeInsets.only(left: 6.w, bottom: 5.h, top: 12.h),
baseColor: Color(0XFFD8D8D8), child: Shimmer.fromColors(
highlightColor: Color(0XFFD8D8D8), baseColor: Color(0XFFD8D8D8),
child: Container( highlightColor: Color(0XFFD8D8D8),
decoration: BoxDecoration( child: Container(
color: Color(0XFFD8D8D8), decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2), color: Color(0XFFD8D8D8),
borderRadius: BorderRadius.circular(2),
),
width: 108.w,
height: 20.h,
), ),
width: 108.w,
height: 20.h,
), ),
),),Padding(padding: EdgeInsets.only(left: 6.w,), ),
Padding(
padding: EdgeInsets.only(
left: 6.w,
),
child: Shimmer.fromColors( child: Shimmer.fromColors(
baseColor: Color(0XFFD8D8D8), baseColor: Color(0XFFD8D8D8),
highlightColor: Color(0XFFD8D8D8), highlightColor: Color(0XFFD8D8D8),
@ -148,63 +174,9 @@ class _UnionList extends State<UnionList> {
width: 260.w, width: 260.w,
height: 20.h, height: 20.h,
), ),
),),
],
),
);
}
Widget buildSearchItem() {
return Container(
height: 36.h,
margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0),
padding: EdgeInsets.fromLTRB(0, 6.h, 0, 6.h),
decoration: BoxDecoration(
color: Color(0xFFF5FAF7),
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode());
widget.queryStore(editingController.text);
},
controller: editingController,
cursorHeight: 25.h,
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(
vertical: 12.h,
),
prefixIcon:InkWell(
onTap: () {
widget.queryStore(editingController.text);
},
child: Icon(
Icons.search,
size: 24,
color: Colors.black,
),
),
suffixIcon: InkWell(
onTap: () {
editingController.clear();
},
child: Icon(
Icons.close,
size: 19,
color: Colors.grey,
), ),
), ),
border: InputBorder.none, ],
),
), ),
); );
} }
@ -275,62 +247,65 @@ class _UnionList extends State<UnionList> {
), ),
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
height: 40.h, height: 40.h,
), ),
Text( Text(
store?.storeName ?? "", store?.storeName ?? "",
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
color: Color(0xFF0D0D0D), color: Color(0xFF0D0D0D),
fontSize: 14.sp, fontSize: 14.sp,
fontWeight: MyFontWeight.bold, fontWeight: MyFontWeight.bold,
), ),
),
SizedBox(
height: 5.h,
),
Expanded(
child: Text(
"${S.of(context).dizhi}:${store.address}",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF4D4D4D),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
), ),
SizedBox( ),
height: 5.h, )
],
)),
if (store.distance != null)
Container(
width: 59.w,
height: 18.h,
alignment: Alignment.center,
margin: EdgeInsets.only(top: 20.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: Color(0xFF32A060),
),
child: Visibility(
child: 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(0xFFFFFFFF),
fontSize: 10.sp,
), ),
Expanded(child: Text(
"${S.of(context).dizhi}:${store.address}",
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(0xFF4D4D4D),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),)
],
)),
if(store.distance != null)
Container(
width: 59.w,
height: 18.h,
alignment: Alignment.center,
margin: EdgeInsets.only(top: 20.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: Color(0xFF32A060),
),
child: Visibility(
child: 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(0xFFFFFFFF),
fontSize: 10.sp,
), ),
visible: store.distance != null,
), ),
visible: store.distance != null,
), ),
),
], ],
), ),
), ),
@ -339,130 +314,4 @@ class _UnionList extends State<UnionList> {
), ),
); );
} }
///
showDeleteDialog() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Container(
width: MediaQuery.of(context).size.width - 84.w,
height: 130.h,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"您即将进行扫码点餐",
style: TextStyle(
fontSize: 17.sp,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
SizedBox(
height: 30.h,
),
Row(
children: [
Expanded(
child: InkWell(
child: BorderText(
text: "取消",
textColor: Color(0xFF32A060),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
borderColor: Color(0xFF32A060),
radius: 4,
padding: EdgeInsets.all(12),
borderWidth: 1,
),
onTap: () {
Navigator.of(context).pop();
},
),
flex: 1,
),
SizedBox(
width: 16.w,
),
Expanded(
child: InkWell(
child: RoundButton(
text: "确定",
textColor: Colors.white,
radius: 4,
padding: EdgeInsets.all(12),
backgroup: Color(0xFF32A060),
fontSize: 16.sp,
fontWeight: FontWeight.bold,
),
onTap: () {
toScan();
Navigator.of(context).pop();
},
),
flex: 1,
),
],
)
],
),
),
);
},
);
}
///
toScan() async {
if (await Permission.camera.isPermanentlyDenied) {
showCupertinoDialog(
context: context,
builder: (context) {
return RequestPermission(
"assets/image/icon_camera_permission_tips.webp",
S.of(context).ninxiangjiquanxianweikaiqi,
S.of(context).weilekaipaizhaoxuanzhetouxiang,
S.of(context).kaiqiquanxian,
(result) async {
if (result) {
await openAppSettings();
}
},
heightRatioWithWidth: 0.82,
);
});
} else if (await Permission.camera.isGranted) {
// http://pos.app.gznl.top/placeorder/?tableId=1315903669597634560&tenantCode=1166&shopId=1300372027722432512
//
// 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');
// 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"];
if (tableId != null &&
tableId != "" &&
tenantCode != null &&
tenantCode != "" &&
shopId != null &&
shopId != "") {
Navigator.of(context).pushNamed(
'/router/store_order',
arguments: {
"id": shopId,
"tenant": tenantCode,
"storeName": "",
"tableId": int.tryParse(tableId),
},
);
}
} else {
await Permission.camera.request();
}
}
} }

942
lib/union/union_page.dart

File diff suppressed because it is too large Load Diff

382
lib/union/union_select_city.dart

@ -1,14 +1,20 @@
import 'dart:convert'; import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../retrofit/data/ip_data.dart';
import '../retrofit/retrofit_api.dart';
class UnionSelectCity extends StatefulWidget { class UnionSelectCity extends StatefulWidget {
final Map<String, dynamic> arguments;
UnionSelectCity({this.arguments});
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
return _UnionSelectCity(); return _UnionSelectCity();
@ -18,25 +24,58 @@ class UnionSelectCity extends StatefulWidget {
class _UnionSelectCity extends State<UnionSelectCity> { class _UnionSelectCity extends State<UnionSelectCity> {
RefreshController refreshController = RefreshController(); RefreshController refreshController = RefreshController();
Map<String, dynamic> areaMap; Map<String, dynamic> areaMap;
ApiService apiIpService;
String ipName;
int ipState = 0;
List<String> hotCity = [];
List<String> areaList = []; List<String> areaList = [];
final TextEditingController editingController = TextEditingController();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
areaCode(); areaCode();
queryIpInfo();
} }
void areaCode() async { void areaCode({String searchTxt}) async {
var value = var value =
await rootBundle.loadString('assets/map_style/chinese_cities.json'); await rootBundle.loadString('assets/map_style/chinese_cities.json');
areaList.clear();
areaMap = jsonDecode(value); areaMap = jsonDecode(value);
hotCity = (areaMap["热门城市"] as List).map((e) {
return e["area"].toString();
}).toList();
areaMap.remove("热门城市");
Map<String, dynamic> tempAreaMap = jsonDecode(value);
areaMap.forEach((key, value) { areaMap.forEach((key, value) {
areaList.add(key); if (searchTxt != null && searchTxt.trim() != "")
value.forEach((element) {
if (!element["area"].contains(searchTxt))
(tempAreaMap[key] as List)
.removeWhere((el) => el["area"] == element["area"]);
});
if (tempAreaMap[key].isNotEmpty) areaList.add(key);
}); });
areaMap = tempAreaMap;
setState(() {}); setState(() {});
} }
queryIpInfo() async {
apiIpService = ApiService(
Dio(),
context: context,
isIp: true
);
IpData baseData = await apiIpService.getIpInfo().catchError((onError) {});
if (baseData != null) {
ipName = baseData.city.replaceAll("", "");
if(ipName != widget.arguments["cityName"] ){
ipState=2;
setState((){});
}
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -60,9 +99,9 @@ class _UnionSelectCity extends State<UnionSelectCity> {
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child:Container( child: Container(
padding: EdgeInsets.only(right:21.w), padding: EdgeInsets.only(right: 21.w),
child: Icon( child: Icon(
Icons.arrow_back_ios, Icons.arrow_back_ios,
color: Colors.black, color: Colors.black,
), ),
@ -70,206 +109,112 @@ class _UnionSelectCity extends State<UnionSelectCity> {
Expanded(child: searchCityItem()) Expanded(child: searchCityItem())
], ],
), ),
Padding(padding:EdgeInsets.only(top: 16.h,bottom: 24.h), Padding(
child:Row( padding: EdgeInsets.only(top: 16.h, bottom: 24.h),
children: [ child: Row(
Padding(padding:EdgeInsets.only(right: 10.w), crossAxisAlignment: CrossAxisAlignment.center,
child: Text( children: [
"当前位置", Padding(
style: TextStyle( padding: EdgeInsets.only(right: 10.w),
color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
),),
Image.asset(
"assets/image/icon_union_location.webp",
width:20,
height:20,
),
Padding(padding:EdgeInsets.only(left:8.w,),
child: Text(
"当前位置",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
),),
],
)),
Padding(padding:EdgeInsets.only(bottom: 16.h),
child: Text(
"热门城市",
style: TextStyle(
color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
),),
Padding(padding:EdgeInsets.only(right: 14.h,bottom: 14.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
Navigator.of(context).pop("上海");},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h),
child: Text(
"上海",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
)
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
Navigator.of(context).pop("深圳");},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h),
child: Text(
"深圳",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
)
)), GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
Navigator.of(context).pop("北京");},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h),
child: Text(
"北京",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
)
)), GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
Navigator.of(context).pop("广州");},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h),
child: Text(
"广州",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
)
)),
],
),),
Padding(padding:EdgeInsets.only(right: 14.h,),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
Navigator.of(context).pop("成都");},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4),
),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h),
child: Text( child: Text(
"成都", (ipState == 0||ipState == 1) ? "当前位置" : "已选:",
style: TextStyle( style: TextStyle(
color: Color(0xFF4D4D4D), color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
fontSize: 16.sp, fontSize: 16.sp,
), ),
)
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
Navigator.of(context).pop("杭州");},
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4),
), ),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), ),
Image.asset(
"assets/image/icon_union_location.webp",
width: 20,
height: 20,
),
Expanded(
// padding: EdgeInsets.only(
// left: 8.w,
// ),
child: Text( child: Text(
"杭州", (ipState== 1) ? (ipName??""):widget.arguments["cityName"] ?? "",
style: TextStyle( style: TextStyle(
color: Color(0xFF4D4D4D), color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
fontSize: 16.sp, fontSize: 16.sp,
), ),
) ),
)), ),
GestureDetector( if(ipState == 2)
Icon(
Icons.gps_fixed,
color: Colors.grey,
size: 18,
),
if(ipState == 2)
Padding(padding:EdgeInsets.only(left:5.w,right: 12.w),
child:GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: (){ onTap: (){
Navigator.of(context).pop("南京");}, setState((){
child: Container( ipState = 1;
decoration: BoxDecoration( Navigator.of(context).pop(ipName);
color: Color(0xFFF7F7F7), });
borderRadius: BorderRadius.circular(4), },
), child: Text(
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), "重新定位",
child: Text(
"南京",
style: TextStyle( style: TextStyle(
color: Color(0xFF4D4D4D), color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
fontSize: 16.sp, fontSize: 16.sp,
), ),
) ),
)), ),)
GestureDetector( ],
)),
Padding(
padding: EdgeInsets.only(bottom: 16.h),
child: Text(
"热门城市",
style: TextStyle(
color: Color(0xFFA29E9E),
fontWeight: MyFontWeight.medium,
fontSize: 16.sp,
),
),
),
GridView.builder(
itemCount: hotCity.length,
padding: EdgeInsets.only(right: 14.h, bottom: 14.h),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 12.w,
mainAxisSpacing: 12.w,
childAspectRatio: 2.5,
),
itemBuilder: (context, index) {
return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: (){ onTap: () {
Navigator.of(context).pop("重庆");}, Navigator.of(context).pop(hotCity[index]);
setState((){});
},
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFF7F7F7), color: Color(0xFFF7F7F7),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
), ),
padding: EdgeInsets.symmetric(horizontal:24.w,vertical:5.h), alignment: Alignment.center,
child: Text( child: Text(
"重庆", hotCity[index],
style: TextStyle( style: TextStyle(
color: Color(0xFF4D4D4D), color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium, fontWeight: MyFontWeight.medium,
fontSize: 16.sp, fontSize: 16.sp,
), ),
) )));
), },
), ),
],
),)
], ],
), ),
), ),
@ -284,7 +229,7 @@ class _UnionSelectCity extends State<UnionSelectCity> {
return Container( return Container(
height: 36.h, height: 36.h,
margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0), margin: EdgeInsets.fromLTRB(6.w, 0, 14.w, 0),
padding: EdgeInsets.fromLTRB(0, 6.h, 0, 0), // padding: EdgeInsets.fromLTRB(0, 6.h, 0, 0),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFF1F1F1), color: Color(0xFFF1F1F1),
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
@ -302,12 +247,14 @@ class _UnionSelectCity extends State<UnionSelectCity> {
onEditingComplete: () { onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
}, },
controller: editingController, onChanged: (txt) {
areaCode(searchTxt: txt);
},
cursorHeight: 25.h, cursorHeight: 25.h,
decoration: InputDecoration( decoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric( contentPadding: EdgeInsets.symmetric(
// vertical: 12.h, vertical: 14.h,
// ), ),
hintText: "输入城市名进行搜索", hintText: "输入城市名进行搜索",
hintStyle: TextStyle( hintStyle: TextStyle(
fontSize: 12.sp, fontSize: 12.sp,
@ -315,7 +262,7 @@ class _UnionSelectCity extends State<UnionSelectCity> {
), ),
prefixIcon: InkWell( prefixIcon: InkWell(
onTap: () {}, onTap: () {},
child:Image.asset( child: Image.asset(
"assets/image/icon_search.webp", "assets/image/icon_search.webp",
width: 16, width: 16,
height: 16, height: 16,
@ -328,7 +275,7 @@ class _UnionSelectCity extends State<UnionSelectCity> {
} }
Widget sortList() { Widget sortList() {
return ListView.builder( return areaList.length != 0 ?ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemCount: areaList.length, itemCount: areaList.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
@ -340,7 +287,15 @@ class _UnionSelectCity extends State<UnionSelectCity> {
child: sortItem(position), child: sortItem(position),
); );
}, },
); ):Padding(padding:EdgeInsets.only(top:12.h),
child: Text(
"抱歉,未找到相关位置,可尝试修改后重试",
style: TextStyle(
color: Color(0xFF4D4D4D),
fontWeight: MyFontWeight.medium,
fontSize: 14.sp,
),
));
} }
Widget sortItem(int position) { Widget sortItem(int position) {
@ -369,46 +324,51 @@ class _UnionSelectCity extends State<UnionSelectCity> {
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 8.h, top: 8.h,
), ),
child: Column( child: mapWidget(position),
children: (areaMap[areaList[position]] as List).map((e) {
return globalRoamingItem(e);
}).toList(),
),
) )
], ],
); );
} }
Widget globalRoamingItem(data) { Widget mapWidget(position) {
int mapIndex = 0;
return Column(
children: (areaMap[areaList[position]] as List).map((e) {
mapIndex += 1;
return globalRoamingItem(
e, mapIndex == areaMap[areaList[position]].length);
}).toList(),
);
}
Widget globalRoamingItem(data, isLast) {
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Navigator.of(context).pop(data["area"]); Navigator.of(context).pop(data["area"]);
}, },
child: Container( child: Container(
child: Column( width: double.infinity,
mainAxisAlignment: MainAxisAlignment.start, child: Text(
crossAxisAlignment: CrossAxisAlignment.start, data["area"],
children: [ style: TextStyle(
Padding( color: Color(0xFF000000),
padding: EdgeInsets.only(left: 12.w), fontWeight: MyFontWeight.regular,
child: Text( fontSize: 14.sp,
data["area"], ),
style: TextStyle( ),
color: Color(0xFF000000), decoration: BoxDecoration(
fontWeight: MyFontWeight.regular, border: isLast
fontSize: 14.sp, ? null
: Border(
bottom: BorderSide(
width: 1.w,
color: Color(0xFFDCDCDC),
style: BorderStyle.solid,
),
), ),
),
),
Container(
margin: EdgeInsets.symmetric(vertical: 16.h),
width: double.infinity,
height: 1.h,
color: Color(0xFFDCDCDC),
)
],
), ),
padding: EdgeInsets.only(top: 16.h, bottom: 16.h, left: 16.w),
), ),
); );
} }

Loading…
Cancel
Save