Browse Source
批量下架页面更改; 首页ui边调整; 登录页面更改; 我的页面更改,新增门店设置,不要商家设置; 订单列表更改,核销显示完成,核销页面待调试核对; 商品排序更改; 商户信息页面改成门店设置,接口页面对接调试完成; app成就徽章页面调整更改; 分组列表接口更改; 商品页面更改; 订单列表核销更改; 核销页面接口数据对接; 申请退款弹窗更改; 选择门店页面数据调整更改; 新增门店列表实体类; 新增门店设置图片上传页面;wr_2023_business
wurong
1 year ago
21 changed files with 4261 additions and 947 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,356 @@ |
|||||||
|
import 'dart:convert'; |
||||||
|
import 'dart:io'; |
||||||
|
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_svg/svg.dart'; |
||||||
|
import 'package:huixiang/generated/l10n.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/upload_result.dart'; |
||||||
|
import 'package:huixiang/retrofit/data/user_info.dart'; |
||||||
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||||
|
import 'package:huixiang/utils/flutter_utils.dart'; |
||||||
|
import 'package:huixiang/utils/font_weight.dart'; |
||||||
|
import 'package:huixiang/view_widget/cupertino_date_picker.dart'; |
||||||
|
import 'package:huixiang/view_widget/custom_image.dart'; |
||||||
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
||||||
|
import 'package:image_pickers/image_pickers.dart'; |
||||||
|
import 'package:intl/intl.dart'; |
||||||
|
import 'package:permission_handler/permission_handler.dart'; |
||||||
|
import 'package:shared_preferences/shared_preferences.dart'; |
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||||
|
|
||||||
|
import '../../retrofit/business_api.dart'; |
||||||
|
import '../../utils/business_instance.dart'; |
||||||
|
|
||||||
|
class ShopImageInfo extends StatefulWidget { |
||||||
|
final Map<String, dynamic> arguments; |
||||||
|
|
||||||
|
ShopImageInfo({this.arguments}); |
||||||
|
|
||||||
|
@override |
||||||
|
State<StatefulWidget> createState() { |
||||||
|
return _ShopImageInfo(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class _ShopImageInfo extends State<ShopImageInfo> { |
||||||
|
String filePath; |
||||||
|
String logoPath; |
||||||
|
BusinessApiService businessService; |
||||||
|
Map<String, String> imageInfo = { |
||||||
|
"logo": "", |
||||||
|
"facade": "", |
||||||
|
}; |
||||||
|
|
||||||
|
@override |
||||||
|
void initState() { |
||||||
|
super.initState(); |
||||||
|
// SharedPreferences.getInstance().then((value) => { |
||||||
|
// imageInfo["logo"] = widget.arguments["logo"], |
||||||
|
// imageInfo["facade"] = widget.arguments["facade"], |
||||||
|
// }); |
||||||
|
} |
||||||
|
|
||||||
|
refresh() async { |
||||||
|
setState(() {}); |
||||||
|
} |
||||||
|
|
||||||
|
@override |
||||||
|
Widget build(BuildContext context) { |
||||||
|
return Scaffold( |
||||||
|
resizeToAvoidBottomInset: false, |
||||||
|
backgroundColor: Color(0xFFF8F8FA), |
||||||
|
appBar: MyAppBar( |
||||||
|
title: "门店图片", |
||||||
|
titleColor: Colors.black, |
||||||
|
background: Color(0xFFFFFFFF), |
||||||
|
leadingColor: Colors.black, |
||||||
|
), |
||||||
|
body: Column( |
||||||
|
mainAxisAlignment: MainAxisAlignment.start, |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Container( |
||||||
|
margin: EdgeInsets.symmetric(vertical: 16.h, horizontal: 14.w), |
||||||
|
padding: EdgeInsets.only(top: 16.h, left: 18.w, bottom: 16.h), |
||||||
|
width: double.infinity, |
||||||
|
decoration: BoxDecoration( |
||||||
|
color: Colors.white, |
||||||
|
borderRadius: BorderRadius.circular(8.w), |
||||||
|
), |
||||||
|
child: Column( |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Padding( |
||||||
|
padding: EdgeInsets.only(bottom: 16.h), |
||||||
|
child: Text( |
||||||
|
"店铺logo", |
||||||
|
style: TextStyle( |
||||||
|
color: Color(0xFF1A1A1A), |
||||||
|
fontSize: 14.sp, |
||||||
|
fontWeight: MyFontWeight.regular, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
GestureDetector( |
||||||
|
behavior: HitTestBehavior.opaque, |
||||||
|
onTap: () { |
||||||
|
showImagePicker(1); |
||||||
|
}, |
||||||
|
child: Container( |
||||||
|
height: 77.h, |
||||||
|
width: 77.h, |
||||||
|
decoration: BoxDecoration( |
||||||
|
color: Color(0xFFF2F2F2), |
||||||
|
borderRadius: BorderRadius.circular(4), |
||||||
|
), |
||||||
|
alignment: Alignment.center, |
||||||
|
child: (widget.arguments["logo"] != "") |
||||||
|
? (logoPath == null |
||||||
|
? MImage( |
||||||
|
widget.arguments["logo"], |
||||||
|
fit: BoxFit.contain, |
||||||
|
radius: BorderRadius.circular(2), |
||||||
|
width: MediaQuery.of(context).size.width / 1.5, |
||||||
|
height: MediaQuery.of(context).size.width / 1.5, |
||||||
|
errorSrc: "assets/image/default_2_1.webp", |
||||||
|
fadeSrc: "assets/image/default_2_1.webp", |
||||||
|
) |
||||||
|
: Image.file( |
||||||
|
File(logoPath), |
||||||
|
width: MediaQuery.of(context).size.width / 1.5, |
||||||
|
height: MediaQuery.of(context).size.width / 1.5, |
||||||
|
fit: BoxFit.cover, |
||||||
|
)) |
||||||
|
: SvgPicture.asset( |
||||||
|
"assets/svg/zhaopianshipin.svg", |
||||||
|
width: 24.h, |
||||||
|
height: 24.h, |
||||||
|
fit: BoxFit.contain, |
||||||
|
), |
||||||
|
), |
||||||
|
) |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
Container( |
||||||
|
margin: EdgeInsets.symmetric(vertical: 16.h, horizontal: 14.w), |
||||||
|
padding: EdgeInsets.only(top: 16.h, left: 18.w, bottom: 16.h), |
||||||
|
width: double.infinity, |
||||||
|
decoration: BoxDecoration( |
||||||
|
color: Colors.white, |
||||||
|
borderRadius: BorderRadius.circular(8.w), |
||||||
|
), |
||||||
|
child: Column( |
||||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||||
|
children: [ |
||||||
|
Padding( |
||||||
|
padding: EdgeInsets.only(bottom: 16.h), |
||||||
|
child: Text( |
||||||
|
"门面图", |
||||||
|
style: TextStyle( |
||||||
|
color: Color(0xFF1A1A1A), |
||||||
|
fontSize: 14.sp, |
||||||
|
fontWeight: MyFontWeight.regular, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
GestureDetector( |
||||||
|
behavior: HitTestBehavior.opaque, |
||||||
|
onTap: () { |
||||||
|
showImagePicker(2); |
||||||
|
}, |
||||||
|
child: Container( |
||||||
|
height: 77.h, |
||||||
|
width: 77.h, |
||||||
|
decoration: BoxDecoration( |
||||||
|
color: Color(0xFFF2F2F2), |
||||||
|
borderRadius: BorderRadius.circular(4), |
||||||
|
), |
||||||
|
alignment: Alignment.center, |
||||||
|
child: (widget.arguments["facade"] != "") |
||||||
|
? (filePath == null |
||||||
|
? MImage( |
||||||
|
widget.arguments["facade"], |
||||||
|
fit: BoxFit.contain, |
||||||
|
radius: BorderRadius.circular(2), |
||||||
|
width: MediaQuery.of(context).size.width / 1.5, |
||||||
|
height: MediaQuery.of(context).size.width / 1.5, |
||||||
|
errorSrc: "assets/image/default_2_1.webp", |
||||||
|
fadeSrc: "assets/image/default_2_1.webp", |
||||||
|
) |
||||||
|
: Image.file( |
||||||
|
File(filePath), |
||||||
|
width: MediaQuery.of(context).size.width / 1.5, |
||||||
|
height: MediaQuery.of(context).size.width / 1.5, |
||||||
|
fit: BoxFit.cover, |
||||||
|
)) |
||||||
|
: SvgPicture.asset( |
||||||
|
"assets/svg/zhaopianshipin.svg", |
||||||
|
width: 24.h, |
||||||
|
height: 24.h, |
||||||
|
fit: BoxFit.contain, |
||||||
|
), |
||||||
|
), |
||||||
|
) |
||||||
|
], |
||||||
|
), |
||||||
|
), |
||||||
|
Spacer(), |
||||||
|
GestureDetector( |
||||||
|
behavior: HitTestBehavior.opaque, |
||||||
|
onTap: (){ |
||||||
|
Navigator.of(context).pop([imageInfo["logo"] == "" ? widget.arguments["logo"]:imageInfo["logo"], |
||||||
|
imageInfo["facade"] == "" ? widget.arguments["facade"]:imageInfo["facade"]]); |
||||||
|
}, |
||||||
|
child: Container( |
||||||
|
width: double.infinity, |
||||||
|
alignment: Alignment.center, |
||||||
|
margin: EdgeInsets.only(bottom: 55.h, left: 16.w, right: 16.w), |
||||||
|
padding: EdgeInsets.symmetric(vertical: 16.h), |
||||||
|
decoration: BoxDecoration( |
||||||
|
borderRadius: BorderRadius.circular(27), |
||||||
|
color: Color(0xFF30415B)), |
||||||
|
child: Text( |
||||||
|
S.of(context).baocun, |
||||||
|
style: TextStyle( |
||||||
|
fontWeight: MyFontWeight.semi_bold, |
||||||
|
fontSize: 16.sp, |
||||||
|
color: Colors.white, |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
) |
||||||
|
], |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
///显示图片选择方式 |
||||||
|
showImagePicker(index) { |
||||||
|
showCupertinoModalPopup( |
||||||
|
context: context, |
||||||
|
builder: (contetx) { |
||||||
|
return CupertinoActionSheet( |
||||||
|
title: Text(S.of(context).genghuantouxiang), |
||||||
|
actions: [ |
||||||
|
CupertinoActionSheetAction( |
||||||
|
child: Text(S.of(context).paizhao), |
||||||
|
onPressed: () { |
||||||
|
openCamera(index); |
||||||
|
Navigator.of(context).pop(); |
||||||
|
}, |
||||||
|
isDefaultAction: true, |
||||||
|
isDestructiveAction: false, |
||||||
|
), |
||||||
|
CupertinoActionSheetAction( |
||||||
|
child: Text(S.of(context).xiangce), |
||||||
|
onPressed: () { |
||||||
|
openStorage(index); |
||||||
|
Navigator.of(context).pop(); |
||||||
|
}, |
||||||
|
isDefaultAction: true, |
||||||
|
isDestructiveAction: false, |
||||||
|
), |
||||||
|
], |
||||||
|
cancelButton: CupertinoActionSheetAction( |
||||||
|
onPressed: () { |
||||||
|
Navigator.of(context).pop(); |
||||||
|
}, |
||||||
|
child: Text(S.of(context).quxiao), |
||||||
|
isDestructiveAction: true, |
||||||
|
), |
||||||
|
); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
///拍照 |
||||||
|
openCamera(index) async { |
||||||
|
if (await Permission.camera.isGranted) { |
||||||
|
Media medias = await ImagePickers.openCamera( |
||||||
|
cameraMimeType: CameraMimeType.photo, |
||||||
|
cropConfig: CropConfig( |
||||||
|
enableCrop: true, |
||||||
|
width: 200, |
||||||
|
height: 200, |
||||||
|
), |
||||||
|
compressSize: 500, |
||||||
|
); |
||||||
|
if (medias == null) return; |
||||||
|
if(index == 1){ |
||||||
|
logoPath = medias.path; |
||||||
|
}else{ |
||||||
|
filePath = medias.path; |
||||||
|
} |
||||||
|
fileImgUpload(index); |
||||||
|
} else { |
||||||
|
await Permission.camera.request(); |
||||||
|
openCamera(index); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
///打开相册 |
||||||
|
openStorage(index) async { |
||||||
|
if (await Permission.storage.isGranted) { |
||||||
|
List<Media> medias = await ImagePickers.pickerPaths( |
||||||
|
galleryMode: GalleryMode.image, |
||||||
|
selectCount: 1, |
||||||
|
showGif: true, |
||||||
|
showCamera: false, |
||||||
|
compressSize: 500, |
||||||
|
uiConfig: UIConfig( |
||||||
|
uiThemeColor: Color(0xFFFFFFFF), |
||||||
|
), |
||||||
|
cropConfig: CropConfig( |
||||||
|
enableCrop: true, |
||||||
|
width: 200, |
||||||
|
height: 200, |
||||||
|
), |
||||||
|
); |
||||||
|
if (medias == null || medias.length == 0) return; |
||||||
|
if (index == 1) { |
||||||
|
logoPath = medias[0].path; |
||||||
|
} else { |
||||||
|
filePath = medias[0].path; |
||||||
|
} |
||||||
|
setState(() {}); |
||||||
|
fileImgUpload(index); |
||||||
|
} else { |
||||||
|
await Permission.storage.request(); |
||||||
|
openStorage(index); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
///文件上传 |
||||||
|
fileImgUpload(index) async { |
||||||
|
EasyLoading.show( |
||||||
|
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); |
||||||
|
if (businessService == null) { |
||||||
|
businessService = BusinessApiService(Dio(), |
||||||
|
context: context, |
||||||
|
token: BusinessInstance.instance.businessToken, |
||||||
|
tenant: BusinessInstance.instance.businessTenant, |
||||||
|
storeId: widget.arguments["storeId"]); |
||||||
|
} |
||||||
|
if (logoPath != null && logoPath != "" && await File(logoPath).exists() || filePath != null && filePath != "" && await File(filePath).exists()) { |
||||||
|
BaseData<UploadResult> baseData = await businessService |
||||||
|
.upload(File(index == 1 ? logoPath:filePath), 1) |
||||||
|
.catchError((onError) { |
||||||
|
SmartDialog.showToast(AppUtils.dioErrorTypeToString(onError.type), |
||||||
|
alignment: Alignment.center); |
||||||
|
}); |
||||||
|
if (baseData != null && baseData.isSuccess) { |
||||||
|
UploadResult uploadResult = baseData.data; |
||||||
|
if (index == 1) { |
||||||
|
imageInfo["logo"] = uploadResult.url; |
||||||
|
} else { |
||||||
|
imageInfo["facade"] = uploadResult.url; |
||||||
|
} |
||||||
|
} |
||||||
|
EasyLoading.dismiss(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue