statistics_sms_page.dart 15.4 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/statics_model.dart';
import 'package:one_key/provider/my_model.dart';
import 'package:one_key/provider/statistics_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.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';

class StatisticsSmsPage extends StatefulWidget {
  final List selectData;
  StatisticsSmsPage({Key key, this.selectData}) : super(key: key);

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

class _StatisticsSmsPageState extends State<StatisticsSmsPage> {
  StatisticsProvider _provider;
  MyModel _myModel;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      _getSmsInfo(context);
    });
  }

  ///文本
  Widget _textWidget(String title, {Color textColor = MyColours.color_333333}) {
    return Container(
      // alignment: Alignment.center,
      height: ScreenUtil().setWidth(40),
      child: Text(
        title,
        style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: ScreenUtil().setSp(28),
            color: textColor),
      ),
    );
  }

  ///获取短信余量
  _getSmsInfo(context) async {
    await _myModel.getSmsInfo(context);
  }

  @override
  Widget build(BuildContext context) {
    _provider = Provider.of<StatisticsProvider>(context, listen: true);
    _myModel = Provider.of<MyModel>(context, listen: true);
    return Scaffold(
      backgroundColor: MyColours.color_f5f5f5,
      appBar: SystemAppBar(
        '短信营销',
        onTap: () {
         if (Navigator.canPop(context)) {
          Navigator.pop(context);
          }
        },
      ),
      body: Column(children: [
        Expanded(
            child: SingleChildScrollView(
                child: Padding(
                    padding: EdgeInsets.symmetric(
                        horizontal: ScreenUtil().setWidth(30),
                        vertical: ScreenUtil().setWidth(20)),
                    child: Column(children: [
                      Container(
                          decoration: BoxDecoration(
                              boxShadow: [
                                BoxShadow(
                                    color: MyColours.color_e5e5e5,
                                    blurRadius: ScreenUtil().setWidth(30))
                              ],
                              borderRadius: BorderRadius.all(
                                Radius.circular(ScreenUtil().setWidth(20)),
                              )),
                          child: Column(
                            children: [
                              Container(
                                height: ScreenUtil().setWidth(100),
                                padding: EdgeInsets.only(
                                    top: ScreenUtil().setWidth(30),
                                    left: ScreenUtil().setWidth(30),
                                    right: ScreenUtil().setWidth(30),
                                    bottom: ScreenUtil().setWidth(20)),
                                decoration: BoxDecoration(
                                    color: MyColours.color_F9F9F9,
                                    borderRadius: BorderRadius.only(
                                      topLeft: Radius.circular(
                                          ScreenUtil().setWidth(20)),
                                      topRight: Radius.circular(
                                          ScreenUtil().setWidth(20)),
                                    )),
                                child: Row(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.center,
                                    children: [
                                      _textWidget('当前已选择'),
                                      _textWidget('${widget.selectData.length}',
                                          textColor: MyColours.color_199095),
                                      _textWidget('人/短信剩余条数'),
                                      _textWidget('${_myModel.smsInfo}',
                                          textColor: MyColours.color_199095),
                                      _textWidget('条')
                                    ]),
                              ),
                              Container(
                                  // height: ScreenUtil().setWidth(140 * 2),
                                  padding: EdgeInsets.all(
                                    ScreenUtil().setWidth(30),
                                  ),
                                  decoration: BoxDecoration(
                                      color: MyColours.color_ffffff,
                                      borderRadius: BorderRadius.only(
                                        bottomLeft: Radius.circular(
                                            ScreenUtil().setWidth(20)),
                                        bottomRight: Radius.circular(
                                            ScreenUtil().setWidth(20)),
                                      )),
                                  child: TextField(
                                    // controller: controller,
                                    maxLines: 5,
                                    // inputFormatters: [
                                    //   LengthLimitingTextInputFormatter(9),
                                    //   FilteringTextInputFormatter.digitsOnly
                                    // ],

                                    // inputFormatters: [
                                    //   NumLengthInputFormatter(
                                    //       decimalLength: 2, integerLength: 6),
                                    // ],
                                    // focusNode: numberFocusNode,

                                    //光标颜色
                                    cursorColor: MyColours.color_199095,
                                    //输入文本的样式
                                    style: TextStyle(
                                        fontSize: ScreenUtil().setSp(32),
                                        color: MyColours.color_333333),
                                    textAlign: TextAlign.left,
                                    textInputAction: TextInputAction.done,
                                    decoration: InputDecoration(
                                      isDense: true,
                                      hintText: "请输入要发送的短信内容",
                                      hintStyle: TextStyle(
                                        color: MyColours.color_999999,
                                        fontSize: ScreenUtil().setSp(32),
                                      ),
                                      contentPadding: EdgeInsets.zero,
                                      border: OutlineInputBorder(
                                          borderSide: BorderSide.none),
                                    ),
                                    onChanged: (value) {},
                                    onEditingComplete: () {
                                      FocusScope.of(context)
                                          .requestFocus(FocusNode()); //隐藏键盘
                                      // _updateMoney();
                                    },
                                    keyboardType: TextInputType.multiline,
                                  ))
                            ],
                          )),
                      VEmptyView(20),
                      Container(
                          // height: ScreenUtil().setWidth(146 * 2),
                          decoration: BoxDecoration(
                              boxShadow: [
                                BoxShadow(
                                    color: MyColours.color_e5e5e5,
                                    blurRadius: ScreenUtil().setWidth(30))
                              ],
                              borderRadius: BorderRadius.all(
                                Radius.circular(ScreenUtil().setWidth(20)),
                              )),
                          child: Column(
                            children: [
                              Container(
                                width: double.infinity,
                                height: ScreenUtil().setWidth(100),
                                padding: EdgeInsets.only(
                                    top: ScreenUtil().setWidth(30),
                                    left: ScreenUtil().setWidth(30),
                                    right: ScreenUtil().setWidth(30),
                                    bottom: ScreenUtil().setWidth(20)),
                                decoration: BoxDecoration(
                                    color: MyColours.color_F9F9F9,
                                    borderRadius: BorderRadius.only(
                                      topLeft: Radius.circular(
                                          ScreenUtil().setWidth(20)),
                                      topRight: Radius.circular(
                                          ScreenUtil().setWidth(20)),
                                    )),
                                child: _textWidget('店铺名称名称'),
                              ),
                              Container(
                                  // height: ScreenUtil().setWidth(140 * 2),
                                  padding: EdgeInsets.all(
                                    ScreenUtil().setWidth(30),
                                  ),
                                  decoration: BoxDecoration(
                                      color: MyColours.color_ffffff,
                                      borderRadius: BorderRadius.only(
                                        bottomLeft: Radius.circular(
                                            ScreenUtil().setWidth(20)),
                                        bottomRight: Radius.circular(
                                            ScreenUtil().setWidth(20)),
                                      )),
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.end,
                                    children: [
                                      Row(
                                        children: [
                                          Image.asset(
                                            Utils.getImgPath('phonesms'),
                                            width: ScreenUtil().setWidth(40),
                                            height: ScreenUtil().setWidth(40),
                                          ),
                                          HEmptyView(60),
                                          Expanded(
                                              child: TextField(
                                            // controller: controller,
                                            maxLines: 1,
                                            // inputFormatters: [
                                            //   LengthLimitingTextInputFormatter(9),
                                            //   FilteringTextInputFormatter.digitsOnly
                                            // ],

                                            // inputFormatters: [
                                            //   NumLengthInputFormatter(
                                            //       decimalLength: 2, integerLength: 6),
                                            // ],
                                            // focusNode: numberFocusNode,

                                            //光标颜色
                                            cursorColor: MyColours.color_199095,
                                            //输入文本的样式
                                            style: TextStyle(
                                                fontSize:
                                                    ScreenUtil().setSp(32),
                                                color: MyColours.color_333333),
                                            textAlign: TextAlign.left,
                                            textInputAction:
                                                TextInputAction.done,
                                            decoration: InputDecoration(
                                              isDense: true,
                                              hintText: "请输入电话",
                                              hintStyle: TextStyle(
                                                color: MyColours.color_999999,
                                                fontSize:
                                                    ScreenUtil().setSp(32),
                                              ),
                                              contentPadding: EdgeInsets.zero,
                                              border: OutlineInputBorder(
                                                  borderSide: BorderSide.none),
                                            ),
                                            onChanged: (value) {},
                                            onEditingComplete: () {
                                              FocusScope.of(context)
                                                  .requestFocus(
                                                      FocusNode()); //隐藏键盘
                                              // _updateMoney();
                                            },
                                            keyboardType: TextInputType.text,
                                          ))
                                        ],
                                      ),
                                      VEmptyView(30),
                                      MyDivider(
                                        ScreenUtil().setWidth(264 * 2),
                                        ScreenUtil().setWidth(2),
                                        color: MyColours.color_F0F0F0,
                                      ),
                                      VEmptyView(20),
                                      Text(
                                        '审核结果会以电话/短信的方式通知',
                                        style: TextStyle(
                                            fontSize: ScreenUtil().setSp(26),
                                            color: MyColours.color_199095),
                                      ),
                                    ],
                                  ))
                            ],
                          )),
                    ])))),
        Padding(
          padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
          child: RoundButton(
            height: ScreenUtil().setWidth(80),
            text: '提交审核',
            radius: ScreenUtil().setWidth(10),
            fontSize: 34,
            isBold: false,
          ),
        ),
        VEmptyView(40)
      ]),
    );
  }
}