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. 174
      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 isRefresh = true;
bool isLoadingData = false; bool isLoadingData = false;
ScrollController sc = ScrollController(); ScrollController sc = ScrollController();
List<Article> articles = []; List<Article> articles = [];
@override @override
@ -53,7 +52,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
} }
/// ///
queryCommunity() async { queryCommunity(String searchKey) async {
if(!isRefresh){ if(!isRefresh){
isRefresh = true; isRefresh = true;
return; return;
@ -76,22 +75,46 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
pageNum += 1; pageNum += 1;
isLoadMore = false; isLoadMore = false;
} }
else pageNum = 1; else if(searchKey == null)pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"mid":"", "mid":"",
"onlyFollow": widget.typeStr == "关注" ? true : false, "onlyFollow": widget.typeStr == "关注" ? true : false,
"onlyMe": false, "onlyMe": false,
"pageNum": pageNum, "pageNum": searchKey == null?pageNum:1,
"pageSize": 10, "pageSize": 10,
"searchKey": "" "searchKey": searchKey??""
}).catchError((error) { }).catchError((error) {
if(searchKey == null) {
refreshController.refreshFailed(); refreshController.refreshFailed();
refreshController.loadFailed(); refreshController.loadFailed();
}
}); });
if(searchKey == null) {
refreshController.refreshCompleted(); refreshController.refreshCompleted();
refreshController.loadComplete(); refreshController.loadComplete();
}
if (baseData.isSuccess) { 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) { if (pageNum == 1) {
articles.clear(); articles.clear();
} }
@ -117,6 +140,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
refreshController.loadNoData(); refreshController.loadNoData();
} }
} }
}
isLoadingData = false; isLoadingData = false;
} }
@ -125,7 +149,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return FutureBuilder( return FutureBuilder(
future: queryCommunity(), future: queryCommunity(null),
builder: (context, position) { builder: (context, position) {
return SmartRefresher( return SmartRefresher(
controller: refreshController, controller: refreshController,
@ -172,7 +196,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
"userId": userId, "userId": userId,
}, },
).then((value) { ).then((value) {
queryDetails(articles[position].id); queryCommunity(articles[position].id);
// onRefresh(); // onRefresh();
// setState(() {}); // 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 @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
} }

174
lib/mine/personal_page.dart

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

2
lib/store/store_view/shop_goods.dart

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

Loading…
Cancel
Save