verification_coupon_page.dart 11.3 KB
import 'package:flutter/material.dart';

import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/net/dio_util.dart';

import 'package:one_key/provider/coupon_provider.dart';

import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';

import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.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 '../../utils/screen_util.dart';

/**
 * 核销券详情页
 */

class VerificationCouponPage extends StatefulWidget {
  VerificationCouponPage({
    Key key,
  }) : super(key: key);

  @override
  _VerificationCouponPageState createState() => _VerificationCouponPageState();
}

class _VerificationCouponPageState extends State<VerificationCouponPage> {
  ScrollController controller = ScrollController();
  final heightCell = ScreenUtil().setWidth(80);
  CouponProvider couponProvider;

  @override
  void initState() {
    super.initState();
  }

  ///时间选择
  Widget _select(String title, String hintText, GestureTapCallback onTap) {
    return InkWell(
      onTap: onTap,
      child: Container(
        padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(28)),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              // height: ScreenUtil().setWidth(40),
              // color: Colors.red,
              child: Text(
                title,
                style: TextStyle(
                    color: Color.fromRGBO(0, 0, 0, 0.9),
                    fontWeight: FontWeight.bold,
                    fontSize: ScreenUtil().setSp(32)),
              ),
            ),
            HEmptyView(20),
            Spacer(),
            Text(hintText,
                style: TextStyle(
                  color: hintText == '点击选择'
                      ? MyColours.color_999999
                      : MyColours.color_515151,
                  fontSize: ScreenUtil().setSp(32),
                )),
            HEmptyView(20),
            Image.asset(
              Utils.getImgPath('arrow_right_new'),
              width: ScreenUtil().setWidth(20),
            ),
            HEmptyView(32),
          ],
        ),
      ),
    );
  }

  ///输入框
  Widget _item(String title, String subTitle,
      {Color textColor = MyColours.color_40000000, int fontSize = 16}) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: ScreenUtil().setWidth(24)),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
            child: Text(
              title,
              style: TextStyle(color: MyColours.color_515151, fontSize: w(16)),
            ),
          ),
          HEmptyView(60),
          Expanded(
              child: Text(
            subTitle,
            maxLines: 20,
            textAlign: TextAlign.right,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(
              color: textColor,
              fontSize: w(fontSize),
            ),
          ))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    couponProvider = Provider.of<CouponProvider>(context, listen: true);
    return Scaffold(
      backgroundColor: MyColours.color_ffffff,
      appBar: SystemAppBar(
        '优惠券详情',
        onTap: () {
          Navigator.pop(context);
        },
      ),
      body: Column(children: [
        Expanded(
          child: SingleChildScrollView(
              controller: controller,
              physics: BouncingScrollPhysics(),
              child: Padding(
                  padding: EdgeInsets.symmetric(
                      horizontal: ScreenUtil().setWidth(32)),
                  child: Column(
                    children: [
                      VEmptyView(56),
                      _item('券用途', '代金券/折扣券/菜品券',
                          textColor: MyColours.color_438E93, fontSize: 20),
                      Container(
                        height: ScreenUtil().setWidth(2),
                        color: MyColours.color_E7E7E7,
                      ),
                      VEmptyView(24),
                      _item('券金额/折扣率/所含菜品', '200元/9折/精品烤鸭',
                          textColor: MyColours.color_438E93, fontSize: 20),
                      Container(
                        height: ScreenUtil().setWidth(2),
                        color: MyColours.color_E7E7E7,
                      ),
                      VEmptyView(24),
                      _item('券要求', '满200可用'),
                      Container(
                        height: ScreenUtil().setWidth(2),
                        color: MyColours.color_E7E7E7,
                      ),
                      VEmptyView(24),
                      _item('有效期从', '2022-4-4'), //Utils.getDateStrFromJiekou(
                      // widget.couponSunModel.stime)
                      Container(
                        height: ScreenUtil().setWidth(2),
                        color: MyColours.color_E7E7E7,
                      ),
                      VEmptyView(24),
                      _item('有效期至', '2022-4-4'),
                      // widget.couponSunModel.isType == '1'
                      //     ? Column(
                      //         crossAxisAlignment: CrossAxisAlignment.start,
                      //         children: [
                      //           Container(
                      //             height: ScreenUtil().setWidth(2),
                      //             color: MyColours.color_E7E7E7,
                      //           ),
                      //           VEmptyView(24),
                      //           _item('创建人', widget.couponSunModel.uid),
                      //         ],
                      //       )
                      //     : SizedBox(),
                      // widget.couponSunModel.isType == '1'
                      //     ? Column(
                      //         crossAxisAlignment: CrossAxisAlignment.start,
                      //         children: [
                      //           Container(
                      //             height: ScreenUtil().setWidth(2),
                      //             color: MyColours.color_E7E7E7,
                      //           ),
                      //           VEmptyView(24),
                      //           _select(
                      //             '谁可以发放',
                      //             '查看',
                      //             () async {
                      //               await NavigatorUtil.goCouponToPersonnalPage(
                      //                   context, widget.couponSunModel.uidList,
                      //                   onlyShow: true);
                      //             },
                      //           )
                      //         ],
                      //       )
                      //     : SizedBox(),
                      // widget.couponSunModel.explain != null &&
                      //         widget.couponSunModel.explain != ''
                      //     ? Container(
                      //         height: ScreenUtil().setWidth(2),
                      //         color: MyColours.color_E7E7E7,
                      //       )
                      //     : SizedBox(),
                      // widget.couponSunModel.explain != null &&
                      //         widget.couponSunModel.explain != ''
                      //     ? VEmptyView(24)
                      //     : SizedBox(),
                      _item('券说明',
                          '最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多'),

                      Container(
                        height: ScreenUtil().setWidth(2),
                        color: MyColours.color_E7E7E7,
                      ),
                      // VEmptyView(24),
                      // _item('券状态',
                      //     widget.couponSunModel.status == '1' ? '发放中' : '停用')
                    ],
                  ))),
        ),
        true
            ? Padding(
                padding: EdgeInsets.only(bottom: w(58)),
                child: Image.asset(
                  Utils.getImgPath('has_use'),
                  width: w(50),
                ),
              )
            : Container(
                height: ScreenUtil().setWidth(91 * 2),
                width: double.infinity,
                padding: EdgeInsets.only(
                  top: ScreenUtil().setWidth(16 * 2),
                  bottom: ScreenUtil().setWidth(35 * 2),
                  left: ScreenUtil().setWidth(45 * 2),
                  right: ScreenUtil().setWidth(45 * 2),
                ),
                decoration: BoxDecoration(
                  color: MyColours.color_ffffff,
                  boxShadow: [
                    BoxShadow(
                        spreadRadius: ScreenUtil().setWidth(2),
                        color: Color.fromRGBO(0, 0, 0, 0.1),
                        offset: Offset(0, ScreenUtil().setWidth(-2)),
                        blurRadius: ScreenUtil().setWidth(8))
                  ],
                  borderRadius: BorderRadius.all(
                    Radius.circular(ScreenUtil().setWidth(16)),
                  ),
                ),
                child: RoundButton(
                  text: '核销使用',
                  height: ScreenUtil().setWidth(80),
                  radius: ScreenUtil().setWidth(14),
                  isBold: false,
                  fontSize: 28,
                  onPressed: () async {
                    DialogUtil.cupertinoAlertDialog(context,
                        content: '确定要核销当前优惠券吗?核销使用后,该券不能再次使用。');
                    //            "stime": fromDate == '点击选择'
                    //     ? ""
                    //     : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
                    // "etime": endDate == '点击选择'
                    //     ? ''
                    //     : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',
                    // UserModel userModel =
                    //     Provider.of<UserModel>(context, listen: false);
                    // if (userModel.user.role_name == '管理员' ||
                    //     userModel.user.role_name == '店长') {
                    // NavigatorUtil.goRechargeEditPage(context);
                    // } else {
                    //   bool needRefresh =
                    //       await NavigatorUtil.goCouponEditPage(context);
                    //   print(needRefresh);
                    //   if (needRefresh != null && needRefresh) {
                    //     bus.emit('refresh_coupon_list_f');
                    //     //刷新页面数据
                    //     // _controller.callRefresh();
                    //     // _couponNetworkData(tabController.index);
                    //   }
                    // }
                  },
                ),
              )
      ]),
    );
  }
}