|
|
@@ -3,12 +3,12 @@ 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;
|
|
|
|
|
|
@@ -50,40 +50,40 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
TextEditingController sendCompanyAddreddController = TextEditingController();
|
|
|
TextEditingController receiptCompanyAddressController = TextEditingController();
|
|
|
|
|
|
- List<dynamic> goodsCateGoryList = [];
|
|
|
- List<dynamic> goodsPackageList = [];
|
|
|
+ List < dynamic > goodsCateGoryList = [];
|
|
|
+ List < dynamic > goodsPackageList = [];
|
|
|
//请求字段-------------------------
|
|
|
int sendCompanyId; //寄件公司Id
|
|
|
- String sendCompanyName=''; //寄件公司名称 不能为空
|
|
|
- String sendCompanyPhone=''; //寄件公司电话 不能为空
|
|
|
- String sendCompanyCode=''; //寄件公司编码
|
|
|
- String sendCompanyProvinceName=''; //寄件公司省名称 不能为空
|
|
|
- String sendCompanyProvinceCode=''; //寄件公司省编码 不能为空
|
|
|
- String sendCompanyCityName=''; //寄件公司市名称 不能为空
|
|
|
- String sendCompanyCityCode=''; //寄件公司市编码 不能为空
|
|
|
- String sendCompanyAreaName=''; //寄件公司区名称 不能为空
|
|
|
- String sendCompanyAreaCode=''; //寄件公司区编码 不能为空
|
|
|
- String sendCompanyAddress=''; //寄件公司详细地址,不能为空
|
|
|
+ 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=1; //商品数量 不能为空
|
|
|
+ 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=''; //备注
|
|
|
+ double goodsWeight = 0.0; //商品重量
|
|
|
+ double goodsPriceProtection = 0.0; //商品保价
|
|
|
+ double goodsAgencyFund = 0.0; //商品代收款
|
|
|
+ double goodsFreight = 0.0; //商品运费 不能为空
|
|
|
+ String memo = ''; //备注
|
|
|
|
|
|
|
|
|
String sendPCA = ' '; //Text组件内容必须有空格,否则报null
|
|
|
@@ -97,8 +97,8 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
|
|
|
- goodsCategory().then((resp){
|
|
|
- if(isNotError(context, resp)){
|
|
|
+ goodsCategory().then((resp) {
|
|
|
+ if (isNotError(context, resp)) {
|
|
|
GoodsCategory goodsCategoryObj = GoodsCategory.fromJson(resp.data);
|
|
|
setState(() {
|
|
|
goodsCateGoryList = goodsCategoryObj.data;
|
|
|
@@ -108,8 +108,8 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- goodsPackage().then((resp){
|
|
|
- if(isNotError(context, resp)){
|
|
|
+ goodsPackage().then((resp) {
|
|
|
+ if (isNotError(context, resp)) {
|
|
|
GoodsPackage goodsPackageObj = GoodsPackage.fromJson(resp.data);
|
|
|
setState(() {
|
|
|
goodsPackageList = goodsPackageObj.data;
|
|
|
@@ -204,15 +204,15 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
- sendCompanyAddreddController.addListener((){
|
|
|
+
|
|
|
+ sendCompanyAddreddController.addListener(() {
|
|
|
setState(() {
|
|
|
- sendCompanyAddress =sendCompanyAddreddController.text;
|
|
|
+ sendCompanyAddress = sendCompanyAddreddController.text;
|
|
|
});
|
|
|
});
|
|
|
- receiptCompanyAddressController.addListener((){
|
|
|
+ receiptCompanyAddressController.addListener(() {
|
|
|
setState(() {
|
|
|
- receiptCompanyAddress =receiptCompanyAddressController.text;
|
|
|
+ receiptCompanyAddress = receiptCompanyAddressController.text;
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
@@ -602,7 +602,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
SizedBox(
|
|
|
width: ScreenUtil.getInstance().setWidth(500),
|
|
|
child: TextField(
|
|
|
- controller: type=='send'?sendCompanyAddreddController:receiptCompanyAddressController,
|
|
|
+ controller: type == 'send' ? sendCompanyAddreddController : receiptCompanyAddressController,
|
|
|
textAlign: TextAlign.end,
|
|
|
decoration: InputDecoration(
|
|
|
border: InputBorder.none
|
|
|
@@ -650,10 +650,10 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
color: Color.fromRGBO(37, 102, 242, 1),
|
|
|
),
|
|
|
child: Center(
|
|
|
- child:Row(
|
|
|
+ child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: <Widget>[
|
|
|
- Offstage(
|
|
|
+ children: < Widget > [
|
|
|
+ Offstage(
|
|
|
offstage: submitStatus,
|
|
|
child: SizedBox(
|
|
|
width: ScreenUtil.getInstance().setWidth(45),
|
|
|
@@ -663,17 +663,14 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
),
|
|
|
Text("提交", style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(32), color: Colors.white), ),
|
|
|
],
|
|
|
- )
|
|
|
+ )
|
|
|
),
|
|
|
),
|
|
|
onTap: () {
|
|
|
- // if(!submitStatus){
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // setState(() {
|
|
|
- // submitStatus = false;
|
|
|
- // });
|
|
|
- String errStr ='';
|
|
|
+ if (!submitStatus) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String errStr = '';
|
|
|
print('sendCompanyId---${sendCompanyId}');
|
|
|
print('sendCompanyName---${sendCompanyName}');
|
|
|
print('sendCompanyPhone---${sendCompanyPhone}');
|
|
|
@@ -705,52 +702,56 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
print('goodsAgencyFund---${goodsAgencyFund}');
|
|
|
print('goodsFreight---${goodsFreight}');
|
|
|
print('memo---${memo}');
|
|
|
- return;
|
|
|
+
|
|
|
// if (!isChinaPhoneLegal(sendCompanyPhone)) {
|
|
|
-
|
|
|
+
|
|
|
// }
|
|
|
- if(sendCompanyPhone==''){
|
|
|
- errStr ='请填写发件电话';
|
|
|
+ if (sendCompanyPhone == '') {
|
|
|
+ errStr = '请填写发件电话';
|
|
|
}
|
|
|
- if(sendCompanyName==''){
|
|
|
+ if (sendCompanyName == '') {
|
|
|
errStr = '请填写发件企业名称';
|
|
|
}
|
|
|
- if(sendCompanyProvinceName==''){
|
|
|
- errStr ='请填写发件城市/区域';
|
|
|
+ if (sendCompanyProvinceName == '') {
|
|
|
+ errStr = '请填写发件城市/区域';
|
|
|
}
|
|
|
- if(sendCompanyAddress==''){
|
|
|
- errStr ='请填写发件详细地址';
|
|
|
+ if (sendCompanyAddress == '') {
|
|
|
+ errStr = '请填写发件详细地址';
|
|
|
}
|
|
|
- if(receiptCompanyPhone==''){
|
|
|
- errStr='请填写收件电话';
|
|
|
+ if (receiptCompanyPhone == '') {
|
|
|
+ errStr = '请填写收件电话';
|
|
|
}
|
|
|
- if(receiptCompanyName==''){
|
|
|
- errStr='请填写收件企业名称';
|
|
|
+ if (receiptCompanyName == '') {
|
|
|
+ errStr = '请填写收件企业名称';
|
|
|
}
|
|
|
- if(receiptCompanyProvinceName==''){
|
|
|
- errStr ='请填写收件城市/区域';
|
|
|
+ if (receiptCompanyProvinceName == '') {
|
|
|
+ errStr = '请填写收件城市/区域';
|
|
|
}
|
|
|
- if(receiptCompanyAddress==''){
|
|
|
- errStr ='请填写收件详细地址';
|
|
|
+ if (receiptCompanyAddress == '') {
|
|
|
+ errStr = '请填写收件详细地址';
|
|
|
}
|
|
|
- if(goods==''){
|
|
|
- errStr ='请填写货物名称';
|
|
|
+ if (goods == '') {
|
|
|
+ errStr = '请填写货物名称';
|
|
|
}
|
|
|
- if(goodsQuantity==0.0){
|
|
|
- errStr ='请填写货物数量';
|
|
|
+ if (goodsQuantity == 0.0) {
|
|
|
+ errStr = '请填写货物数量';
|
|
|
}
|
|
|
- if(goodsFreight==0.0){
|
|
|
+ if (goodsFreight == 0.0) {
|
|
|
errStr = '请填写运费';
|
|
|
}
|
|
|
- if(errStr!=''){
|
|
|
+ if (errStr != '') {
|
|
|
showError(errStr);
|
|
|
+ return;
|
|
|
}
|
|
|
+ setState(() {
|
|
|
+ submitStatus = false;
|
|
|
+ });
|
|
|
createOrder(
|
|
|
- sendCompanyId??"",//寄件公司Id
|
|
|
- sendCompanyName,//寄件公司名称 不能为空
|
|
|
- sendCompanyPhone,//寄件公司电话 不能为空
|
|
|
- sendCompanyCode??'',//寄件公司编码
|
|
|
- sendCompanyProvinceName,//寄件公司省名称 不能为空
|
|
|
+ sendCompanyId ?? "", //寄件公司Id
|
|
|
+ sendCompanyName, //寄件公司名称 不能为空
|
|
|
+ sendCompanyPhone, //寄件公司电话 不能为空
|
|
|
+ sendCompanyCode ?? '', //寄件公司编码
|
|
|
+ sendCompanyProvinceName, //寄件公司省名称 不能为空
|
|
|
sendCompanyProvinceCode, //寄件公司省编码 不能为空
|
|
|
sendCompanyCityName, //寄件公司市名称 不能为空
|
|
|
sendCompanyCityCode, //寄件公司市编码 不能为空
|
|
|
@@ -758,41 +759,50 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
sendCompanyAreaCode, //寄件公司区编码 不能为空
|
|
|
sendCompanyAddress, //寄件公司详细地址,不能为空
|
|
|
receiptCompanyId, //收件公司id
|
|
|
- receiptCompanyPhone,//收件公司电话 不能为空
|
|
|
+ receiptCompanyPhone, //收件公司电话 不能为空
|
|
|
receiptCompanyName, //收件公司名称 不能为空
|
|
|
- receiptCompanyProvinceName,//收件公司省名称 不能为空
|
|
|
+ receiptCompanyProvinceName, //收件公司省名称 不能为空
|
|
|
receiptCompanyProvinceCode, //收件公司省编码 不能为空
|
|
|
receiptCompanyCityName, //收件公司市名称 不能为空
|
|
|
receiptCompanyCityCode, //收件公市编码 不能为空
|
|
|
- receiptCompanyAreaName,//收件公区名称 不能为空
|
|
|
+ receiptCompanyAreaName, //收件公区名称 不能为空
|
|
|
receiptCompanyAreaCode, //收件公司区编码 不能为空
|
|
|
receiptCompanyAddress, //收件公司地址详情 不能为空
|
|
|
goods, //商品名称 不能为空
|
|
|
goodsQuantity, //商品数量 不能为空
|
|
|
- goodsPackingId,//商品包装ID
|
|
|
+ goodsPackingId, //商品包装ID
|
|
|
goodsCategoryId, //商品类别ID
|
|
|
goodsPaymentMethod, //付款方式 1,现付 2 到付
|
|
|
goodsWeight, //商品重量
|
|
|
- goodsPriceProtection*100, //商品保价,已分为单位
|
|
|
- goodsAgencyFund*100, //商品代收款,已分为单位
|
|
|
- goodsFreight*100,//商品运费 不能为空 ,已分为单位
|
|
|
- memo,//备注
|
|
|
- ).then((resp){
|
|
|
- if(isNotError(context, resp)){
|
|
|
- setState(() {
|
|
|
+ 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( //调用对话框
|
|
|
- childCallback: (val) {
|
|
|
- if(!val){
|
|
|
- //跳转
|
|
|
- }
|
|
|
- },
|
|
|
- );
|
|
|
+ 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 = false;
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
@@ -800,7 +810,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- showError(String str){
|
|
|
+ showError(String str) {
|
|
|
showDialog < Null > (
|
|
|
context: context, //BuildContext对象
|
|
|
barrierDismissible: false,
|
|
|
@@ -908,7 +918,7 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
//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, )
|
|
|
+ child: Text(key == '包装类型' ? showTextGoodsPackage : key == '商品类型' ? showTextGoodsCategory : showTextPaymentMehod, textAlign: TextAlign.end, )
|
|
|
),
|
|
|
Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1), )
|
|
|
],
|
|
|
@@ -933,17 +943,17 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
}
|
|
|
|
|
|
showPickerModal(BuildContext context, String type) {
|
|
|
- List<dynamic> data = [];
|
|
|
- if(type=='包装类型'){
|
|
|
- for(int i=0;i<goodsPackageList.length;i++){
|
|
|
+ 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++){
|
|
|
+ } else if (type == '商品类型') {
|
|
|
+ for (int i = 0; i < goodsCateGoryList.length; i++) {
|
|
|
data.add(goodsCateGoryList[i].name);
|
|
|
}
|
|
|
- }else if(type=='付款方式'){
|
|
|
- data = ['现付','到付'];
|
|
|
+ } else if (type == '付款方式') {
|
|
|
+ data = ['现付', '到付'];
|
|
|
}
|
|
|
new Picker(
|
|
|
adapter: PickerDataAdapter < String > (pickerdata: data),
|
|
|
@@ -958,21 +968,21 @@ class _SendExpressPageState extends State < SendExpressPage > with AutomaticKeep
|
|
|
changeToFirst: true,
|
|
|
hideHeader: false,
|
|
|
onConfirm: (Picker picker, List value) {
|
|
|
- if(type=='包装类型'){
|
|
|
+ if (type == '包装类型') {
|
|
|
setState(() {
|
|
|
- showTextGoodsPackage =goodsPackageList[value[0]].name;
|
|
|
+ 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;
|
|
|
- }
|
|
|
+ } 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);
|