|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:one_key/models/user.dart';
|
|
|
|
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../constant/state.dart';
|
|
|
|
import '../../../provider/marketing_center_provider.dart';
|
|
|
|
import '../../../provider/user_model.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/MyDivider.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/page_exception.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import '../../online_check/photo_view_wiget.dart';
|
|
|
|
|
|
|
|
import 'dart:convert' as convert;
|
|
|
|
|
|
|
|
import 'dart:math' as math;
|
|
|
|
|
|
|
|
import 'package:flutter_swiper/flutter_swiper.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 小程序通知卡片样式
|
|
|
|
*/
|
|
|
|
|
|
|
|
class MiniprogramSettingPage extends StatefulWidget {
|
|
|
|
MiniprogramSettingPage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_MiniprogramSettingPageState createState() => _MiniprogramSettingPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
|
|
|
|
MarketingCenterProvider marketingCenterProvider;
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
|
|
|
|
String miniType;
|
|
|
|
PageController pageController;
|
|
|
|
double pageOffset = 0;
|
|
|
|
|
|
|
|
SwiperController swiperController = SwiperController();
|
|
|
|
|
|
|
|
List<String> types = ['0', '1', '2', '3'];
|
|
|
|
|
|
|
|
User user;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
pageController = PageController(viewportFraction: 1);
|
|
|
|
pageController.addListener(() {
|
|
|
|
setState(() => pageOffset = pageController.page);
|
|
|
|
});
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
getDzSellerConf();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
getDzSellerConf() async {
|
|
|
|
bool success = await marketingCenterProvider.getDzSellerConf(context,
|
|
|
|
showLoading: false, selfDismiss: true);
|
|
|
|
if (success) {
|
|
|
|
marketingCenterProvider.pageStateSettingMini = PageState.Success;
|
|
|
|
miniType = marketingCenterProvider.dzSellerConfModel.liteStyle ?? '2';
|
|
|
|
int index = types.indexOf(miniType);
|
|
|
|
if (index >= 0) {
|
|
|
|
swiperController.index = index;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
marketingCenterProvider.pageStateSettingMini =
|
|
|
|
PageState.ConnectivityError;
|
|
|
|
}
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
String returnWeek(DateTime day, BuildContext context) {
|
|
|
|
String date = "周${Utils.formatWeekDayNum(day.weekday)} ";
|
|
|
|
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
marketingCenterProvider =
|
|
|
|
Provider.of<MarketingCenterProvider>(context, listen: true);
|
|
|
|
|
|
|
|
user = Provider.of<UserModel>(context, listen: false).user;
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar('小程序通知卡片样式'),
|
|
|
|
body: Consumer<MarketingCenterProvider>(builder: (context1, model, _) {
|
|
|
|
if (model.pageStateSettingMini != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageStateSettingMini,
|
|
|
|
callback: () async {},
|
|
|
|
emptyMsg: "暂时没有信息展示哦",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(16), top: w(12), bottom: w(11), right: w(16)),
|
|
|
|
child: Text(
|
|
|
|
'通知主题选择(左右滑动选择要使用的主题)',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151, fontSize: font(16)),
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
child: MyDivider(double.infinity, w(0.5),
|
|
|
|
color: MyColours.color_E7E7E7)),
|
|
|
|
VEmptyView(240),
|
|
|
|
Container(
|
|
|
|
height: w(145),
|
|
|
|
child: Swiper(
|
|
|
|
controller: swiperController,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
if (types[index] == '0') {
|
|
|
|
return Container(
|
|
|
|
color: Color.fromRGBO(81, 81, 81, 0.4),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(10)),
|
|
|
|
width: w(180),
|
|
|
|
height: h(145),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
'无样式',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_FFEFC5,
|
|
|
|
fontSize: font(20)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container(
|
|
|
|
color: Color.fromRGBO(81, 81, 81, 0.4),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(10)),
|
|
|
|
width: w(180),
|
|
|
|
height: h(145),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
VEmptyView(20),
|
|
|
|
Text(
|
|
|
|
'${Provider.of<UserModel>(context, listen: false).user.sellername}',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_FFEFC5,
|
|
|
|
fontSize: font(12)),
|
|
|
|
),
|
|
|
|
VEmptyView(50),
|
|
|
|
Text(
|
|
|
|
'${Utils.addZeroNumber(DateTime.now().month)}月${Utils.addZeroNumber(DateTime.now().day)}日',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_FFEFC5,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: font(20)),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
returnWeek(DateTime.now(), context) +
|
|
|
|
(types[index] == '1'
|
|
|
|
? '中午'
|
|
|
|
: types[index] == '2'
|
|
|
|
? (user.noon != '00:00'
|
|
|
|
? user.noon.split('-')[0]
|
|
|
|
: '14:30')
|
|
|
|
: '午餐'),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_FFEFC5,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: font(18)),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
onTap: (v) {
|
|
|
|
print(v);
|
|
|
|
},
|
|
|
|
onIndexChanged: (index) {
|
|
|
|
print(index);
|
|
|
|
miniType = types[index];
|
|
|
|
// marketingCenterProvider.isThemeTitle =
|
|
|
|
// marketingCenterProvider
|
|
|
|
// .templeteDatas[index].isSetTitle ==
|
|
|
|
// '1'
|
|
|
|
// ? true
|
|
|
|
// : false;
|
|
|
|
// marketingCenterProvider.isThemeColor =
|
|
|
|
// marketingCenterProvider
|
|
|
|
// .templeteDatas[index].isSetColor ==
|
|
|
|
// '1'
|
|
|
|
// ? true
|
|
|
|
// : false;
|
|
|
|
|
|
|
|
// setState(() {
|
|
|
|
// swiperController.index = index;
|
|
|
|
// });
|
|
|
|
|
|
|
|
// 当前选中的主题
|
|
|
|
},
|
|
|
|
index: swiperController.index,
|
|
|
|
itemCount: types.length,
|
|
|
|
viewportFraction: 0.5,
|
|
|
|
scale: 0.4,
|
|
|
|
))
|
|
|
|
],
|
|
|
|
))),
|
|
|
|
Container(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: w(24), vertical: w(35)),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
text: '返回',
|
|
|
|
width: w(100),
|
|
|
|
height: w(43),
|
|
|
|
radius: r(5),
|
|
|
|
fontSize: 32,
|
|
|
|
isBold: true,
|
|
|
|
gradientStart: MyColours.color_ffffff,
|
|
|
|
gradientEnd: MyColours.color_ffffff,
|
|
|
|
textColor: MyColours.color_438E93,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
HEmptyView(24),
|
|
|
|
Expanded(
|
|
|
|
child: RoundButton(
|
|
|
|
text: '保存并返回',
|
|
|
|
height: w(43),
|
|
|
|
radius: r(5),
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 32,
|
|
|
|
gradientStart: MyColours.color_438E93,
|
|
|
|
gradientEnd: MyColours.color_438E93,
|
|
|
|
textColor: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
onPressed: () async {
|
|
|
|
bool success = await marketingCenterProvider.setConfing(
|
|
|
|
context,
|
|
|
|
{
|
|
|
|
'sid':
|
|
|
|
Provider.of<UserModel>(context, listen: false)
|
|
|
|
.user
|
|
|
|
.sellerid,
|
|
|
|
'key': 'lite_style',
|
|
|
|
'value': miniType
|
|
|
|
},
|
|
|
|
needToast: false);
|
|
|
|
if (success) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SlidingCard extends StatelessWidget {
|
|
|
|
final double offset;
|
|
|
|
final String movie;
|
|
|
|
final int index;
|
|
|
|
const SlidingCard({this.offset, this.movie, this.index});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
int select = 0;
|
|
|
|
double gauss = math.exp(-(math.pow((offset.abs() - 0.5), 2) / 0.08));
|
|
|
|
if (Offset(-32 * gauss * offset.sign, 0).dx == -0.0) {
|
|
|
|
//最中间的图
|
|
|
|
select = index;
|
|
|
|
}
|
|
|
|
return Transform.translate(
|
|
|
|
offset: Offset(-32 * gauss * offset.sign, 0),
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
print(gauss);
|
|
|
|
print(Offset(-32 * gauss * offset.sign, 0));
|
|
|
|
print(index);
|
|
|
|
},
|
|
|
|
child: Card(
|
|
|
|
margin: EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
|
|
|
elevation: 8,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(32),
|
|
|
|
),
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
r(10),
|
|
|
|
),
|
|
|
|
child: Image.network(
|
|
|
|
'${movie}',
|
|
|
|
width: select == index ? w(375) : w(179),
|
|
|
|
height: select == index ? w(359) : w(90),
|
|
|
|
// height: MediaQuery.of(context).size.height * 0.3,
|
|
|
|
alignment: Alignment(-offset.abs(), 0),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// SizedBox(
|
|
|
|
// height: 8,
|
|
|
|
// ),
|
|
|
|
// Expanded(
|
|
|
|
// child: Padding(
|
|
|
|
// padding: const EdgeInsets.all(8.0),
|
|
|
|
// child: Column(
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
// children: <Widget>[
|
|
|
|
// Text(
|
|
|
|
// '${movie.name}',
|
|
|
|
// style:
|
|
|
|
// TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// SizedBox(
|
|
|
|
// height: 10,
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// '上架时间: ${movie.date}',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 14, fontWeight: FontWeight.normal),
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// '${movie.intor}',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 14,
|
|
|
|
// fontWeight: FontWeight.normal,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// Spacer(),
|
|
|
|
// Row(
|
|
|
|
// children: <Widget>[
|
|
|
|
// SizedBox(width: 16,),
|
|
|
|
// Text(
|
|
|
|
// '${movie.price}',
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
|
// ),
|
|
|
|
// Spacer(),
|
|
|
|
// MaterialButton(
|
|
|
|
// onPressed: () {},
|
|
|
|
// color: Colors.black,
|
|
|
|
// child: Text('购买'),
|
|
|
|
// textColor: Colors.white,
|
|
|
|
// shape: RoundedRectangleBorder(
|
|
|
|
// borderRadius: BorderRadius.circular(32),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// SizedBox(width: 16,),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|