parent
19af701c61
commit
5049c99c50
@ -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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue