Commit c27c11c0b0765ff4c91e74c29c4daba2fcf9fc18

Authored by wdn127929
1 parent 9f1a868d

设置小程序卡片样式OK

1 -  
2 import 'dart:convert'; 1 import 'dart:convert';
3 2
4 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
@@ -20,9 +19,6 @@ import '../../../widgets/MyDivider.dart'; @@ -20,9 +19,6 @@ import '../../../widgets/MyDivider.dart';
20 import '../../../widgets/h_empty_view.dart'; 19 import '../../../widgets/h_empty_view.dart';
21 import '../../../widgets/page_exception.dart'; 20 import '../../../widgets/page_exception.dart';
22 import '../../../widgets/round_button.dart'; 21 import '../../../widgets/round_button.dart';
23 -import '../../online_check/photo_view_wiget.dart';  
24 -  
25 -import 'dart:convert' as convert;  
26 22
27 import 'dart:math' as math; 23 import 'dart:math' as math;
28 24
@@ -45,13 +41,31 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -45,13 +41,31 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
45 late MarketingCenterProvider marketingCenterProvider; 41 late MarketingCenterProvider marketingCenterProvider;
46 ScrollController controller = ScrollController(); 42 ScrollController controller = ScrollController();
47 43
48 - String? miniType; 44 + String miniType = '2-3';
49 late PageController pageController; 45 late PageController pageController;
50 double? pageOffset = 0; 46 double? pageOffset = 0;
51 47
52 SwiperController swiperController = SwiperController(); 48 SwiperController swiperController = SwiperController();
53 49
54 - List<String?> types = ['0', '1', '2', '3']; 50 + List<String> types = [
  51 + '0',
  52 + '1-1',
  53 + '1-2',
  54 + '1-3',
  55 + '1-4',
  56 + '2-1',
  57 + '2-2',
  58 + '2-3',
  59 + '2-4',
  60 + '3-1',
  61 + '3-2',
  62 + '3-3',
  63 + '3-4',
  64 + '4-1',
  65 + '4-2',
  66 + '4-3',
  67 + '4-4',
  68 + ];
55 69
56 User? user; 70 User? user;
57 71
@@ -75,7 +89,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -75,7 +89,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
75 showLoading: false, selfDismiss: true); 89 showLoading: false, selfDismiss: true);
76 if (success) { 90 if (success) {
77 marketingCenterProvider.pageStateSettingMini = PageState.Success; 91 marketingCenterProvider.pageStateSettingMini = PageState.Success;
78 - miniType = marketingCenterProvider.dzSellerConfModel!.liteStyle ?? '3'; 92 + miniType = marketingCenterProvider.dzSellerConfModel!.liteStyle ?? '2-3';
79 tilteContentC.text = marketingCenterProvider 93 tilteContentC.text = marketingCenterProvider
80 .dzSellerConfModel!.liteStyleTitle ?? 94 .dzSellerConfModel!.liteStyleTitle ??
81 "您预订的${Provider.of<UserModel>(context, listen: false).user!.sellername},已经安排,点击查看详情"; 95 "您预订的${Provider.of<UserModel>(context, listen: false).user!.sellername},已经安排,点击查看详情";
@@ -91,7 +105,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -91,7 +105,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
91 } 105 }
92 106
93 String returnWeek(DateTime day, BuildContext context) { 107 String returnWeek(DateTime day, BuildContext context) {
94 - String date = "周${Utils.formatWeekDayNum(day.weekday)} "; 108 + String date = "周${Utils.formatWeekDayNum(day.weekday)} ";
95 109
96 return date; 110 return date;
97 } 111 }
@@ -103,7 +117,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -103,7 +117,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
103 117
104 user = Provider.of<UserModel>(context, listen: false).user; 118 user = Provider.of<UserModel>(context, listen: false).user;
105 return Scaffold( 119 return Scaffold(
106 - backgroundColor: MyColours.color_ffffff, 120 + backgroundColor: MyColours.color_f3f3f3,
107 appBar: SystemAppBar('小程序通知卡片样式'), 121 appBar: SystemAppBar('小程序通知卡片样式'),
108 body: Consumer<MarketingCenterProvider>(builder: (context1, model, _) { 122 body: Consumer<MarketingCenterProvider>(builder: (context1, model, _) {
109 if (model.pageStateSettingMini != PageState.Success) { 123 if (model.pageStateSettingMini != PageState.Success) {
@@ -138,6 +152,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -138,6 +152,7 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
138 right: w(20), 152 right: w(20),
139 ), 153 ),
140 decoration: BoxDecoration( 154 decoration: BoxDecoration(
  155 + color: MyColours.color_ffffff,
141 borderRadius: BorderRadius.circular(r(10)), 156 borderRadius: BorderRadius.circular(r(10)),
142 border: Border.all( 157 border: Border.all(
143 width: w(1), color: MyColours.color_DBDBDB)), 158 width: w(1), color: MyColours.color_DBDBDB)),
@@ -198,16 +213,16 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -198,16 +213,16 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
198 color: MyColours.color_E7E7E7)), 213 color: MyColours.color_E7E7E7)),
199 VEmptyView(240), 214 VEmptyView(240),
200 Container( 215 Container(
201 - height: w(145), 216 + height: w(168),
202 child: Swiper( 217 child: Swiper(
203 controller: swiperController, 218 controller: swiperController,
204 itemBuilder: (BuildContext context, int index) { 219 itemBuilder: (BuildContext context, int index) {
205 if (types[index] == '0') { 220 if (types[index] == '0') {
206 return Container( 221 return Container(
207 - color: Color.fromRGBO(81, 81, 81, 0.4), 222 + color: MyColours.color_99000000,
208 padding: EdgeInsets.symmetric(horizontal: w(10)), 223 padding: EdgeInsets.symmetric(horizontal: w(10)),
209 - width: w(180),  
210 - height: h(145), 224 + width: w(210),
  225 + height: h(168),
211 alignment: Alignment.center, 226 alignment: Alignment.center,
212 child: Text( 227 child: Text(
213 '无样式', 228 '无样式',
@@ -219,56 +234,411 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> { @@ -219,56 +234,411 @@ class _MiniprogramSettingPageState extends State<MiniprogramSettingPage> {
219 fontSize: font(20)), 234 fontSize: font(20)),
220 ), 235 ),
221 ); 236 );
222 - }  
223 - return Container(  
224 - color: Color.fromRGBO(81, 81, 81, 0.4),  
225 - padding: EdgeInsets.symmetric(horizontal: w(10)),  
226 - width: w(180),  
227 - height: h(145),  
228 - child: Column(  
229 - children: [  
230 - VEmptyView(20),  
231 - Text(  
232 - '${Provider.of<UserModel>(context, listen: false).user!.sellername}',  
233 - textAlign: TextAlign.center,  
234 - maxLines: 2,  
235 - overflow: TextOverflow.ellipsis,  
236 - style: TextStyle(  
237 - color: MyColours.color_FFEFC5,  
238 - fontSize: font(12)), 237 + } else {
  238 + List<String> subType = types[index].split('-');
  239 + String subType0 = subType[0]; //几号模版
  240 + String subType1 = subType[1]; //模版下面的子样式
  241 + if (subType0 == '1') {
  242 + //1号模版
  243 + String month =
  244 + '${Utils.addZeroNumber(DateTime.now().month)}月${Utils.addZeroNumber(DateTime.now().day)}日 ';
  245 + String week = returnWeek(DateTime.now(), context);
  246 + String hour = subType1 == '1' || subType1 == '3'
  247 + ? (user!.noon != '00:00'
  248 + ? '${user!.noon!.split('-')[0]} '
  249 + : '14:30 ')
  250 + : '';
  251 + String section =
  252 + subType1 == '1' || subType1 == '4'
  253 + ? '午餐'
  254 + : subType1 == '2'
  255 + ? '中午'
  256 + : '';
  257 +
  258 + String time = month + week + hour + section;
  259 +
  260 + return Container(
  261 + color: MyColours.color_ffffff,
  262 + // width: w(210),
  263 + height: h(168),
  264 + child: Column(
  265 + mainAxisAlignment:
  266 + MainAxisAlignment.spaceBetween,
  267 + children: [
  268 + Container(
  269 + alignment: Alignment.center,
  270 + // color: Color.fromRGBO(81, 81, 81, 0.4),
  271 + color: MyColours.color_99000000,
  272 + width: w(210),
  273 + height: h(26),
  274 + child: Text(
  275 + '${Provider.of<UserModel>(context, listen: false).user!.sellername}',
  276 + textAlign: TextAlign.center,
  277 + maxLines: 1,
  278 + overflow: TextOverflow.ellipsis,
  279 + style: TextStyle(
  280 + fontWeight: FontWeight.bold,
  281 + color: MyColours.color_FFEFC5,
  282 + fontSize: font(12)),
  283 + )),
  284 + Container(
  285 + alignment: Alignment.center,
  286 + // color: Color.fromRGBO(81, 81, 81, 0.4),
  287 + color: MyColours.color_99000000,
  288 + width: w(210),
  289 + height: h(26),
  290 + child: Text(
  291 + time,
  292 + textAlign: TextAlign.center,
  293 + maxLines: 2,
  294 + overflow: TextOverflow.ellipsis,
  295 + style: TextStyle(
  296 + color: MyColours.color_FFEFC5,
  297 + fontWeight: FontWeight.bold,
  298 + fontSize: font(12)),
  299 + )),
  300 + ],
239 ), 301 ),
240 - VEmptyView(50),  
241 - Text(  
242 - '${Utils.addZeroNumber(DateTime.now().month)}月${Utils.addZeroNumber(DateTime.now().day)}日',  
243 - textAlign: TextAlign.center,  
244 - maxLines: 2,  
245 - overflow: TextOverflow.ellipsis,  
246 - style: TextStyle(  
247 - color: MyColours.color_FFEFC5,  
248 - fontWeight: FontWeight.bold,  
249 - fontSize: font(20)), 302 + );
  303 + } else if (subType0 == '2') {
  304 + //2号模版
  305 +
  306 + String week = returnWeek(DateTime.now(), context);
  307 + String hour = subType1 == '1' || subType1 == '3'
  308 + ? (user!.noon != '00:00'
  309 + ? '${user!.noon!.split('-')[0]} '
  310 + : '14:30 ')
  311 + : '';
  312 + String section =
  313 + subType1 == '1' || subType1 == '4'
  314 + ? '午餐'
  315 + : subType1 == '2'
  316 + ? '中午'
  317 + : '';
  318 +
  319 + String time = week + hour + section;
  320 +
  321 + return Container(
  322 + // color: Color.fromRGBO(81, 81, 81, 0.4),
  323 + color: MyColours.color_99000000,
  324 + padding:
  325 + EdgeInsets.symmetric(horizontal: w(10)),
  326 + width: w(210),
  327 + height: h(168),
  328 + child: Column(
  329 + children: [
  330 + VEmptyView(66),
  331 + Text(
  332 + '${Provider.of<UserModel>(context, listen: false).user!.sellername}',
  333 + textAlign: TextAlign.center,
  334 + maxLines: 2,
  335 + overflow: TextOverflow.ellipsis,
  336 + style: TextStyle(
  337 + fontWeight: FontWeight.bold,
  338 + color: MyColours.color_FFEFC5,
  339 + fontSize: font(12)),
  340 + ),
  341 + VEmptyView(60),
  342 + Text(
  343 + '${Utils.addZeroNumber(DateTime.now().month)}/${Utils.addZeroNumber(DateTime.now().day)}',
  344 + textAlign: TextAlign.center,
  345 + maxLines: 2,
  346 + overflow: TextOverflow.ellipsis,
  347 + style: TextStyle(
  348 + color: MyColours.color_FFEFC5,
  349 + fontWeight: FontWeight.bold,
  350 + fontSize: font(24)),
  351 + ),
  352 + VEmptyView(8),
  353 + Text(
  354 + time,
  355 + textAlign: TextAlign.center,
  356 + maxLines: 2,
  357 + overflow: TextOverflow.ellipsis,
  358 + style: TextStyle(
  359 + color: MyColours.color_FFEFC5,
  360 + fontWeight: FontWeight.bold,
  361 + fontSize: font(12)),
  362 + )
  363 + ],
250 ), 364 ),
251 - VEmptyView(10),  
252 - Text(  
253 - returnWeek(DateTime.now(), context) +  
254 - (types[index] == '1' 365 + );
  366 + } else if (subType0 == '3') {
  367 + //3号模版
  368 + String month =
  369 + '${Utils.addZeroNumber(DateTime.now().month)}月${Utils.addZeroNumber(DateTime.now().day)}日 ';
  370 + String week = returnWeek(DateTime.now(), context);
  371 + String hour = subType1 == '1' || subType1 == '3'
  372 + ? (user!.noon != '00:00'
  373 + ? '${user!.noon!.split('-')[0]}'
  374 + : '14:30')
  375 + : '';
  376 + String section =
  377 + subType1 == '1' || subType1 == '4'
  378 + ? '午餐'
  379 + : subType1 == '2'
255 ? '中午' 380 ? '中午'
256 - : types[index] == '2'  
257 - ? (user!.noon != '00:00'  
258 - ? user!.noon!.split('-')[0]  
259 - : '14:30')  
260 - : '午餐'),  
261 - textAlign: TextAlign.center,  
262 - maxLines: 2,  
263 - overflow: TextOverflow.ellipsis,  
264 - style: TextStyle(  
265 - color: MyColours.color_FFEFC5,  
266 - fontWeight: FontWeight.bold,  
267 - fontSize: font(18)),  
268 - )  
269 - ],  
270 - ),  
271 - ); 381 + : '';
  382 +
  383 + if (hour != '') {
  384 + section = section + ' ';
  385 + }
  386 +
  387 + String time = section + hour;
  388 +
  389 + return Container(
  390 + color: MyColours.color_99000000,
  391 + width: w(210),
  392 + height: h(168),
  393 + padding: EdgeInsets.only(
  394 + right: w(20), bottom: w(20)),
  395 + child: Column(
  396 + mainAxisAlignment:
  397 + MainAxisAlignment.spaceBetween,
  398 + children: [
  399 + Container(
  400 + alignment: Alignment.centerLeft,
  401 + padding: EdgeInsets.only(
  402 + top: w(20),
  403 + left: w(12),
  404 + right: w(12)),
  405 + // color: Color.fromRGBO(81, 81, 81, 0.4),
  406 +
  407 + width: w(210),
  408 + // height: h(26),
  409 + child: Text(
  410 + '${Provider.of<UserModel>(context, listen: false).user!.sellername}',
  411 + textAlign: TextAlign.center,
  412 + maxLines: 2,
  413 + overflow: TextOverflow.ellipsis,
  414 + style: TextStyle(
  415 + fontWeight: FontWeight.bold,
  416 + color: MyColours.color_FFEFC5,
  417 + fontSize: font(12)),
  418 + )),
  419 + Column(
  420 + // crossAxisAlignment:
  421 + // CrossAxisAlignment.stretch,
  422 + crossAxisAlignment:
  423 + CrossAxisAlignment.end,
  424 + children: [
  425 + Container(
  426 + alignment: Alignment.centerRight,
  427 + height: w(34),
  428 + child: Row(
  429 + mainAxisAlignment:
  430 + MainAxisAlignment.end,
  431 + children: [
  432 + Text(
  433 + month,
  434 + textAlign: TextAlign.center,
  435 + maxLines: 1,
  436 + overflow:
  437 + TextOverflow.ellipsis,
  438 + style: TextStyle(
  439 + color: MyColours
  440 + .color_FFEFC5,
  441 + fontWeight:
  442 + FontWeight.bold,
  443 + fontSize: font(24)),
  444 + ),
  445 + Container(
  446 + width: w(10),
  447 + height: w(34),
  448 + child: Text(
  449 + week,
  450 + textAlign:
  451 + TextAlign.center,
  452 + maxLines: 3,
  453 + overflow:
  454 + TextOverflow.ellipsis,
  455 + style: TextStyle(
  456 + // writingMode: TextWritingMode.verticalLr,
  457 + color: MyColours
  458 + .color_FFEFC5,
  459 + fontWeight:
  460 + FontWeight.bold,
  461 + fontSize: font(12)),
  462 + )),
  463 + ],
  464 + )),
  465 + VEmptyView(14),
  466 + Container(
  467 + child: Container(
  468 +
  469 + // constraints: BoxConstraints(
  470 + // maxWidth: w(300)),
  471 + decoration: BoxDecoration(
  472 + color: MyColours
  473 + .color_66FFEFC5,
  474 + borderRadius:
  475 + BorderRadius.circular(
  476 + r(3))),
  477 + padding: EdgeInsets.symmetric(
  478 + horizontal: w(4),
  479 + vertical: w(3)),
  480 + // height: h(26),
  481 + child: Text(
  482 + time,
  483 + maxLines: 1,
  484 + overflow:
  485 + TextOverflow.ellipsis,
  486 + style: TextStyle(
  487 + color: MyColours
  488 + .color_FFEFC5,
  489 + fontWeight:
  490 + FontWeight.bold,
  491 + fontSize: font(10)),
  492 + ))),
  493 + ],
  494 + ),
  495 + ],
  496 + ),
  497 + );
  498 + } else {
  499 + //4号模版
  500 + String month =
  501 + '${Utils.addZeroNumber(DateTime.now().month)}/${Utils.addZeroNumber(DateTime.now().day)} ';
  502 + String week = returnWeek(DateTime.now(), context);
  503 + String hour = subType1 == '1' || subType1 == '3'
  504 + ? (user!.noon != '00:00'
  505 + ? '${user!.noon!.split('-')[0]}'
  506 + : '14:30')
  507 + : '';
  508 + String section =
  509 + subType1 == '1' || subType1 == '4'
  510 + ? '午餐'
  511 + : subType1 == '2'
  512 + ? '中午'
  513 + : '';
  514 +
  515 + if (section != '') {
  516 + hour = hour + ' ';
  517 + }
  518 +
  519 + String time = hour + section;
  520 +
  521 + return Container(
  522 + color: MyColours.color_ffffff,
  523 + width: w(210),
  524 + height: h(168),
  525 + child: Column(
  526 + mainAxisAlignment:
  527 + MainAxisAlignment.spaceBetween,
  528 + children: [
  529 + Spacer(),
  530 + Container(
  531 + // height: w(45),
  532 + color: MyColours.color_99000000,
  533 + padding: EdgeInsets.only(
  534 + top: w(8),
  535 + left: w(8),
  536 + bottom: w(8),
  537 + right: w(13)),
  538 + child: Row(
  539 + mainAxisAlignment:
  540 + MainAxisAlignment.spaceBetween,
  541 + children: [
  542 + Text(
  543 + '${Provider.of<UserModel>(context, listen: false).user!.sellername}',
  544 + textAlign: TextAlign.center,
  545 + overflow: TextOverflow.ellipsis,
  546 + style: TextStyle(
  547 + fontWeight: FontWeight.bold,
  548 + color: MyColours.color_FFEFC5,
  549 + fontSize: font(10)),
  550 + ),
  551 + Column(
  552 + crossAxisAlignment:
  553 + CrossAxisAlignment.end,
  554 + children: [
  555 + Container(
  556 + alignment:
  557 + Alignment.centerRight,
  558 + // height: w(34),
  559 + child: Row(
  560 + mainAxisAlignment:
  561 + MainAxisAlignment.end,
  562 + children: [
  563 + Text(
  564 + month,
  565 + textAlign:
  566 + TextAlign.right,
  567 + maxLines: 1,
  568 + overflow: TextOverflow
  569 + .ellipsis,
  570 + style: TextStyle(
  571 + color: MyColours
  572 + .color_FFEFC5,
  573 + fontWeight:
  574 + FontWeight
  575 + .bold,
  576 + fontSize:
  577 + font(10)),
  578 + ),
  579 + HEmptyView(10),
  580 + Container(
  581 + // width: w(10),
  582 + // height: w(34),
  583 + child: Text(
  584 + week,
  585 + textAlign:
  586 + TextAlign.right,
  587 + // maxLines: 3,
  588 + overflow: TextOverflow
  589 + .ellipsis,
  590 + style: TextStyle(
  591 + // writingMode: TextWritingMode.verticalLr,
  592 + color: MyColours
  593 + .color_FFEFC5,
  594 + fontWeight:
  595 + FontWeight
  596 + .bold,
  597 + fontSize:
  598 + font(10)),
  599 + )),
  600 + ],
  601 + )),
  602 + VEmptyView(8),
  603 + Container(
  604 + alignment: Alignment.center,
  605 + width: w(60),
  606 + height: w(13),
  607 + // constraints: BoxConstraints(
  608 + // maxWidth: w(300)),
  609 + decoration: BoxDecoration(
  610 + color: MyColours
  611 + .color_66FFEFC5,
  612 + borderRadius:
  613 + BorderRadius
  614 + .circular(
  615 + r(3))),
  616 + // padding:
  617 + // EdgeInsets.symmetric(
  618 + // horizontal: w(4),
  619 + // vertical: w(3)),
  620 + // height: h(26),
  621 + child: Text(
  622 + time,
  623 + maxLines: 1,
  624 + overflow:
  625 + TextOverflow.ellipsis,
  626 + style: TextStyle(
  627 + color: MyColours
  628 + .color_FFEFC5,
  629 + fontWeight:
  630 + FontWeight.bold,
  631 + fontSize: font(10)),
  632 + )),
  633 + ],
  634 + ),
  635 + ],
  636 + )),
  637 + ],
  638 + ),
  639 + );
  640 + }
  641 + }
272 }, 642 },
273 onTap: (v) { 643 onTap: (v) {
274 print(v); 644 print(v);
@@ -31,6 +31,8 @@ class MyColours { @@ -31,6 +31,8 @@ class MyColours {
31 static const Color color_F7C797 = Color(0xffF7C797); 31 static const Color color_F7C797 = Color(0xffF7C797);
32 static const Color color_FEF3E6 = Color(0xffFEF3E6); 32 static const Color color_FEF3E6 = Color(0xffFEF3E6);
33 static const Color color_66000000 = Color(0x66000000); 33 static const Color color_66000000 = Color(0x66000000);
  34 + static const Color color_66FFEFC5= Color(0x66FFEFC5);
  35 +
34 static const Color color_00A870 = Color(0xff00A870); 36 static const Color color_00A870 = Color(0xff00A870);
35 static const Color color_F6F6F6 = Color(0xffF6F6F6); 37 static const Color color_F6F6F6 = Color(0xffF6F6F6);
36 static const Color color_E6000000 = Color(0xE6000000); 38 static const Color color_E6000000 = Color(0xE6000000);