|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:image_picker/image_picker.dart';
|
|
|
|
import 'package:one_key/provider/marketing_center_provider.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../../app.dart';
|
|
|
|
import '../../../../models/theme_color_model.dart';
|
|
|
|
import '../../../../models/upload_img_model.dart';
|
|
|
|
import '../../../../provider/upload_img_provider.dart';
|
|
|
|
import '../../../../provider/user_model.dart';
|
|
|
|
import '../../../../res/colors.dart';
|
|
|
|
import '../../../../utils/screen_util.dart';
|
|
|
|
import '../../../../utils/upload_image_util.dart';
|
|
|
|
import '../../../../widgets/round_button.dart';
|
|
|
|
import '../../../online_check/photo_view_wiget.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 首图形象展示
|
|
...
|
...
|
@@ -32,6 +44,12 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
TextEditingController sloganC = TextEditingController();
|
|
|
|
FocusNode sloganNode = FocusNode();
|
|
|
|
|
|
|
|
final picker = ImagePicker();
|
|
|
|
|
|
|
|
UploadImageProvider _uploadImageProvider;
|
|
|
|
|
|
|
|
MarketingCenterProvider _marketingCenterProvider;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
...
|
...
|
@@ -179,9 +197,71 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
//查看大图
|
|
|
|
_showPhotoView(BuildContext context, int index, List imgs,
|
|
|
|
{isShow = false, List dashName}) async {
|
|
|
|
// if (imgs.length == 1 &&
|
|
|
|
// imgs[0] ==
|
|
|
|
// 'http://nosqn.colorcun.com/custom/lite-online/image/def-banner.png') {
|
|
|
|
// imgs[0] = 'http://nosqn.colorcun.com/app/seller-hj-empty.png';
|
|
|
|
// }
|
|
|
|
Utils.setBarStatus(false, color: Colors.black);
|
|
|
|
dynamic result = await showGeneralDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: false,
|
|
|
|
// barrierColor: Colors.red,
|
|
|
|
barrierLabel:
|
|
|
|
MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
|
|
|
transitionDuration: const Duration(milliseconds: 150),
|
|
|
|
pageBuilder: (BuildContext context, Animation animation,
|
|
|
|
Animation secondaryAnimation) {
|
|
|
|
Widget child = Stack(
|
|
|
|
children: <Widget>[
|
|
|
|
PhotoPreview(
|
|
|
|
initialIndex: index,
|
|
|
|
photoList: imgs,
|
|
|
|
isShow: isShow,
|
|
|
|
dashName: dashName)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
return child;
|
|
|
|
});
|
|
|
|
Utils.setBarStatus(true, color: Colors.white);
|
|
|
|
}
|
|
|
|
|
|
|
|
///#相机拍照,单图选择
|
|
|
|
Future _getFromPictureOrCamera(UploadImgModel imgModel, imageSource) async {
|
|
|
|
final pickedFile = await picker.getImage(source: imageSource);
|
|
|
|
setState(() {
|
|
|
|
if (pickedFile != null) {
|
|
|
|
imgModel.file = File(pickedFile.path);
|
|
|
|
imgModel.process = 0.01;
|
|
|
|
} else {
|
|
|
|
print('No image selected.');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (pickedFile != null) {
|
|
|
|
// if (title == '头像') {
|
|
|
|
// _uploadImageProvider.imgSizeTouxiang = 76;
|
|
|
|
// _uploadImageProvider.touxiang.qiniuUrl = null;
|
|
|
|
// } else {
|
|
|
|
// _uploadImageProvider.imgSizeErweima = 76;
|
|
|
|
_uploadImageProvider.firstImage.qiniuUrl = null;
|
|
|
|
// }
|
|
|
|
UploadImageUtil().startUploadOnly(
|
|
|
|
context, File(pickedFile.path), 4, true, _uploadImageProvider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
ThemeColorModel themeColerModel = themeColorData[themeColorIndex];
|
|
|
|
_uploadImageProvider =
|
|
|
|
Provider.of<UploadImageProvider>(context, listen: true);
|
|
|
|
|
|
|
|
_marketingCenterProvider =
|
|
|
|
Provider.of<MarketingCenterProvider>(context, listen: true);
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
...
|
...
|
@@ -203,8 +283,6 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
setState(() {
|
|
|
|
themeColorIndex = object;
|
|
|
|
});
|
|
|
|
App.sp.setInt("themeColor",
|
|
|
|
themeColorData[themeColorIndex].color.value);
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
VEmptyView(24),
|
|
...
|
...
|
@@ -239,8 +317,9 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
height: w(39),
|
|
|
|
child: TextField(
|
|
|
|
maxLines: 1,
|
|
|
|
controller: sloganC,
|
|
|
|
focusNode: sloganNode,
|
|
|
|
controller: titleC,
|
|
|
|
focusNode: titleNode,
|
|
|
|
|
|
|
|
cursorColor: MyColours.color_F8F9FD,
|
|
|
|
|
|
|
|
// autofocuzs: true,
|
|
...
|
...
|
@@ -292,11 +371,11 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
height: w(39),
|
|
|
|
child: TextField(
|
|
|
|
maxLines: 1,
|
|
|
|
controller: titleC,
|
|
|
|
focusNode: titleNode,
|
|
|
|
|
|
|
|
// autofocus: true,
|
|
|
|
cursorColor: MyColours.color_F8F9FD,
|
|
|
|
|
|
|
|
controller: sloganC,
|
|
|
|
focusNode: sloganNode,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(20),
|
|
|
|
foreground: Paint()
|
|
...
|
...
|
@@ -340,37 +419,139 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {},
|
|
|
|
child: true
|
|
|
|
? InkWell(
|
|
|
|
onTap: () {
|
|
|
|
print('object');
|
|
|
|
_uploadImageProvider.firstImage.file != null ||
|
|
|
|
(_uploadImageProvider.firstImage.qiniuUrl != null &&
|
|
|
|
_uploadImageProvider.firstImage.qiniuUrl != '')
|
|
|
|
? InkWell(
|
|
|
|
onTap: () {
|
|
|
|
double process;
|
|
|
|
String qiniuUrl;
|
|
|
|
List<String> tempList = [];
|
|
|
|
// if (title == '头像') {
|
|
|
|
process = _uploadImageProvider.firstImage.process;
|
|
|
|
qiniuUrl = _uploadImageProvider.firstImage.qiniuUrl;
|
|
|
|
// } else {
|
|
|
|
// process = _uploadImageProvider.erweima.process;
|
|
|
|
// qiniuUrl = _uploadImageProvider.erweima.qiniuUrl;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (qiniuUrl != null && qiniuUrl != '') {
|
|
|
|
// tempList.add(qiniuUrl);
|
|
|
|
|
|
|
|
// ///没有上传完成的不可以点击
|
|
|
|
// _showPhotoView(context, 0, tempList);
|
|
|
|
|
|
|
|
_uploadImageProvider.firstImage.qiniuUrl = null;
|
|
|
|
_uploadImageProvider.firstImage.process = 0;
|
|
|
|
setState(() {});
|
|
|
|
Utils.getPickPermission(context, () {
|
|
|
|
_getFromPictureOrCamera(
|
|
|
|
_uploadImageProvider.firstImage,
|
|
|
|
ImageSource.gallery);
|
|
|
|
},
|
|
|
|
Platform.isAndroid
|
|
|
|
? Permission.storage
|
|
|
|
: Permission.photos);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
child:
|
|
|
|
Stack(alignment: Alignment.bottomCenter, children: [
|
|
|
|
Stack(clipBehavior: Clip.none, children: [
|
|
|
|
_uploadImageProvider.firstImage.qiniuUrl != null &&
|
|
|
|
_uploadImageProvider.firstImage.qiniuUrl !=
|
|
|
|
''
|
|
|
|
? Image.network(
|
|
|
|
_uploadImageProvider.firstImage.qiniuUrl,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: double.infinity,
|
|
|
|
// width: ScreenUtil()
|
|
|
|
// .setWidth(imgSize * 2),
|
|
|
|
height: ScreenUtil().setWidth(
|
|
|
|
_uploadImageProvider.imgSizefirstImage *
|
|
|
|
2),
|
|
|
|
)
|
|
|
|
: Image.file(
|
|
|
|
_uploadImageProvider.firstImage.file,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: double.infinity,
|
|
|
|
// width: ScreenUtil()
|
|
|
|
// .setWidth(imgSize * 2),
|
|
|
|
height: ScreenUtil().setWidth(
|
|
|
|
_uploadImageProvider.imgSizefirstImage *
|
|
|
|
2),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
left: 0,
|
|
|
|
top: 0,
|
|
|
|
child: (_uploadImageProvider.firstImage.file !=
|
|
|
|
null) &&
|
|
|
|
_uploadImageProvider
|
|
|
|
.firstImage.process !=
|
|
|
|
1 &&
|
|
|
|
_uploadImageProvider
|
|
|
|
.firstImage.process !=
|
|
|
|
0.01
|
|
|
|
? Container(
|
|
|
|
width: ScreenUtil().screenWidth,
|
|
|
|
height: w(_uploadImageProvider
|
|
|
|
.imgSizefirstImage),
|
|
|
|
color: MyColours.color_4D000000,
|
|
|
|
child: Center(
|
|
|
|
child: Text('上传中',
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
MyColours.color_F8F9FD)),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Container()),
|
|
|
|
]),
|
|
|
|
_uploadImageProvider.firstImage.process == 1
|
|
|
|
? Container(
|
|
|
|
width: w(150),
|
|
|
|
height: w(30),
|
|
|
|
color: MyColours.color_4D000000,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
'点击图片可以更换',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_F8F9FD,
|
|
|
|
fontSize: font(14),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
))
|
|
|
|
: SizedBox(),
|
|
|
|
]))
|
|
|
|
: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
// double process;
|
|
|
|
// String qiniuUrl;
|
|
|
|
// List<String> tempList = [];
|
|
|
|
// if (title == '头像') {
|
|
|
|
// process = _uploadImageProvider.touxiang.process;
|
|
|
|
// qiniuUrl = _uploadImageProvider.touxiang.qiniuUrl;
|
|
|
|
// } else {
|
|
|
|
// process = _uploadImageProvider.erweima.process;
|
|
|
|
// qiniuUrl = _uploadImageProvider.erweima.qiniuUrl;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (qiniuUrl != null && qiniuUrl != '') {
|
|
|
|
// tempList.add(qiniuUrl);
|
|
|
|
|
|
|
|
// ///没有上传完成的不可以点击
|
|
|
|
// _showPhotoView(context, 0, tempList);
|
|
|
|
// } else {
|
|
|
|
Utils.getPickPermission(context, () {
|
|
|
|
_getFromPictureOrCamera(
|
|
|
|
_uploadImageProvider.firstImage,
|
|
|
|
ImageSource.gallery);
|
|
|
|
},
|
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
children: [
|
|
|
|
Image.network(
|
|
|
|
'https://www.ssfiction.com/wp-content/uploads/2020/08/20200805_5f2b1669e9a24.jpg',
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: w(150),
|
|
|
|
height: w(30),
|
|
|
|
color: MyColours.color_4D000000,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
'点击图片可以更换',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_F8F9FD,
|
|
|
|
fontSize: font(14),
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
)),
|
|
|
|
]))
|
|
|
|
: Container(
|
|
|
|
Platform.isAndroid
|
|
|
|
? Permission.storage
|
|
|
|
: Permission.photos);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
color: MyColours.color_d9d9d9,
|
|
|
|
width: double.infinity,
|
|
|
|
height: w(210),
|
|
|
|
height: w(_uploadImageProvider.imgSizefirstImage),
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
...
|
...
|
@@ -394,8 +575,7 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
...
|
...
|
@@ -412,7 +592,49 @@ class _FirstImagePageState extends State<FirstImagePage> { |
|
|
|
fontSize: 34,
|
|
|
|
height: w(40),
|
|
|
|
isBold: true,
|
|
|
|
onPressed: () {},
|
|
|
|
onPressed: () async {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
if (titleC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入标题!');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (titleC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入店铺slogan!');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (_uploadImageProvider.firstImage.qiniuUrl == null) {
|
|
|
|
Utils.showToast('请上传图片!');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_uploadImageProvider.firstImage.process < 1) {
|
|
|
|
Utils.showToast('正在上传图片,请稍等');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
App.sp.setInt(
|
|
|
|
"themeColor", themeColorData[themeColorIndex].color.value);
|
|
|
|
//接口
|
|
|
|
Map homeData = {
|
|
|
|
'theme_color': themeColorData[themeColorIndex].color.value,
|
|
|
|
'title': titleC.text,
|
|
|
|
'slogan': sloganC.text,
|
|
|
|
'image': _uploadImageProvider.firstImage.qiniuUrl
|
|
|
|
};
|
|
|
|
Map<String, String> params = {
|
|
|
|
'sid': Provider.of<UserModel>(context, listen: false)
|
|
|
|
.user
|
|
|
|
.sellerid,
|
|
|
|
'home': json.encode(homeData)
|
|
|
|
};
|
|
|
|
|
|
|
|
bool success = await _marketingCenterProvider
|
|
|
|
.setSellerTemplateConf(context, params, showLoading: true);
|
|
|
|
if (success) {
|
|
|
|
Utils.showToast('保存成功');
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
...
|
...
|
|