From 41d3170e0078bacefccf63634632fcddc503f493 Mon Sep 17 00:00:00 2001 From: fmk Date: Sat, 16 Oct 2021 14:43:12 +0800 Subject: [PATCH] safety --- lib/store/store_view/settlement.dart | 220 +++++++++++++++++---------- 1 file changed, 139 insertions(+), 81 deletions(-) diff --git a/lib/store/store_view/settlement.dart b/lib/store/store_view/settlement.dart index 7be71df7..91e5be3d 100644 --- a/lib/store/store_view/settlement.dart +++ b/lib/store/store_view/settlement.dart @@ -1,6 +1,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:huixiang/generated/l10n.dart'; @@ -40,11 +41,24 @@ class _Settlement extends State { Function(int type) callback; GestureTapCallback callbackEx; int isSelected = 0; + StoreInfo storeInfo; + SettleOrderInfo settleOrderInfo; + + TextEditingController _vc; + List addressBgs = [ + "assets/svg/dingdan_ziqu.svg", + "assets/svg/dingdan_waimai.svg", + "assets/svg/dingdan_wuliu.svg", + ]; @override void initState() { super.initState(); storeInfo = widget.arguments["storeInfo"]; + + _vc = TextEditingController( + text: storeInfo != null ? storeInfo.headMobile : ""); + SharedPreferences.getInstance().then((value) { String minToken = value.getString("minToken"); String tenant = value.getString("tenant"); @@ -58,9 +72,6 @@ class _Settlement extends State { }); } - StoreInfo storeInfo; - SettleOrderInfo settleOrderInfo; - ///订单结算信息 queryOrderInfo() async { BaseData baseData = await minService.getOrderInfo({ @@ -77,6 +88,8 @@ class _Settlement extends State { } } + bool isEdit = false; + @override Widget build(BuildContext context) { return Stack( @@ -130,36 +143,94 @@ class _Settlement extends State { ], borderRadius: BorderRadius.circular(8), ), - padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.h), + padding: EdgeInsets.symmetric( + horizontal: 12.w, + vertical: 15.h, + ), child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - child: Text( - S.of(context).yuliudianhua, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF4C4C4C), - ), - ), - ), Text( - storeInfo != null ? storeInfo.headMobile : "", + S.of(context).yuliudianhua, + overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 14.sp, - fontWeight: MyFontWeight.medium, + fontWeight: MyFontWeight.regular, color: Color(0xFF4C4C4C), ), ), + SizedBox( + width: 50, + ), + Expanded( + child: isEdit + ? Container( + height: 30.h, + alignment: Alignment.centerRight, + child: TextField( + controller: _vc, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF4C4C4C), + ), + textAlign: TextAlign.right, + textAlignVertical: TextAlignVertical.center, + keyboardType: TextInputType.phone, + decoration: InputDecoration( + errorBorder: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + hintText: "", + hintStyle: TextStyle( + fontSize: 10.sp, + color: Color(0xFFA29E9E), + ), + ), + textInputAction: TextInputAction.next, + inputFormatters: [ + LengthLimitingTextInputFormatter(11) + ], + cursorColor: Colors.grey, + ), + ) + : Container( + height: 30.h, + alignment: Alignment.centerRight, + child: Text( + storeInfo != null + ? storeInfo.headMobile + : "", + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF4C4C4C), + ), + ), + ), + ), GestureDetector( onTap: () { - showAlertDialog(); + setState(() { + this.isEdit = !this.isEdit; + }); }, - child: Image.asset( - "assets/image/pen.png", - height: 14.h, - width: 14.w, + child: Container( + padding: EdgeInsets.all(8), + child: isEdit + ? Icon( + Icons.check, + size: 14.w, + color: Color(0xFF32A060), + ) + : Image.asset( + "assets/image/pen.png", + height: 14.h, + width: 14.w, + ), ), ), ], @@ -238,16 +309,6 @@ class _Settlement extends State { ); } - String title = ""; - String center = ""; - TextEditingController _vc = TextEditingController(); - - List addressBgs = [ - "assets/svg/dingdan_ziqu.svg", - "assets/svg/dingdan_waimai.svg", - "assets/svg/dingdan_wuliu.svg", - ]; - Widget distributionMode() { return Container( height: 143.h, @@ -289,15 +350,15 @@ class _Settlement extends State { children: [ Expanded( flex: 1, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - selectedBtn = 0; - }); - }, + child: GestureDetector( + onTap: () { + setState(() { + selectedBtn = 0; + }); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, child: Text( S.of(context).daodianziqu, style: TextStyle( @@ -311,15 +372,15 @@ class _Settlement extends State { ), Expanded( flex: 1, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - selectedBtn = 1; - }); - }, + child: GestureDetector( + onTap: () { + setState(() { + selectedBtn = 1; + }); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, child: Text( S.of(context).waimaipeisong, style: TextStyle( @@ -333,17 +394,14 @@ class _Settlement extends State { ), Expanded( flex: 1, - child: Container( - height: 50.h, - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - // selectedBtn = 2; - SmartDialog.showToast("该功能暂未开放!", - alignment: Alignment.center); - }); - }, + child: GestureDetector( + onTap: () { + SmartDialog.showToast("该功能暂未开放!", + alignment: Alignment.center); + }, + child: Container( + height: 50.h, + alignment: Alignment.center, child: Text( S.of(context).kuaidiwuliu, style: TextStyle( @@ -737,26 +795,26 @@ class _Settlement extends State { } ///手机号编辑 - showAlertDialog() { - //显示对话框 - showDialog( - barrierDismissible: false, - context: context, - builder: (context) { - return RenameDialog( - contentWidget: RenameDialogContent( - title: "请输入新的手机号码", - okBtnTap: () { - // print( - // "输入框中的文字为:${_vc.text}", - // ); - }, - vc: _vc, - cancelBtnTap: () {}, - ), - ); - }); - } + // showAlertDialog() { + // //显示对话框 + // showDialog( + // barrierDismissible: false, + // context: context, + // builder: (context) { + // return RenameDialog( + // contentWidget: RenameDialogContent( + // title: "请输入新的手机号码", + // okBtnTap: () { + // // print( + // // "输入框中的文字为:${_vc.text}", + // // ); + // }, + // vc: _vc, + // cancelBtnTap: () {}, + // ), + // ); + // }); + // } ///优惠券弹窗 couponCart() {