From ea9190ab5a67bc8584de8fb31bfefdf17d2611b0 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 28 Jan 2021 13:43:47 +0800 Subject: [PATCH 1/4] add moving company select page update deto create page --- lib/constants/api.dart | 4 + lib/model/manager/moving_company_model.dart | 42 ++++++ .../deto_create_page/deto_create_page.dart | 100 +++++++++----- .../deto_create_page/widget/common_radio.dart | 12 +- .../select_move_company_page.dart | 123 ++++++++++++++++++ lib/pages/manager_func.dart | 12 +- lib/pages/personal/personal_page.dart | 2 +- .../widget/add_fixed_submit_page.dart | 2 +- 8 files changed, 255 insertions(+), 42 deletions(-) create mode 100644 lib/model/manager/moving_company_model.dart create mode 100644 lib/pages/goods_deto_page/select_move_company_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 5e35bae5..6a645430 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -114,8 +114,12 @@ class _Manager { /// 报事报修:确认完成订单 String get reportRepairComplete => '/user/reportRepair/completeOrder'; + ///报事报修:用户评价 String get reportRepairEvaluate => '/user/reportRepair/evaluate'; + + ///物品出户:获取搬家公司手机号 + String get getMovingCompanyTel => '/user/articleOut/getMovingCompanyTel'; } class _Upload { diff --git a/lib/model/manager/moving_company_model.dart b/lib/model/manager/moving_company_model.dart new file mode 100644 index 00000000..561d8b15 --- /dev/null +++ b/lib/model/manager/moving_company_model.dart @@ -0,0 +1,42 @@ +class MovingCompanyModel { + List appMovingCompanyVoList; + + MovingCompanyModel({this.appMovingCompanyVoList}); + + MovingCompanyModel.fromJson(Map json) { + if (json['appMovingCompanyVoList'] != null) { + appMovingCompanyVoList = new List(); + json['appMovingCompanyVoList'].forEach((v) { + appMovingCompanyVoList.add(new AppMovingCompanyVoList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.appMovingCompanyVoList != null) { + data['appMovingCompanyVoList'] = + this.appMovingCompanyVoList.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class AppMovingCompanyVoList { + String name; + String tel; + + AppMovingCompanyVoList({this.name, this.tel}); + + AppMovingCompanyVoList.fromJson(Map json) { + name = json['name']; + tel = json['tel']; + } + + Map toJson() { + final Map data = new Map(); + data['name'] = this.name; + data['tel'] = this.tel; + return data; + } +} diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index b9f2401d..9ff838f3 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -4,6 +4,7 @@ import 'dart:io'; // Flutter imports: +import 'package:akuCommunity/pages/goods_deto_page/select_move_company_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -130,34 +131,34 @@ class _DetoCreatePageState extends State { ); } - Widget _inkWellCheckbox() { - return InkWell( - child: Container( - padding: EdgeInsets.only(bottom: 24.w), - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - BeeCheckBox( - onChange: (value) { - needMoveCompany = value; - }, - ), - 10.w.widthBox, - Container( - child: Text( - '是否需要物业提供搬家公司联系方式', - style: TextStyle( - fontSize: 28.sp, - color: Color(0xff333333), - ), - ), - ), - ], - ), - ), - ); - } + // Widget _inkWellCheckbox() { + // return InkWell( + // child: Container( + // padding: EdgeInsets.only(bottom: 24.w), + // child: Row( + // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // BeeCheckBox( + // onChange: (value) { + // needMoveCompany = value; + // }, + // ), + // 10.w.widthBox, + // Container( + // child: Text( + // '是否需要物业提供搬家公司联系方式', + // style: TextStyle( + // fontSize: 28.sp, + // color: Color(0xff333333), + // ), + // ), + // ), + // ], + // ), + // ), + // ); + // } Widget _getWeight() { return Container( @@ -241,6 +242,7 @@ class _DetoCreatePageState extends State { .toList() ], ), + 20.w.heightBox, ], ), ); @@ -340,6 +342,39 @@ class _DetoCreatePageState extends State { setState(() {}); } + Widget _getMovingCompany(String movingCompany) { + return Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + '搬家公司信息'.text.color(ktextPrimary).size(28.sp).make(), + 16.w.heightBox, + InkWell( + onTap: () { + SelectMoveCompanyPage().to(); + }, + child: Padding( + padding: EdgeInsets.symmetric(vertical: 30.w), + child: Row( + children: [ + (movingCompany.isEmptyOrNull ? '请选择搬家公司' : movingCompany) + .text + .color(ktextSubColor) + .size(36.sp) + .bold + .make(), + Spacer(), + Icon(CupertinoIcons.chevron_right, size: 30.w), + ], + ), + ), + ), + BeeDivider.horizontal(), + ], + ), + ); + } + @override Widget build(BuildContext context) { return BeeScaffold( @@ -359,7 +394,7 @@ class _DetoCreatePageState extends State { _showItmePicker(); }), _getApproach(), - _selectApproach == 0 ? SizedBox() : _inkWellCheckbox(), + _selectApproach == 0 ? SizedBox() : _getMovingCompany(''), Container( margin: EdgeInsets.only(top: 54.w, bottom: 24.w), child: Text( @@ -381,11 +416,6 @@ class _DetoCreatePageState extends State { onPressed: () {}, ), ); - // Positioned( - // bottom: 0, - // child: BottomButton(title: '确认提交'), - // ) - // ], - // ), + // } } diff --git a/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart b/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart index b9aceab2..9cf8f612 100644 --- a/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart +++ b/lib/pages/goods_deto_page/deto_create_page/widget/common_radio.dart @@ -36,7 +36,7 @@ class _CommonRadioState extends State { color: _selected ? kPrimaryColor : Color(0xFF979797), width: 3.w, ), - borderRadius: BorderRadius.circular(20.w), + borderRadius: BorderRadius.circular(widget.size??20.w), ), duration: Duration(milliseconds: 300), curve: Curves.easeInOutCubic, @@ -58,9 +58,13 @@ class _CommonRadioState extends State { ), ), ), - 10.w.widthBox, - widget.text, - 10.w.widthBox, + ...widget.text == null + ? [SizedBox()] + : [ + 10.w.widthBox, + widget.text, + 10.w.widthBox, + ] ], ); } diff --git a/lib/pages/goods_deto_page/select_move_company_page.dart b/lib/pages/goods_deto_page/select_move_company_page.dart new file mode 100644 index 00000000..4a43f9f1 --- /dev/null +++ b/lib/pages/goods_deto_page/select_move_company_page.dart @@ -0,0 +1,123 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/model/manager/moving_company_model.dart'; +import 'package:akuCommunity/pages/goods_deto_page/deto_create_page/widget/common_radio.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/widget/bee_divider.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class SelectMoveCompanyPage extends StatefulWidget { + SelectMoveCompanyPage({Key key}) : super(key: key); + + @override + _SelectMoveCompanyPageState createState() => _SelectMoveCompanyPageState(); +} + +class _SelectMoveCompanyPageState extends State { + int _selected; + MovingCompanyModel _companyModel; + + Widget _buildCard(int index, String name, String tel) { + return Container( + padding: EdgeInsets.symmetric(vertical: 28.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + _selected = index; + setState(() {}); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + child: CommonRadio( + size: 32.w, + value: index, + groupValue: _selected, + ), + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + name.text.color(ktextPrimary).size(28.sp).bold.make(), + 20.w.heightBox, + Row( + children: [ + Icon( + CupertinoIcons.phone_arrow_up_right, + size: 40.w, + color: kDarkSubColor, + ), + 8.w.widthBox, + '电话:$tel' + .text + .color(Color(0xFF999999)) + .size(24.sp) + .bold + .make(), + ], + ), + ], + ).expand(), + ], + ), + ); + } + + Widget _buildForself(int index) { + return Container( + padding: EdgeInsets.symmetric(vertical: 28.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { + _selected = index; + setState(() {}); + }, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), + child: CommonRadio( + size: 32.w, + value: index, + groupValue: _selected, + ), + ), + ), + '自己联系'.text.color(ktextPrimary).size(28.sp).bold.make() + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '搬家公司', + body: EasyRefresh( + onRefresh: () async { + _companyModel = await ManagerFunc.getMovingCompanyTel(); + }, + header: MaterialHeader(), + child: ListView( + padding: EdgeInsets.all(32.w), + children: [ + ..._companyModel.appMovingCompanyVoList + .map((e) => _buildCard( + _companyModel.appMovingCompanyVoList.indexOf(e), + e.name, + e.tel)) + .toList(), + _buildForself( + _companyModel.appMovingCompanyVoList.length + ) + ].sepWidget(separate: BeeDivider.horizontal()), + ), + ), + ); + } +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 04a32c52..004708b9 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,4 +1,5 @@ // Package imports: +import 'package:akuCommunity/model/manager/moving_company_model.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; @@ -27,10 +28,11 @@ class ManagerFunc { } static reportRepairInsert( - int type, String reportDetail, List fileUrls) async { + int id, int type, String reportDetail, List fileUrls) async { BaseModel baseModel = await NetUtil().post( API.manager.reportRepairInsert, params: { + 'buildingUnitEstateld': id, 'type': type, 'reportDetail': reportDetail, 'fileUrls': fileUrls, @@ -92,4 +94,12 @@ class ManagerFunc { ); return baseModel; } + + static Future getMovingCompanyTel() async { + BaseModel baseModel = await NetUtil().get( + API.manager.getMovingCompanyTel, + showMessage: false, + ); + return MovingCompanyModel.fromJson(baseModel.data); + } } diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index 89c47821..1d950994 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -129,7 +129,7 @@ class _PersonalIndexState extends State //TODO PLACEHOLDER placeholder: R.ASSETS_ICONS_PROPOSAL_PNG, image: API - .image(userProvider.userInfoModel.imgUrl), + .image(userProvider?.userInfoModel?.imgUrl), height: 106.w, width: 106.w, ), diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 8195fe3b..f79250e4 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -229,7 +229,7 @@ class _AddFixedSubmitPageState extends State { ? () async { List urls = await NetUtil() .uploadFiles(_files, API.upload.uploadRepair); - BaseModel baseModel = await ManagerFunc.reportRepairInsert( + BaseModel baseModel = await ManagerFunc.reportRepairInsert(userProvider.userDetailModel.id, _selectType + 1, _textEditingController.text, urls); if (baseModel.status) { FinishFixedSubmitPage().to(); From 505e61e10d92359c98c0495e8b530d693a2b9a06 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 28 Jan 2021 14:38:05 +0800 Subject: [PATCH 2/4] =?UTF-8?q?update=20=E6=8A=A5=E4=BA=8B=E6=8A=A5?= =?UTF-8?q?=E4=BF=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/manager_func.dart | 2 +- .../widget/add_fixed_submit_page.dart | 47 ++++++++----------- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 004708b9..40e5f3b0 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -32,7 +32,7 @@ class ManagerFunc { BaseModel baseModel = await NetUtil().post( API.manager.reportRepairInsert, params: { - 'buildingUnitEstateld': id, + 'buildingUnitEstateId': id, 'type': type, 'reportDetail': reportDetail, 'fileUrls': fileUrls, diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 22740739..3947d1e4 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -161,7 +161,9 @@ class _AddFixedSubmitPageState extends State { width: 686.w, child: TextField( controller: _textEditingController, - onEditingComplete: () {}, + onChanged: (value) { + setState(() {}); + }, maxLines: 10, minLines: 5, decoration: InputDecoration( @@ -204,6 +206,15 @@ class _AddFixedSubmitPageState extends State { } } + int _getBuildUnitEstateNameId(String estateName) { + int a = int.parse(estateName.split('|')[0]); + return a; + } + + String _getEstateName(String estateNmae) { + return estateNmae.split('|')[1]; + } + @override Widget build(BuildContext context) { UserProvider userProvider = Provider.of(context); @@ -217,37 +228,13 @@ class _AddFixedSubmitPageState extends State { kEstateName, userProvider.userDetailModel.estateNames.isEmpty ? '' - : userProvider.userDetailModel.estateNames[0]), + : _getEstateName( + userProvider.userDetailModel.estateNames[0])), _getType(), _buildReportCard(), _addImages(), ], ).expand(), - MaterialButton( - minWidth: double.infinity, - height: 98.w, - onPressed: _canSubmit(_selectType, _textEditingController.text) - ? () async { - List urls = await NetUtil() - .uploadFiles(_files, API.upload.uploadRepair); - BaseModel baseModel = await ManagerFunc.reportRepairInsert(userProvider.userDetailModel.id, - _selectType + 1, _textEditingController.text, urls); - if (baseModel.status) { - FinishFixedSubmitPage().to(); - } else - BotToast.showText(text: baseModel.message); - } - : () { - BotToast.showText(text: '请填写完整报修信息!'); - }, - child: '确认提交'.text.black.bold.size(32.sp).make(), - color: kPrimaryColor, - elevation: 0, - ) - .box - .padding(EdgeInsets.only( - bottom: MediaQuery.of(context).padding.bottom)) - .make() ], ), bottomNavi: BottomButton( @@ -256,7 +243,11 @@ class _AddFixedSubmitPageState extends State { List urls = await NetUtil() .uploadFiles(_files, API.upload.uploadRepair); BaseModel baseModel = await ManagerFunc.reportRepairInsert( - _selectType + 1, _textEditingController.text, urls); + _getBuildUnitEstateNameId( + userProvider.userDetailModel.estateNames[0]), + _selectType + 1, + _textEditingController.text, + urls); if (baseModel.status) { FinishFixedSubmitPage().to(); } else From 4c93484e58b7fd9262117a735af7711499707dba Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 28 Jan 2021 15:09:28 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9A=E8=8E=B7=E5=8F=96=E6=90=AC=E5=AE=B6=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E7=94=B5=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../select_move_company_page.dart | 49 +++++++++++++------ lib/pages/manager_func.dart | 5 +- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/lib/pages/goods_deto_page/select_move_company_page.dart b/lib/pages/goods_deto_page/select_move_company_page.dart index 4a43f9f1..cc10ee1b 100644 --- a/lib/pages/goods_deto_page/select_move_company_page.dart +++ b/lib/pages/goods_deto_page/select_move_company_page.dart @@ -19,6 +19,19 @@ class SelectMoveCompanyPage extends StatefulWidget { class _SelectMoveCompanyPageState extends State { int _selected; MovingCompanyModel _companyModel; + EasyRefreshController _controller; + bool _onloading = true; + @override + void initState() { + super.initState(); + _controller = EasyRefreshController(); + } + + @override + void dispose() { + _controller = EasyRefreshController(); + super.dispose(); + } Widget _buildCard(int index, String name, String tel) { return Container( @@ -94,29 +107,37 @@ class _SelectMoveCompanyPageState extends State { ); } + Widget _emptyWidget() { + return Container(); + } + @override Widget build(BuildContext context) { return BeeScaffold( title: '搬家公司', body: EasyRefresh( + firstRefresh: true, + controller: _controller, onRefresh: () async { _companyModel = await ManagerFunc.getMovingCompanyTel(); + _onloading = false; + setState(() {}); }, header: MaterialHeader(), - child: ListView( - padding: EdgeInsets.all(32.w), - children: [ - ..._companyModel.appMovingCompanyVoList - .map((e) => _buildCard( - _companyModel.appMovingCompanyVoList.indexOf(e), - e.name, - e.tel)) - .toList(), - _buildForself( - _companyModel.appMovingCompanyVoList.length - ) - ].sepWidget(separate: BeeDivider.horizontal()), - ), + child: _onloading + ? _emptyWidget() + : ListView( + padding: EdgeInsets.all(32.w), + children: [ + ..._companyModel.appMovingCompanyVoList + .map((e) => _buildCard( + _companyModel.appMovingCompanyVoList.indexOf(e), + e.name, + e.tel)) + .toList(), + _buildForself(_companyModel.appMovingCompanyVoList.length) + ].sepWidget(separate: BeeDivider.horizontal()), + ), ), ); } diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 40e5f3b0..f6ace3cf 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -96,10 +96,9 @@ class ManagerFunc { } static Future getMovingCompanyTel() async { - BaseModel baseModel = await NetUtil().get( + Response response= await NetUtil().dio.get( API.manager.getMovingCompanyTel, - showMessage: false, ); - return MovingCompanyModel.fromJson(baseModel.data); + return MovingCompanyModel.fromJson(response.data); } } From e3eb91d6d6a862063f7f5913c1413cba25dad006 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 28 Jan 2021 17:58:23 +0800 Subject: [PATCH 4/4] =?UTF-8?q?finish=20deto=20create=20page=20=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E6=8E=A5=E5=8F=A3=EF=BC=9A=E6=8F=90=E4=BA=A4=E7=89=A9?= =?UTF-8?q?=E5=93=81=E5=87=BA=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 3 + .../deto_create_page/deto_create_page.dart | 69 +++++++--- .../select_move_company_page.dart | 121 ++++++++++-------- lib/pages/manager_func.dart | 31 ++++- .../widget/add_fixed_submit_page.dart | 14 +- lib/utils/bee_parse.dart | 9 ++ 6 files changed, 168 insertions(+), 79 deletions(-) create mode 100644 lib/utils/bee_parse.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 0afdb293..15c1bbc7 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -121,6 +121,9 @@ class _Manager { ///物品出户:获取搬家公司手机号 String get getMovingCompanyTel => '/user/articleOut/getMovingCompanyTel'; + + ///物品出户:提交物品出户信息 + String get articleOutSubmit => '/user/articleOut/submit'; } class _Community { diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index 9ff838f3..119b1a6d 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -4,7 +4,13 @@ import 'dart:io'; // Flutter imports: +import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/pages/goods_deto_page/select_move_company_page.dart'; +import 'package:akuCommunity/pages/manager_func.dart'; +import 'package:akuCommunity/utils/bee_parse.dart'; +import 'package:akuCommunity/utils/network/base_model.dart'; +import 'package:akuCommunity/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -20,15 +26,10 @@ import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; -import 'package:akuCommunity/widget/buttons/bee_check_box.dart'; import 'package:akuCommunity/widget/buttons/bee_check_button.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; -import 'package:akuCommunity/widget/buttons/radio_button.dart'; -import 'package:akuCommunity/widget/picker/bee_custom_picker.dart'; import 'package:akuCommunity/widget/picker/bee_date_picker.dart'; import 'package:akuCommunity/widget/picker/grid_image_picker.dart'; -import 'widget/common_picker.dart'; -import 'widget/common_radio.dart'; class DetoCreatePage extends StatefulWidget { DetoCreatePage({Key key}) : super(key: key); @@ -40,15 +41,12 @@ class DetoCreatePage extends StatefulWidget { class _DetoCreatePageState extends State { List _files = []; UserProvider get userProvider => Provider.of(context); - String get firstEstateName { - return userProvider.userDetailModel.estateNames.isEmpty - ? '' - : userProvider.userDetailModel.estateNames[0]; - } String _itemName; DateTime _date; + String get datetime=>DateUtil.formatDate(_date, format: "yyyy-MM-dd HH:mm:ss"); int _selectWeight; + String _selectTel; List _listWeight = [ '< 50kg', '50kg-100kg', @@ -350,8 +348,8 @@ class _DetoCreatePageState extends State { '搬家公司信息'.text.color(ktextPrimary).size(28.sp).make(), 16.w.heightBox, InkWell( - onTap: () { - SelectMoveCompanyPage().to(); + onTap: () async { + _selectTel = await SelectMoveCompanyPage().to(); }, child: Padding( padding: EdgeInsets.symmetric(vertical: 30.w), @@ -375,17 +373,37 @@ class _DetoCreatePageState extends State { ); } + bool _canSubmit(int weight, int approach, DateTime dateTime, String item) { + if (weight == null) { + return false; + } else if (approach == null) { + return false; + } else if (dateTime == null) { + return false; + } else if (item.isEmptyOrNull) { + return false; + } else { + return true; + } + } + @override Widget build(BuildContext context) { + UserProvider userProvider = Provider.of(context); return BeeScaffold( title: '物品出户', body: ListView( padding: EdgeInsets.all(32.w), children: [ - _houseAddress(kEstateName, firstEstateName), + _houseAddress( + kEstateName, + userProvider.userDetailModel.estateNames.isEmpty + ? '' + : BeeParse.getEstateName( + userProvider.userDetailModel.estateNames[0])), _getWeight(), _itemPicker( - '出户时间', DateUtil.formatDate(_date, format: "yyyy-MM-dd HH:mm:ss"), + '出户时间', datetime, () async { _date = await BeeDatePicker.timePicker(DateTime.now()); setState(() {}); @@ -413,7 +431,28 @@ class _DetoCreatePageState extends State { ), bottomNavi: BottomButton( child: '确认提交'.text.color(ktextPrimary).bold.make(), - onPressed: () {}, + onPressed: _canSubmit(_selectWeight, _selectApproach, _date, _itemName) + ? () async { + List urls = await NetUtil() + .uploadFiles(_files, API.upload.uploadRepair); + BaseModel baseModel = await ManagerFunc.articleOutSubmit( + id: BeeParse.getEstateNameId( + userProvider.userDetailModel.estateNames[0]), + name: _itemName, + weight: _selectWeight + 1, + approach: _selectApproach + 1, + tel: _selectTel, + time: datetime, + urls: urls, + ); + if (baseModel.status) { + Get.back(); + } else + BotToast.showText(text: baseModel.message); + } + : () { + BotToast.showText(text: '请填写完整物品出户信息!'); + }, ), ); // diff --git a/lib/pages/goods_deto_page/select_move_company_page.dart b/lib/pages/goods_deto_page/select_move_company_page.dart index cc10ee1b..4afae0c6 100644 --- a/lib/pages/goods_deto_page/select_move_company_page.dart +++ b/lib/pages/goods_deto_page/select_move_company_page.dart @@ -4,10 +4,13 @@ import 'package:akuCommunity/pages/goods_deto_page/deto_create_page/widget/commo import 'package:akuCommunity/pages/manager_func.dart'; import 'package:akuCommunity/widget/bee_divider.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; class SelectMoveCompanyPage extends StatefulWidget { SelectMoveCompanyPage({Key key}) : super(key: key); @@ -21,6 +24,14 @@ class _SelectMoveCompanyPageState extends State { MovingCompanyModel _companyModel; EasyRefreshController _controller; bool _onloading = true; + String get result { + if (_selected == _companyModel.appMovingCompanyVoList.length) { + return null; + } else { + return _companyModel.appMovingCompanyVoList[_selected].tel; + } + } + @override void initState() { super.initState(); @@ -34,17 +45,17 @@ class _SelectMoveCompanyPageState extends State { } Widget _buildCard(int index, String name, String tel) { - return Container( - padding: EdgeInsets.symmetric(vertical: 28.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - _selected = index; - setState(() {}); - }, - child: Padding( + return GestureDetector( + onTap: () { + _selected = index; + setState(() {}); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 28.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), child: CommonRadio( size: 32.w, @@ -52,47 +63,47 @@ class _SelectMoveCompanyPageState extends State { groupValue: _selected, ), ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - name.text.color(ktextPrimary).size(28.sp).bold.make(), - 20.w.heightBox, - Row( - children: [ - Icon( - CupertinoIcons.phone_arrow_up_right, - size: 40.w, - color: kDarkSubColor, - ), - 8.w.widthBox, - '电话:$tel' - .text - .color(Color(0xFF999999)) - .size(24.sp) - .bold - .make(), - ], - ), - ], - ).expand(), - ], + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + name.text.color(ktextPrimary).size(28.sp).bold.make(), + 20.w.heightBox, + Row( + children: [ + Icon( + CupertinoIcons.phone_arrow_up_right, + size: 40.w, + color: kDarkSubColor, + ), + 8.w.widthBox, + '电话:$tel' + .text + .color(Color(0xFF999999)) + .size(24.sp) + .bold + .make(), + ], + ), + ], + ).expand(), + ], + ), ), ); } Widget _buildForself(int index) { - return Container( - padding: EdgeInsets.symmetric(vertical: 28.w), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - _selected = index; - setState(() {}); - }, - child: Padding( + return GestureDetector( + onTap: () { + _selected = index; + setState(() {}); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 28.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.w), child: CommonRadio( size: 32.w, @@ -100,9 +111,9 @@ class _SelectMoveCompanyPageState extends State { groupValue: _selected, ), ), - ), - '自己联系'.text.color(ktextPrimary).size(28.sp).bold.make() - ], + '自己联系'.text.color(ktextPrimary).size(28.sp).bold.make() + ], + ), ), ); } @@ -139,6 +150,16 @@ class _SelectMoveCompanyPageState extends State { ].sepWidget(separate: BeeDivider.horizontal()), ), ), + bottomNavi: BottomButton( + child: '确定'.text.color(ktextPrimary).size(32.sp).bold.make(), + onPressed: () { + if (_selected == null) { + BotToast.showText(text: '请选择搬家公司!'); + } else { + Get.back(result: result); + } + }, + ), ); } } diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index f6ace3cf..a67718e0 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -96,9 +96,34 @@ class ManagerFunc { } static Future getMovingCompanyTel() async { - Response response= await NetUtil().dio.get( - API.manager.getMovingCompanyTel, - ); + Response response = await NetUtil().dio.get( + API.manager.getMovingCompanyTel, + ); return MovingCompanyModel.fromJson(response.data); } + + static Future articleOutSubmit({ + int id, + String name, + int weight, + int approach, + String tel, + String time, + List urls, + }) async { + BaseModel baseModel = await NetUtil().post( + API.manager.articleOutSubmit, + params: { + 'buildingUnitEstateId': id, + 'name': name, + 'weight': weight, + 'approach': approach, + 'movingCompanyTel': tel, + 'expectedTime': DateUtil.formatDateStr(time,format: "yyyy-MM-dd HH:mm:ss"), + 'imgUrls': urls, + }, + showMessage: true, + ); + return baseModel; + } } diff --git a/lib/pages/things_page/widget/add_fixed_submit_page.dart b/lib/pages/things_page/widget/add_fixed_submit_page.dart index 3947d1e4..aa48d944 100644 --- a/lib/pages/things_page/widget/add_fixed_submit_page.dart +++ b/lib/pages/things_page/widget/add_fixed_submit_page.dart @@ -2,6 +2,7 @@ import 'dart:io'; // Flutter imports: +import 'package:akuCommunity/utils/bee_parse.dart'; import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -206,15 +207,6 @@ class _AddFixedSubmitPageState extends State { } } - int _getBuildUnitEstateNameId(String estateName) { - int a = int.parse(estateName.split('|')[0]); - return a; - } - - String _getEstateName(String estateNmae) { - return estateNmae.split('|')[1]; - } - @override Widget build(BuildContext context) { UserProvider userProvider = Provider.of(context); @@ -228,7 +220,7 @@ class _AddFixedSubmitPageState extends State { kEstateName, userProvider.userDetailModel.estateNames.isEmpty ? '' - : _getEstateName( + : BeeParse.getEstateName( userProvider.userDetailModel.estateNames[0])), _getType(), _buildReportCard(), @@ -243,7 +235,7 @@ class _AddFixedSubmitPageState extends State { List urls = await NetUtil() .uploadFiles(_files, API.upload.uploadRepair); BaseModel baseModel = await ManagerFunc.reportRepairInsert( - _getBuildUnitEstateNameId( + BeeParse.getEstateNameId( userProvider.userDetailModel.estateNames[0]), _selectType + 1, _textEditingController.text, diff --git a/lib/utils/bee_parse.dart b/lib/utils/bee_parse.dart new file mode 100644 index 00000000..655d9343 --- /dev/null +++ b/lib/utils/bee_parse.dart @@ -0,0 +1,9 @@ +class BeeParse{ + static int getEstateNameId(String estateName) { + int a = int.parse(estateName.split('|')[0]); + return a; + } + static String getEstateName(String estateNmae) { + return estateNmae.split('|')[1]; + } +} \ No newline at end of file