| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009 |
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:city_pickers/city_pickers.dart';
- import 'package:flutter_picker/flutter_picker.dart';
- import 'dart:async';
- import 'send_express_page/order_detail_page.dart';
- import '../util/util.dart';
- import '../util/api.dart';
- import '../util/models.dart';
- import '../showAlert.dart';
- import '../send_Dialog.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;
- bool submitStatus = true;
- List < LikePhoneList > likePhoneList = [];
- var timer;
- bool sendPhoneOrGetPhoneTab = true; //区分电话提示层点击时填入发件信息或手机信息的标记
- TextEditingController sendCompanyPhoneController = TextEditingController();
- TextEditingController sendCompanyCodeController = TextEditingController();
- TextEditingController sendCompanyNameController = TextEditingController();
- TextEditingController receiptCompanyPhoneController = TextEditingController();
- TextEditingController receiptCompanyNameController = TextEditingController();
- TextEditingController sendCompanyAddreddController = TextEditingController();
- TextEditingController receiptCompanyAddressController = TextEditingController();
- List < dynamic > goodsCateGoryList = [];
- List < dynamic > goodsPackageList = [];
- //请求字段-------------------------
- String sendCompanyId = '0'; //寄件公司Id
- String sendCompanyName = ''; //寄件公司名称 不能为空
- String sendCompanyPhone = ''; //寄件公司电话 不能为空
- String sendCompanyCode = ''; //寄件公司编码
- String sendCompanyProvinceName = ''; //寄件公司省名称 不能为空
- String sendCompanyProvinceCode = ''; //寄件公司省编码 不能为空
- String sendCompanyCityName = ''; //寄件公司市名称 不能为空
- String sendCompanyCityCode = ''; //寄件公司市编码 不能为空
- String sendCompanyAreaName = ''; //寄件公司区名称 不能为空
- String sendCompanyAreaCode = ''; //寄件公司区编码 不能为空
- String sendCompanyAddress = ''; //寄件公司详细地址,不能为空
- String receiptCompanyId = '0'; //收件公司id
- String receiptCompanyPhone = ''; //收件公司电话 不能为空
- String receiptCompanyName = ''; //收件公司名称 不能为空
- String receiptCompanyProvinceName = ''; //收件公司省名称 不能为空
- String receiptCompanyProvinceCode = ''; //收件公司省编码 不能为空
- String receiptCompanyCityName = ''; //收件公司市名称 不能为空
- String receiptCompanyCityCode = ''; //收件公市编码 不能为空
- String receiptCompanyAreaName = ''; //收件公区名称 不能为空
- String receiptCompanyAreaCode = ''; //收件公司区编码 不能为空
- String receiptCompanyAddress = ''; //收件公司地址详情 不能为空
- String goods = ''; //商品名称 不能为空
- int goodsQuantity = 1; //商品数量 不能为空
- int goodsPackingId; //商品包装ID
- int goodsCategoryId; //商品类别ID
- int goodsPaymentMethod = 1; //付款方式 1,现付 2 到付
- double goodsWeight = 0.0; //商品重量
- double goodsPriceProtection = 0.0; //商品保价
- double goodsAgencyFund = 0.0; //商品代收款
- double goodsFreight = 0.0; //商品运费 不能为空
- String memo = ''; //备注
- String sendPCA = ' '; //Text组件内容必须有空格,否则报null
- String getPCA = ' ';
- String showTextGoodsCategory = ' ';
- String showTextGoodsPackage = ' ';
- String showTextPaymentMehod = '现付';
- @override
- void initState() {
- super.initState();
- goodsCategory().then((resp) {
- if (isNotError(context, resp)) {
- GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
- setState(() {
- goodsCateGoryList = goodsCategoryObj.data;
- showTextGoodsCategory = goodsCateGoryList[0].name;
- goodsCategoryId = goodsCateGoryList[0].id;
- });
- }
- });
- goodsPackage().then((resp) {
- if (isNotError(context, resp)) {
- GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
- setState(() {
- goodsPackageList = goodsPackageObj.data;
- showTextGoodsPackage = goodsPackageList[0].name;
- goodsPackingId = goodsPackageList[0].id;
- });
- }
- });
- _scrollController.addListener(() {
- if (!tipStatus) {
- setState(() {
- tipStatus = true;
- });
- }
- //if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) {}
- });
- sendCompanyPhoneController.addListener(() {
-
- setState(() {
- sendCompanyPhone = sendCompanyPhoneController.text;
- });
-
- if (timer != null) {
- timer.cancel();
- }
- if (sendCompanyPhoneController.text.length < 6 || sendCompanyPhoneController.text.length > 11) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 500), () {
- if (sendCompanyPhoneController.text.length >= 6 && sendCompanyPhoneController.text.length < 11) {
- likePhone(sendCompanyPhoneController.text).then((resp) {
- if (isNotError(context, resp)) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = true;
- 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;
- });
- }
- });
- }
- });
- });
- receiptCompanyPhoneController.addListener(() {
-
- setState(() {
- receiptCompanyPhone = receiptCompanyPhoneController.text;
- });
-
- if (timer != null) {
- timer.cancel();
- }
- if (receiptCompanyPhoneController.text.length < 6 || receiptCompanyPhoneController.text.length > 11) {
- setState(() {
- tipStatus = true;
- });
- }
- timer = Timer(Duration(milliseconds: 500), () {
- if (receiptCompanyPhoneController.text.length >= 6 && receiptCompanyPhoneController.text.length < 11) {
- likePhone(receiptCompanyPhoneController.text).then((resp) {
- if (isNotError(context, resp)) {
- LikePhone likePhoneObj = LikePhone.fromJson(resp.data);
- likePhoneList = likePhoneObj.data;
- }
- if (likePhoneList.length > 0) {
- sendPhoneOrGetPhoneTab = false;
- RenderObject getPhoneKey = _getPhoneKey.currentContext.findRenderObject();
- setState(() {
- tipWidth = getPhoneKey.paintBounds.size.width;
- tipHeight = getPhoneKey.paintBounds.size.height;
- tipPosX = getPhoneKey.getTransformTo(null).getTranslation().x;
- tipPosY = getPhoneKey.getTransformTo(null).getTranslation().y - ScreenUtil.getInstance().setHeight(90);
- tipStatus = false;
- });
- } else {
- setState(() {
- tipStatus = true;
- });
- }
- });
- }
- });
- });
- sendCompanyAddreddController.addListener(() {
- setState(() {
- sendCompanyAddress = sendCompanyAddreddController.text;
- });
- });
- receiptCompanyAddressController.addListener(() {
- setState(() {
- receiptCompanyAddress = receiptCompanyAddressController.text;
- });
- });
- }
- @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.builder(
- itemCount: likePhoneList.length,
- itemBuilder: (BuildContext context, int index) {
- return _tipItem(likePhoneList[index]);
- },
- )
- ),
- )
- )
- ],
- ),
- 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('包装类型'),
- _packageType('商品类型'),
- _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 > [
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(500),
- child: TextField(
- controller: tab == 'sendPhone' ? sendCompanyPhoneController : receiptCompanyPhoneController,
- keyboardType: TextInputType.number,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- 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(
- controller: (key == '企业名称') ? (type == 'send' ? sendCompanyNameController : receiptCompanyNameController) : (key == '企业编码' ? sendCompanyCodeController : null),
- 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 == '运费') {
- goodsFreight = double.parse(value);
- String temp =goodsFreight.toStringAsFixed(1);
- goodsFreight = double.parse(temp);
- } else if (key == '代收') {
- goodsAgencyFund = double.parse(value);
- String temp =goodsAgencyFund.toStringAsFixed(1);
- goodsAgencyFund = double.parse(temp);
- } else if (key == '保价') {
- goodsPriceProtection = double.parse(value);
- String temp =goodsPriceProtection.toStringAsFixed(1);
- goodsPriceProtection = double.parse(temp);
- } else if (key == '重量') {
- goodsWeight = double.parse(value);
- String temp =goodsWeight.toStringAsFixed(1);
- goodsWeight = double.parse(temp);
- }
- }
- },
- ),
- ),
- 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(
- controller: type == 'send' ? sendCompanyAddreddController : receiptCompanyAddressController,
- textAlign: TextAlign.end,
- decoration: InputDecoration(
- border: InputBorder.none
- ),
- ),
- ),
- 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: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: < Widget > [
- Offstage(
- offstage: submitStatus,
- child: SizedBox(
- width: ScreenUtil.getInstance().setWidth(45),
- height: ScreenUtil.getInstance().setHeight(45),
- child: Image.asset('lib/images/loading.gif'),
- ),
- ),
- Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
- ],
- )
- ),
- ),
- onTap: () {
- if (!submitStatus) {
- return;
- }
- String errStr = '';
- print('sendCompanyId---${sendCompanyId}');
- print('sendCompanyName---${sendCompanyName}');
- print('sendCompanyPhone---${sendCompanyPhone}');
- print('sendCompanyCode---${sendCompanyCode}');
- print('sendCompanyProvinceName---${sendCompanyProvinceName}');
- print('sendCompanyProvinceCode---${sendCompanyProvinceCode}');
- print('sendCompanyCityName---${sendCompanyCityName}');
- print('sendCompanyCityCode---${sendCompanyCityCode}');
- print('sendCompanyAreaName---${sendCompanyAreaName}');
- print('sendCompanyAreaCode---${sendCompanyAreaCode}');
- print('sendCompanyAddress---${sendCompanyAddress}');
- print('receiptCompanyId---${receiptCompanyId}');
- print('receiptCompanyPhone---${receiptCompanyPhone}');
- print('receiptCompanyName---${receiptCompanyName}');
- print('receiptCompanyProvinceName---${receiptCompanyProvinceName}');
- print('receiptCompanyProvinceCode---${receiptCompanyProvinceCode}');
- print('receiptCompanyCityName---${receiptCompanyCityName}');
- print('receiptCompanyCityCode---${receiptCompanyCityCode}');
- print('receiptCompanyAreaName---${receiptCompanyAreaName}');
- print('receiptCompanyAreaCode---${receiptCompanyAreaCode}');
- print('receiptCompanyAddress---${receiptCompanyAddress}');
- print('goods---${goods}');
- print('goodsQuantity---${goodsQuantity}');
- print('goodsPackingId---${goodsPackingId}');
- print('goodsCategoryId---${goodsCategoryId}');
- print('goodsPaymentMethod---${goodsPaymentMethod}');
- print('goodsWeight---${goodsWeight}');
- print('goodsPriceProtection---${goodsPriceProtection}');
- print('goodsAgencyFund---${goodsAgencyFund}');
- print('goodsFreight---${goodsFreight}');
- print('memo---${memo}');
- // if (!isChinaPhoneLegal(sendCompanyPhone)) {
- // }
- if (sendCompanyPhone == '') {
- errStr = '请填写发件电话';
- }
- if (sendCompanyName == '') {
- errStr = '请填写发件企业名称';
- }
- if (sendCompanyProvinceName == '') {
- errStr = '请填写发件城市/区域';
- }
- if (sendCompanyAddress == '') {
- errStr = '请填写发件详细地址';
- }
- if (receiptCompanyPhone == '') {
- errStr = '请填写收件电话';
- }
- if (receiptCompanyName == '') {
- errStr = '请填写收件企业名称';
- }
- if (receiptCompanyProvinceName == '') {
- errStr = '请填写收件城市/区域';
- }
- if (receiptCompanyAddress == '') {
- errStr = '请填写收件详细地址';
- }
- if (goods == '') {
- errStr = '请填写货物名称';
- }
- if (goodsQuantity == 0) {
- errStr = '请填写货物数量';
- }
- if(int.tryParse(goodsQuantity.toString())==null){
- errStr='货物数量格式错误';
- }
- if (goodsFreight == 0.0) {
- errStr = '请填写运费';
- }
- if(int.tryParse(sendCompanyPhone)==null || int.tryParse(receiptCompanyPhone)==null || sendCompanyPhone.length!=11 || receiptCompanyPhone.length!=11){
- errStr='请输入正确的电话';
- }
- if (errStr != '') {
- showError(errStr);
- return;
- }
- return;
- setState(() {
- submitStatus = false;
- });
- createOrder(
- sendCompanyId, //寄件公司Id
- sendCompanyName, //寄件公司名称 不能为空
- sendCompanyPhone, //寄件公司电话 不能为空
- sendCompanyCode ?? '', //寄件公司编码
- sendCompanyProvinceName, //寄件公司省名称 不能为空
- sendCompanyProvinceCode, //寄件公司省编码 不能为空
- sendCompanyCityName, //寄件公司市名称 不能为空
- sendCompanyCityCode, //寄件公司市编码 不能为空
- sendCompanyAreaName, //寄件公司区名称 不能为空
- sendCompanyAreaCode, //寄件公司区编码 不能为空
- sendCompanyAddress, //寄件公司详细地址,不能为空
- receiptCompanyId, //收件公司id
- receiptCompanyPhone, //收件公司电话 不能为空
- receiptCompanyName, //收件公司名称 不能为空
- receiptCompanyProvinceName, //收件公司省名称 不能为空
- receiptCompanyProvinceCode, //收件公司省编码 不能为空
- receiptCompanyCityName, //收件公司市名称 不能为空
- receiptCompanyCityCode, //收件公市编码 不能为空
- receiptCompanyAreaName, //收件公区名称 不能为空
- receiptCompanyAreaCode, //收件公司区编码 不能为空
- receiptCompanyAddress, //收件公司地址详情 不能为空
- goods, //商品名称 不能为空
- goodsQuantity, //商品数量 不能为空
- goodsPackingId, //商品包装ID
- goodsCategoryId, //商品类别ID
- goodsPaymentMethod, //付款方式 1,现付 2 到付
- goodsWeight, //商品重量
- goodsPriceProtection * 100, //商品保价,已分为单位
- goodsAgencyFund * 100, //商品代收款,已分为单位
- goodsFreight * 100, //商品运费 不能为空 ,已分为单位
- memo, //备注
- ).then((resp) {
- if (isNotError(context, resp)) {
- setState(() {
- submitStatus = true;
- });
- CreateOrder orderObj = CreateOrder.fromJson(resp.data);
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return SendDialog( //调用对话框
- orderNo: orderObj.orderNo,
- childCallback: (val) {
- if (!val) {
- //跳转
- Navigator.push(context, MaterialPageRoute(builder: (context) {
- return OrderDetail(orderId: orderObj.orderNo, );
- }));
- }
- },
- );
- });
- } else {
- setState(() {
- submitStatus = true;
- });
- }
- });
- },
- );
- }
- showError(String str) {
- showDialog < Null > (
- context: context, //BuildContext对象
- barrierDismissible: false,
- builder: (BuildContext context) {
- return MyAlertDialog( //调用对话框
- text: str, childCallback: (val) {},
- );
- });
- }
- Future getCity(context) async {
- Result result = await CityPickers.showCityPicker(
- context: context,
- );
- return result;
- }
- Widget _tipItem(LikePhoneList obj) {
- return Container(
- child: Column(
- children: < Widget > [
- InkWell(
- child: 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(obj.uzerPhone, style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(74, 74, 74, 1)
- ), )
- ),
- SizedBox(
- width: ScreenUtil.getInstance().setWidth(185),
- child: Text(obj.areaCode,
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(155, 155, 155, 1)
- ), ),
- ),
- Text(obj.companyName,
- textAlign: TextAlign.left,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: ScreenUtil.getInstance().setSp(28),
- color: Color.fromRGBO(155, 155, 155, 1)
- ),
- )
- ],
- ),
- ),
- ),
- onTap: () {
- if (sendPhoneOrGetPhoneTab) {
- sendCompanyPhone = obj.uzerPhone;
- sendCompanyCode = obj.companyCode;
- sendCompanyName = obj.companyName;
- sendCompanyId = obj.id.toString();
- sendCompanyPhoneController.text = obj.uzerPhone;
- sendCompanyCodeController.text = obj.companyCode;
- sendCompanyNameController.text = obj.companyName;
- } else {
- receiptCompanyPhone = obj.uzerPhone;
- receiptCompanyName = obj.companyName;
- receiptCompanyPhoneController.text = obj.uzerPhone;
- receiptCompanyNameController.text = obj.companyName;
- receiptCompanyId = obj.id.toString();
- }
- setState(() {
- FocusScope.of(context).requestFocus(FocusNode());
- tipStatus = true;
- });
- },
- ),
- _underLine()
- ],
- ),
- );
- }
- Widget _packageType(String key) {
- 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(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(key == '包装类型' ? showTextGoodsPackage : key == '商品类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
- ),
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
- ],
- )
- )
- ],
- ),
- )
- ),
- onTap: () {
- showPickerModal(context, key);
- },
- ),
- Expanded(
- flex: 0,
- child: _underLine()
- )
- ],
- )
- );
- }
- showPickerModal(BuildContext context, String type) {
- List < dynamic > data = [];
- if (type == '包装类型') {
- for (int i = 0; i < goodsPackageList.length; i++) {
- data.add(goodsPackageList[i].name);
- }
- } else if (type == '商品类型') {
- for (int i = 0; i < goodsCateGoryList.length; i++) {
- data.add(goodsCateGoryList[i].name);
- }
- } else if (type == '付款方式') {
- data = ['现付', '到付'];
- }
- new Picker(
- adapter: PickerDataAdapter < String > (pickerdata: data),
- 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) {
- if (type == '包装类型') {
- setState(() {
- showTextGoodsPackage = goodsPackageList[value[0]].name;
- goodsPackingId = goodsPackageList[value[0]].id;
- });
- } else if (type == '商品类型') {
- showTextGoodsCategory = goodsCateGoryList[value[0]].name;
- goodsCategoryId = goodsCateGoryList[value[0]].id;
- } else if (type == '付款方式') {
- showTextPaymentMehod = data[value[0]];
- if (showTextPaymentMehod == '现付') {
- goodsPaymentMethod = 1;
- } else {
- goodsPaymentMethod = 2;
- }
- }
- }
- ).showModal(this.context); //_scaffoldKey.currentState);
- }
- }
|