| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:city_pickers/city_pickers.dart';
- import 'package:flutter_picker/flutter_picker.dart';
- class SendExpressPage extends StatefulWidget {
- final Widget child;
- SendExpressPage({
- Key key,
- this.child
- }): super(key: key);
- _SendExpressPageState createState() => _SendExpressPageState();
- }
- class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeepAliveClientMixin {
- ScrollController _scrollController = ScrollController();
- //组件自用字段-----------------------------
- GlobalKey _sendPhoneKey = GlobalKey();
- GlobalKey _getPhoneKey = GlobalKey();
- double tipWidth = 0;
- double tipHeight = 0;
- double tipPosX = 0;
- double tipPosY = 0;
- bool tipStatus = true;
- //请求字段-------------------------
- int sendCompanyId; //寄件公司Id
- String sendCompanyName; //寄件公司名称 不能为空
- String sendCompanyPhone; //寄件公司电话 不能为空
- String sendCompanyCode; //寄件公司编码 不能为空
- String sendCompanyProvinceName; //寄件公司省名称 不能为空
- String sendCompanyProvinceCode; //寄件公司省编码 不能为空
- String sendCompanyCityName; //寄件公司市名称 不能为空
- String sendCompanyCityCode; //寄件公司市编码 不能为空
- String sendCompanyAreaName; //寄件公司区名称 不能为空
- String sendCompanyAreaCode; //寄件公司区编码 不能为空
- String sendCompanyAddress; //寄件公司详细地址,不能为空
- int receiptCompanyId; //收件公司id
- String receiptCompanyPhone; //收件公司电话 不能为空
- String receiptCompanyName; //收件公司名称 不能为空
- String receiptCompanyProvinceName; //收件公司省名称 不能为空
- String receiptCompanyProvinceCode; //收件公司省编码 不能为空
- String receiptCompanyCityName; //收件公司市名称 不能为空
- String receiptCompanyCityCode; //收件公市编码 不能为空
- String receiptCompanyAreaName; //收件公区名称 不能为空
- String receiptCompanyAreaCode; //收件公司区编码 不能为空
- String receiptCompanyAddress; //收件公司地址详情 不能为空
- String goods; //商品名称不能为空
- int goodsQuantity; //商品数量 不能为空
- int goodsPackingId; //商品包装ID
- int goodsCategoryId; //商品包装类别ID
- int goodsPaymentMethod; //付款方式
- double goodsWeight; //商品重量
- double goodsPriceProtection; //商品保价
- double goodsAgencyFund; //商品代收款
- String memo; //备注
- String sendPCA = ' ';//Text组件内容必须有空格,否则报null
- String getPCA = ' ';
- @override
- void initState() {
- super.initState();
- _scrollController.addListener(() {
- if (!tipStatus) {
- setState(() {
- tipStatus = true;
- });
- }
- print('滚动了');
- if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
- });
- }
- @override
- bool get wantKeepAlive => true;
- @override
- Widget build(BuildContext context) {
- return Container(
- child: Scaffold(
- appBar: AppBar(
- title: Text('发件', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(36)), ),
- centerTitle: true,
- backgroundColor: Color.fromRGBO(64, 98, 254, 1),
- ),
- body:
- Stack(
- children: < Widget > [
- Container(
- color: Color.fromRGBO(246, 246, 254, 1),
- padding: EdgeInsets.fromLTRB(0, ScreenUtil.getInstance().setHeight(20), 0, ScreenUtil.getInstance().setHeight(20)),
- child: ListView(
- controller: _scrollController,
- children: < Widget > [
- _sendInfo(context),
- _getInfo(context),
- _itemInfoWidget(),
- _submitBtn()
- ],
- ),
- ),
- Positioned(
- top: tipPosY,
- left: tipPosX,
- child: Offstage(
- offstage: tipStatus,
- child: Container(
- width: tipWidth,
- height: ScreenUtil.getInstance().setHeight(450),
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- decoration: BoxDecoration(
- color: Color.fromRGBO(244, 248, 251, 1),
- ),
- child: ListView(
- children: < Widget > [
- _tipItem(),
- _tipItem(),
- ],
- ),
- ),
- )
- )
- ],
- ),
- resizeToAvoidBottomPadding: false //键盘弹出,页面不跟随向上滑动,防止出现溢出错误
- ),
- );
- }
- Widget _sendInfo(BuildContext context) {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- _titleWidget('lib/images/icon_send.png', '发件信息'),
- _underLine(),
- _inputWiget('电话', 'sendPhone'),
- _contentWiget('企业编码', 'send', true),
- _contentWiget('企业名称', 'send', true),
- _cityWiget('城市/区域', context, 'send'),
- _lastContentWiget('详细地址', 'send')
- ],
- )
- );
- }
- Widget _getInfo(BuildContext context) {
- return Container(
- color: Colors.white,
- margin: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(20)),
- child: Column(
- children: < Widget > [
- _titleWidget('lib/images/icon_shoujian.png', '收件信息'),
- _underLine(),
- _inputWiget('电话', 'getPhone'),
- //_contentWiget('企业编码', 'get', true),
- _contentWiget('企业名称', 'get', true),
- _cityWiget('城市/区域', context, 'get'),
- _lastContentWiget('详细地址', 'get')
- ],
- )
- );
- }
- Widget _itemInfoWidget() {
- return Container(
- child: Container(
- color: Colors.white,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: < Widget > [
- _titleWidget('lib/images/icon_huowu.png', "货物信息"),
- _underLine(),
- _contentWiget("货物名称", 'goods', true),
- _contentWiget("数量", 'goods'),
- _contentWiget("运费", 'goods'),
- _contentWiget("代收", 'goods'),
- _contentWiget("保价", 'goods'),
- _contentWiget("重量", 'goods'),
- _packageType(),
- _descWidget()
- ],
- ),
- )
- );
- }
- Widget _titleWidget(String iconUrl, String str) {
- return Container(
- height: ScreenUtil.getInstance().setHeight(90),
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: < Widget > [
- Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setHeight(20)),
- child: Image.asset(
- iconUrl,
- width: ScreenUtil.getInstance().setWidth(40),
- height: ScreenUtil.getInstance().setHeight(40),
- )
- ),
- Text(str, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32)), )
- ],
- ),
- ),
- );
- }
- Widget _underLine() {
- return Container(
- color: Color.fromRGBO(223, 223, 223, 1),
- height: ScreenUtil.getInstance().setHeight(1),
- );
- }
- Widget _inputWiget(String key, String tab) {
- return Padding(
- key: tab == 'sendPhone' ? _sendPhoneKey : _getPhoneKey,
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: TextField(
- keyboardType: TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- onChanged: ((value) {
- if (tab == 'sendPhone') {
- if (value.length >= 4) {
- RenderObject sendPhoneObj = _sendPhoneKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = sendPhoneObj.paintBounds.size.width;
- tipHeight = sendPhoneObj.paintBounds.size.height;
- tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
- tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- // print(tipWidth);
- // print(tipHeight);
- // print(tipPosX);
- // print(tipPosY);
- } else if (tab == 'getPhone') {
- if (value.length >= 4) {
- RenderObject sendPhoneObj = _getPhoneKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = sendPhoneObj.paintBounds.size.width;
- tipHeight = sendPhoneObj.paintBounds.size.height;
- tipPosX = sendPhoneObj.getTransformTo(null).getTranslation().x;
- tipPosY = sendPhoneObj.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- // print(tipWidth);
- // print(tipHeight);
- // print(tipPosX);
- // print(tipPosY);
- }
- }),
- onEditingComplete: () {
- setState(() {
- FocusScope.of(context).requestFocus(FocusNode());
- tipStatus = true;
- });
- },
- ),
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- Widget _contentWiget(String key, String type, [bool keyboardType = false]) { //false是数字键盘
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: TextField(
- keyboardType: keyboardType ? TextInputType.text : TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- onChanged: (value) {
- if (type == 'send') {
- if (key == '企业编码') {
- setState(() {
- sendCompanyCode = value;
- });
- } else if (key == '企业名称') {
- setState(() {
- sendCompanyName = value;
- });
- }
- } else if (type == 'get') {
- if (key == '企业编码') {
- setState(() {
- sendCompanyCode = value;
- });
- } else if (key == '企业名称') {
- setState(() {
- receiptCompanyName = value;
- });
- }
- } else {
- if (key == '货物名称') {
- goods = value;
- } else if (key == '数量') {
- goodsQuantity = int.parse(value);
- } else if (key == '运费') {
- } else if (key == '代收') {
- goodsAgencyFund = double.parse(value);
- } else if (key == '保价') {
- goodsPriceProtection = double.parse(value);
- } else if (key == '重量') {
- goodsWeight = double.parse(value);
- }
- }
- },
- ),
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- Widget _cityWiget(String key, BuildContext context, String type) {
- return
- GestureDetector(
- child: Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Text(type == 'send' ? sendPCA : getPCA, textAlign: TextAlign.end, overflow: TextOverflow.ellipsis, )
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- ),
- onTap: () {
- getCity(context).then((resp) {
- if (resp == null) {
- return;
- }
- print(resp.toString());
- setState(() {
- if (type == 'send') {
- sendPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
- sendCompanyProvinceName = resp.provinceName;
- sendCompanyProvinceCode = resp.provinceId;
- sendCompanyCityName = resp.cityName;
- sendCompanyCityCode = resp.cityId;
- sendCompanyAreaName = resp.areaName;
- sendCompanyAreaCode = resp.areaId;
- } else {
- getPCA = resp.provinceName + ' ' + resp.cityName + ' ' + ' ' + resp.areaName;
- receiptCompanyProvinceName = resp.provinceName;
- receiptCompanyProvinceCode = resp.provinceId;
- receiptCompanyCityName = resp.cityName;
- receiptCompanyCityCode = resp.cityId;
- receiptCompanyAreaName = resp.areaName;
- receiptCompanyAreaCode = resp.areaId;
- }
- });
- //print(value);
- });
- },
- );
- }
- Widget _lastContentWiget(String key, String type) {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text(key, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: TextField(
- //keyboardType: TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- onChanged: (value) {
- if (type == 'send') {
- setState(() {
- sendCompanyAddress = value;
- });
- } else {
- setState(() {
- receiptCompanyAddress = value;
- });
- }
- },
- ),
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- )
- );
- }
- Widget _descWidget() {
- return
- Container(
- padding: EdgeInsets.all(ScreenUtil.getInstance().setWidth(30)),
- //child: Text(str, maxLines: 100, style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- child: TextField(
- maxLines: 3,
- decoration: InputDecoration(
- border: InputBorder.none,
- hintText: "请输入备注内容"
- ),
- onChanged: (value) {
- setState(() {
- memo = value;
- });
- },
- ),
- );
- }
- Widget _submitBtn() {
- return GestureDetector(
- child: Container(
- margin: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(50), ScreenUtil.getInstance().setWidth(30), ScreenUtil.getInstance().setWidth(40)),
- height: ScreenUtil.getInstance().setHeight(88),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(Radius.circular(4)),
- color: Color.fromRGBO(37, 102, 242, 1),
- ),
- child: Center(
- child: Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
- ),
- ),
- onTap: () {
- print('提交');
- },
- );
- }
- Future getCity(context) async {
- Result result = await CityPickers.showCityPicker(
- context: context,
- );
- return result;
- }
- Widget _tipItem() {
- return Container(
- child: Column(
- children: < Widget > [
- Container(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: < Widget > [
- Padding(
- padding: EdgeInsets.only(right: ScreenUtil.getInstance().setWidth(50)),
- child: Text("15901462275", style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(74, 74, 74, 1)
- ), )
- ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(185),
- child: Text('WX11042',
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(155, 155, 155, 1)
- ), ),
- ),
- Text('天华盛业',
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(155, 155, 155, 1)
- ),
- )
- ],
- ),
- ),
- ),
- _underLine()
- ],
- ),
- );
- }
- Widget _packageType() {
- return Padding(
- padding: EdgeInsets.only(left: ScreenUtil.getInstance().setWidth(30)),
- child: Column(
- children: < Widget > [
- InkWell(
- child: SizedBox(
- height: ScreenUtil.getInstance().setHeight(89),
- child: Center(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: < Widget > [
- Expanded(
- flex: 0,
- child: Text('包装类型', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
- ),
- Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.end,
- children: < Widget > [
- //Text('${value}', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(136, 136, 136, 1)), ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: Text('纸箱', textAlign: TextAlign.end, )
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- onTap: () {
- showPickerModal(context);
- },
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- showPickerModal(BuildContext context) {
- new Picker(
- adapter: PickerDataAdapter < String > (pickerdata: ['纸箱', '木箱']),
- height: ScreenUtil.getInstance().setHeight(450),
- confirmText: '确定',
- confirmTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(64, 98, 254, 1)),
- cancelText: '取消',
- cancelTextStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(153, 153, 153, 1)),
- headercolor: Color.fromRGBO(245, 245, 245, 1),
- itemExtent: ScreenUtil.getInstance().setHeight(80),
- textStyle: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(42, 42, 42, 1)),
- changeToFirst: true,
- hideHeader: false,
- onConfirm: (Picker picker, List value) {
- // setState(() {
- // _siteName = stationObj.data[value[0]].name;
- // });
- // setKey('stationId', stationObj.data[value[0]].id.toString());
- }
- ).showModal(this.context); //_scaffoldKey.currentState);
- }
- }
|