Browse Source

Merge remote-tracking branch 'origin/remove_uniapp' into remove_uniapp

remove_uniapp
fmk 3 years ago
parent
commit
77c5ce9486
  1. 120
      lib/community/community_child_page.dart
  2. 964
      lib/mine/personal_page.dart
  3. 1
      lib/order/order_view/order_info.dart
  4. 2
      lib/store/store_view/shop_goods.dart

120
lib/community/community_child_page.dart

@ -36,7 +36,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
bool isRefresh = true;
bool isLoadingData = false;
ScrollController sc = ScrollController();
List<Article> articles = [];
@override
@ -53,7 +52,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
}
///
queryCommunity() async {
queryCommunity(String searchKey) async {
if(!isRefresh){
isRefresh = true;
return;
@ -76,45 +75,70 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
pageNum += 1;
isLoadMore = false;
}
else pageNum = 1;
else if(searchKey == null)pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"mid":"",
"onlyFollow": widget.typeStr == "关注" ? true : false,
"onlyMe": false,
"pageNum": pageNum,
"pageNum": searchKey == null?pageNum:1,
"pageSize": 10,
"searchKey": ""
"searchKey": searchKey??""
}).catchError((error) {
refreshController.refreshFailed();
refreshController.loadFailed();
if(searchKey == null) {
refreshController.refreshFailed();
refreshController.loadFailed();
}
});
refreshController.refreshCompleted();
refreshController.loadComplete();
if(searchKey == null) {
refreshController.refreshCompleted();
refreshController.loadComplete();
}
if (baseData.isSuccess) {
if (pageNum == 1) {
articles.clear();
}
baseData.data.list.forEach((element) {
var article = Article();
article.id = element.id;
article.content = jsonEncode(element.subjectInfo);
article.mainTitle =element.subject;
article.followed = element.selfFollow;
article.authorHeadImg = element.memberInfo?.avatar;
article.authorName = element.memberInfo?.nickname;
article.location = element.location;
article.createTime = element.createTime;
article.author = element.memberInfo?.mid;
article.viewers = element?.viewers;
article.likes = element?.likes;
article.comments = element?.comments;
articles.add(article);
});
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime));
// print("comments: ${comments.length}");
if (int.tryParse(baseData.data.total) < (pageNum * 10)) {
refreshController.loadNoData();
if(searchKey != null){
if(baseData?.data?.list != null && baseData.data.list.isNotEmpty)
articles.forEach((element) {
if(element.id == searchKey){
element.content = jsonEncode(baseData.data.list[0].subjectInfo);
element.mainTitle =baseData.data.list[0].subject;
element.followed = baseData.data.list[0].selfFollow;
element.authorHeadImg = baseData.data.list[0].memberInfo?.avatar;
element.authorName = baseData.data.list[0].memberInfo?.nickname;
element.location = baseData.data.list[0].location;
element.createTime = baseData.data.list[0].createTime;
element.author = baseData.data.list[0].memberInfo?.mid;
element.viewers = baseData.data.list[0]?.viewers;
element.likes = baseData.data.list[0]?.likes;
element.comments = baseData.data.list[0]?.comments;
this.isRefresh = false;
setState(() {
});
}
});
}else{
if (pageNum == 1) {
articles.clear();
}
baseData.data.list.forEach((element) {
var article = Article();
article.id = element.id;
article.content = jsonEncode(element.subjectInfo);
article.mainTitle =element.subject;
article.followed = element.selfFollow;
article.authorHeadImg = element.memberInfo?.avatar;
article.authorName = element.memberInfo?.nickname;
article.location = element.location;
article.createTime = element.createTime;
article.author = element.memberInfo?.mid;
article.viewers = element?.viewers;
article.likes = element?.likes;
article.comments = element?.comments;
articles.add(article);
});
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime));
// print("comments: ${comments.length}");
if (int.tryParse(baseData.data.total) < (pageNum * 10)) {
refreshController.loadNoData();
}
}
}
@ -125,7 +149,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
Widget build(BuildContext context) {
super.build(context);
return FutureBuilder(
future: queryCommunity(),
future: queryCommunity(null),
builder: (context, position) {
return SmartRefresher(
controller: refreshController,
@ -172,7 +196,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
"userId": userId,
},
).then((value) {
queryDetails(articles[position].id);
queryCommunity(articles[position].id);
// onRefresh();
// setState(() {});
});
@ -187,32 +211,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
);
}
///
queryDetails(id) async {
SharedPreferences value = await SharedPreferences.getInstance();
if (apiService == null)
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
BaseData<Article> baseData = await apiService.informationInfo(id)
.catchError((onError) {
debugPrint(onError.toString());
});
if (baseData != null && baseData.isSuccess) {
this.articles.forEach((element) {
if(element.id == id){
isRefresh = false;
setState(() {
element.likes = baseData.data.likes;
element.viewers = baseData.data.viewers;
});
}
});
}
}
@override
bool get wantKeepAlive => true;
}

964
lib/mine/personal_page.dart

File diff suppressed because it is too large Load Diff

1
lib/order/order_view/order_info.dart

@ -102,6 +102,7 @@ class _OrderInfoView extends State<OrderInfoView> {
color: Color(0xFF353535),
),
),
SizedBox(width:10.w),
Expanded(
child: Text(
rightText,

2
lib/store/store_view/shop_goods.dart

@ -142,7 +142,7 @@ class _ShopGoods extends State<ShopGoods> {
text: S.of(context).xuanguige,
textColor: Colors.white,
fontWeight: MyFontWeight.medium,
radius: 11,
radius: 3,
backgroup: Color(0xFF32A060),
fontSize: 11.sp,
padding: EdgeInsets.symmetric(vertical: 5.h),

Loading…
Cancel
Save