From 19af701c614c0b95b5a188241ec80ca150943696 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Tue, 18 May 2021 18:21:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=9A=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E5=95=86=E5=8A=A1=E8=8E=B7=E5=8F=96=E5=88=86=E7=B1=BB=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 12 +++ .../electronic_commerc_category_model.dart | 19 ++++ .../electronic_commerc_category_model.g.dart | 15 +++ .../electronic_commerc_detail_model.dart | 37 ++++++++ .../electronic_commerc_detail_model.g.dart | 21 +++++ .../electronic_commerc_list_model.dart | 24 +++++ .../electronic_commerc_list_model.g.dart | 19 ++++ .../electronic_commerc_page.dart | 94 +++++++++++++++---- lib/pages/splash/splash_page.dart | 1 - 9 files changed, 224 insertions(+), 18 deletions(-) create mode 100644 lib/models/electronic_commerc/electronic_commerc_category_model.dart create mode 100644 lib/models/electronic_commerc/electronic_commerc_category_model.g.dart create mode 100644 lib/models/electronic_commerc/electronic_commerc_detail_model.dart create mode 100644 lib/models/electronic_commerc/electronic_commerc_detail_model.g.dart create mode 100644 lib/models/electronic_commerc/electronic_commerc_list_model.dart create mode 100644 lib/models/electronic_commerc/electronic_commerc_list_model.g.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 0003529b..a4a77282 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -236,6 +236,18 @@ class _Manager { ///一键报警:记录一键报警信息 String get recordAlarmInfo => '/user/alarm/insertAlarmRecord'; + + ///app电子商务:查询所有的电子商务分类(【全部】是app页面默认显示的值) + String get electronicCommercCategory => + '/user/electronicCommerce/categoryList'; + + ///app电子商务:根据电子商务分类主键id查询电子商务信息 + String get electronicCommercList => + '/user/electronicCommerce/electronicCommerceList'; + + ///app电子商务:根据电子商务主键id 查询电子商务信息详情 + String get electronicCommercDetail => + '/user/electronicCommerce/findElectronicCommerceById'; } class _Community { diff --git a/lib/models/electronic_commerc/electronic_commerc_category_model.dart b/lib/models/electronic_commerc/electronic_commerc_category_model.dart new file mode 100644 index 00000000..b863ce3e --- /dev/null +++ b/lib/models/electronic_commerc/electronic_commerc_category_model.dart @@ -0,0 +1,19 @@ +import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'electronic_commerc_category_model.g.dart'; + +@JsonSerializable() +class ElectronicCommercCategoryModel extends Equatable { + final int id; + final String name; + ElectronicCommercCategoryModel({ + required this.id, + required this.name, + }); + + factory ElectronicCommercCategoryModel.fromJson(Map json) => + _$ElectronicCommercCategoryModelFromJson(json); + + @override + List get props => [id, name]; +} diff --git a/lib/models/electronic_commerc/electronic_commerc_category_model.g.dart b/lib/models/electronic_commerc/electronic_commerc_category_model.g.dart new file mode 100644 index 00000000..9fa732c3 --- /dev/null +++ b/lib/models/electronic_commerc/electronic_commerc_category_model.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'electronic_commerc_category_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ElectronicCommercCategoryModel _$ElectronicCommercCategoryModelFromJson( + Map json) { + return ElectronicCommercCategoryModel( + id: json['id'] as int, + name: json['name'] as String, + ); +} diff --git a/lib/models/electronic_commerc/electronic_commerc_detail_model.dart b/lib/models/electronic_commerc/electronic_commerc_detail_model.dart new file mode 100644 index 00000000..606aa741 --- /dev/null +++ b/lib/models/electronic_commerc/electronic_commerc_detail_model.dart @@ -0,0 +1,37 @@ +import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'electronic_commerc_detail_model.g.dart'; + +@JsonSerializable() +class ElectronicCommercDetailModel extends Equatable { + final int id; + final String title; + final String code; + final String content; + final String electronicCommerceCategoryName; + final String createName; + final String createDate; + ElectronicCommercDetailModel({ + required this.id, + required this.title, + required this.code, + required this.content, + required this.electronicCommerceCategoryName, + required this.createName, + required this.createDate, + }); + factory ElectronicCommercDetailModel.fromJson(Map json) => + _$ElectronicCommercDetailModelFromJson(json); + @override + List get props { + return [ + id, + title, + code, + content, + electronicCommerceCategoryName, + createName, + createDate, + ]; + } +} diff --git a/lib/models/electronic_commerc/electronic_commerc_detail_model.g.dart b/lib/models/electronic_commerc/electronic_commerc_detail_model.g.dart new file mode 100644 index 00000000..6b72f7a3 --- /dev/null +++ b/lib/models/electronic_commerc/electronic_commerc_detail_model.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'electronic_commerc_detail_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ElectronicCommercDetailModel _$ElectronicCommercDetailModelFromJson( + Map json) { + return ElectronicCommercDetailModel( + id: json['id'] as int, + title: json['title'] as String, + code: json['code'] as String, + content: json['content'] as String, + electronicCommerceCategoryName: + json['electronicCommerceCategoryName'] as String, + createName: json['createName'] as String, + createDate: json['createDate'] as String, + ); +} diff --git a/lib/models/electronic_commerc/electronic_commerc_list_model.dart b/lib/models/electronic_commerc/electronic_commerc_list_model.dart new file mode 100644 index 00000000..7cf347ef --- /dev/null +++ b/lib/models/electronic_commerc/electronic_commerc_list_model.dart @@ -0,0 +1,24 @@ +import 'package:equatable/equatable.dart'; + +import 'package:aku_community/model/common/img_model.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'electronic_commerc_list_model.g.dart'; + +@JsonSerializable() +class ElectronicCommercListModel extends Equatable { + final int id; + final String title; + final String createDate; + final List imgList; + ElectronicCommercListModel({ + required this.id, + required this.title, + required this.createDate, + required this.imgList, + }); + factory ElectronicCommercListModel.fromJson(Map json) => + _$ElectronicCommercListModelFromJson(json); + + @override + List get props => [id, title, createDate, imgList]; +} diff --git a/lib/models/electronic_commerc/electronic_commerc_list_model.g.dart b/lib/models/electronic_commerc/electronic_commerc_list_model.g.dart new file mode 100644 index 00000000..f71683be --- /dev/null +++ b/lib/models/electronic_commerc/electronic_commerc_list_model.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'electronic_commerc_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ElectronicCommercListModel _$ElectronicCommercListModelFromJson( + Map json) { + return ElectronicCommercListModel( + id: json['id'] as int, + title: json['title'] as String, + createDate: json['createDate'] as String, + imgList: (json['imgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); +} diff --git a/lib/pages/electronic_commerc/electronic_commerc_page.dart b/lib/pages/electronic_commerc/electronic_commerc_page.dart index 9a2404ae..61fdf445 100644 --- a/lib/pages/electronic_commerc/electronic_commerc_page.dart +++ b/lib/pages/electronic_commerc/electronic_commerc_page.dart @@ -1,7 +1,15 @@ +import 'package:aku_community/constants/api.dart'; import 'package:aku_community/pages/electronic_commerc/electronic_commerc_view.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; +import 'package:velocity_x/velocity_x.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:aku_community/extensions/num_ext.dart'; +import 'package:aku_community/models/electronic_commerc/electronic_commerc_category_model.dart'; class ElectronicCommercPage extends StatefulWidget { ElectronicCommercPage({Key? key}) : super(key: key); @@ -12,25 +20,30 @@ class ElectronicCommercPage extends StatefulWidget { class _ElectronicCommercPageState extends State with TickerProviderStateMixin { - List _tabs = [ - '小区教育', - '健康运动', - '家政服务', - '居家养老', - '装修服务', - '物业租售', - '网上商城', - '代购代送', - '网上询价', - '网上采购', - '商品退换', - '质量投诉' - ]; + List _tabs = ['']; late TabController _tabController; + bool _onloading = true; + late List _models; @override void initState() { super.initState(); _tabController = TabController(length: _tabs.length, vsync: this); + Future.delayed( + Duration( + milliseconds: 0, + ), () async { + BaseModel baseModel = + await NetUtil().get(API.manager.electronicCommercCategory); + if (baseModel.status == true && baseModel.data != null) { + _models = (baseModel.data as List) + .map((e) => ElectronicCommercCategoryModel.fromJson(e)) + .toList(); + _tabs = List.generate(_models.length, (index) => _models[index].name); + _onloading = false; + _tabController = TabController(length: _tabs.length, vsync: this); + setState(() {}); + } + }); } @override @@ -52,11 +65,58 @@ class _ElectronicCommercPageState extends State controller: _tabController, children: List.generate( _tabs.length, - (index) => ElectronicCommercView( - index: index, - ), + (index) => _onloading + ? ListView( + children: [_buildShimmer()], + ) + : ElectronicCommercView( + index: index, + ), ), ), ); } + + _buildShimmer() { + return Padding( + padding: EdgeInsets.all(32.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Shimmer.fromColors( + baseColor: Colors.black12, + highlightColor: Colors.white10, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + 50.hb, + VxBox().height(53.w).width(152.w).color(Colors.white).make(), + 30.hb, + VxBox().height(40.w).width(600.w).color(Colors.white).make(), + 24.hb, + VxBox().height(33.w).width(263.w).color(Colors.white).make(), + ], + ), + ), + // Divider( + // height: 50.w, + // thickness: 1.w, + // color: Color(0xFFD8D8D8), + // ), + // GridView.count( + // crossAxisCount: 2, + // children: [ + // VxBox().height(53.w).width(53.w).color(Colors.white).make(), + + // ], + // ) + ], + ), + ); + } } diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index fab8de13..c389817f 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -18,7 +18,6 @@ import 'package:aku_community/provider/user_provider.dart'; import 'package:aku_community/utils/developer_util.dart'; import 'package:aku_community/utils/hive_store.dart'; -//TODO splashPage class SplashPage extends StatefulWidget { SplashPage({Key? key}) : super(key: key);