添加:电子商务详情页

对接:获取电子商务详情
hmxc
张萌 4 years ago
parent 19af701c61
commit 5049c99c50

@ -1,8 +1,20 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/model/common/img_model.dart';
import 'package:aku_community/pages/electronic_commerc/electronic_commerc_detail_page.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:aku_community/models/electronic_commerc/electronic_commerc_list_model.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:aku_community/const/resource.dart';
class ElectronicCommercCard extends StatefulWidget {
final int index;
ElectronicCommercCard({Key? key, required this.index}) : super(key: key);
final ElectronicCommercListModel model;
ElectronicCommercCard({Key? key, required this.model})
: super(key: key);
@override
_ElectronicCommercCardState createState() => _ElectronicCommercCardState();
@ -11,6 +23,59 @@ class ElectronicCommercCard extends StatefulWidget {
class _ElectronicCommercCardState extends State<ElectronicCommercCard> {
@override
Widget build(BuildContext context) {
return Container();
return _buildCard(widget.model);
}
_buildCard(ElectronicCommercListModel model) {
return MaterialButton(
color: Colors.white,
elevation: 0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onPressed: () {
Get.to(() => ElectronicCommercDetailPage(id: model.id));
},
padding: EdgeInsets.zero,
child: Container(
height: 248.w,
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(model.title),
Spacer(),
DefaultTextStyle(
style: TextStyle(
color: ktextSubColor,
fontSize: 20.sp,
),
child: Row(
children: [
// Text('测试'),
Spacer(),
Text('发布于 ${DateUtil.formatDateStr(
model.createDate,
format: 'yyyy-MM-dd HH:mm',
)}'),
],
),
),
],
),
),
32.w.widthBox,
FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
width: 240.w,
height: 200.w,
fit: BoxFit.cover,
image: API.image(ImgModel.first(model.imgList)),
),
],
),
),
);
}
}

@ -0,0 +1,98 @@
import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/constants/api.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:bot_toast/bot_toast.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aku_community/models/electronic_commerc/electronic_commerc_detail_model.dart';
import 'package:velocity_x/velocity_x.dart';
class ElectronicCommercDetailPage extends StatefulWidget {
final int id;
ElectronicCommercDetailPage({Key? key, required this.id}) : super(key: key);
@override
_ElectronicCommercDetailPageState createState() => _ElectronicCommercDetailPageState();
}
class _ElectronicCommercDetailPageState extends State<ElectronicCommercDetailPage> {
late EasyRefreshController _easyRefreshController;
bool _onload = true;
late ElectronicCommercDetailModel _detailModel;
@override
void initState() {
super.initState();
_easyRefreshController = EasyRefreshController();
}
@override
void dispose() {
_easyRefreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: _onload?'':_detailModel.electronicCommerceCategoryName,
bodyColor: Colors.white,
body: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
onRefresh: () async {
BaseModel baseModel = await NetUtil()
.get(API.manager.electronicCommercDetail, params: {
"electronicCommerceId": widget.id,
});
if (baseModel.status! && baseModel.data != null) {
_detailModel = ElectronicCommercDetailModel.fromJson(baseModel.data);
} else {
BotToast.showText(text: '无法获取信息');
}
_onload = false;
setState(() {});
},
child: _onload
? _emptyWidget()
: ListView(
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [
_detailModel.title.text
.size(32.sp)
.color(ktextPrimary)
.bold
.align(TextAlign.center)
.make(),
24.w.heightBox,
SizedBox(
width: double.infinity,
child: _detailModel.content.text
.size(28.sp)
.color(ktextPrimary)
.make(),
),
40.w.heightBox,
Row(
children: [
Spacer(),
'发布于 ${DateUtil.formatDateStr(_detailModel.createDate, format: 'MM-dd HH:mm')}'
.text
.size(24.sp)
.color(ktextSubColor)
.make(),
],
)
],
),
),
);
}
Widget _emptyWidget() {
return Container();
}
}

@ -4,6 +4,7 @@ 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:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
import 'package:velocity_x/velocity_x.dart';
@ -32,12 +33,14 @@ class _ElectronicCommercPageState extends State<ElectronicCommercPage>
Duration(
milliseconds: 0,
), () async {
final cancel = BotToast.showLoading();
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();
cancel();
_tabs = List.generate(_models.length, (index) => _models[index].name);
_onloading = false;
_tabController = TabController(length: _tabs.length, vsync: this);
@ -70,7 +73,7 @@ class _ElectronicCommercPageState extends State<ElectronicCommercPage>
children: [_buildShimmer()],
)
: ElectronicCommercView(
index: index,
id: _models[index].id,
),
),
),
@ -103,18 +106,20 @@ class _ElectronicCommercPageState extends State<ElectronicCommercPage>
],
),
),
// 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(),
// ],
// )
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(),
VxBox().height(53.w).width(53.w).color(Colors.white).make(),
VxBox().height(53.w).width(53.w).color(Colors.white).make(),
VxBox().height(53.w).width(53.w).color(Colors.white).make(),
],
)
],
),
);

@ -1,23 +1,65 @@
import 'package:aku_community/constants/api.dart';
import 'package:aku_community/pages/electronic_commerc/electronic_commerc_card.dart';
import 'package:aku_community/pages/things_page/widget/bee_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:aku_community/models/electronic_commerc/electronic_commerc_list_model.dart';
import 'package:velocity_x/velocity_x.dart';
class ElectronicCommercView extends StatefulWidget {
final int index;
ElectronicCommercView({Key? key, required this.index}) : super(key: key);
final int id;
ElectronicCommercView({Key? key, required this.id}) : super(key: key);
@override
_ElectronicCommercViewState createState() => _ElectronicCommercViewState();
}
class _ElectronicCommercViewState extends State<ElectronicCommercView> {
late EasyRefreshController _refreshController;
@override
void initState() {
super.initState();
_refreshController = EasyRefreshController();
}
@override
void dispose() {
_refreshController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView(
padding: EdgeInsets.symmetric(vertical: 24.w,horizontal: 32.w),
children: [
ElectronicCommercCard(index: widget.index),
],
// return ListView(
// padding: EdgeInsets.symmetric(vertical: 24.w,horizontal: 32.w),
// children: [
// ElectronicCommercCard(index: widget.index),
// ],
// );
return BeeListView(
path: API.manager.electronicCommercList,
controller: _refreshController,
extraParams: {
"electronicCommerceCategoryId":widget.id
},
convert: (models) {
return models.tableList!
.map((e) => ElectronicCommercListModel.fromJson(e))
.toList();
},
builder: (items) {
return ListView.separated(
padding: EdgeInsets.symmetric(vertical: 24.w),
itemBuilder: (context, index) {
return ElectronicCommercCard(
model: items[index],
);
},
separatorBuilder: (_, __) {
return 24.w.heightBox;
},
itemCount: items.length);
});
}
}

@ -40,7 +40,7 @@ class _PublicInformationDetailPageState
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '公共资讯',
title: _onload ? '' : _detailModel.newsCategoryName,
bodyColor: Colors.white,
body: EasyRefresh(
firstRefresh: true,
@ -64,7 +64,7 @@ class _PublicInformationDetailPageState
padding: EdgeInsets.symmetric(vertical: 24.w, horizontal: 32.w),
children: [
_detailModel.title.text
.size(36.sp)
.size(32.sp)
.color(ktextPrimary)
.bold
.align(TextAlign.center)

Loading…
Cancel
Save