From c5feb7e9b72566c2209dc604ec25b769399b7ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com> Date: Wed, 20 Apr 2022 20:39:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=BF=E6=B0=91=E7=94=B5=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/user/convenient_phone_model.dart | 21 ----- .../convenience_phone_model.dart | 26 ++++++ .../convenience_phone_model.g.dart | 16 ++++ .../convenient_phone_page.dart | 80 ++++++++++--------- .../personal/wallet/balance_record_view.dart | 3 + .../personal/wallet/point_record_view.dart | 6 +- lib/utils/application_utils.dart | 4 - 7 files changed, 92 insertions(+), 64 deletions(-) delete mode 100644 lib/model/user/convenient_phone_model.dart create mode 100644 lib/models/convenience_phone/convenience_phone_model.dart create mode 100644 lib/models/convenience_phone/convenience_phone_model.g.dart diff --git a/lib/model/user/convenient_phone_model.dart b/lib/model/user/convenient_phone_model.dart deleted file mode 100644 index dd99cf34..00000000 --- a/lib/model/user/convenient_phone_model.dart +++ /dev/null @@ -1,21 +0,0 @@ -class ConvenientPhoneModel { - int? id; - String? name; - String? tel; - - ConvenientPhoneModel({this.id, this.name, this.tel}); - - ConvenientPhoneModel.fromJson(Map json) { - id = json['id']; - name = json['name']; - tel = json['tel']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['name'] = this.name; - data['tel'] = this.tel; - return data; - } -} diff --git a/lib/models/convenience_phone/convenience_phone_model.dart b/lib/models/convenience_phone/convenience_phone_model.dart new file mode 100644 index 00000000..a0288753 --- /dev/null +++ b/lib/models/convenience_phone/convenience_phone_model.dart @@ -0,0 +1,26 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:equatable/equatable.dart'; + +part 'convenience_phone_model.g.dart'; + + +@JsonSerializable() +class ConveniencePhoneModel extends Equatable { + final int id; + final String name; + final String tel; + final int type; + + factory ConveniencePhoneModel.fromJson(Map json) => + _$ConveniencePhoneModelFromJson(json); + + const ConveniencePhoneModel({ + required this.id, + required this.name, + required this.tel, + required this.type, + }); + + @override + List get props => [id, name, tel, type,]; +} \ No newline at end of file diff --git a/lib/models/convenience_phone/convenience_phone_model.g.dart b/lib/models/convenience_phone/convenience_phone_model.g.dart new file mode 100644 index 00000000..e09ab5c1 --- /dev/null +++ b/lib/models/convenience_phone/convenience_phone_model.g.dart @@ -0,0 +1,16 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'convenience_phone_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ConveniencePhoneModel _$ConveniencePhoneModelFromJson( + Map json) => + ConveniencePhoneModel( + id: json['id'] as int, + name: json['name'] as String, + tel: json['tel'] as String, + type: json['type'] as int, + ); diff --git a/lib/pages/convenient_phone/convenient_phone_page.dart b/lib/pages/convenient_phone/convenient_phone_page.dart index 0e954537..6c03a7ed 100644 --- a/lib/pages/convenient_phone/convenient_phone_page.dart +++ b/lib/pages/convenient_phone/convenient_phone_page.dart @@ -1,7 +1,7 @@ import 'package:aku_new_community/const/resource.dart'; -import 'package:aku_new_community/constants/api.dart'; -import 'package:aku_new_community/model/user/convenient_phone_model.dart'; -import 'package:aku_new_community/pages/things_page/widget/bee_list_view.dart'; +import 'package:aku_new_community/constants/saas_api.dart'; +import 'package:aku_new_community/models/convenience_phone/convenience_phone_model.dart'; +import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -19,8 +19,10 @@ class ConvenientPhonePage extends StatefulWidget { } class _ConvenientPhonePageState extends State { - EasyRefreshController? _easyRefreshController; - TextEditingController? _textEditingController; + late EasyRefreshController _easyRefreshController; + late TextEditingController _textEditingController; + + List _models = []; @override void initState() { @@ -31,12 +33,12 @@ class _ConvenientPhonePageState extends State { @override void dispose() { - _easyRefreshController?.dispose(); - _textEditingController?.dispose(); + _easyRefreshController.dispose(); + _textEditingController.dispose(); super.dispose(); } - Widget _buildTile(ConvenientPhoneModel model) { + Widget _buildTile(ConveniencePhoneModel model) { return Column( children: [ Row( @@ -45,9 +47,9 @@ class _ConvenientPhonePageState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - model.name!.text.black.size(32.sp).make(), + model.name.text.black.size(32.sp).make(), 12.w.heightBox, - model.tel!.text.color(Color(0xFF999999)).size(28.sp).make(), + model.tel.text.color(Color(0xFF999999)).size(28.sp).make(), ], ).expand(), IconButton( @@ -58,7 +60,7 @@ class _ConvenientPhonePageState extends State { ), onPressed: () async { bool? result = await Get.dialog(CupertinoAlertDialog( - title: model.tel!.text.isIntrinsic.make(), + title: '是否拨打电话 ${model.tel}'.text.isIntrinsic.make(), actions: [ CupertinoDialogAction( child: '取消'.text.isIntrinsic.make(), @@ -99,8 +101,8 @@ class _ConvenientPhonePageState extends State { ), child: TextField( controller: _textEditingController, - onSubmitted: (value) { - _easyRefreshController!.callRefresh(); + onChanged: (value) { + _easyRefreshController.callRefresh(); setState(() {}); }, decoration: InputDecoration( @@ -119,32 +121,36 @@ class _ConvenientPhonePageState extends State { ), ), Expanded( - child: BeeListView( - extraParams: {'name': _textEditingController!.text}, + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), controller: _easyRefreshController, - path: API.manager.convenientPhone, - convert: (model) { - return model.rows - .map((e) => ConvenientPhoneModel.fromJson(e)) - .toList(); - }, - builder: (items) { - return ListView.separated( - padding: - EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), - itemBuilder: (context, index) { - return _buildTile(items[index]); - }, - separatorBuilder: (context, index) { - return Divider( - thickness: 1.w, - height: 40.w, - color: Color(0xFFD8D8D8), - ); - }, - itemCount: items.length, - ); + onRefresh: () async { + var base = + await NetUtil().get(SAASAPI.conveniencePhone.list, params: { + 'name': _textEditingController.text, + }); + if (base.success) { + _models = (base.data as List) + .map((e) => ConveniencePhoneModel.fromJson(e)) + .toList(); + } + setState(() {}); }, + child: ListView.separated( + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + itemBuilder: (context, index) { + return _buildTile(_models[index]); + }, + separatorBuilder: (context, index) { + return Divider( + thickness: 1.w, + height: 40.w, + color: Color(0xFFD8D8D8), + ); + }, + itemCount: _models.length, + ), ), ), ], diff --git a/lib/pages/personal/wallet/balance_record_view.dart b/lib/pages/personal/wallet/balance_record_view.dart index 019f7d05..0a3a4fe4 100644 --- a/lib/pages/personal/wallet/balance_record_view.dart +++ b/lib/pages/personal/wallet/balance_record_view.dart @@ -146,6 +146,8 @@ class _BalanceRecordViewState extends State { _models = baseList.rows .map((e) => TradeRecordListModel.fromJson(e)) .toList(); + + setState(() {}); }, onLoad: () async { _pageNum++; @@ -164,6 +166,7 @@ class _BalanceRecordViewState extends State { } else { _refreshController.finishLoad(noMore: true); } + setState(() {}); }, child: ListView( padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), diff --git a/lib/pages/personal/wallet/point_record_view.dart b/lib/pages/personal/wallet/point_record_view.dart index a5a38329..d3e8bf54 100644 --- a/lib/pages/personal/wallet/point_record_view.dart +++ b/lib/pages/personal/wallet/point_record_view.dart @@ -146,6 +146,7 @@ class _PointRecordViewState extends State { _models = baseList.rows .map((e) => TradeRecordListModel.fromJson(e)) .toList(); + setState(() {}); }, onLoad: () async { _pageNum++; @@ -164,6 +165,7 @@ class _PointRecordViewState extends State { } else { _refreshController.finishLoad(noMore: true); } + setState(() {}); }, child: ListView( padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), @@ -193,8 +195,8 @@ class _PointRecordViewState extends State { .text .size(28.sp) .color(incom(model.type) - ? Colors.red - : Colors.black.withOpacity(0.85)) + ? Colors.red + : Colors.black.withOpacity(0.85)) .make(), ], ), diff --git a/lib/utils/application_utils.dart b/lib/utils/application_utils.dart index df6f6d29..1d61f98a 100644 --- a/lib/utils/application_utils.dart +++ b/lib/utils/application_utils.dart @@ -81,8 +81,6 @@ class ApplicationUtil { title: '便民电话', imgPath: Assets.newIcon.imgBmdh.path, onTap: () { - BotToast.showText(text: '此功能暂未上线'); - return; Get.to(() => ConvenientPhonePage()); }), AppElement( @@ -170,8 +168,6 @@ class ApplicationUtil { title: '社区介绍', imgPath: Assets.newIcon.icSqjs.path, onTap: () { - // BotToast.showText(text: '此功能升级中,敬请期待'); - // return; Get.to(() => CommunityIntroducePage()); }), // AppElement('家政服务', R.ASSETS_ICONS_FUNC_JZFW_PNG, () => HouseKeepingPage()),