|
|
|
@ -1,28 +1,32 @@
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/cupertino.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/retrofit/data/store.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: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:shared_preferences/shared_preferences.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'; |
|
|
|
|
|
|
|
|
|
class UnionList extends StatefulWidget { |
|
|
|
|
final RefreshController refreshController; |
|
|
|
|
final List<Store> storeList; |
|
|
|
|
final Function onRefresh; |
|
|
|
|
final Function queryStore; |
|
|
|
|
|
|
|
|
|
UnionList(this.refreshController,this.storeList,this.onRefresh,this.queryStore); |
|
|
|
|
final String serviceType; |
|
|
|
|
final BMFCoordinate latLng; |
|
|
|
|
final String searchKey; |
|
|
|
|
final String city; |
|
|
|
|
|
|
|
|
|
UnionList(Key key, this.serviceType, this.latLng, this.searchKey, this.city) |
|
|
|
|
: super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
State<StatefulWidget> createState() { |
|
|
|
@ -30,89 +34,105 @@ class UnionList extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class _UnionList extends State<UnionList> { |
|
|
|
|
final TextEditingController editingController = TextEditingController(); |
|
|
|
|
class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin { |
|
|
|
|
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 |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Column( |
|
|
|
|
children: [ |
|
|
|
|
// buildSearchItem(), |
|
|
|
|
Container( |
|
|
|
|
height: MediaQuery.of(context).size.height - |
|
|
|
|
103.h - |
|
|
|
|
MediaQuery.of(context).padding.top, |
|
|
|
|
child: SmartRefresher( |
|
|
|
|
controller: widget.refreshController, |
|
|
|
|
enablePullUp: false, |
|
|
|
|
enablePullDown: true, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
header: MyHeader(), |
|
|
|
|
onRefresh: widget.onRefresh, |
|
|
|
|
child: (widget.storeList == null || widget.storeList.length == 0) |
|
|
|
|
? NoDataView( |
|
|
|
|
src:"assets/image/di_zhi.webp", |
|
|
|
|
isShowBtn: false, |
|
|
|
|
text: "暂无店铺列表~", |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
margin: EdgeInsets.only(top: 120.h), |
|
|
|
|
):ListView.builder( |
|
|
|
|
itemCount:widget.storeList == null ? 0 : widget.storeList.length, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 8.h, |
|
|
|
|
bottom: 100.h, /* + (375.h - 88.h) + 4.h*/ |
|
|
|
|
), |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
// if (widget.storeList[position].posType.code == "NORMALSTORE") { |
|
|
|
|
// showDeleteDialog(); |
|
|
|
|
// } |
|
|
|
|
// else |
|
|
|
|
// if ( widget.storeList[position].storeName == "一心回乡商城") { |
|
|
|
|
// Navigator.of(context).pushNamed( |
|
|
|
|
// '/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), |
|
|
|
|
); |
|
|
|
|
})), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
return SmartRefresher( |
|
|
|
|
controller: _refreshController, |
|
|
|
|
enablePullDown: true, |
|
|
|
|
enablePullUp: false, |
|
|
|
|
header: MyHeader(color: Colors.white,), |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
onRefresh: queryStore, |
|
|
|
|
child: (storeList == null || storeList.length == 0) |
|
|
|
|
? NoDataView( |
|
|
|
|
src: "assets/image/di_zhi.webp", |
|
|
|
|
isShowBtn: false, |
|
|
|
|
text: "暂无店铺列表~", |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
margin: EdgeInsets.only(top: 120.h), |
|
|
|
|
) |
|
|
|
|
: ListView.builder( |
|
|
|
|
itemCount: storeList.length, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
top: 8.h, |
|
|
|
|
bottom: 100.h, |
|
|
|
|
), |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
{ |
|
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
|
'/router/store_order', |
|
|
|
|
arguments: { |
|
|
|
|
"id": storeList[position].id, |
|
|
|
|
"tenant": storeList[position].tenantCode, |
|
|
|
|
"storeName": storeList[position].storeName, |
|
|
|
|
"distance": storeList[position].distance |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: buildStoreItem(storeList[position], position), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget sm(){ |
|
|
|
|
Widget sm() { |
|
|
|
|
return Container( |
|
|
|
|
margin:EdgeInsets.symmetric(horizontal: 14.w,vertical: 8.h), |
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 14.w, vertical: 8.h), |
|
|
|
|
width: double.infinity, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
borderRadius: BorderRadius.circular(6), |
|
|
|
|
), |
|
|
|
|
height: 223.h, |
|
|
|
|
child:Column( |
|
|
|
|
child: Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Shimmer.fromColors( |
|
|
|
@ -124,19 +144,25 @@ class _UnionList extends State<UnionList> {
|
|
|
|
|
height: 140.h, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Padding(padding: EdgeInsets.only(left: 6.w,bottom: 5.h,top: 12.h), |
|
|
|
|
child: Shimmer.fromColors( |
|
|
|
|
baseColor: Color(0XFFD8D8D8), |
|
|
|
|
highlightColor: Color(0XFFD8D8D8), |
|
|
|
|
child: Container( |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0XFFD8D8D8), |
|
|
|
|
borderRadius: BorderRadius.circular(2), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 6.w, bottom: 5.h, top: 12.h), |
|
|
|
|
child: Shimmer.fromColors( |
|
|
|
|
baseColor: Color(0XFFD8D8D8), |
|
|
|
|
highlightColor: Color(0XFFD8D8D8), |
|
|
|
|
child: Container( |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
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( |
|
|
|
|
baseColor: Color(0XFFD8D8D8), |
|
|
|
|
highlightColor: Color(0XFFD8D8D8), |
|
|
|
@ -148,63 +174,9 @@ class _UnionList extends State<UnionList> {
|
|
|
|
|
width: 260.w, |
|
|
|
|
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( |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
SizedBox( |
|
|
|
|
height: 40.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
store?.storeName ?? "", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
fontWeight: MyFontWeight.bold, |
|
|
|
|
), |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
SizedBox( |
|
|
|
|
height: 40.h, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
store?.storeName ?? "", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|