Commit 776990f1754a981484ad711918b0016f456d4d3c

Authored by weixin_45529955
1 parent baabadcb

扫码领消费金 UI OK

  1 +import 'package:flutter/material.dart';
  2 +import 'package:flutter/services.dart';
  3 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  4 +import 'package:one_key/res/colors.dart';
  5 +import 'package:one_key/route/navigator_util.dart';
  6 +import 'package:one_key/utils/screen_util.dart';
  7 +import 'package:one_key/widgets/h_empty_view.dart';
  8 +import 'package:one_key/widgets/round_button.dart';
  9 +import 'package:one_key/widgets/system_app_bar.dart';
  10 +
  11 +/**
  12 + * 发放消费金
  13 + */
  14 +
  15 +class GrantPage extends StatefulWidget {
  16 + const GrantPage({super.key});
  17 +
  18 + @override
  19 + State<GrantPage> createState() => _GrantPageState();
  20 +}
  21 +
  22 +class _GrantPageState extends State<GrantPage> {
  23 + ScrollController controller = ScrollController();
  24 + List ladderSelectFree = [];
  25 +
  26 + @override
  27 + void initState() {
  28 + super.initState();
  29 + ladderSelectFree.add('1');
  30 +
  31 + WidgetsBinding.instance.addPostFrameCallback((_) {
  32 + // _getConsumeConfig();
  33 + });
  34 + }
  35 +
  36 + ///发放阶梯
  37 + Widget _ladderWidget() {
  38 + return ListView.builder(
  39 + controller: controller,
  40 + shrinkWrap: true,
  41 + itemCount: ladderSelectFree.length,
  42 + itemBuilder: (context, index) {
  43 + dynamic data = ladderSelectFree[index];
  44 + return Container(
  45 + padding: EdgeInsets.only(
  46 + left: w(16),
  47 + // top: w(12),
  48 + bottom: w(12),
  49 + ),
  50 + child: Column(
  51 + children: [
  52 + Container(
  53 + height: w(48),
  54 + padding: EdgeInsets.only(right: w(16)),
  55 + decoration: BoxDecoration(
  56 + border: Border(
  57 + bottom: BorderSide(
  58 + color: MyColours.color_E7E7E7, width: w(0.5)))),
  59 + child: Row(
  60 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  61 + children: [
  62 + Text(
  63 + '发放(${index + 1})',
  64 + style: TextStyle(
  65 + color: MyColours.color_515151, fontSize: font(14)),
  66 + ),
  67 + InkWell(
  68 + onTap: () {
  69 + //删除媒体
  70 + ladderSelectFree.remove(data);
  71 + setState(() {});
  72 + },
  73 + child: Padding(
  74 + padding: EdgeInsets.only(top: w(8), bottom: w(8)),
  75 + child: Text(
  76 + '删除',
  77 + style: TextStyle(
  78 + color: MyColours.color_438E93,
  79 + fontSize: font(12)),
  80 + ),
  81 + ))
  82 + ],
  83 + ),
  84 + ),
  85 + _ladderPriceWidget(TextEditingController(), FocusNode(),
  86 + width: 50),
  87 + ],
  88 + ),
  89 + );
  90 + });
  91 + }
  92 +
  93 + //阶梯返还金额widget
  94 + Widget _ladderPriceWidget(
  95 + TextEditingController controllerGive, FocusNode focusNodeGive,
  96 + {num width = 40}) {
  97 + return Container(
  98 + height: w(40),
  99 + margin: EdgeInsets.only(left: w(width)),
  100 + padding: EdgeInsets.only(top: w(8), bottom: w(8)),
  101 + decoration: BoxDecoration(
  102 + border: Border(
  103 + bottom:
  104 + BorderSide(color: MyColours.color_E7E7E7, width: w(0.5)))),
  105 + child: Row(
  106 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  107 + children: [
  108 + Text(
  109 + '发放消费金',
  110 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  111 + ),
  112 + HEmptyView(10),
  113 + Container(
  114 + width: w(54),
  115 + height: w(26),
  116 + alignment: Alignment.center,
  117 + decoration: BoxDecoration(
  118 + border: Border.all(color: MyColours.color_999999, width: w(1))),
  119 + child: TextField(
  120 + controller: controllerGive,
  121 + textAlign: TextAlign.center,
  122 + textAlignVertical: TextAlignVertical.center,
  123 + maxLines: 1,
  124 + // //光标颜色
  125 + // cursorColor:
  126 + // widget.isSelect ? Colors.white : MyColours.color_199095,
  127 + //输入文本的样式
  128 + inputFormatters: [
  129 + FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
  130 + ], // 限制输入为数字,
  131 + style: TextStyle(
  132 + color: MyColours.color_515151,
  133 + fontSize: ScreenUtil().setSp(20),
  134 + ),
  135 + focusNode: focusNodeGive,
  136 + decoration: InputDecoration(
  137 + isCollapsed: true,
  138 + border: OutlineInputBorder(borderSide: BorderSide.none),
  139 + hintText: '请输入数字',
  140 + hintStyle: TextStyle(
  141 + color: MyColours.color_999999,
  142 + fontSize: ScreenUtil().setSp(20),
  143 + ),
  144 + enabledBorder: new UnderlineInputBorder(
  145 + borderSide: BorderSide.none,
  146 + ),
  147 + focusedBorder: new UnderlineInputBorder(
  148 + borderSide: BorderSide.none,
  149 + ),
  150 + ),
  151 + onChanged: (value) {},
  152 + onEditingComplete: () {
  153 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  154 + },
  155 + keyboardType: TextInputType.numberWithOptions()),
  156 + ),
  157 + HEmptyView(10),
  158 + Text(
  159 + '元',
  160 + style: TextStyle(color: MyColours.color_515151, fontSize: font(14)),
  161 + ),
  162 + HEmptyView(10),
  163 + Spacer(),
  164 + RoundButton(
  165 + text: '查看二维码',
  166 + width: w(86),
  167 + height: w(24),
  168 + fontSize: 28,
  169 + gradientStart: MyColours.color_438E93,
  170 + gradientEnd: MyColours.color_438E93,
  171 + textColor: MyColours.color_ffffff,
  172 + isBold: false,
  173 + radius: 5,
  174 + onPressed: () {
  175 + //跳转到二维码展示页面
  176 + NavigatorUtil.goGrantWechatPage(context);
  177 + },
  178 + ),
  179 + HEmptyView(32),
  180 + ],
  181 + ),
  182 + );
  183 + }
  184 +
  185 + @override
  186 + Widget build(BuildContext context) {
  187 + return Scaffold(
  188 + backgroundColor: MyColours.color_ffffff,
  189 + appBar: SystemAppBar('发放消费金'),
  190 + body: Column(
  191 + children: [
  192 + _ladderWidget(),
  193 + InkWell(
  194 + onTap: () {
  195 + // LadderData data = LadderData();
  196 + ladderSelectFree.add('1');
  197 + setState(() {});
  198 + },
  199 + child: Container(
  200 + height: w(30),
  201 + margin: EdgeInsets.only(left: w(60), right: w(16)),
  202 + alignment: Alignment.centerLeft,
  203 + child: Text(
  204 + '+增加阶梯',
  205 + style: TextStyle(
  206 + color: MyColours.color_438E93, fontSize: font(12)),
  207 + ),
  208 + )),
  209 + ],
  210 + ),
  211 + );
  212 + }
  213 +}
  1 +import 'dart:io';
  2 +import 'dart:typed_data';
  3 +import 'dart:ui';
  4 +
  5 +import 'package:cached_network_image/cached_network_image.dart';
  6 +import 'package:flutter/cupertino.dart';
  7 +import 'package:flutter/material.dart';
  8 +import 'package:flutter/rendering.dart';
  9 +import 'package:flutter_screenutil/flutter_screenutil.dart';
  10 +import 'package:image_gallery_saver/image_gallery_saver.dart';
  11 +import 'package:one_key/provider/user_model.dart';
  12 +import 'package:one_key/widgets/round_button.dart';
  13 +import 'package:one_key/widgets/system_app_bar.dart';
  14 +import 'package:one_key/widgets/v_empty_view.dart';
  15 +import 'package:permission_handler/permission_handler.dart';
  16 +import 'package:provider/provider.dart';
  17 +
  18 +import '../../../constant/state.dart';
  19 +import '../../../provider/finance_provider.dart';
  20 +import '../../../res/colors.dart';
  21 +import '../../../utils/screen_util.dart';
  22 +import '../../../utils/utils.dart';
  23 +import '../../../widgets/h_empty_view.dart';
  24 +import '../../../widgets/loading.dart';
  25 +import 'dart:ui' as ui;
  26 +
  27 +/**
  28 + * 扫码领消费金
  29 + */
  30 +
  31 +class GrantWechatPage extends StatefulWidget {
  32 + const GrantWechatPage({super.key});
  33 +
  34 + @override
  35 + State<GrantWechatPage> createState() => _GrantWechatPageState();
  36 +}
  37 +
  38 +class _GrantWechatPageState extends State<GrantWechatPage> {
  39 + FinanceProvider? financeProvider;
  40 +
  41 + final GlobalKey globalKey = GlobalKey();
  42 +
  43 + @override
  44 + void initState() {
  45 + super.initState();
  46 +
  47 + WidgetsBinding.instance.addPostFrameCallback((_) async {
  48 + _createPayQrcode();
  49 + });
  50 + }
  51 +
  52 + _createPayQrcode() {
  53 + financeProvider!.createPayQrcode(context);
  54 + }
  55 +
  56 + /// 截图
  57 + Future<Uint8List?> _capturePng(
  58 + GlobalKey globalKey,
  59 + // {
  60 + // double pixelRatio = 2.0, //截屏的图片与原图的比例
  61 + // }
  62 + ) async {
  63 + try {
  64 + RenderRepaintBoundary boundary =
  65 + globalKey.currentContext?.findRenderObject() as RenderRepaintBoundary;
  66 + double dpr = ui.window.devicePixelRatio; // 获取当前设备的像素比
  67 + var image = await boundary.toImage(pixelRatio: dpr);
  68 + ByteData? byteData = await image.toByteData(format: ImageByteFormat.png);
  69 + Uint8List? pngBytes = byteData?.buffer.asUint8List();
  70 + return pngBytes;
  71 + } catch (e) {
  72 + print(e);
  73 + }
  74 + return null;
  75 + }
  76 +
  77 + @override
  78 + Widget build(BuildContext context) {
  79 + financeProvider = Provider.of<FinanceProvider>(context, listen: true);
  80 + return Scaffold(
  81 + appBar: SystemAppBar('扫码领消费金'),
  82 + backgroundColor: MyColours.color_ffffff,
  83 + body: Column(
  84 + children: [
  85 + Expanded(
  86 + child: SingleChildScrollView(
  87 + child: Column(
  88 + crossAxisAlignment: CrossAxisAlignment.start,
  89 + children: [
  90 + VEmptyView(100),
  91 + //二维码图片
  92 +
  93 + //
  94 + RepaintBoundary(
  95 + key: globalKey,
  96 + child: Column(
  97 + children: [
  98 + Container(
  99 + margin: EdgeInsets.symmetric(horizontal: w(57)),
  100 + padding: EdgeInsets.symmetric(
  101 + horizontal: w(25), vertical: w(35)),
  102 + color: MyColours.color_438E93,
  103 + child: Column(
  104 + children: [
  105 + Text(
  106 + '微信扫码领取消费金\n消费时可直接抵扣',
  107 + style: TextStyle(
  108 + color: MyColours.color_ffffff,
  109 + fontSize: font(16),
  110 + fontWeight: FontWeight.bold),
  111 + ),
  112 + VEmptyView(20),
  113 + Consumer<FinanceProvider>(
  114 + builder: (context, model, _) {
  115 + if (model.pageState != PageState.Success) {
  116 + return Container(
  117 + height: w(210),
  118 + child: Center(
  119 + child: SizedBox(
  120 + width:
  121 + ScreenUtil().setWidth(40),
  122 + height:
  123 + ScreenUtil().setWidth(40),
  124 + child:
  125 + CupertinoActivityIndicator(
  126 + color: MyColours.color_ffffff,
  127 + ))),
  128 + );
  129 + } else {
  130 + return Container(
  131 + padding: EdgeInsets.symmetric(
  132 + horizontal: w(21),
  133 + vertical: w(16)),
  134 + color: MyColours.color_ffffff,
  135 + child: Column(
  136 + children: [
  137 + CachedNetworkImage(
  138 + imageUrl: financeProvider!
  139 + .paymentCodeUrl),
  140 + // VEmptyView(28),
  141 + Text(
  142 + '${Provider.of<UserModel>(context).user!.sellername}',
  143 + maxLines: 3,
  144 + overflow: TextOverflow.ellipsis,
  145 + style: TextStyle(
  146 + color:
  147 + MyColours.color_000000,
  148 + fontSize: font(14)),
  149 + ),
  150 + VEmptyView(28),
  151 + Text(
  152 + '消费金:¥50.00',
  153 + maxLines: 3,
  154 + overflow: TextOverflow.ellipsis,
  155 + style: TextStyle(
  156 + color:
  157 + MyColours.color_000000,
  158 + fontSize: font(14)),
  159 + ),
  160 + ],
  161 + ));
  162 + }
  163 + })
  164 + ],
  165 + ),
  166 + ),
  167 + // Container(
  168 + // margin: EdgeInsets.symmetric(horizontal: w(57)),
  169 + // padding: EdgeInsets.symmetric(
  170 + // horizontal: w(25), vertical: w(11)),
  171 + // decoration: BoxDecoration(
  172 + // color: MyColours.color_ffffff,
  173 + // border: Border.all(
  174 + // color: MyColours.color_09BB07,
  175 + // width: w(2))),
  176 + // child: Row(
  177 + // mainAxisAlignment: MainAxisAlignment.center,
  178 + // children: [
  179 + // Image.asset(
  180 + // Utils.getImgPath('vector'),
  181 + // width: w(37),
  182 + // ),
  183 + // HEmptyView(12),
  184 + // Text(
  185 + // '微信支付',
  186 + // style: TextStyle(
  187 + // color: MyColours.color_515151,
  188 + // fontSize: font(28)),
  189 + // )
  190 + // ],
  191 + // )),
  192 + ],
  193 + )),
  194 +
  195 + VEmptyView(160),
  196 + // Padding(
  197 + // padding: EdgeInsets.symmetric(horizontal: w(16)),
  198 + // child: Text(
  199 + // '提示:',
  200 + // textAlign: TextAlign.left,
  201 + // style: TextStyle(
  202 + // fontSize: w(16),
  203 + // height: 1.5,
  204 + // fontWeight: FontWeight.bold,
  205 + // color: MyColours.color_000000),
  206 + // )),
  207 + // Padding(
  208 + // padding: EdgeInsets.symmetric(horizontal: w(16)),
  209 + // child: Text(
  210 + // '请将收款码出示给顾客,顾客扫码支付时可以自动识别拥有的代金券,并自动在餐厅设定的规则下使用。',
  211 + // textAlign: TextAlign.left,
  212 + // style: TextStyle(
  213 + // fontSize: w(14),
  214 + // height: 1.5,
  215 + // color: MyColours.color_000000),
  216 + // ))
  217 + ],
  218 + ),
  219 + ),
  220 + ),
  221 + Container(
  222 + padding: EdgeInsets.symmetric(vertical: w(13), horizontal: w(79)),
  223 + child: RoundButton(
  224 + text: '保存二维码图片',
  225 + height: w(43),
  226 + radius: r(5),
  227 + gradientStart: MyColours.color_ffffff,
  228 + gradientEnd: MyColours.color_ffffff,
  229 + borderColor: MyColours.color_438E93,
  230 + textColor: MyColours.color_438E93,
  231 + isBold: true,
  232 + fontSize: 32,
  233 + onPressed: () {
  234 + Utils.getPickPermission(context, () async {
  235 + //获取截屏图像
  236 + //添加到图片数组中
  237 + Loading.showLoading(
  238 + context,
  239 + );
  240 + Uint8List? value = await _capturePng(globalKey);
  241 + if (value != null) {
  242 + print(value);
  243 + final result = await ImageGallerySaver.saveImage(value,
  244 + quality: 100);
  245 + if (result != null) {
  246 + Utils.showToast("保存成功");
  247 + } else {
  248 + print('error');
  249 + Utils.showToast("保存失败");
  250 + // toast("");
  251 + }
  252 + Loading.hideLoading(context);
  253 + // setState(() {});
  254 + }
  255 + }, Platform.isIOS ? Permission.photos : Permission.storage);
  256 + },
  257 + ),
  258 + )
  259 + ],
  260 + ));
  261 + }
  262 +}
1 -  
2 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
3 import 'package:flutter_screenutil/flutter_screenutil.dart'; 2 import 'package:flutter_screenutil/flutter_screenutil.dart';
4 import 'package:one_key/route/navigator_util.dart'; 3 import 'package:one_key/route/navigator_util.dart';
@@ -444,6 +443,41 @@ class _MarketingCenterHomePageState extends State<MarketingCenterHomePage> { @@ -444,6 +443,41 @@ class _MarketingCenterHomePageState extends State<MarketingCenterHomePage> {
444 padding: EdgeInsets.only(left: w(16)), 443 padding: EdgeInsets.only(left: w(16)),
445 child: MyDivider(double.infinity, w(0.5), 444 child: MyDivider(double.infinity, w(0.5),
446 color: MyColours.color_E7E7E7)), 445 color: MyColours.color_E7E7E7)),
  446 + VEmptyView(24),
  447 + InkWell(
  448 + onTap: () {
  449 + NavigatorUtil.goGrantPage(context);
  450 + },
  451 + child: Padding(
  452 + padding: EdgeInsets.only(
  453 + left: w(16),
  454 + top: w(12),
  455 + bottom: w(12),
  456 + right: w(12)),
  457 + child: Row(
  458 + children: [
  459 + Text(
  460 + '为团购客户发消费金',
  461 + style: TextStyle(
  462 + color: MyColours.color_515151,
  463 + fontSize: ScreenUtil().setWidth(32)),
  464 + ),
  465 + Spacer(),
  466 + Container(
  467 + padding: EdgeInsets.symmetric(
  468 + horizontal: w(7), vertical: w(4)),
  469 + child: Image.asset(
  470 + "assets/arrow_right_new.png",
  471 + width: ScreenUtil().setWidth(18),
  472 + height: ScreenUtil().setWidth(32),
  473 + ),
  474 + )
  475 + ],
  476 + ))),
  477 + Padding(
  478 + padding: EdgeInsets.only(left: w(16)),
  479 + child: MyDivider(double.infinity, w(0.5),
  480 + color: MyColours.color_E7E7E7)),
447 // InkWell( 481 // InkWell(
448 // onTap: () { 482 // onTap: () {
449 // setState(() { 483 // setState(() {
@@ -2442,6 +2442,23 @@ class NavigatorUtil { @@ -2442,6 +2442,23 @@ class NavigatorUtil {
2442 replace: replace); 2442 replace: replace);
2443 } 2443 }
2444 2444
  2445 + ///发放消费金
  2446 + static Future<dynamic> goGrantPage(
  2447 + BuildContext context, {
  2448 + replace = false,
  2449 + }) {
  2450 + return _navigateTo(context, "${Routes.grant_page}", replace: replace);
  2451 + }
  2452 +
  2453 + ///发放消费金
  2454 + static Future<dynamic> goGrantWechatPage(
  2455 + BuildContext context, {
  2456 + replace = false,
  2457 + }) {
  2458 + return _navigateTo(context, "${Routes.grant_wechat_page}",
  2459 + replace: replace);
  2460 + }
  2461 +
2445 ///支付返券------优惠券选择 2462 ///支付返券------优惠券选择
2446 static Future<dynamic> goPaymentGiftSelectPage( 2463 static Future<dynamic> goPaymentGiftSelectPage(
2447 BuildContext context, String type, Map object, String from, String end, 2464 BuildContext context, String type, Map object, String from, String end,
@@ -90,6 +90,8 @@ import 'package:one_key/pages/my/finance_manage/deposit_record_detail_page.dart' @@ -90,6 +90,8 @@ import 'package:one_key/pages/my/finance_manage/deposit_record_detail_page.dart'
90 import 'package:one_key/pages/my/finance_manage/record_home_classify_home_page.dart'; 90 import 'package:one_key/pages/my/finance_manage/record_home_classify_home_page.dart';
91 import 'package:one_key/pages/my/finance_manage/vip_record_detail_page.dart'; 91 import 'package:one_key/pages/my/finance_manage/vip_record_detail_page.dart';
92 import 'package:one_key/pages/my/marketing_center/book_notification/marking_interaction_page.dart'; 92 import 'package:one_key/pages/my/marketing_center/book_notification/marking_interaction_page.dart';
  93 +import 'package:one_key/pages/my/marketing_center/grant_page.dart';
  94 +import 'package:one_key/pages/my/marketing_center/grant_wechat_image_page.dart';
93 import 'package:one_key/pages/my/menu_type/menu_set_price_page.dart'; 95 import 'package:one_key/pages/my/menu_type/menu_set_price_page.dart';
94 import 'package:one_key/pages/my/personnel_type/base_info_personnal_page.dart'; 96 import 'package:one_key/pages/my/personnel_type/base_info_personnal_page.dart';
95 import 'package:one_key/pages/my/personnel_type/personnel_detail_page.dart'; 97 import 'package:one_key/pages/my/personnel_type/personnel_detail_page.dart';
@@ -4315,6 +4317,20 @@ var returnMoneyPageHandle = new Handler( @@ -4315,6 +4317,20 @@ var returnMoneyPageHandle = new Handler(
4315 create: (_) => FinanceProvider(), child: ReturnMoneyPage()); 4317 create: (_) => FinanceProvider(), child: ReturnMoneyPage());
4316 }); 4318 });
4317 4319
  4320 +///发放消费金
  4321 +var grantPageHandle = new Handler(
  4322 + handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
  4323 + return ChangeNotifierProvider<FinanceProvider>(
  4324 + create: (_) => FinanceProvider(), child: GrantPage());
  4325 +});
  4326 +
  4327 +///扫码领消费金
  4328 +var grantWechatPageHandle = new Handler(
  4329 + handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
  4330 + return ChangeNotifierProvider<FinanceProvider>(
  4331 + create: (_) => FinanceProvider(), child: GrantWechatPage());
  4332 +});
  4333 +
4318 // /选择优惠券 4334 // /选择优惠券
4319 // var paymentGiftSelectPageHandle = new Handler( 4335 // var paymentGiftSelectPageHandle = new Handler(
4320 // handlerFunc: (BuildContext? context, Map<String, List<Object>> params) { 4336 // handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
@@ -433,6 +433,13 @@ class Routes { @@ -433,6 +433,13 @@ class Routes {
433 433
434 static String return_money_page = "/return_money_page"; // 支付返消费金 434 static String return_money_page = "/return_money_page"; // 支付返消费金
435 435
  436 + static String grant_page = "/grant_page"; // 发放消费金
  437 +
  438 + static String grant_wechat_page = "/grant_wechat_page"; // 扫码领消费金
  439 +
  440 +
  441 +
  442 +
436 static void configureRoutes(FluroRouter router) { 443 static void configureRoutes(FluroRouter router) {
437 router.notFoundHandler = new Handler( 444 router.notFoundHandler = new Handler(
438 handlerFunc: (BuildContext? context, Map<String, List<String>> params) { 445 handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
@@ -819,5 +826,11 @@ class Routes { @@ -819,5 +826,11 @@ class Routes {
819 router.define(table_home, handler: tableHomeHandle); 826 router.define(table_home, handler: tableHomeHandle);
820 827
821 router.define(return_money_page, handler: returnMoneyPageHandle); 828 router.define(return_money_page, handler: returnMoneyPageHandle);
  829 +
  830 + router.define( grant_page, handler: grantPageHandle);
  831 +
  832 +
  833 + router.define( grant_wechat_page , handler: grantWechatPageHandle);
  834 +
822 } 835 }
823 } 836 }