|
|
|
@ -5,12 +5,16 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_html/flutter_html.dart'; |
|
|
|
|
import 'package:flutter_html/image_render.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/memberCommentList.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/activity.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/article.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/page.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/share_dialog.dart'; |
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_defines.dart'; |
|
|
|
|
import 'package:sharesdk_plugin/sharesdk_interface.dart'; |
|
|
|
@ -36,10 +40,15 @@ class StoreDetailsPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _StoreDetailsPage extends State<StoreDetailsPage> { |
|
|
|
|
ApiService apiService; |
|
|
|
|
RefreshController _refreshController; |
|
|
|
|
bool isLiked = false; |
|
|
|
|
int commentTotal = 0; |
|
|
|
|
var commentTextController = TextEditingController(); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
_refreshController = RefreshController(); |
|
|
|
|
|
|
|
|
|
if (Platform.isAndroid) WebView.platform = SurfaceAndroidWebView(); |
|
|
|
|
|
|
|
|
@ -47,23 +56,26 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
apiService = |
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token")); |
|
|
|
|
queryHtml(); |
|
|
|
|
queryMemberCommentList(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Activity activity; |
|
|
|
|
Article article; |
|
|
|
|
List<MemberCommentList> memberList = []; |
|
|
|
|
|
|
|
|
|
queryHtml() async { |
|
|
|
|
BaseData baseData = await apiService.informationInfo( |
|
|
|
|
widget.arguments["activityId"] ?? widget.arguments["articleId"]); |
|
|
|
|
|
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
if (widget.arguments.containsKey("activityId")) { |
|
|
|
|
activity = Activity.fromJson(baseData.data); |
|
|
|
|
} else if (widget.arguments.containsKey("articleId")) { |
|
|
|
|
article = Article.fromJson(baseData.data); |
|
|
|
|
} |
|
|
|
|
setState(() {}); |
|
|
|
|
setState(() { |
|
|
|
|
if (widget.arguments.containsKey("activityId")) { |
|
|
|
|
activity = Activity.fromJson(baseData.data); |
|
|
|
|
} else if (widget.arguments.containsKey("articleId")) { |
|
|
|
|
article = Article.fromJson(baseData.data); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -124,6 +136,75 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//评论列表 |
|
|
|
|
queryMemberCommentList() async { |
|
|
|
|
BaseData baseData = await apiService.memberCommentList({ |
|
|
|
|
"pageNum": 1, |
|
|
|
|
"pageSize": 100, |
|
|
|
|
"relationalId": |
|
|
|
|
widget.arguments["activityId"] ?? widget.arguments["articleId"], |
|
|
|
|
"relationalType": 1 |
|
|
|
|
}).catchError((error) { |
|
|
|
|
_refreshController.refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
PageInfo pageInfo = PageInfo.fromJson(baseData.data); |
|
|
|
|
_refreshController.refreshCompleted(); |
|
|
|
|
setState(() { |
|
|
|
|
commentTotal = pageInfo.size; |
|
|
|
|
memberList = |
|
|
|
|
pageInfo.list.map((e) => MemberCommentList.fromMap(e)).toList(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//评论点赞 |
|
|
|
|
queryCommentLike(String id) async { |
|
|
|
|
BaseData baseData = |
|
|
|
|
await apiService.commentLike(id).catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
memberList.forEach((element) { |
|
|
|
|
if (element.id == id) { |
|
|
|
|
element.likes += 1; |
|
|
|
|
element.isFabulous = true; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//给文章/活动点赞 |
|
|
|
|
queryInformationLikes() async { |
|
|
|
|
BaseData baseData = |
|
|
|
|
await apiService.commentLike(widget.arguments["activityId"] ?? widget.arguments["articleId"]).catchError((onError) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
setState(() { |
|
|
|
|
isLiked = true; |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//发布评论 |
|
|
|
|
queryMemberComment(String content) async { |
|
|
|
|
BaseData baseData = await apiService.memberComment({ |
|
|
|
|
"content":content, |
|
|
|
|
"parentId":0, |
|
|
|
|
"relationalId":widget.arguments["activityId"] ?? widget.arguments["articleId"], |
|
|
|
|
"relationalType": 1 |
|
|
|
|
}).catchError((error) { |
|
|
|
|
_refreshController.refreshFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
commentTextController.text = ""; |
|
|
|
|
queryMemberCommentList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Scaffold( |
|
|
|
@ -157,6 +238,7 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
color: Color(0xFFF7F7F7), |
|
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
child: Text( |
|
|
|
@ -187,13 +269,16 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
if (activity != null) { |
|
|
|
|
if (widget.arguments["source"] != null |
|
|
|
|
&& widget.arguments["source"] == activity.storeId) { |
|
|
|
|
if (widget.arguments["source"] != null && |
|
|
|
|
widget.arguments["source"] == activity.storeId) { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
} else { |
|
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
|
'/router/union_detail_page', |
|
|
|
|
arguments: {"id": activity.storeId, "source": widget.arguments["activityId"]}); |
|
|
|
|
arguments: { |
|
|
|
|
"id": activity.storeId, |
|
|
|
|
"source": widget.arguments["activityId"] |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
@ -271,6 +356,131 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 2), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Text("评论(${commentTotal.toString()})", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xff1A1A1A))), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 16.w, |
|
|
|
|
), |
|
|
|
|
Text("喜欢(${article?.likes??activity?.likes??"0"})", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0xff1A1A1A))), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
ListView.builder( |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
itemCount: memberList != null ? memberList.length : 0, |
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () {}, |
|
|
|
|
child: commentItem(memberList[position],position,memberList.length), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 12.h, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Colors.white, |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 2), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0) |
|
|
|
|
], |
|
|
|
|
borderRadius: new BorderRadius.only( |
|
|
|
|
topLeft: Radius.circular(8.0), |
|
|
|
|
topRight: Radius.circular(8.0), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
flex: 1, |
|
|
|
|
child: Container( |
|
|
|
|
decoration: new BoxDecoration( |
|
|
|
|
color: Color(0xffF2F2F2), |
|
|
|
|
borderRadius: BorderRadius.circular(2.0)), |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
|
margin: const EdgeInsets.fromLTRB(4, 0, 4, 0), |
|
|
|
|
alignment: Alignment.topLeft, |
|
|
|
|
child: TextField( |
|
|
|
|
maxLines: 8, |
|
|
|
|
minLines: 1, |
|
|
|
|
controller: commentTextController, |
|
|
|
|
decoration: InputDecoration( |
|
|
|
|
border: InputBorder.none, |
|
|
|
|
hintText: "留下您精彩的评论吧~", |
|
|
|
|
hintStyle: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Color(0xffCDCCCC), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 20.w, right: 20.w), |
|
|
|
|
child: GestureDetector( |
|
|
|
|
onTap: (){ |
|
|
|
|
var commentText = commentTextController.text; |
|
|
|
|
if (commentText == "") { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
queryMemberComment(commentText); |
|
|
|
|
}, |
|
|
|
|
child:Text( |
|
|
|
|
"发送", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
color: Color(0XFF1A1A1A)), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
GestureDetector(onTap: (){ |
|
|
|
|
queryInformationLikes(); |
|
|
|
|
},child: Image.asset(isLiked?"assets/image/icon_like.png":"assets/image/icon_like_h.png"),) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
@ -329,6 +539,150 @@ class _StoreDetailsPage extends State<StoreDetailsPage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget commentItem(MemberCommentList memberList,int index,int max) { |
|
|
|
|
return Container( |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
ClipOval( |
|
|
|
|
child: Image.network( |
|
|
|
|
memberList.userAvatarUrl, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
width: 40.w, |
|
|
|
|
height: 40.h, |
|
|
|
|
), |
|
|
|
|
clipBehavior: Clip.hardEdge, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 12.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: Container( |
|
|
|
|
height: 60.h, |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text.rich( |
|
|
|
|
TextSpan(children: [ |
|
|
|
|
TextSpan( |
|
|
|
|
text: memberList.username, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Colors.black), |
|
|
|
|
), |
|
|
|
|
]), |
|
|
|
|
textDirection: TextDirection.ltr, |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
memberList.createTime, |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xff808080), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
alignment: Alignment.topRight, |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
queryCommentLike(memberList.id); |
|
|
|
|
}, |
|
|
|
|
child: Image.asset( |
|
|
|
|
!(memberList.isFabulous ?? false) |
|
|
|
|
? "assets/image/icon_like_h.png" |
|
|
|
|
: "assets/image/icon_like.png", |
|
|
|
|
width: 16.w, |
|
|
|
|
height: 16.h, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
memberList.likes.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, color: Color(0xff1A1A1A)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 68, right: 16), |
|
|
|
|
child: Align( |
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
child: Text( |
|
|
|
|
memberList.content, |
|
|
|
|
style: TextStyle(fontSize: 14.sp, color: Color(0xff1A1A1A)), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 12.h, |
|
|
|
|
), |
|
|
|
|
if(memberList.parentContent != null) |
|
|
|
|
Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
margin: EdgeInsets.only(left: 68.w, right: 16.w), |
|
|
|
|
decoration: new BoxDecoration( |
|
|
|
|
color: Color(0xffF2F2F2), |
|
|
|
|
borderRadius: BorderRadius.circular(2.0), |
|
|
|
|
), |
|
|
|
|
child: Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 4.w, top: 4.h, bottom: 4.h), |
|
|
|
|
child: Row( |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
memberList.parentUserName??"", |
|
|
|
|
style: TextStyle(fontSize: 12.sp, color: Color(0xff808080)), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
memberList.parentContent ?? "", |
|
|
|
|
style: TextStyle(fontSize: 12.sp, color: Color(0xff808080)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if (index == max - 1) |
|
|
|
|
Container( |
|
|
|
|
height: 63.h, |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
color: Color(0xffF2F2F2), |
|
|
|
|
boxShadow: [ |
|
|
|
|
BoxShadow( |
|
|
|
|
color: Colors.black.withAlpha(12), |
|
|
|
|
offset: Offset(0, 2), |
|
|
|
|
blurRadius: 14, |
|
|
|
|
spreadRadius: 0) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
margin: EdgeInsets.only(top: 30.h), |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
child: Text( |
|
|
|
|
"-已显示全部评论-", |
|
|
|
|
style: TextStyle(fontSize: 14.sp, color: Color(0xff353535)), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void dispose() { |
|
|
|
|
if (chewieAudioController != null) chewieAudioController.dispose(); |
|
|
|
|