parent
5a41c92d6c
commit
289a93793a
@ -0,0 +1,127 @@
|
||||
class ActivityListModel {
|
||||
String content;
|
||||
Goods goods;
|
||||
int id;
|
||||
List<ImgList> imgList;
|
||||
int originId;
|
||||
int trendType;
|
||||
String updatedAt;
|
||||
Short short;
|
||||
|
||||
ActivityListModel(
|
||||
{this.content,
|
||||
this.goods,
|
||||
this.id,
|
||||
this.imgList,
|
||||
this.originId,
|
||||
this.trendType,
|
||||
this.updatedAt,
|
||||
this.short});
|
||||
|
||||
ActivityListModel.fromJson(Map<String, dynamic> json) {
|
||||
content = json['content'];
|
||||
goods = json['goods'] != null ? new Goods.fromJson(json['goods']) : null;
|
||||
id = json['id'];
|
||||
if (json['imgList'] != null) {
|
||||
imgList = new List<ImgList>();
|
||||
json['imgList'].forEach((v) {
|
||||
imgList.add(new ImgList.fromJson(v));
|
||||
});
|
||||
}
|
||||
originId = json['originId'];
|
||||
trendType = json['trendType'];
|
||||
updatedAt = json['updatedAt'];
|
||||
short = json['short'] != null ? new Short.fromJson(json['short']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['content'] = this.content;
|
||||
if (this.goods != null) {
|
||||
data['goods'] = this.goods.toJson();
|
||||
}
|
||||
data['id'] = this.id;
|
||||
if (this.imgList != null) {
|
||||
data['imgList'] = this.imgList.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['originId'] = this.originId;
|
||||
data['trendType'] = this.trendType;
|
||||
data['updatedAt'] = this.updatedAt;
|
||||
if (this.short != null) {
|
||||
data['short'] = this.short.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Goods {
|
||||
int id;
|
||||
String mainPhotoURL;
|
||||
String name;
|
||||
String price;
|
||||
|
||||
Goods({this.id, this.mainPhotoURL, this.name, this.price});
|
||||
|
||||
Goods.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
mainPhotoURL = json['mainPhotoURL'];
|
||||
name = json['name'];
|
||||
price = json['price'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['mainPhotoURL'] = this.mainPhotoURL;
|
||||
data['name'] = this.name;
|
||||
data['price'] = this.price;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ImgList {
|
||||
num height;
|
||||
int id;
|
||||
int momentsCopyId;
|
||||
String url;
|
||||
num width;
|
||||
|
||||
ImgList({this.height, this.id, this.momentsCopyId, this.url, this.width});
|
||||
|
||||
ImgList.fromJson(Map<String, dynamic> json) {
|
||||
height = json['height'];
|
||||
id = json['id'];
|
||||
momentsCopyId = json['momentsCopyId'];
|
||||
url = json['url'];
|
||||
width = json['width'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['height'] = this.height;
|
||||
data['id'] = this.id;
|
||||
data['momentsCopyId'] = this.momentsCopyId;
|
||||
data['url'] = this.url;
|
||||
data['width'] = this.width;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Short {
|
||||
String mediaUrl;
|
||||
String coverUrl;
|
||||
|
||||
Short({this.mediaUrl, this.coverUrl});
|
||||
|
||||
Short.fromJson(Map<String, dynamic> json) {
|
||||
mediaUrl = json['media_url'];
|
||||
coverUrl = json['cover_url'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['media_url'] = this.mediaUrl;
|
||||
data['cover_url'] = this.coverUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:recook/constants/api.dart';
|
||||
import 'package:recook/manager/http_manager.dart';
|
||||
import 'package:recook/pages/live/models/activity_list_model.dart';
|
||||
import 'package:recook/pages/live/widget/user_activity_card.dart';
|
||||
import 'package:recook/widgets/refresh_widget.dart';
|
||||
|
||||
class UserActivityView extends StatefulWidget {
|
||||
final int id;
|
||||
UserActivityView({Key key, @required this.id}) : super(key: key);
|
||||
|
||||
@override
|
||||
_UserActivityViewState createState() => _UserActivityViewState();
|
||||
}
|
||||
|
||||
class _UserActivityViewState extends State<UserActivityView>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
List<ActivityListModel> activityListModels = [];
|
||||
int _page = 1;
|
||||
GSRefreshController _controller = GSRefreshController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return RefreshWidget(
|
||||
controller: _controller,
|
||||
onRefresh: () {
|
||||
getActivityModels().then((models) {
|
||||
_page = 1;
|
||||
setState(() {
|
||||
activityListModels = models;
|
||||
});
|
||||
_controller.refreshCompleted();
|
||||
});
|
||||
},
|
||||
body: ListView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
return UserActivityCard(model: activityListModels[index]);
|
||||
},
|
||||
itemCount: activityListModels.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<List> getActivityModels() async {
|
||||
ResultData resultData = await HttpManager.post(LiveAPI.activityList, {
|
||||
'userId': widget.id,
|
||||
'page': _page,
|
||||
'limit': 10,
|
||||
});
|
||||
if (resultData?.data['data']['list'] == null)
|
||||
return [];
|
||||
else
|
||||
return (resultData?.data['data']['list'] as List)
|
||||
.map((e) => ActivityListModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
|
||||
class RecookDateUtil {
|
||||
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(0);
|
||||
|
||||
///字符串获取日期
|
||||
RecookDateUtil.fromString(String rawData) {
|
||||
dateTime = DateUtil.getDateTime(rawData);
|
||||
}
|
||||
|
||||
///日期设置
|
||||
RecookDateUtil(this.dateTime);
|
||||
|
||||
String get prefixDay {
|
||||
if (isToday)
|
||||
return '今天';
|
||||
else if (isYesterday)
|
||||
return '昨天';
|
||||
else
|
||||
return DateUtil.formatDate(dateTime, format: 'M/d');
|
||||
}
|
||||
|
||||
String get detailDate => DateUtil.formatDate(dateTime, format: 'HH:mm');
|
||||
|
||||
/// 判断今天
|
||||
bool get isToday {
|
||||
DateTime now = DateTime.now();
|
||||
return now.month == dateTime.month &&
|
||||
now.year == dateTime.year &&
|
||||
now.day == dateTime.day;
|
||||
}
|
||||
|
||||
///判断昨天
|
||||
bool get isYesterday {
|
||||
DateTime now = DateTime.now();
|
||||
return now.month == dateTime.month &&
|
||||
now.year == dateTime.year &&
|
||||
now.day == (dateTime.day + 1);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue