Browse Source

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

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

66
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,22 +75,46 @@ 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) {
if(searchKey == null) {
refreshController.refreshFailed();
refreshController.loadFailed();
}
});
if(searchKey == null) {
refreshController.refreshCompleted();
refreshController.loadComplete();
}
if (baseData.isSuccess) {
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();
}
@ -117,6 +140,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
refreshController.loadNoData();
}
}
}
isLoadingData = false;
}
@ -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;
}

202
lib/mine/personal_page.dart

@ -30,6 +30,7 @@ class PersonalPage extends StatefulWidget {
final Map<String, dynamic> arguments;
PersonalPage({this.arguments});
@override
State<StatefulWidget> createState() {
return _PersonalPage();
@ -47,10 +48,10 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
MemberInfor memberInfor;
String filePath;
bool isLoadMore = false;
bool isRefresh = true;
bool isLoadingData = false;
String memberId;
Map<String, dynamic> modifyInfo = {
"background": ""
};
Map<String, dynamic> modifyInfo = {"background": ""};
@override
void initState() {
@ -59,14 +60,15 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
WidgetsBinding.instance.addObserver(this);
SharedPreferences.getInstance().then((value) => {
apiService = ApiService(Dio(),
context: context, token: value.getString('token'),
context: context,
token: value.getString('token'),
showLoading: true),
_onRefresh(),
});
}
_onRefresh() async {
queryCommunity();
queryCommunity(null);
queryMember(memberId);
}
@ -89,13 +91,21 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
memberInfor = baseData.data;
});
refreshController.refreshCompleted();
}else {
} else {
refreshController.refreshFailed();
}
}
///
queryCommunity() async {
queryCommunity(String searchKey) async {
if(!isRefresh){
isRefresh = true;
return;
}
if(isLoadingData){
return;
}
isLoadingData = true;
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId');
@ -103,27 +113,54 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
Dio(),
context: context,
token: value.getString("token"),
showLoading: false
);
}
if(isLoadMore){
pageNum += 1;
isLoadMore = false;
}
else pageNum = 1;
else if(searchKey == null)pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"mid":memberId == "0" ? userId : memberId,
"mid": memberId == "0" ? userId : memberId,
"onlyFollow": false,
"onlyMe": true,
"pageNum": pageNum,
"pageNum": searchKey == null?pageNum:1,
"pageSize": 10,
"searchKey": ""
"searchKey": searchKey??""
}).catchError((error) {
if(searchKey == null) {
refreshController.refreshFailed();
refreshController.loadFailed();
}
});
if (baseData.isSuccess) {
if(searchKey == null) {
refreshController.refreshCompleted();
refreshController.loadComplete();
}
if (baseData.isSuccess) {
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();
}
@ -131,7 +168,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
var article = Article();
article.id = element.id;
article.content = jsonEncode(element.subjectInfo);
article.mainTitle = element.subject;
article.mainTitle =element.subject;
article.followed = element.selfFollow;
article.authorHeadImg = element.memberInfo?.avatar;
article.authorName = element.memberInfo?.nickname;
@ -144,17 +181,16 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
articles.add(article);
});
setState(() {
});
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime));
// print("comments: ${comments.length}");
if (int.tryParse(baseData.data.total) < (pageNum * 10)) {
refreshController.loadNoData();
}
}
else{
refreshController.refreshFailed();
refreshController.loadFailed();
}
isLoadingData = false;
}
///
@ -165,7 +201,9 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
.pushNamed('/router/login_page', arguments: {"login": "login"});
return;
}
await Navigator.of(context).pushNamed('/router/user_info_page').then((value) {
await Navigator.of(context)
.pushNamed('/router/user_info_page')
.then((value) {
_onRefresh();
setState(() {});
});
@ -273,7 +311,9 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
///
fileUpload() async {
if (filePath != null && filePath != "" && await File(filePath).exists()) {
BaseData<UploadResult> baseData = await apiService.upload(File(filePath), 123123123,false).catchError((onError) {});
BaseData<UploadResult> baseData = await apiService
.upload(File(filePath), 123123123, false)
.catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
UploadResult uploadResult = baseData.data;
modifyInfo["background"] = uploadResult.url;
@ -305,7 +345,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
scrollController: scrollController,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child:Column(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -313,16 +353,15 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
height: 248,
color: Color(0xFFFFFFFF),
// color: Colors.red,
child:
Stack(
child: Stack(
// alignment: Alignment.bottomLeft,
children: [
Positioned(
top:0,
top: 0,
left: 0,
bottom: 36,
right: 0,
child:Stack(
child: Stack(
alignment: Alignment.bottomRight,
children: [
Container(
@ -334,10 +373,8 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
width: double.infinity,
height: 260.h,
fit: BoxFit.cover,
errorSrc:
"assets/image/default_1.webp",
fadeSrc:
"assets/image/default_1.webp",
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
))),
Container(
margin: EdgeInsets.only(
@ -347,10 +384,8 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
color: Colors.transparent,
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
GestureDetector(
child: Image.asset(
@ -365,15 +400,15 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
],
),
),
if(memberId == "0")
if (memberId == "0")
Positioned(
bottom: 9,
right: 16.w,
child:GestureDetector(
onTap: (){
child: GestureDetector(
onTap: () {
showImagePicker();
},
child:Container(
child: Container(
padding: EdgeInsets.only(left: 2, right: 2),
width: 59.w,
height: 23.h,
@ -403,14 +438,12 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
),
Container(
color: Color(0xFFFFFFFF),
child:
Column(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(
left: 86, top: 12, right: 16),
margin: EdgeInsets.only(left: 86, top: 12, right: 16),
child: GestureDetector(
onTap: () {
setState(() {
@ -424,8 +457,11 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
Expanded(
flex: 1,
child: Text(
memberId == "0" ? ((memberInfor?.signature == "") ? "还未编辑个性签名~" : memberInfor?.signature ?? "")
:"个性签名: ${(memberInfor?.signature == "") ? "还未编辑个性签名~" :memberInfor?.signature ?? ""}",
memberId == "0"
? ((memberInfor?.signature == "")
? "还未编辑个性签名~"
: memberInfor?.signature ?? "")
: "个性签名: ${(memberInfor?.signature == "") ? "还未编辑个性签名~" : memberInfor?.signature ?? ""}",
overflow: isShrink
? TextOverflow.visible
: TextOverflow.ellipsis,
@ -433,8 +469,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF868686),
fontWeight:
MyFontWeight.regular,
fontWeight: MyFontWeight.regular,
height: 1.5),
)),
Icon(
@ -450,8 +485,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
Container(
margin: EdgeInsets.only(left: 16, right: 16),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
@ -464,12 +498,13 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
child: Column(
children: [
Text(
memberInfor != null ? memberInfor.follow.toString() : "0",
memberInfor != null
? memberInfor.follow.toString()
: "0",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
fontWeight: MyFontWeight.semi_bold,
),
),
SizedBox(
@ -480,8 +515,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight:
MyFontWeight.regular,
fontWeight: MyFontWeight.regular,
),
),
],
@ -498,12 +532,13 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
child: Column(
children: [
Text(
memberInfor != null ? memberInfor.fans.toString() : "0",
memberInfor != null
? memberInfor.fans.toString()
: "0",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
fontWeight: MyFontWeight.semi_bold,
),
),
SizedBox(
@ -514,8 +549,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight:
MyFontWeight.regular,
fontWeight: MyFontWeight.regular,
),
),
],
@ -532,12 +566,12 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
child: Column(
children: [
Text(
(memberInfor?.trendTotal??0).toString(),
(memberInfor?.trendTotal ?? 0)
.toString(),
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
fontWeight: MyFontWeight.semi_bold,
),
),
SizedBox(
@ -548,8 +582,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight:
MyFontWeight.regular,
fontWeight: MyFontWeight.regular,
),
),
],
@ -566,12 +599,12 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
child: Column(
children: [
Text(
(memberInfor?.gainLikeTotal ?? 0).toString(),
(memberInfor?.gainLikeTotal ?? 0)
.toString(),
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
fontWeight: MyFontWeight.semi_bold,
),
),
SizedBox(
@ -582,8 +615,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight:
MyFontWeight.regular,
fontWeight: MyFontWeight.regular,
),
),
],
@ -601,16 +633,14 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
Padding(
padding: EdgeInsets.only(left: 16),
child: Text(
memberId != "0" ?
"TA的动态":
"我的动态",
memberId != "0" ? "TA的动态" : "我的动态",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
),
)),
dynamicList()
dynamicList(),
],
),
),
@ -635,13 +665,15 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
GestureDetector(
onTap: (){
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PhotoViewGalleryScreen(
images: [(memberInfor?.headimg ?? "").isEmpty?
"https://lmg.jj20.com/up/allimg/tx30/09041130358711081.jpg":memberInfor?.headimg
images: [
(memberInfor?.headimg ?? "").isEmpty
? "https://lmg.jj20.com/up/allimg/tx30/09041130358711081.jpg"
: memberInfor?.headimg
], //list
index: 0, //index
),
@ -674,7 +706,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
height: 20,
),
Spacer(),
if(memberId == "0")
if (memberId == "0")
GestureDetector(
onTap: () {
setState(() {
@ -683,7 +715,8 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
},
child: Container(
height: 23,
padding: EdgeInsets.only(left: 6, right: 6, bottom: 2, top: 2),
padding:
EdgeInsets.only(left: 6, right: 6, bottom: 2, top: 2),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
@ -704,18 +737,21 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
),
)
],
),));
),
));
}
Widget dynamicList() {
return Container(
child: (articles == null || articles.length == 0)? NoDataView(
child: (articles == null || articles.length == 0)
? NoDataView(
src: "assets/image/dong_tai.webp",
isShowBtn: false,
text: "目前暂无发布动态,要把开心的事讲出来哦~",
fontSize: 16.sp,
margin: EdgeInsets.only(left: 60.w,right: 60.w),
):ListView.builder(
margin: EdgeInsets.only(left: 60.w, right: 60.w),
)
: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
@ -724,9 +760,9 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
articles[position],
memberId == "0" ? 1 : 0,
exitFull: () {
setState(() {
_onRefresh();
});
// setState(() {
// _onRefresh();
// });
},
removalDynamic: () {
setState(() {
@ -742,7 +778,7 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver {
"userId": userId,
},
).then((value) {
_onRefresh();
queryCommunity(articles[position].id);
});
},
);

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