diff --git a/assets/image/2x/home_coupon.png b/assets/image/2x/home_coupon.png new file mode 100644 index 00000000..ae9a63ca Binary files /dev/null and b/assets/image/2x/home_coupon.png differ diff --git a/assets/image/2x/home_order.png b/assets/image/2x/home_order.png new file mode 100644 index 00000000..33612170 Binary files /dev/null and b/assets/image/2x/home_order.png differ diff --git a/assets/image/2x/home_recharge.png b/assets/image/2x/home_recharge.png new file mode 100644 index 00000000..9f8380c8 Binary files /dev/null and b/assets/image/2x/home_recharge.png differ diff --git a/assets/image/2x/integral_return.png b/assets/image/2x/integral_return.png new file mode 100644 index 00000000..1e1699bc Binary files /dev/null and b/assets/image/2x/integral_return.png differ diff --git a/assets/image/2x/ketang.png b/assets/image/2x/ketang.png new file mode 100644 index 00000000..c65f4956 Binary files /dev/null and b/assets/image/2x/ketang.png differ diff --git a/assets/image/2x/ketang_like.png b/assets/image/2x/ketang_like.png new file mode 100644 index 00000000..e9b86803 Binary files /dev/null and b/assets/image/2x/ketang_like.png differ diff --git a/assets/image/2x/ketang_message.png b/assets/image/2x/ketang_message.png new file mode 100644 index 00000000..f69de896 Binary files /dev/null and b/assets/image/2x/ketang_message.png differ diff --git a/assets/image/2x/ketang_play.png b/assets/image/2x/ketang_play.png new file mode 100644 index 00000000..0329d21b Binary files /dev/null and b/assets/image/2x/ketang_play.png differ diff --git a/assets/image/3x/home_coupon.png b/assets/image/3x/home_coupon.png new file mode 100644 index 00000000..7e2d35e6 Binary files /dev/null and b/assets/image/3x/home_coupon.png differ diff --git a/assets/image/3x/home_order.png b/assets/image/3x/home_order.png new file mode 100644 index 00000000..715c6bb0 Binary files /dev/null and b/assets/image/3x/home_order.png differ diff --git a/assets/image/3x/home_recharge.png b/assets/image/3x/home_recharge.png new file mode 100644 index 00000000..fe963e61 Binary files /dev/null and b/assets/image/3x/home_recharge.png differ diff --git a/assets/image/3x/integral_return.png b/assets/image/3x/integral_return.png new file mode 100644 index 00000000..13290b60 Binary files /dev/null and b/assets/image/3x/integral_return.png differ diff --git a/assets/image/3x/ketang.png b/assets/image/3x/ketang.png new file mode 100644 index 00000000..9d0fb402 Binary files /dev/null and b/assets/image/3x/ketang.png differ diff --git a/assets/image/3x/ketang_like.png b/assets/image/3x/ketang_like.png new file mode 100644 index 00000000..5d55917b Binary files /dev/null and b/assets/image/3x/ketang_like.png differ diff --git a/assets/image/3x/ketang_message.png b/assets/image/3x/ketang_message.png new file mode 100644 index 00000000..a0cba0df Binary files /dev/null and b/assets/image/3x/ketang_message.png differ diff --git a/assets/image/3x/ketang_play.png b/assets/image/3x/ketang_play.png new file mode 100644 index 00000000..300a2912 Binary files /dev/null and b/assets/image/3x/ketang_play.png differ diff --git a/assets/image/home_coupon.png b/assets/image/home_coupon.png new file mode 100644 index 00000000..e19036ef Binary files /dev/null and b/assets/image/home_coupon.png differ diff --git a/assets/image/home_order.png b/assets/image/home_order.png new file mode 100644 index 00000000..861a96f7 Binary files /dev/null and b/assets/image/home_order.png differ diff --git a/assets/image/home_recharge.png b/assets/image/home_recharge.png new file mode 100644 index 00000000..a86370de Binary files /dev/null and b/assets/image/home_recharge.png differ diff --git a/assets/image/integral_return.png b/assets/image/integral_return.png new file mode 100644 index 00000000..c90e78b6 Binary files /dev/null and b/assets/image/integral_return.png differ diff --git a/assets/image/ketang.png b/assets/image/ketang.png new file mode 100644 index 00000000..e3ed6ce4 Binary files /dev/null and b/assets/image/ketang.png differ diff --git a/assets/image/ketang_like.png b/assets/image/ketang_like.png new file mode 100644 index 00000000..2dcc4f9e Binary files /dev/null and b/assets/image/ketang_like.png differ diff --git a/assets/image/ketang_message.png b/assets/image/ketang_message.png new file mode 100644 index 00000000..cb153759 Binary files /dev/null and b/assets/image/ketang_message.png differ diff --git a/assets/image/ketang_play.png b/assets/image/ketang_play.png new file mode 100644 index 00000000..73ce258a Binary files /dev/null and b/assets/image/ketang_play.png differ diff --git a/lib/community/community_course.dart b/lib/community/community_course.dart new file mode 100644 index 00000000..93ba3cf5 --- /dev/null +++ b/lib/community/community_course.dart @@ -0,0 +1,278 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:huixiang/main.dart'; +import 'package:huixiang/retrofit/data/banner.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/brand.dart'; +import 'package:huixiang/retrofit/data/category_select_list.dart'; +import 'package:huixiang/retrofit/data/collect_class_list.dart'; +import 'package:huixiang/retrofit/data/course_list.dart'; +import 'package:huixiang/retrofit/data/page.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/event_type.dart'; +import 'package:huixiang/view_widget/classic_header.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/store_title_tab.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'community_view/class_list_view.dart'; +import 'community_view/class_title_tab.dart'; +import 'community_view/course_banner.dart'; +import 'community_view/home_class.dart'; + +class CommunityCourse extends StatefulWidget { + @override + State createState() { + return _CommunityCourse(); + } +} + +class _CommunityCourse extends State + with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { + final ScrollController scrollController = ScrollController(); + final RefreshController refreshController = RefreshController(); + + ApiService apiService; + List globaKeys = []; + List brands = []; + List bannerData = []; + List classSelectList = []; + List classList = []; + List classTabList = []; + List collectList = []; + List collect = []; + int checkIndex = 0; + + @override + void initState() { + super.initState(); + + eventBus.on().listen((event) { + print("object: CommunityCourse"); + if (event.type < 3) { + setState(() {}); + } + }); + queryCourseBanner(); + classListAsync(); + collectionList(); + } + + ///banner + queryCourseBanner() async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = + await apiService.queryBanner({ + "model": {"type": "COURSE_BANNER"}, + }).catchError((onError) { + refreshController.refreshFailed(); + }); + if (baseData != null && baseData.isSuccess) { + bannerData.clear(); + bannerData.addAll(baseData.data.records); + refreshController.refreshCompleted(); + } else { + refreshController.refreshFailed(); + } + EasyLoading.dismiss(); + } + + ///课程分类列表 + classListAsync() async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = await apiService.categoryList().catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + classSelectList = baseData.data; + }); + queryClassList(""); + } + EasyLoading.dismiss(); + } + + ///课程列表 + queryClassList(categoryId) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = await apiService.courseList({ + "categoryId":categoryId, + "pageNum": 1, + "pageSize":10, + "searchKey": "", + "state":0 + }).catchError((error) { + if(categoryId == ""){ + refreshController.refreshFailed(); + refreshController.loadFailed(); + } + }); + + if (baseData.isSuccess) { + if(categoryId == "") { + refreshController.refreshCompleted(); + refreshController.loadComplete(); + setState(() { + classList.clear(); + classList.addAll(baseData.data.list); + }); + if(classSelectList.length > 0) + queryClassList(classSelectList[checkIndex].id); + }else{ + setState(() { + classTabList.clear(); + classTabList.addAll(baseData.data.list); + }); + } + } + } + + ///课程的合集列表 + collectionList() async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = await apiService.collectList().catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + collectList.clear(); + collectList.addAll(baseData.data); + if(collectList.length > 0) + collectCourse(collectList[0].id); + }); + } + EasyLoading.dismiss(); + } + + ///合集包含的课程列表 + collectCourse(collectId) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = await apiService.collect(collectId).catchError((error) { + }); + if (baseData != null && baseData.isSuccess) { + setState(() { + collect.clear(); + collect.addAll(baseData.data); + }); + } + } + + _onRefresh(){ + classListAsync(); + } + + @override + Widget build(BuildContext context) { + super.build(context); + return + Stack( + children: [ + Positioned( + child: Container( + child: SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: ClampingScrollPhysics(), + onRefresh: _onRefresh, + scrollController: scrollController, + child: Container( + child: SingleChildScrollView( + physics: NeverScrollableScrollPhysics(), + child: Container( + color: Color(0xFFF7F7F7), + margin: EdgeInsets.only(top: 16.h), + child: Column( + children: classChildItem(), + ), + ), + ), + ), + ), + ), + bottom:0, + top: 0, + left: 0, + right: 0, + ), + if (brands != null && brands.length > 0) + Positioned( + child: Container( + color: Colors.white, + child: StoreTitleTab( + brands, + globaKeys, + scrollController, + isScroll: true, + ), + ), + top: 0, + left: 0, + right: 0, + ), + ], + ); + } + + List classChildItem() { + var widgets = [ + ///课程banner + CourseBanner(bannerData,), + + SizedBox(height: 28), + + ///合集列表 + HomeClass(collect,collectList,), + + ///课程导航栏 + ClassTitleTab(classSelectList,(index){ + checkIndex = index; + queryClassList(classSelectList[index].id); + }), + + ///课程列表 + ClassListView(classTabList), + + ]; + + return widgets; + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/community/community_details.dart b/lib/community/community_details.dart index 81e3151e..59ddd16b 100644 --- a/lib/community/community_details.dart +++ b/lib/community/community_details.dart @@ -138,10 +138,14 @@ class _CommunityDetails extends State with WidgetsBindingObser commentKey, comunity?.likes ?? comunity?.likes.toString() ?? 0, comunity.id, + 1, isKeyBoardShow, _reply, _delCommentTips, 12.sp, + requestApiFinish: (total){setState(() { + commentTotal = total; + });}, ), if (memberList == null || memberList.length == 0) Container( @@ -186,7 +190,7 @@ class _CommunityDetails extends State with WidgetsBindingObser ///给文章/活动点赞 _queryInformationLikes() async { - BaseData baseData = await apiService.informationLikes(comunity.id); + BaseData baseData = await apiService.informationLikes(comunity.id).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { commentKey.currentState.setState(() {}); setState(() { diff --git a/lib/community/community_page.dart b/lib/community/community_page.dart index 4c9c9b9e..a67e7df8 100644 --- a/lib/community/community_page.dart +++ b/lib/community/community_page.dart @@ -7,6 +7,8 @@ import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/my_tab.dart'; +import 'community_course.dart'; + class CommunityPage extends StatefulWidget { @override State createState() { @@ -22,8 +24,8 @@ class _CommunityPage extends State "关注", "推荐", "头条", + "课程", "关于我们", - // "课程", // "直播", ]; @@ -96,7 +98,10 @@ class _CommunityPage extends State return BrandPage(); }else if(e == "头条"){ return HotArticlePage(); - } else { + }else if(e == "课程"){ + return CommunityCourse(); + } + else { return CommunityChildPage(e); } }).toList(), diff --git a/lib/community/community_view/class_details.dart b/lib/community/community_view/class_details.dart new file mode 100644 index 00000000..706c4a34 --- /dev/null +++ b/lib/community/community_view/class_details.dart @@ -0,0 +1,615 @@ +import 'dart:io'; + +import 'package:chewie/chewie.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; +import 'package:huixiang/retrofit/data/chapter.dart'; +import 'package:huixiang/retrofit/data/course_details.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:chewie/src/chewie_progress_colors.dart' as chewie; +import 'package:huixiang/view_widget/tips_dialog.dart'; +import 'package:huixiang/web/web_view/comment_list.dart'; +import 'package:huixiang/web/web_view/input_comment.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import 'package:video_player/video_player.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class ClassDetails extends StatefulWidget { + final Map arguments; + + ClassDetails({this.arguments}); + @override + State createState() { + return _ClassDetails(); + } +} + +class _ClassDetails extends State with WidgetsBindingObserver{ + VideoPlayerController videoPlayerController; + Chewie chewies; + ChewieController chewieAudioController; + ApiService apiService; + final GlobalKey commentKey = GlobalKey(); + final ScrollController scrollController = ScrollController(); + bool isKeyBoardShow = false; + var commentFocus = FocusNode(); + String parenId = "0"; + String hintText = S.current.liuxianinjingcaidepinglunba; + final GlobalKey inputKey = GlobalKey(); + final TextEditingController commentTextController = TextEditingController(); + int commentTotal = 0; + CourseDetails course; + List chapterList = []; + bool isShowImg = true; + int chapterIndex = 0; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + courseDetails(widget.arguments["id"]); + queryChapterList(widget.arguments["id"]); + } + + ///课程章节列表 + queryChapterList(courseId) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData> baseData = await apiService.catalogList(courseId).catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + chapterList.clear(); + chapterList.addAll(baseData.data); + chapterIndex = 0; + initVideo(chapterList[chapterIndex].content.fileUrl); + }); + + } + EasyLoading.dismiss(); + } + + ///课程详情 + courseDetails(id) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData baseData = await apiService.course(id).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + course = baseData.data; + }); + } + } + + + @override + void dispose() { + /** + * 页面销毁时,视频播放器也销毁 + */ + + if (chewieAudioController != null) { + chewieAudioController.pause(); + chewieAudioController.dispose(); + chewieAudioController = null; + } + if (videoPlayerController != null) { + videoPlayerController.pause(); + videoPlayerController.dispose(); + } + super.dispose(); + } + + @override + void didChangeMetrics() { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + if (MediaQuery + .of(context) + .viewInsets + .bottom == 0) { + if (isKeyBoardShow) { + FocusScope.of(context).requestFocus(FocusNode()); + if (mounted) + setState(() { + hintText = S.current.liuxianinjingcaidepinglunba; + isKeyBoardShow = false; + }); + } + } else { + if (mounted) + setState(() { + isKeyBoardShow = true; + }); + } + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + child:Column( + children: [ + Expanded( + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + children: [ + Stack( + children: [ + videoWidget( + MediaQuery.of(context).size.width, + videoPlayerController != null + ? (MediaQuery.of(context).size.width) / + videoPlayerController.value.aspectRatio + : MediaQuery.of(context).size.width / 2, + chapterList.length>chapterIndex?chapterList[chapterIndex].content.coverImg:"", + ), + Container( + margin: EdgeInsets.only(top: 40.h, left: 16.w, right: 16.w), + decoration: BoxDecoration( + color: Colors.transparent, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + child: Image.asset( + "assets/image/integral_return.png", + width: 24, + height: 24, + ), + onTap: () { + Navigator.of(context).pop(course.viewers+1); + }, + ), + ], + ), + ), + ], + ), + Container( + height: 123, + margin: EdgeInsets.only(bottom: 16.h), + padding: EdgeInsets.only(left: 16,top: 16,right: 10), + 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: [ + Row( + children: [ + Container( + height: 22.h, + width: 40.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + border: Border.all( + width: 1, + color: Color(0xFFFF7A1A), + style: BorderStyle.solid, + ), + ), + child: Text( + ( course?.tags != null && course.tags.length > 0 )?course.tags[0] : "", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFFFF7A1A), + ), + ), + ), + SizedBox( + width: 6.w, + ), + Expanded( + child: Text( + course != null ?course.subject:"", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF1A1A1A), + ), + ), + flex: 1, + ) + ], + ), + SizedBox( + height:10.h, + ), + Padding(padding: EdgeInsets.only(right: 16), + child: Row( + children: [ + Expanded( + child: Text( + "讲师:${course !=null ? course.author.name :""}", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + )), + Text( + "播放次数:", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF808080), + ), + ), + SizedBox( + width:4, + ), + Text( + course != null ? course.viewers.toString() :"", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF808080), + ), + ), + ], + ),), + SizedBox( + height:10.h, + ), + Text( + course != null ?course.introduce:"", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ), + anthology(), + CommentList( + commentKey, + course?.likes ?? course?.likes?? 0, + widget.arguments["id"], + 3, + isKeyBoardShow, + _reply, + _delCommentTips, + 12.sp, + requestApiFinish: (total){setState(() { + commentTotal = total; + });}, + ), + if (commentTotal == 0) + Container( + width: double.infinity, + alignment: Alignment.topCenter, + margin: EdgeInsets.only(top: 40), + padding: EdgeInsets.all(22.h), + child: Text( + S + .of(context) + .zanwupinglun, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: Color(0xFFA0A0A0), + ), + ), + ), + ], + ), + ), + flex: 1,), + /// 富文本评论的输入框 + InputComment( + inputKey, + hintText, + isKeyBoardShow, + commentFocus, + commentTextController, + _toComment, + _queryMemberComment, + _queryCourseLikes, + isLike:course?.selfLiked, + ), + ], + ), + ), + ); + } + + initVideo(videoUrl) async { + videoPlayerController = VideoPlayerController.network( + videoUrl, + )..initialize().then((value) { + chewieAudioController = ChewieController( + videoPlayerController: videoPlayerController, + aspectRatio: videoPlayerController.value.aspectRatio, + //宽高比 + autoPlay: false, + //自动播放 + looping: false, + //循环播放 + allowFullScreen: true, + // 拖动条样式颜色 + materialProgressColors: chewie.ChewieProgressColors( + playedColor: Colors.white, + handleColor: Colors.white, + backgroundColor: Colors.grey, + bufferedColor: Colors.transparent, + ), + autoInitialize: true, + ); + chewieAudioController.addListener(_fullScreenListener); + if (mounted) setState(() {}); + }); + } + + Future _fullScreenListener() async { + if (!chewieAudioController.isFullScreen) { + Future.delayed(Duration(seconds: 1), () { + }); + } + } + + Widget videoWidget(double width, double height, src) { + print("src : $src"); + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaleFactor: 0.9, + ), + child: !isShowImg + ? (chewieAudioController != null + ? Container( + width: width, + height: height, + child: chewies = Chewie( + controller: chewieAudioController, + ), + ) + : Container( + width: width, + height: height, + )) + : GestureDetector( + onTap: (){ + setState(() { + isShowImg = false; + }); + }, + child: Container( + width: width, + height: width / 7 * 5, + color: Colors.black, + child: Stack( + children: [ + Center( + child: MImage( + src, + fit: BoxFit.cover, + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + ), + Center( + child: Icon( + Icons.play_circle_outline, + color: Colors.white, + size: 60, + ), + ), + ], + ), + ), + ), + ); + } + + Widget anthology() { + return Container( + color: Colors.white, + margin: EdgeInsets.only(bottom: 16), + padding: EdgeInsets.all(16), + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "选集", + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF1A1A1A), + ), + ), + Text( + "共${chapterList.length}集", + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF1A1A1A), + ), + ), + ], + ), + Container( + height: 70.h, + margin: EdgeInsets.only(top:10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + physics: BouncingScrollPhysics(), + itemCount:chapterList.length, + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + setState(() { + chapterIndex = position; + isShowImg = true; + initVideo(chapterList[position].content.fileUrl); + }); + }, + child: classSelectItem(chapterList[position],position), + ); + }, + ), + ), + ], + ), + ); + } + + Widget classSelectItem(Chapter chapterList,position) { + return Container( + width: 106.w, + alignment: Alignment.center, + margin: EdgeInsets.symmetric( + horizontal: 6.w, + vertical: 3, + ), + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: position==chapterIndex ? Color(0xFF32A060): Color(0xFFE5E5E5), + ), + child: Text( + chapterList?.name ?? chapterList.name ?? "", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: position == chapterIndex ? Colors.white :Color(0xFF7C7C7C), + ), + ), + ); + } + + // ///给文章/活动点赞 + // _queryInformationLikes() async { + // BaseData baseData = await apiService.courseLikes(widget.arguments["id"]).catchError((onError) {}); + // if (baseData != null && baseData.isSuccess) { + // commentKey.currentState.setState(() {}); + // setState(() { + // comunity.likes -= 1; + // else + // comunity.likes += 1; + // + // }); + // } else { + // // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + // } + // } + + ///课程点赞 + _queryCourseLikes() async { + BaseData baseData = await apiService.courseLikes(widget.arguments["id"]).catchError((onError) {}); + if (baseData != null && baseData.isSuccess) { + setState(() { + if (course.selfLiked ?? false) + course.likes -= 1; + else + course.likes += 1; + course.selfLiked = !course.selfLiked ?? false; + }); + commentKey.currentState.setState(() {}); + } else { + // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + + ///发布评论 + _queryMemberComment(String content) async { + BaseData baseData = await apiService.memberComment({ + "content": content, + "parentId": parenId, + "relationalId":widget.arguments["id"], + "relationalType": 3 + }).catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + CommentListState state = commentKey.currentState; + state.queryMemberCommentList(); + commentTextController.text = ""; + FocusScope.of(context).unfocus(); + // _toComment(); + } + } + + ///滑动到评论列表 + _toComment() { + if (commentKey.currentContext == null) return; + RenderBox firstRenderBox = commentKey.currentContext.findRenderObject(); + Offset first = firstRenderBox.localToGlobal(Offset.zero); + scrollController.animateTo( + first.dy + + scrollController.offset - + (kToolbarHeight + MediaQuery + .of(context) + .padding + .top), + duration: Duration(milliseconds: 300), + curve: Curves.easeIn, + ); + } + + ///评论 回复 + _reply(memberComment) { + FocusScope.of(context).requestFocus(commentFocus); + parenId = memberComment.id; + hintText = S.of(context).huifu_("${memberComment.username}"); + } + + ///删除评论 + delComment(memberComment) async { + BaseData baseData = await apiService.delComment(memberComment.id); + if (baseData != null && baseData.isSuccess) { + CommentListState state = commentKey.currentState; + state.queryMemberCommentList(); + } + } + + ///删除评论的提示 + _delCommentTips(memberComment) { + SmartDialog.show(widget: Tips(() { + delComment(memberComment); + })); + } +} diff --git a/lib/community/community_view/class_list_view.dart b/lib/community/community_view/class_list_view.dart new file mode 100644 index 00000000..884b6b50 --- /dev/null +++ b/lib/community/community_view/class_list_view.dart @@ -0,0 +1,196 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/retrofit/data/course_list.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; + +class ClassListView extends StatefulWidget { + final List classList; + + ClassListView(this.classList); + + @override + State createState() { + return _ClassListView(); + } +} + +class _ClassListView extends State { + @override + Widget build(BuildContext context) { + return GridView.builder( + itemCount:widget.classList == null ? 0 : widget.classList.length, + padding: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 13.h, + bottom: 16.h, + ), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + //一行的Widget数量 + crossAxisCount:2, + //水平子Widget之间间距 + crossAxisSpacing: 11.w, + //垂直子Widget之间间距 + mainAxisSpacing: 16.w, + //子Widget宽高比例 0.59 + childAspectRatio: + 260 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), + ), + itemBuilder: (context, index) { + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/class_details', + arguments: {"id": widget.classList[index].id}) + .then((value) => {widget.classList[index].viewers = value != null?value:widget.classList[index].viewers+1}); + }, + child: classListItem(widget.classList[index]), + ); + }, + ); + } + + Widget classListItem(CourseList classList) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(4), + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(10), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + color: Colors.white, + ), + margin: EdgeInsets.symmetric( + vertical: 3, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + alignment: Alignment(0.9, 0.9), + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(10), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + color: Color.fromARGB(90, 0, 0, 0), + ), + child: ClipRRect( + child: + Opacity( + opacity: 0.6, + child:MImage( + classList.coverImg, + width: double.infinity, + height: 120, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + ), + borderRadius: BorderRadius.vertical( + top: Radius.circular(4), + ), + ), + ), + Container( + padding: EdgeInsets.only(left: 4), + child: Row( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset( + "assets/image/ketang_play.png", + width: 16.w, + height: 16.h, + color: Colors.white, + ), + SizedBox(width: 5), + Text( + classList.viewers.toString(), + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), + ], + ), + SizedBox(width: 8), + // Row( + // children: [ + // Image.asset( + // "assets/image/ketang_message.png", + // width: 16.w, + // height: 16.h, + // color: Colors.white, + // ), + // SizedBox(width: 5), + // Text( + // classList.viewers.toString(), + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Colors.white, + // ), + // ), + // ], + // ), + ], + ), + ), + ], + ), + Expanded(child:Container( + padding: EdgeInsets.all(10), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + classList.subject, + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + ), + SizedBox(height: 2), + Text( + "讲师:${classList.author.name}", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ),) + ], + ), + ); + } +} diff --git a/lib/community/community_view/class_title_tab.dart b/lib/community/community_view/class_title_tab.dart new file mode 100644 index 00000000..44f47df3 --- /dev/null +++ b/lib/community/community_view/class_title_tab.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/category_select_list.dart'; +import 'package:huixiang/retrofit/data/goods_category.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/my_tab.dart'; + +class ClassTitleTab extends StatefulWidget { + final List classSelectList; + final Function notifyClassSelectList; + + ClassTitleTab(this.classSelectList,this.notifyClassSelectList); + + @override + State createState() { + return _ClassTitleTab(); + } +} + +class _ClassTitleTab extends State + with SingleTickerProviderStateMixin { + TabController tabController; + + @override + void initState() { + super.initState(); + if (widget.classSelectList != null && widget.classSelectList.length > 0) + tabController = TabController(length: widget.classSelectList.length, vsync: this ); + } + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.centerLeft, + child: DefaultTabController( + length:widget.classSelectList == null + ? 0 + : widget.classSelectList.length, + child: TabBar( + isScrollable: true, + //可滚动 + indicatorColor: Color(0xff39B54A), + labelColor: Color(0xff32A060), + labelStyle: TextStyle( + fontSize: 14.sp, + fontWeight: FontWeight.bold, + ), + unselectedLabelStyle: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + ), + controller: tabController, + //未选中文字颜色 + unselectedLabelColor: Color(0xff4D4D4D), + indicatorSize: TabBarIndicatorSize.label, + onTap: (index){ + widget.notifyClassSelectList(index); + }, + //指示器与文字等宽 + tabs:widget.classSelectList == null + ? [] + : widget.classSelectList + .map((e) => MyTab(text: e.name)) + .toList(), + ), + ), + ); + } + +} diff --git a/lib/community/community_view/course_banner.dart b/lib/community/community_view/course_banner.dart new file mode 100644 index 00000000..bf0241b9 --- /dev/null +++ b/lib/community/community_view/course_banner.dart @@ -0,0 +1,119 @@ + +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:huixiang/retrofit/data/banner.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/custom_image.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; + +class CourseBanner extends StatefulWidget { + + final List bannerData; + + CourseBanner(this.bannerData); + + @override + State createState() { + return _CourseBanner(); + } + +} + +class _CourseBanner extends State { + ApiService apiService; + final RefreshController refreshController = RefreshController(); + List bannerData = []; + + + @override + Widget build(BuildContext context) { + return Container( + child: AspectRatio( + aspectRatio: 2.08, + child: Swiper( + viewportFraction: 0.88, + scale: 0.93, + pagination: SwiperPagination( + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8, + activeSize: 8, + space: 5, + activeColor: Colors.black, + color: Colors.black.withAlpha(76), + ), + ), + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + onTap: () { + bannerClick(widget.bannerData[position]); + }, + child: MImage( + (widget.bannerData != null && position < widget.bannerData.length) + ? widget.bannerData[position].imgUrl + : "", + fit: BoxFit.cover, + radius: BorderRadius.circular(8), + errorSrc: "assets/image/default_2_1.png", + fadeSrc: "assets/image/default_2_1.png", + ), + ); + }, + itemCount: (widget.bannerData != null && widget.bannerData.length > 0) + ? widget.bannerData.length + : 1), + ), + ); + } + + /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) + bannerClick(BannerData bannerData) async { + switch (bannerData.contentType) { + case 1: + Navigator.of(context).pushNamed('/router/integral_store_page', + arguments: {"goodsId": bannerData.content}); + break; + case 2: + Navigator.of(context) + .pushNamed('/router/web_page', arguments: { + "activityId": bannerData.content, + }); + break; + case 3: + Navigator.of(context) + .pushNamed('/router/web_page', arguments: { + "articleId": bannerData.content, + }); + break; + case 4: + String router = bannerData.content; + if (router.contains("?")) { + String params = router.substring(router.indexOf("?")); + params = params.replaceAll("?", ""); + Map map = jsonDecode(params); + Navigator.of(context).pushNamed(router, arguments: map); + } else { + Navigator.of(context).pushNamed(router); + } + break; + case 5: + Navigator.of(context) + .pushNamed('/router/class_details', arguments: { + "id": bannerData.content, + }); + break; + } + } + } + + + + + + + diff --git a/lib/community/community_view/home_class.dart b/lib/community/community_view/home_class.dart new file mode 100644 index 00000000..a48984ea --- /dev/null +++ b/lib/community/community_view/home_class.dart @@ -0,0 +1,264 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:huixiang/retrofit/data/collect_class_list.dart'; +import 'package:huixiang/retrofit/data/course_list.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/view_widget/custom_image.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class HomeClass extends StatefulWidget { + final List collect; + final List collectList; + + HomeClass(this.collect,this.collectList); + @override + State createState() { + return _HomeClass(); + } +} + +class _HomeClass extends State { + ApiService apiService; + BMFCoordinate latLng; + + final TextEditingController editingController = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return ListView.builder( + padding: EdgeInsets.zero, + itemCount:widget.collectList == null ? 0 : widget.collectList.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return collectItem(widget.collectList[position]); + }, + ); + } + + Widget collectItem(CollectClassList collectList) { + return Container( + width: 168, + height: 230, + margin: EdgeInsets.symmetric( + horizontal: 6.w, + vertical:10, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding(padding: EdgeInsets.only(left: 16,top: 5), + child: Text( + collectList.name, + style: TextStyle( + fontSize: 15.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), + ),), + Container( + height: 189, + margin: EdgeInsets.only(top:10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.symmetric(horizontal: 10), + itemCount:widget.collect == null ? 0 : widget.collect.length, + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/class_details', + arguments: {"id":widget.collect[position].id}) + .then((value) => {widget.collect[position].viewers = value != null?value:widget.collect[position].viewers+1}); + }, + child: classItem(widget.collect[position]), + ); + }, + ), + ), + ], + ), + ); + } + + Widget classItem(CourseList collect) { + return Container( + width: 168, + height: 189, + decoration: BoxDecoration( + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(4), + ), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(10), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + color: Colors.white, + ), + margin: EdgeInsets.symmetric( + horizontal:6, + ), + child: Column( + children: [ + Stack( + alignment: Alignment.topRight, + children: [ + Stack( + alignment: Alignment(0.9,0.9), + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(10), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + color: Color.fromARGB(90, 0, 0, 0), + ), + child: ClipRRect( + child: Opacity( + opacity: 0.6, + child: MImage( + collect.coverImg, + width: double.infinity, + height: 120, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.png", + fadeSrc: "assets/image/default_1.png", + ), + ), + borderRadius: BorderRadius.vertical( + top: Radius.circular(4), + ), + ), + ), + Container( + padding: EdgeInsets.only(left: 4), + child:Row( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Image.asset( + "assets/image/ketang_play.png", + width: 16.w, + height: 16.h, + color: Colors.white, + ), + SizedBox(width:5), + Text( + collect.viewers.toString(), + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), + ], + ), + SizedBox(width:8), + // Row( + // children: [ + // Image.asset( + // "assets/image/ketang_message.png", + // width: 16.w, + // height: 16.h, + // color: Colors.white, + // ), + // SizedBox(width:5), + // Text( + // collect.viewers.toString(), + // style: TextStyle( + // fontSize: 12.sp, + // fontWeight: MyFontWeight.regular, + // color: Colors.white, + // ), + // ), + // ], + // ), + ], + ), + + ), + ], + ), + Container( + margin: EdgeInsets.only(top: 8,right: 8), + height: 16.h, + width: 30.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(2), + color: Color(0xFFFFCD00), + ), + child: Text( + ( collect?.tags != null && collect.tags.length > 0 )?collect.tags[0] : "", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF634815), + ), + ), + ), + ], + ), + Expanded(child: + Container( + padding: EdgeInsets.all(10), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: Text( + collect.subject, + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + ),), + ], + ), + SizedBox(height:5), + Text( + "讲师:${collect.author.name}", + overflow: TextOverflow.ellipsis, + maxLines: 2, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + ], + ), + ),), + ], + ), + ); + } +} diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index 2dcac26b..257d70a9 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -32,22 +32,21 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'home_view/shortcut_operation.dart'; + class HomePage extends StatefulWidget { - final GestureTapCallback callback; + final Function changeTab; - HomePage(this.callback); + HomePage(this.changeTab); @override State createState() { - return _HomePage(callback); + return _HomePage(); } } class _HomePage extends State with AutomaticKeepAliveClientMixin { ApiService apiService; - final GestureTapCallback callback; - - _HomePage(this.callback); @override void initState() { @@ -78,6 +77,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { List
articles = []; List gooods = []; Founder founder; + bool isSigned = false; queryHome() async { EasyLoading.show(status: S.of(context).zhengzaijiazai); @@ -263,8 +263,15 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ///banner HomeBanner(bannerData, controller), + ///快捷操作 + ShortcutOperation((){ + widget.changeTab(1); + }), + ///签到 - SignView(), + SignView(isSigned,(value){setState(() { + isSigned = value; + });}), // ///热门文章 // HotArticle(articles), @@ -273,14 +280,16 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { // ///品牌介绍 // BrandView(brandData), - ///快捷下单 + ///店铺推荐 QuickOrder(), - CouponView(), + ///超级优惠券 + // CouponView(), ///积分商城 - HomeIntegralStore(gooods, callback), + HomeIntegralStore(gooods), + ///精选活动 FeaturedActivity(), ///积分商品头Tab diff --git a/lib/home/home_view/home_banner.dart b/lib/home/home_view/home_banner.dart index a72834a8..a677bc8d 100644 --- a/lib/home/home_view/home_banner.dart +++ b/lib/home/home_view/home_banner.dart @@ -69,26 +69,24 @@ class _HomeBanner extends State { ); } - /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) + /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) bannerClick(BannerData bannerData) async { switch (bannerData.contentType) { case 1: - Navigator.of(context).pushNamed( - '/router/integral_store_page', - arguments: {"goodsId": bannerData.content}, - ); + Navigator.of(context).pushNamed('/router/integral_store_page', + arguments: {"goodsId": bannerData.content}); break; case 2: - Navigator.of(context).pushNamed( - '/router/web_page', - arguments: {"activityId": bannerData.content}, - ); + Navigator.of(context) + .pushNamed('/router/web_page', arguments: { + "activityId": bannerData.content, + }); break; case 3: - Navigator.of(context).pushNamed( - '/router/web_page', - arguments: {"articleId": bannerData.content}, - ); + Navigator.of(context) + .pushNamed('/router/web_page', arguments: { + "articleId": bannerData.content, + }); break; case 4: String router = bannerData.content; @@ -101,6 +99,12 @@ class _HomeBanner extends State { Navigator.of(context).pushNamed(router); } break; + case 5: + Navigator.of(context) + .pushNamed('/router/class_details', arguments: { + "id": bannerData.content, + }); + break; } } } diff --git a/lib/home/home_view/home_integral_store.dart b/lib/home/home_view/home_integral_store.dart index cd10e1bf..f264618c 100644 --- a/lib/home/home_view/home_integral_store.dart +++ b/lib/home/home_view/home_integral_store.dart @@ -9,10 +9,9 @@ import 'package:huixiang/view_widget/item_title.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class HomeIntegralStore extends StatefulWidget { - final GestureTapCallback callback; final List gooods; - HomeIntegralStore(this.gooods, this.callback); + HomeIntegralStore(this.gooods); @override State createState() { diff --git a/lib/home/home_view/quick_order.dart b/lib/home/home_view/quick_order.dart index 5b0dd87a..3fd1a771 100644 --- a/lib/home/home_view/quick_order.dart +++ b/lib/home/home_view/quick_order.dart @@ -161,7 +161,7 @@ class _QuickOrder extends State { return Column( children: [ ItemTitle( - text: "快捷下单", + text: "店铺推荐", imgPath: "assets/image/icon_points_mall.png", ), Container( diff --git a/lib/home/home_view/shortcut_operation.dart b/lib/home/home_view/shortcut_operation.dart new file mode 100644 index 00000000..2cfdaa20 --- /dev/null +++ b/lib/home/home_view/shortcut_operation.dart @@ -0,0 +1,162 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/activity.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/utils/font_weight.dart'; +import 'package:huixiang/view_widget/item_title.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class ShortcutOperation extends StatefulWidget { + final Function goToOrder; + + ShortcutOperation(this.goToOrder); + + @override + State createState() { + return _ShortcutOperation(); + } +} + +class _ShortcutOperation extends State { + ApiService apiService; + + @override + void initState() { + super.initState(); + } + + + @override + Widget build(BuildContext context) { + return Container( + height: 150.h, + margin: EdgeInsets.only(bottom:15), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: (){ + widget.goToOrder(); + }, + child: Container( + width: 106, + color: Colors.white, + margin: EdgeInsets.only(right:10), + padding: EdgeInsets.only(top: 8,bottom: 8), + child: Column( + children: [ + Text( + "现在下单", + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 15.sp, + color: Colors.black, + ), + ), + SizedBox(height: 5), + Text( + "美味等你来!", + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + color: Colors.black, + ), + ), + SizedBox(height: 20), + Expanded(child: Image.asset( + "assets/image/home_order.png", + width:70, + height:70, + ),), + ], + ), + ), + ), + GestureDetector( + onTap: (){ + Navigator.of(context).pushNamed('/router/recharge_page'); + }, + child: Container( + width: 106, + color: Colors.white, + margin: EdgeInsets.only(right:10), + padding: EdgeInsets.only(top: 8,bottom: 8), + child: Column( + children: [ + Text( + "平台储值", + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 15.sp, + color: Colors.black, + ), + ), + SizedBox(height: 5), + Text( + "充值送会员!", + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + color: Colors.black, + ), + ), + SizedBox(height: 20), + Expanded(child:Image.asset( + "assets/image/home_recharge.png", + width:70, + height:70, + ),), + ], + ), + ), + ), + GestureDetector( + onTap: (){ + Navigator.of(context).pushNamed('/router/roll_center_page'); + }, + child:Container( + width: 106, + color: Colors.white, + padding: EdgeInsets.only(top: 8,bottom: 8), + child: Column( + children: [ + Text( + "天天有劵", + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 15.sp, + color: Colors.black, + ), + ), + SizedBox(height: 5), + Text( + "来领超值好劵!", + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 12.sp, + color: Colors.black, + ), + ), + SizedBox(height: 20), + Expanded(child: Image.asset( + "assets/image/home_coupon.png", + width:70, + height:70, + ), ), + + ], + ), + ), + ), + ], + ), + ); + } + +} diff --git a/lib/home/home_view/sign_view.dart b/lib/home/home_view/sign_view.dart index e595cd34..25b74d92 100644 --- a/lib/home/home_view/sign_view.dart +++ b/lib/home/home_view/sign_view.dart @@ -7,6 +7,13 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class SignView extends StatelessWidget { + final bool isSigned; + final Function setSigned; + + SignView( + this.isSigned, + this.setSigned, + ); @override Widget build(BuildContext context) { @@ -37,7 +44,10 @@ class SignView extends StatelessWidget { value.getString('token') == "") { LoginTipsDialog().show(context); } else { - Navigator.of(context).pushNamed('/router/integral_page'); + Navigator.of(context).pushNamed('/router/integral_page') + .then((value) => { + if (value != null) setSigned(value), + }); } }); }, @@ -94,7 +104,7 @@ class SignView extends StatelessWidget { ], ), Text( - S.of(context).quqiandao, + isSigned ? S.of(context).yiqiandao : S.of(context).quqiandao, style: TextStyle( color: Color(0xFF727272), fontSize: 12.sp, diff --git a/lib/home/huixiang_view/huixiang_banner.dart b/lib/home/huixiang_view/huixiang_banner.dart index de2aebd2..6aa42a5f 100644 --- a/lib/home/huixiang_view/huixiang_banner.dart +++ b/lib/home/huixiang_view/huixiang_banner.dart @@ -62,7 +62,7 @@ class _HuiXiangBanner extends State { ); } - /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) + /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) bannerClick(BannerData bannerData) async { switch (bannerData.contentType) { case 1: @@ -92,6 +92,12 @@ class _HuiXiangBanner extends State { Navigator.of(context).pushNamed(router); } break; + case 5: + Navigator.of(context) + .pushNamed('/router/class_details', arguments: { + "id": bannerData.content, + }); + break; } } diff --git a/lib/home/points_mall_view/points_goods_view.dart b/lib/home/points_mall_view/points_goods_view.dart index 4e434a37..aaabe68d 100644 --- a/lib/home/points_mall_view/points_goods_view.dart +++ b/lib/home/points_mall_view/points_goods_view.dart @@ -100,6 +100,7 @@ class _PointGoods extends State { Text( goods.name, overflow: TextOverflow.ellipsis, + maxLines: 2, style: TextStyle( color: Color(0xff353535), fontWeight: MyFontWeight.medium, @@ -109,17 +110,12 @@ class _PointGoods extends State { SizedBox( height: 5.h, ), - Container( - height: 35.h * AppUtils.textScale(context), - child: Text( - goods.description, - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color(0xFF727272), - fontWeight: MyFontWeight.regular, - fontSize: 12.sp, - ), + Text( + S.of(context).jifen_(goods.price), + style: TextStyle( + color: Color(0xFF32A060), + fontSize: 14.sp, + fontWeight: MyFontWeight.semi_bold, ), ), SizedBox( @@ -143,11 +139,12 @@ class _PointGoods extends State { flex: 1, ), Text( - S.of(context).jifen_(goods.price), + "库存:${goods?.stock ?? goods?.stock ??""}份", style: TextStyle( - color: Color(0xFF32A060), - fontSize: 14.sp, - fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF585858), + decorationColor: Color(0xFF353535), + fontWeight: MyFontWeight.medium, + fontSize: 12.sp, ), ), ], diff --git a/lib/home/points_mall_view/points_mall_banner.dart b/lib/home/points_mall_view/points_mall_banner.dart index a2f3d06a..3e9e6814 100644 --- a/lib/home/points_mall_view/points_mall_banner.dart +++ b/lib/home/points_mall_view/points_mall_banner.dart @@ -69,7 +69,7 @@ class _PointMallBanner extends State { ); } - /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章) + /// contentType 跳转类型(0:不跳转,1:积分商品,2:活动,3:文章,4:页面跳转,5:课程) bannerClick(BannerData bannerData) async { switch (bannerData.contentType) { case 1: @@ -99,10 +99,15 @@ class _PointMallBanner extends State { Navigator.of(context).pushNamed(router); } break; + case 5: + Navigator.of(context) + .pushNamed('/router/class_details', arguments: { + "id": bannerData.content, + }); + break; } } - } diff --git a/lib/integral/integral_detailed_page.dart b/lib/integral/integral_detailed_page.dart index 2e1045b2..c943880c 100644 --- a/lib/integral/integral_detailed_page.dart +++ b/lib/integral/integral_detailed_page.dart @@ -199,6 +199,7 @@ class _IntegralDetailedPage extends State ]; }, body: Container( + color: Colors.white, child: SmartRefresher( controller: refreshController, enablePullDown: true, diff --git a/lib/integral/integral_page.dart b/lib/integral/integral_page.dart index daabc11b..e4f037e1 100644 --- a/lib/integral/integral_page.dart +++ b/lib/integral/integral_page.dart @@ -19,6 +19,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'intergra_view/integral_task.dart'; class IntegralPage extends StatefulWidget { + @override State createState() { return _IntegralPage(); @@ -92,6 +93,7 @@ class _IntegralPage extends State { Scaffold( backgroundColor: Colors.transparent, appBar: MyAppBar( + exit: (){Navigator.of(context).pop(signInfo.todayHasSignin ?? false);}, background: Colors.transparent, leadingColor: Colors.white, title: "", @@ -150,7 +152,7 @@ class _IntegralPage extends State { return; } EasyLoading.show(status: S.of(context).zhengzaijiazai); - BaseData baseData = await apiService.signIn(); + BaseData baseData = await apiService.signIn().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() {}); SmartDialog.show( diff --git a/lib/integral_store/integral_store_details_page.dart b/lib/integral_store/integral_store_details_page.dart index 0aace98c..3612cc6b 100644 --- a/lib/integral_store/integral_store_details_page.dart +++ b/lib/integral_store/integral_store_details_page.dart @@ -52,7 +52,7 @@ class _IntegralStoreDetailsPage extends State { queryGoodsById() async { BaseData baseData = - await apiService.creditGoodsById(arguments["goodsId"]); + await apiService.creditGoodsById(arguments["goodsId"]).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { goods = baseData.data; @@ -63,13 +63,13 @@ class _IntegralStoreDetailsPage extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: MyAppBar( - background: Color(0xFFFFFFFF), - leadingColor: Colors.black, - title: S.of(context).shangpinxiangqing, - titleColor: Colors.black, - titleSize: 16.sp, - ), + // appBar: MyAppBar( + // background: Color(0xFFFFFFFF), + // leadingColor: Colors.black, + // title: S.of(context).shangpinxiangqing, + // titleColor: Colors.black, + // titleSize: 16.sp, + // ), body: Container( child: Column( children: [ @@ -115,31 +115,34 @@ class _IntegralStoreDetailsPage extends State { ), GestureDetector( onTap: () { - if (goods != null && - points != null && - int.tryParse(goods.price) < int.tryParse(points)) { - toExchangeOrder(); - } + // if (goods != null && + // points != null && + // int.tryParse(goods.price) < int.tryParse(points)) { + // toExchangeOrder(); + // } }, child: Container( padding: EdgeInsets.only(top: 16.h, bottom: 16.h), decoration: BoxDecoration( - color: (goods != null && - points != null && - int.tryParse(goods.price) < int.tryParse(points)) - ? Color(0xFF32A060) - : Color(0xFFD8D8D8), + color: + // (goods != null && + // points != null && + // int.tryParse(goods.price) < int.tryParse(points)) + // ? Color(0xFF32A060) + // : + Color(0xFFD8D8D8), borderRadius: BorderRadius.vertical( top: Radius.circular(4), ), ), alignment: Alignment.center, child: Text( - (goods != null && - points != null && - int.tryParse(goods.price) < int.tryParse(points)) - ? S.of(context).duihuan - : S.of(context).jifenbuzu, + // (goods != null && + // points != null && + // int.tryParse(goods.price) < int.tryParse(points)) + // ? S.of(context).duihuan + // : S.of(context).jifenbuzu, + "兑换功能暂未开放", style: TextStyle( fontSize: 16.sp, color: Color(0xFFFFFFFF), @@ -194,62 +197,67 @@ class _IntegralStoreDetailsPage extends State { Container( padding: EdgeInsets.fromLTRB(16.w, 16.h, 16.w, 16.h), child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - child: Text( - goods == null ? "" : goods.name, - overflow: TextOverflow.ellipsis, + Text( + goods == null ? "" : S.of(context).jifen_(goods.price), style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: 18.sp, - color: Color(0xFF353535), + color: Color(0xFF32A060), ), ), - flex: 1, + SizedBox( + width: 10.w, ), - Text( - goods == null - ? "" - : S.of(context).yiduihuanjian("${goods.sales}"), + Expanded(child: Text( + S.of(context).yuan_(goods?.worth??goods?.worth??""), style: TextStyle( - fontSize: 10.sp, + color: Color(0xFF585858), + decoration: TextDecoration.lineThrough, + decorationColor: Color(0xFF585858), fontWeight: MyFontWeight.regular, - color: Color(0xFFA29E9E), + fontSize: 14.sp, + ), + ),), + Text( + "库存:${goods?.stock ?? goods?.stock ??""}份", + style: TextStyle( + color: Color(0xFF585858), + decorationColor: Color(0xFF353535), + fontWeight: MyFontWeight.medium, + fontSize: 12.sp, ), ), ], ), + SizedBox( + height: 8.h, + ), + Text( + goods == null ? "" : goods.name, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontWeight: MyFontWeight.semi_bold, + fontSize: 15.sp, + color: Color(0xFF353535), + ), + ), SizedBox( height: 11.h, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Text( - goods == null ? "" : goods.description, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF727272), - ), - ), - flex: 1, - ), - Text( - goods == null ? "" : S.of(context).jifen_(goods.price), - style: TextStyle( - fontWeight: MyFontWeight.semi_bold, - fontSize: 16.sp, - color: Color(0xFF32A060), - ), - ), - ], + Text( + goods == null ? "" : goods.description, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF727272), + ), ), ], ), @@ -263,28 +271,47 @@ class _IntegralStoreDetailsPage extends State { return Container( child: AspectRatio( aspectRatio: 1.3698, - child: Swiper( - pagination: SwiperPagination( - alignment: Alignment.bottomCenter, - builder: DotSwiperPaginationBuilder( - size: 8, - activeSize: 8, - space: 5, - activeColor: Colors.black, - color: Colors.black.withAlpha(76), + child: Stack( + children: [ + Swiper( + pagination: SwiperPagination( + alignment: Alignment.bottomCenter, + builder: DotSwiperPaginationBuilder( + size: 8, + activeSize: 8, + space: 5, + activeColor: Colors.black, + color: Colors.black.withAlpha(76), + ), + ), + itemBuilder: (context, position) { + return goods == null + ? Container() + : Image.network( + goods.viceImgPaths.elementAt(position), + fit: BoxFit.cover, + ); + }, + itemCount: (goods == null || goods.viceImgPaths == null) + ? 1 + : goods.viceImgPaths.length, ), - ), - itemBuilder: (context, position) { - return goods == null - ? Container() - : Image.network( - goods.viceImgPaths.elementAt(position), - fit: BoxFit.cover, - ); - }, - itemCount: (goods == null || goods.viceImgPaths == null) - ? 1 - : goods.viceImgPaths.length, + GestureDetector( + onTap: (){ + Navigator.of(context).pop(); + }, + child: Container( + margin: EdgeInsets.only(left: 16,top: 52), + padding:EdgeInsets.all(5), + child:Image.asset( + "assets/image/integral_return.png", + // alignment: Alignment.center, + width: 24, + height: 24, + ), + ), + ), + ], ), ), ); diff --git a/lib/main.dart b/lib/main.dart index fbdd0f24..5f02f6b1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -70,6 +70,7 @@ import 'package:tpns_flutter_plugin/android/xg_android_api.dart'; import 'package:tpns_flutter_plugin/tpns_flutter_plugin.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'community/community_view/class_details.dart'; import 'home/guide_page.dart'; import 'home/home_view/activity_list.dart'; import 'main_page.dart'; @@ -307,4 +308,5 @@ Map routers = { '/router/communityFollow': (context, {arguments}) => CommunityFollow(), '/router/releasePage': (context, {arguments}) => ReleasePage(), '/router/activity_list': (context, {arguments}) => ActivityList(), + '/router/class_details': (context, {arguments}) => ClassDetails(arguments: arguments), }; diff --git a/lib/main_page.dart b/lib/main_page.dart index 37fddb5b..24ffd0cf 100644 --- a/lib/main_page.dart +++ b/lib/main_page.dart @@ -78,7 +78,11 @@ class _MainPage extends State with WidgetsBindingObserver { _widgetOptions = [ // BrandPage(), - HomePage(() {}), + HomePage((index) { + setState(() { + pageController.jumpToPage(index); + }); + }), // MainHomePage(), UnionPage(), CommunityPage(), diff --git a/lib/mine/coupons_page.dart b/lib/mine/coupons_page.dart index 8f275736..4d4bd1c2 100644 --- a/lib/mine/coupons_page.dart +++ b/lib/mine/coupons_page.dart @@ -211,7 +211,7 @@ class _CouponsPage extends State { } receiveCoupon(couponId) async { - BaseData baseData = await apiService.receiveCoupon(couponId); + BaseData baseData = await apiService.receiveCoupon(couponId).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { _onRefresh(); showAlertDialog(); diff --git a/lib/mine/fans_page.dart b/lib/mine/fans_page.dart index 3bb4d01b..bd888992 100644 --- a/lib/mine/fans_page.dart +++ b/lib/mine/fans_page.dart @@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/comunity_comment.dart'; import 'package:huixiang/retrofit/data/follow_list.dart'; import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; diff --git a/lib/mine/mine_view/community_follow.dart b/lib/mine/mine_view/community_follow.dart index adc7e022..e12dbfd0 100644 --- a/lib/mine/mine_view/community_follow.dart +++ b/lib/mine/mine_view/community_follow.dart @@ -4,15 +4,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/mine/follow_page.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; -import 'package:huixiang/retrofit/data/comunity_comment.dart'; -import 'package:huixiang/retrofit/data/page.dart'; import 'package:huixiang/retrofit/data/social_info.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/my_tab.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../fans_page.dart'; diff --git a/lib/mine/mine_wallet_page.dart b/lib/mine/mine_wallet_page.dart index c68fd63a..1a3eb244 100644 --- a/lib/mine/mine_wallet_page.dart +++ b/lib/mine/mine_wallet_page.dart @@ -57,7 +57,7 @@ class _MineWalletPage extends State { } queryUserBalance() async { - BaseData baseData = await apiService.queryInfo(); + BaseData baseData = await apiService.queryInfo().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { userInfo = baseData.data; mBalance = double.tryParse(userInfo.money); diff --git a/lib/mine/user_info_page.dart b/lib/mine/user_info_page.dart index 0c09c074..55a8234e 100644 --- a/lib/mine/user_info_page.dart +++ b/lib/mine/user_info_page.dart @@ -344,7 +344,7 @@ class _UserInfoPage extends State { ///调用修改用户信息接口 modifyInfos() async { - var info = await apiService.editInfo(modifyInfo); + var info = await apiService.editInfo(modifyInfo).catchError((onError) {}); if (info.isSuccess) { setState(() { SmartDialog.showToast("用户信息修改成功", alignment: Alignment.center); @@ -355,7 +355,7 @@ class _UserInfoPage extends State { ///文件上传 fileUpload() async { if (filePath != null && filePath != "" && await File(filePath).exists()) { - BaseData baseData = await apiService.upload(File(filePath), 123123123); + BaseData baseData = await apiService.upload(File(filePath), 123123123).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { UploadResult uploadResult = baseData.data; modifyInfo["headimg"] = uploadResult.url; diff --git a/lib/order/exchange_order_page.dart b/lib/order/exchange_order_page.dart index d06bb26d..b14c326b 100644 --- a/lib/order/exchange_order_page.dart +++ b/lib/order/exchange_order_page.dart @@ -4,11 +4,16 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:dio/dio.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:fluwx/fluwx.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; +import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/font_weight.dart'; +import 'package:huixiang/utils/min.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; +import 'package:huixiang/view_widget/round_button.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -26,6 +31,9 @@ class ExchangeOrderPage extends StatefulWidget { class _ExchangeOrderPage extends State { ApiService apiService; + String money = "0"; + String balance = "0"; + var checkIndex = 1; @override void initState() { @@ -51,14 +59,15 @@ class _ExchangeOrderPage extends State { background: Color(0xFFFAFAFA), leadingColor: Colors.black, ), - body: Column( + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( children: [ - Expanded( - child: Column( + Column( children: [ Container( margin: - EdgeInsets.only(left: 16, right: 16, top: 26, bottom: 8), + EdgeInsets.only(left: 16, right: 16, top: 26, bottom: 8), padding: EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white, @@ -110,8 +119,8 @@ class _ExchangeOrderPage extends State { widget.arguments["useTyped"] == 1 ? S.of(context).ziti : widget.arguments["useTyped"] == 2 - ? S.of(context).peisong - : S.of(context).xianshangfafang, + ? S.of(context).peisong + : S.of(context).xianshangfafang, style: TextStyle( fontSize: 14.sp, color: Color(0xFF353535), @@ -153,13 +162,13 @@ class _ExchangeOrderPage extends State { (address != null && address != "") ? address : widget.arguments["useTyped"] == 1 - ? S.of(context).qingxuanzhemendian - : widget.arguments["useTyped"] == - 2 - ? S - .of(context) - .qingxuanzeshouhuodizhi - : S.of(context).xuni, + ? S.of(context).qingxuanzhemendian + : widget.arguments["useTyped"] == + 2 + ? S + .of(context) + .qingxuanzeshouhuodizhi + : S.of(context).xuni, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 14.sp, @@ -205,8 +214,8 @@ class _ExchangeOrderPage extends State { widget.arguments["useTyped"] == 1 ? S.of(context).duihuanhouwugegongzuori : widget.arguments["useTyped"] == 2 - ? S.of(context).duihuanhoufahuo - : S.of(context).feishiwushangpin, + ? S.of(context).duihuanhoufahuo + : S.of(context).feishiwushangpin, style: TextStyle( fontSize: 14.sp, color: widget.arguments["useTyped"] == 3 @@ -220,7 +229,86 @@ class _ExchangeOrderPage extends State { ), Container( margin: - EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16), + EdgeInsets.only(left: 16, right: 16, top: 26, bottom: 8), + padding: EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/image/icon_order_exchange_info.png", + width: 24, + height: 24, + ), + SizedBox(width: 4), + Text( + S.of(context).duihuanxinxi, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + color: Color(0xFF353535)), + ), + ], + ), + SizedBox( + height: 18.h, + ), + Row( + children: [ + Text( + S.of(context).lingqufangshi, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF353535), + ), + ), + SizedBox( + width: 12.w, + ), + Text( + widget.arguments["useTyped"] == 1 + ? S.of(context).ziti + : widget.arguments["useTyped"] == 2 + ? S.of(context).peisong + : S.of(context).xianshangfafang, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF353535), + ), + ), + ], + ), + SizedBox( + height: 12.h, + ), + Text( + "非实物商品兑换后领取到卡包即可使用!", + style: TextStyle( + fontSize: 14.sp, + color: Color(0xFF32A060), + fontWeight: MyFontWeight.medium + ), + ), + ], + ), + ), + Container( + margin: + EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 16), padding: EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white, @@ -310,38 +398,62 @@ class _ExchangeOrderPage extends State { SizedBox( height: 12.h, ), - // Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Text( - // "商品积分", - // style: - // TextStyle(fontSize: 14, color: Color(0xFF353535)), - // ), - // SizedBox( - // width: 12, - // ), - // Text( - // S.of(context).jifen_(widget.arguments["price"]), - // style: TextStyle( - // fontSize: 12, - // color: Colors.black, - // ), - // ), - // ], - // ), - // SizedBox( - // height: 12, - // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - "实付积分", + "应付数额", + style: + TextStyle(fontSize: 14, color: Color(0xFF353535),fontWeight: MyFontWeight.regular), + ), + SizedBox( + width: 12, + ), + Text( + S.of(context).jifen_(widget.arguments["price"]), + style: TextStyle( + fontSize: 12, + color: Colors.black, + ), + ), + ], + ), + SizedBox( + height: 12, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "现金抵扣积分", + style: + TextStyle(fontSize: 14, color: Color(0xFF353535),fontWeight: MyFontWeight.regular), + ), + SizedBox( + width: 12, + ), + Text( + S.of(context).jifen_(widget.arguments["price"]), + style: TextStyle( + fontSize: 12, + color: Colors.black, + ), + ), + ], + ), + SizedBox( + height: 12, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "合计", style: TextStyle( - fontSize: 14.sp, color: Color(0xFF353535)), + fontSize: 14.sp, color: Color(0xFF353535),fontWeight: MyFontWeight.regular), ), SizedBox( width: 12.w, @@ -356,33 +468,360 @@ class _ExchangeOrderPage extends State { ], ), ), - ], - )), - GestureDetector( - onTap: () { - if (!storeIsSelected) return; - creditOrder(); - }, - child: Container( - padding: EdgeInsets.only(top: 16, bottom: 16), - decoration: BoxDecoration( - color: MaterialStateColor.resolveWith((states) => - storeIsSelected ? Color(0xFF32A060) : Color(0xFFD8D8D8)), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(4), - topRight: Radius.circular(4))), - alignment: Alignment.center, - child: Text( - S.of(context).querenduihuan, - style: TextStyle( - fontSize: 16.sp, - color: MaterialStateColor.resolveWith((states) => - storeIsSelected ? Colors.white : Color(0xFFA0A0A0)), - fontWeight: FontWeight.bold), + Container( + margin: + EdgeInsets.only(left: 16, right: 16, bottom: 8), + padding: EdgeInsets.all(20), + decoration: BoxDecoration( + color: Colors.white, + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 3), + blurRadius: 14, + spreadRadius: 0, + ) + ], + borderRadius: BorderRadius.all(Radius.circular(8)), + ), + child: Column( + children: [ + Row( + children: [ + Expanded(child: Text( + "兑换数量", + style: TextStyle( + fontWeight: MyFontWeight.regular, + fontSize: 14.sp, + color: Color(0xFF353535)), + )), + InkWell( + onTap: () { + }, + child: Image.asset( + "assets/image/reduce.png", + width: 22, + height: 22, + ), + ), + Container( + width: 30, + alignment: Alignment.center, + child: Text( + "1", + style: TextStyle( + color: Colors.black, + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + ), + ), + ), + InkWell( + onTap: () { + }, + child: Image.asset( + "assets/image/add.png", + width: 22, + height: 22, + ), + ), + ], + ), + ], + ), + ), + Container( + width: double.infinity, + margin: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 12.h, + bottom:20.h, + ), + padding: EdgeInsets.only( + left: 16.w, + right: 16.w, + top: 20.h, + bottom: 20.h, + ), + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color(0x000000).withAlpha(25), + offset: Offset(0, 1), + blurRadius: 12.0, + ), + ], + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 16.h), + child: Text( + S.of(context).zhifufangshi, + style: TextStyle( + fontSize: 16.sp, + color: Colors.black, + fontWeight: MyFontWeight.regular, + ), + ), + ), + GestureDetector( + onTap: () { + setState(() { + checkIndex = 1; + }); + // widget.payChannelCheck(4); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + checkPayView(1), + Expanded( + child: Container(), + flex: 1, + ), + Text( + "¥$money", + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + SizedBox( + width: 10, + ), + Text( + S.of(context).pingtaiyue, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + setState(() { + checkIndex = 2; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + checkPayView(2), + Expanded( + child: Container(), + flex: 1, + ), + Text( + "¥$balance", + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + SizedBox( + width: 10, + ), + Text( + S.of(context).dianpuyue, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ], + ), + ), + SizedBox( + height: 10, + ), + GestureDetector( + onTap: () { + setState(() { + checkIndex = 3; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + checkPayView(3), + Spacer(), + Image.asset("assets/image/icon_we_chat.png"), + Padding( + padding: EdgeInsets.only(left: 8.w), + child: Text( + S.of(context).weixinzhifu, + style: TextStyle( + fontSize: 14.sp, + color: Color(0xff353535), + fontWeight: MyFontWeight.semi_bold, + ), + ), + ), + ], + ), + ), + ], + ), + ), + // GestureDetector( + // onTap: () { + // if (!storeIsSelected) return; + // creditOrder(); + // }, + // child: Container( + // padding: EdgeInsets.only(top: 16, bottom: 16), + // decoration: BoxDecoration( + // color: MaterialStateColor.resolveWith((states) => + // storeIsSelected ? Color(0xFF32A060) : Color(0xFFD8D8D8)), + // borderRadius: BorderRadius.only( + // topLeft: Radius.circular(4), + // topRight: Radius.circular(4))), + // alignment: Alignment.center, + // child: Text( + // S.of(context).querenduihuan, + // style: TextStyle( + // fontSize: 16.sp, + // color: MaterialStateColor.resolveWith((states) => + // storeIsSelected ? Colors.white : Color(0xFFA0A0A0)), + // fontWeight: FontWeight.bold), + // ), + // ), + // ), + Container( + height: 54.h, + color: Colors.white, + child: Row( + children: [ + Spacer(), + Padding(padding: EdgeInsets.only(top: 7,right: 16), + child:Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + "¥0.0", + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + ], + )), + GestureDetector( + onTap: () { + + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.jiesuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), ), - ), + Container( + height: 54.h, + color: Colors.white, + child: Row( + children: [ + Spacer(), + Padding(padding: EdgeInsets.only(top: 7,right: 16), + child:Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + S.of(context).heji, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + Text( + S.of(context).jifen_(widget.arguments["price"]), + style: TextStyle( + fontSize: 16.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF32A060), + ), + ), + ], + )), + GestureDetector( + onTap: () { + if (!storeIsSelected) return; + creditOrder(); + }, + child: RoundButton( + width: 103.w, + height: 54.h, + text: S.current.duihuan, + textColor: Colors.white, + fontWeight: MyFontWeight.regular, + backgroup: Color(0xFF32A060), + radius: 0, + fontSize: 16.sp, + padding: EdgeInsets.symmetric(vertical: 5.h), + ), + ), + ], + ), + ), + ], ), + + // Expanded( + // child: + // ), + ], + ) ,), + ); + } + + Widget checkPayView(var index) { + return Container( + padding: EdgeInsets.only(right: 16.w), + alignment: Alignment.center, + child: Image.asset( + checkIndex != index + ? "assets/image/icon_radio_unselected.png" + : "assets/image/icon_radio_selected.png", + width: 15.w, + height: 15.h, ), ); } @@ -425,10 +864,44 @@ class _ExchangeOrderPage extends State { "goodsId": widget.arguments["goodsId"], "number": 1, "useTyped": widget.arguments["useTyped"], + "payChannel":checkIndex == 3?"1":"4", if (widget.arguments["useTyped"] == 1) "storeId": storeId, if (widget.arguments["useTyped"] == 2) "userAddressId": userAddressId, }); if (baseDate.isSuccess) { + if(checkIndex == 3){ + if (!(await Min.isInitialize())) { + // 小程序的微信支付和app的充值支付使用同一个WXPayEntryActivity回调, + // 然而充值时小程序未初始化会导致回调内部代码调用getPackage空指针, + // 故而在此初始化一下 + await Min.initialize(); + } + WxPay wxPay = WxPay.fromJson(baseDate.data); + await registerWxApi( + appId: wxPay.appId, + doOnAndroid: true, + universalLink: "https://hx.lotus-wallet.com/app/", + ); + payWithWeChat( + appId: wxPay.appId, + partnerId: wxPay.partnerId, + prepayId: wxPay.prepayId, + packageValue: wxPay.packageValue, + nonceStr: wxPay.nonceStr, + timeStamp: int.tryParse(wxPay.timeStamp), + sign: wxPay.sign, + ); + weChatResponseEventHandler.listen((event) async { + print("payCallback: ${event.errCode}"); + Navigator.of(context).popAndPushNamed( + '/router/order_details', + arguments: { + "id": widget.arguments["goodsId"], + }, + ); + }); + return; + } await Navigator.of(context) .pushNamed('/router/exchange_order_success_page', arguments: { "price": widget.arguments["price"], diff --git a/lib/order/order_view/order_status.dart b/lib/order/order_view/order_status.dart index 2dabdf1f..fd2125c6 100644 --- a/lib/order/order_view/order_status.dart +++ b/lib/order/order_view/order_status.dart @@ -90,6 +90,7 @@ class _OrderStatus extends State { fontSize: 15.sp, ), ), + if(widget.payStatus != 0) Image.asset( statusPicture(widget.title), height: 66.h, diff --git a/lib/retrofit/data/category_select_list.dart b/lib/retrofit/data/category_select_list.dart new file mode 100644 index 00000000..d6309a6e --- /dev/null +++ b/lib/retrofit/data/category_select_list.dart @@ -0,0 +1,114 @@ +/// id : "1452472226421932032" +/// createTime : "2021-10-25 11:08:59" +/// createUser : "1" +/// updateTime : "2021-10-25 11:08:59" +/// updateUser : "1" +/// name : "4444" +/// isTop : true +/// sort : 0 +/// isDelete : 0 + +class CategorySelectList { + CategorySelectList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String name, + bool isTop, + int sort, + int isDelete,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _name = name; + _isTop = isTop; + _sort = sort; + _isDelete = isDelete; +} + + CategorySelectList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _name = json['name']; + _isTop = json['isTop']; + _sort = json['sort']; + _isDelete = json['isDelete']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _name; + bool _isTop; + int _sort; + int _isDelete; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get name => _name; + bool get isTop => _isTop; + int get sort => _sort; + int get isDelete => _isDelete; + + + set id(String value) { + _id = value; + } + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['name'] = _name; + map['isTop'] = _isTop; + map['sort'] = _sort; + map['isDelete'] = _isDelete; + return map; + } + + set createTime(String value) { + _createTime = value; + } + + set createUser(String value) { + _createUser = value; + } + + set updateTime(String value) { + _updateTime = value; + } + + set updateUser(String value) { + _updateUser = value; + } + + set name(String value) { + _name = value; + } + + set isTop(bool value) { + _isTop = value; + } + + set sort(int value) { + _sort = value; + } + + set isDelete(int value) { + _isDelete = value; + } +} \ No newline at end of file diff --git a/lib/retrofit/data/chapter.dart b/lib/retrofit/data/chapter.dart new file mode 100644 index 00000000..f4111ac1 --- /dev/null +++ b/lib/retrofit/data/chapter.dart @@ -0,0 +1,136 @@ +/// id : "1452530820865589248" +/// createTime : "2021-10-25 15:01:49" +/// createUser : "1" +/// updateTime : "2021-11-02 17:09:56" +/// updateUser : "1" +/// courseId : "1452472611438067712" +/// name : "111" +/// content : {"coverImg":"https://pos.upload.gznl.top/0000/2021/11/3e014154-57cc-441e-9d02-aa53975979f5.png","remark":"11111111","fileUrl":"https://pos.upload.gznl.top/0000/2021/11/d87dd996-e269-46eb-b7ef-f8ceddfabef2.mp4"} +/// sort : 0 +/// isDelete : 0 + +class Chapter { + Chapter({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String courseId, + String name, + Content content, + int sort, + int isDelete,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _courseId = courseId; + _name = name; + _content = content; + _sort = sort; + _isDelete = isDelete; +} + + Chapter.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _courseId = json['courseId']; + _name = json['name']; + _content = json['content'] != null ? Content.fromJson(json['content']) : null; + _sort = json['sort']; + _isDelete = json['isDelete']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _courseId; + String _name; + Content _content; + int _sort; + int _isDelete; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get courseId => _courseId; + String get name => _name; + Content get content => _content; + int get sort => _sort; + int get isDelete => _isDelete; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['courseId'] = _courseId; + map['name'] = _name; + if (_content != null) { + map['content'] = _content.toJson(); + } + map['sort'] = _sort; + map['isDelete'] = _isDelete; + return map; + } + +} + +/// coverImg : "https://pos.upload.gznl.top/0000/2021/11/3e014154-57cc-441e-9d02-aa53975979f5.png" +/// remark : "11111111" +/// fileUrl : "https://pos.upload.gznl.top/0000/2021/11/d87dd996-e269-46eb-b7ef-f8ceddfabef2.mp4" + +class Content { + Content({ + String coverImg, + String remark, + String fileUrl,}){ + _coverImg = coverImg; + _remark = remark; + _fileUrl = fileUrl; +} + + Content.fromJson(dynamic json) { + _coverImg = json['coverImg']; + _remark = json['remark']; + _fileUrl = json['fileUrl']; + } + String _coverImg; + String _remark; + String _fileUrl; + + String get coverImg => _coverImg; + String get remark => _remark; + String get fileUrl => _fileUrl; + + + set coverImg(String value) { + _coverImg = value; + } + + Map toJson() { + final map = {}; + map['coverImg'] = _coverImg; + map['remark'] = _remark; + map['fileUrl'] = _fileUrl; + return map; + } + + set remark(String value) { + _remark = value; + } + + set fileUrl(String value) { + _fileUrl = value; + } +} \ No newline at end of file diff --git a/lib/retrofit/data/collect_class_list.dart b/lib/retrofit/data/collect_class_list.dart new file mode 100644 index 00000000..be69a97d --- /dev/null +++ b/lib/retrofit/data/collect_class_list.dart @@ -0,0 +1,114 @@ +/// id : "1454326699855446016" +/// createTime : "2021-10-30 13:58:00" +/// createUser : "1" +/// updateTime : "2021-10-30 13:58:00" +/// updateUser : "1" +/// name : "111" +/// sort : 0 +/// enabled : true +/// isDelete : 0 + +class CollectClassList { + CollectClassList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String name, + int sort, + bool enabled, + int isDelete,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _name = name; + _sort = sort; + _enabled = enabled; + _isDelete = isDelete; +} + + CollectClassList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _name = json['name']; + _sort = json['sort']; + _enabled = json['enabled']; + _isDelete = json['isDelete']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _name; + int _sort; + bool _enabled; + int _isDelete; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get name => _name; + int get sort => _sort; + bool get enabled => _enabled; + int get isDelete => _isDelete; + + + set id(String value) { + _id = value; + } + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['name'] = _name; + map['sort'] = _sort; + map['enabled'] = _enabled; + map['isDelete'] = _isDelete; + return map; + } + + set createTime(String value) { + _createTime = value; + } + + set createUser(String value) { + _createUser = value; + } + + set updateTime(String value) { + _updateTime = value; + } + + set updateUser(String value) { + _updateUser = value; + } + + set name(String value) { + _name = value; + } + + set sort(int value) { + _sort = value; + } + + set enabled(bool value) { + _enabled = value; + } + + set isDelete(int value) { + _isDelete = value; + } +} \ No newline at end of file diff --git a/lib/retrofit/data/course_details.dart b/lib/retrofit/data/course_details.dart new file mode 100644 index 00000000..e1437279 --- /dev/null +++ b/lib/retrofit/data/course_details.dart @@ -0,0 +1,222 @@ +/// id : "1455102859841372160" +/// createTime : "2021-11-01 17:22:11" +/// createUser : "1" +/// updateTime : "2021-11-01 17:22:11" +/// updateUser : "1" +/// categoryId : "1452472226421932032" +/// subject : "后会无期" +/// tags : ["11"] +/// coverImg : "https://pos.upload.gznl.top/0000/2021/11/d8305d15-1a39-4b08-a172-eba7f18b9968.jpg" +/// author : {"name":"1","avatar":"1"} +/// introduce : "1" +/// viewers : 0 +/// likes : 0 +/// state : true +/// isDelete : 0 + +class CourseDetails { + CourseDetails({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String categoryId, + String subject, + List tags, + String coverImg, + Author author, + String introduce, + int viewers, + int likes, + bool selfLiked, + bool state, + int isDelete,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _categoryId = categoryId; + _subject = subject; + _tags = tags; + _coverImg = coverImg; + _author = author; + _introduce = introduce; + _viewers = viewers; + _likes = likes; + _selfLiked = selfLiked; + _state = state; + _isDelete = isDelete; +} + + CourseDetails.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _categoryId = json['categoryId']; + _subject = json['subject']; + _tags = json['tags'] != null ? json['tags'].cast() : []; + _coverImg = json['coverImg']; + _author = json['author'] != null ? Author.fromJson(json['author']) : null; + _introduce = json['introduce']; + _viewers = json['viewers']; + _likes = json['likes']; + _selfLiked = json['selfLiked']; + _state = json['state']; + _isDelete = json['isDelete']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _categoryId; + String _subject; + List _tags; + String _coverImg; + Author _author; + String _introduce; + int _viewers; + int _likes; + bool _selfLiked; + bool _state; + int _isDelete; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get categoryId => _categoryId; + String get subject => _subject; + List get tags => _tags; + String get coverImg => _coverImg; + Author get author => _author; + String get introduce => _introduce; + int get viewers => _viewers; + int get likes => _likes; + bool get selfLiked => _selfLiked; + bool get state => _state; + int get isDelete => _isDelete; + + + set id(String value) { + _id = value; + } + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['categoryId'] = _categoryId; + map['subject'] = _subject; + map['tags'] = _tags; + map['coverImg'] = _coverImg; + if (_author != null) { + map['author'] = _author.toJson(); + } + map['introduce'] = _introduce; + map['viewers'] = _viewers; + map['likes'] = _likes; + map['selfLiked'] = _selfLiked; + map['state'] = _state; + map['isDelete'] = _isDelete; + return map; + } + + set createTime(String value) { + _createTime = value; + } + + set createUser(String value) { + _createUser = value; + } + + set updateTime(String value) { + _updateTime = value; + } + + set updateUser(String value) { + _updateUser = value; + } + + set categoryId(String value) { + _categoryId = value; + } + + set subject(String value) { + _subject = value; + } + + set tags(List value) { + _tags = value; + } + + set coverImg(String value) { + _coverImg = value; + } + + set author(Author value) { + _author = value; + } + + set introduce(String value) { + _introduce = value; + } + + set viewers(int value) { + _viewers = value; + } + + set likes(int value) { + _likes = value; + } + + set selfLiked(bool value) { + _selfLiked = value; + } + + set state(bool value) { + _state = value; + } + + set isDelete(int value) { + _isDelete = value; + } +} + +/// name : "1" +/// avatar : "1" + +class Author { + Author({ + String name, + String avatar,}){ + _name = name; + _avatar = avatar; +} + + Author.fromJson(dynamic json) { + _name = json['name']; + _avatar = json['avatar']; + } + String _name; + String _avatar; + + String get name => _name; + String get avatar => _avatar; + + Map toJson() { + final map = {}; + map['name'] = _name; + map['avatar'] = _avatar; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/data/course_list.dart b/lib/retrofit/data/course_list.dart new file mode 100644 index 00000000..3f9142fa --- /dev/null +++ b/lib/retrofit/data/course_list.dart @@ -0,0 +1,220 @@ +/// id : "1452470112895369216" +/// createTime : "2021-10-25 11:00:35" +/// createUser : "1" +/// updateTime : "2021-10-25 11:00:35" +/// updateUser : "1" +/// categoryId : "1452453250065235968" +/// subject : "11" +/// tags : ["11"] +/// coverImg : "https://pos.upload.gznl.top/0000/2021/10/61dda29b-19cf-4d47-b6c7-c07f895beeaa.jpg" +/// author : {"name":"11","avatar":"11"} +/// introduce : "11" +/// viewers : 0 +/// likes : 0 +/// state : true +/// isDelete : 0 + +class CourseList { + CourseList({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String categoryId, + String subject, + List tags, + String coverImg, + Author author, + String introduce, + int viewers, + int likes, + bool state, + int isDelete,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _categoryId = categoryId; + _subject = subject; + _tags = tags; + _coverImg = coverImg; + _author = author; + _introduce = introduce; + _viewers = viewers; + _likes = likes; + _state = state; + _isDelete = isDelete; +} + + CourseList.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _categoryId = json['categoryId']; + _subject = json['subject']; + _tags = json['tags'] != null ? json['tags'].cast() : []; + _coverImg = json['coverImg']; + _author = json['author'] != null ? Author.fromJson(json['author']) : null; + _introduce = json['introduce']; + _viewers = json['viewers']; + _likes = json['likes']; + _state = json['state']; + _isDelete = json['isDelete']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _categoryId; + String _subject; + List _tags; + String _coverImg; + Author _author; + String _introduce; + int _viewers; + int _likes; + bool _state; + int _isDelete; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get categoryId => _categoryId; + String get subject => _subject; + List get tags => _tags; + String get coverImg => _coverImg; + Author get author => _author; + String get introduce => _introduce; + int get viewers => _viewers; + int get likes => _likes; + bool get state => _state; + int get isDelete => _isDelete; + + + set id(String value) { + _id = value; + } + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['categoryId'] = _categoryId; + map['subject'] = _subject; + map['tags'] = _tags; + map['coverImg'] = _coverImg; + if (_author != null) { + map['author'] = _author.toJson(); + } + map['introduce'] = _introduce; + map['viewers'] = _viewers; + map['likes'] = _likes; + map['state'] = _state; + map['isDelete'] = _isDelete; + return map; + } + + set createTime(String value) { + _createTime = value; + } + + set createUser(String value) { + _createUser = value; + } + + set updateTime(String value) { + _updateTime = value; + } + + set updateUser(String value) { + _updateUser = value; + } + + set categoryId(String value) { + _categoryId = value; + } + + set subject(String value) { + _subject = value; + } + + set tags(List value) { + _tags = value; + } + + set coverImg(String value) { + _coverImg = value; + } + + set author(Author value) { + _author = value; + } + + set introduce(String value) { + _introduce = value; + } + + set viewers(int value) { + _viewers = value; + } + + set likes(int value) { + _likes = value; + } + + set state(bool value) { + _state = value; + } + + set isDelete(int value) { + _isDelete = value; + } +} + +/// name : "11" +/// avatar : "11" + +class Author { + Author({ + String name, + String avatar,}){ + _name = name; + _avatar = avatar; +} + + Author.fromJson(dynamic json) { + _name = json['name']; + _avatar = json['avatar']; + } + String _name; + String _avatar; + + String get name => _name; + String get avatar => _avatar; + + + set name(String value) { + _name = value; + } + + Map toJson() { + final map = {}; + map['name'] = _name; + map['avatar'] = _avatar; + return map; + } + + set avatar(String value) { + _avatar = value; + } +} \ No newline at end of file diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index bd386bcc..7c11a416 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -21,13 +21,12 @@ import 'data/shoppingCart.dart'; part 'min_api.g.dart'; -const base_url = "https://pos.api.lotus-wallet.com/app/"; ///正式 -const baseUrl = "https://pos.api.lotus-wallet.com/app/"; ///正式 +// const base_url = "https://pos.api.lotus-wallet.com/app/"; ///正式 +// const baseUrl = "https://pos.api.lotus-wallet.com/app/"; ///正式 + +const base_url = "http://192.168.10.236:8765/app/";///费韬 +const baseUrl = "http://192.168.10.236:8765/app/";///费韬 -// const base_url = "http://192.168.10.236:8765/app/"; -///费韬 -// const baseUrl = "http://192.168.10.236:8765/app/"; -///费韬 // const base_url = "http://192.168.10.37:8766/app/"; // const baseUrl = "http://192.168.10.37:8766/app/"; diff --git a/lib/retrofit/min_api.g.dart b/lib/retrofit/min_api.g.dart index 02d9988a..1c1cc751 100644 --- a/lib/retrofit/min_api.g.dart +++ b/lib/retrofit/min_api.g.dart @@ -9,7 +9,7 @@ part of 'min_api.dart'; class _MinApiService implements MinApiService { _MinApiService(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'https://pos.api.lotus-wallet.com/app/'; + baseUrl ??= 'http://192.168.10.236:8765/app/'; } final Dio _dio; diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 8df47f39..10b18133 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -20,6 +20,11 @@ import 'package:retrofit/retrofit.dart'; import 'data/address.dart'; import 'data/banner.dart'; import 'data/brand_data.dart'; +import 'data/category_select_list.dart'; +import 'data/chapter.dart'; +import 'data/collect_class_list.dart'; +import 'data/course_details.dart'; +import 'data/course_list.dart'; import 'data/exchange_order.dart'; import 'data/follow_list.dart'; import 'data/goods.dart'; @@ -40,15 +45,19 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const base_url = "https://pos.platform.lotus-wallet.com/app/"; ///正式 +// const baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///正式 -// const base_url = "http://192.168.10.236:8766/app/"; ///费韬 -// const baseUrl = "http://192.168.10.236:8766/app/"; ///费韬 +const base_url = "http://192.168.10.236:8766/app/"; ///费韬 +const baseUrl = "http://192.168.10.236:8766/app/"; ///费韬 // const base_url = "http://192.168.10.37:8766/app/"; // const baseUrl = "http://192.168.10.37:8766/app/"; + +// const base_url = "http://192.168.10.130:8766/app/";///詹云久 +// const baseUrl = "http://192.168.10.130:8766/app/";///詹云久 + @RestApi(baseUrl: baseUrl) abstract class ApiService { factory ApiService( @@ -389,4 +398,32 @@ abstract class ApiService { @GET("/member/socialInfo") Future> socialInfo(); + ///课程分类列表 + @GET("/course/categoryList") + Future>> categoryList(); + + ///课程章节列表 + @GET("/course/catalogList/{courseId}") + Future>> catalogList(@Path("courseId") String courseId); + + /// 课程列表 + @POST("/course/list") + Future>> courseList(@Body() Map map); + + ///课程的合集列表 + @GET("/course/collectList") + Future>> collectList(); + + ///合集包含的课程列表 + @GET("/course/collect/{collectId}") + Future>> collect(@Path("collectId") String collectId); + + ///课程详情 + @GET("/course/{id}") + Future> course(@Path("id") String id); + + ///给文章/活动点赞 + @GET("/course/likes/{courseId}") + Future courseLikes(@Path("courseId") String courseId); + } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 3c96e516..8c3cf22b 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -9,7 +9,7 @@ part of 'retrofit_api.dart'; class _ApiService implements ApiService { _ApiService(this._dio, {this.baseUrl}) { ArgumentError.checkNotNull(_dio, '_dio'); - baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/'; + baseUrl ??= 'http://192.168.10.236:8766/app/'; } final Dio _dio; @@ -346,13 +346,15 @@ class _ApiService implements ApiService { const _extra = {}; final queryParameters = {}; final _data = {}; + final _headers = {}; + _headers.addAll({"Environment":"app"}); _data.addAll(param ?? {}); final _result = await _dio.request>( '/creditOrder/create', queryParameters: queryParameters, options: RequestOptions( method: 'POST', - headers: {}, + headers: _headers, extra: _extra, baseUrl: baseUrl), data: _data); @@ -1345,4 +1347,188 @@ class _ApiService implements ApiService { ); return value; } + + @override + Future>> categoryList() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/course/categoryList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => CategorySelectList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> catalogList(courseId) async { + ArgumentError.checkNotNull(courseId, 'courseId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/course/catalogList/$courseId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => Chapter.fromJson(i as Map)) + .toList()); + return value; + } + + // + // @override + // Future> catalogList(courseId) async { + // ArgumentError.checkNotNull(courseId, 'courseId'); + // const _extra = {}; + // final queryParameters = {}; + // final _data = {}; + // final _result = await _dio.request>( + // '/course/catalogList/$courseId', + // queryParameters: queryParameters, + // options: RequestOptions( + // method: 'GET', + // headers: {}, + // extra: _extra, + // baseUrl: baseUrl), + // data: _data); + // final value = BaseData.fromJson( + // _result.data, + // (json) => json as dynamic, + // ); + // return value; + // } + + @override + Future>> courseList(map) async { + ArgumentError.checkNotNull(map, 'map'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(map ?? {}); + final _result = await _dio.request>( + '/course/list', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => PageInfo.fromJson( + json, + (json) => CourseList.fromJson(json), + ), + ); + return value; + } + + @override + Future>> collectList() async { + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/course/collectList', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => CollectClassList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> collect(collectId) async { + ArgumentError.checkNotNull(collectId, 'collectId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/course/collect/$collectId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map((i) => CourseList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future> course(id) async { + ArgumentError.checkNotNull(id, 'id'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/course/$id', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => CourseDetails.fromJson(json), + ); + return value; + } + + @override + Future> courseLikes(courseId) async { + ArgumentError.checkNotNull(courseId, 'courseId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/course/likes/$courseId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + } diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 3863b879..3009fd2f 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -62,7 +62,6 @@ class _Settlement extends State { CouponListBean couponListBean; PromotionInfoListBean promotion; String mobile; - bool placeOrder = false; @override @@ -318,7 +317,9 @@ class _Settlement extends State { } else { SmartDialog.show( widget: Tips( - () {}, + () { + toOrderDetails(placeOrderFirst.id); + }, text: "${baseData.msg}", )); } @@ -383,10 +384,10 @@ class _Settlement extends State { ), /// 预留的手机号, 可修改 - EditPhoneWidget( - storeInfo, - mobileChange, - ), + // EditPhoneWidget( + // storeInfo, + // mobileChange, + // ), ///订单商品 SettlementOrderCommodity( diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index cb8a5e32..a5b1dc56 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -637,18 +637,19 @@ class _StoreOrderPage extends State } ///选规格 - _queryMiNiDetail(String id) async { + _queryMiNiDetail(String id,int count) async { EasyLoading.show(status: S.current.zhengzaijiazai); BaseData baseData = await minService.miNiDetail(id).catchError((error){}); if (baseData != null && baseData.isSuccess) { - showStoreSelector(baseData.data, id); + showStoreSelector(baseData.data, id,count); } } ///选规格弹窗 - showStoreSelector(MiNiDetail miNiDetail, String id) async { - if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1) { - _addShopCar(miNiDetail, [], 1); + showStoreSelector(MiNiDetail miNiDetail, String id,int count) async { + if (miNiDetail.attrList != null && miNiDetail.attrList.length == 1 + && miNiDetail.attrList[0].attrValueList.length == 1) { + _addShopCar(miNiDetail, [], count); } else { EasyLoading.dismiss(); dialogShowing = true; diff --git a/lib/store/store_view/shop_car.dart b/lib/store/store_view/shop_car.dart index 1519123d..8d96a8f5 100644 --- a/lib/store/store_view/shop_car.dart +++ b/lib/store/store_view/shop_car.dart @@ -8,7 +8,7 @@ import 'package:huixiang/view_widget/round_button.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ShopCar extends StatefulWidget { - final Function(String id) queryMiNiDetail; + final Function(String id,int count) queryMiNiDetail; final Function() clearShopCar; final Function() toDownOrder; final Function(ShoppingCartSkuItemListBean cart) shopCartAdd; diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index 3ebae265..56fd25d3 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -8,7 +8,7 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/round_button.dart'; class ShopGoods extends StatefulWidget { - final Function(String id) queryMiNiDetail; + final Function(String id,int count) queryMiNiDetail; final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) add; final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) reduce; @@ -131,7 +131,7 @@ class _ShopGoods extends State { ], ), Spacer(), - if (!widget.isShopCart) + if (!widget.isShopCart && (widget.productListBean?.attrStyle??0) == 1) Stack( children: [ Container( @@ -150,7 +150,7 @@ class _ShopGoods extends State { widget.productListBean != null ? widget.productListBean.id : widget.shoppingCartSkuItemListBean - .productId, + .productId,0 ); }, ), @@ -173,7 +173,7 @@ class _ShopGoods extends State { ), ], ), - if (widget.isShopCart) + if (widget.isShopCart || (widget.productListBean?.attrStyle??0) == 0) InkWell( onTap: () { widget.reduce(widget.shoppingCartSkuItemListBean); @@ -184,7 +184,7 @@ class _ShopGoods extends State { height: 22, ), ), - if (widget.isShopCart) + if (widget.isShopCart || (widget.productListBean?.attrStyle??0) == 0) Container( width: 30, alignment: Alignment.center, @@ -197,7 +197,7 @@ class _ShopGoods extends State { ), ), ), - if (widget.isShopCart) + if (widget.isShopCart || (widget.productListBean?.attrStyle??0) == 0) InkWell( onTap: () { widget.add(widget.shoppingCartSkuItemListBean); diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index c879e5f9..ae7cf7e8 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -21,7 +21,7 @@ class StoreOrderListPage extends StatefulWidget { final ScrollController controller; final String minToken; final String tenant; - final Function(String id) queryMiNiDetail; + final Function(String id,int count) queryMiNiDetail; ShoppingCart shopCarGoods; @@ -232,14 +232,15 @@ class _StoreOrderListPage extends State { } return InkWell( onTap: () { - widget.queryMiNiDetail(productListBeans[position].id); + widget.queryMiNiDetail(productListBeans[position].id,1); }, child: ShopGoods( (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { - // widget.add(productListBeans[position].id); + widget.queryMiNiDetail(productListBeans[position].id,1); }, (ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) { - // widget.reduce(productListBeans[position].id); + if(count > 0) + widget.queryMiNiDetail(productListBeans[position].id,-1); }, productListBean: productListBeans[position], count: count, diff --git a/lib/union/union_page.dart b/lib/union/union_page.dart index 31e9ec14..a3bfcf92 100644 --- a/lib/union/union_page.dart +++ b/lib/union/union_page.dart @@ -1,5 +1,4 @@ import 'dart:ui'; - import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; @@ -13,7 +12,6 @@ import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/store.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/store/scan.dart'; import 'package:huixiang/utils/event_type.dart'; import 'package:huixiang/utils/location.dart'; import 'package:huixiang/view_widget/border_text.dart'; @@ -93,7 +91,6 @@ class _UnionPage extends State startLocation() async { EasyLoading.show(status: S.current.zhengzaijiazai); - Location.getInstance() .aMapFlutterLocation .onResultCallback() diff --git a/lib/view_widget/my_appbar.dart b/lib/view_widget/my_appbar.dart index aa421290..2013cf3a 100644 --- a/lib/view_widget/my_appbar.dart +++ b/lib/view_widget/my_appbar.dart @@ -16,6 +16,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { final double toolbarHeight; final bool leading; final Brightness brightness; + final Function exit; MyAppBar({ Key key, @@ -32,6 +33,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { this.titleSize = 18, this.brightness = Brightness.light, this.leading = true, + this.exit }) : preferredSize = Size.fromHeight(toolbarHeight ?? kToolbarHeight), super(key: key) { if (actions == null) @@ -58,7 +60,9 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget { leading: leading ? GestureDetector( onTap: () { + if(exit == null) Navigator.of(context).pop(); + else exit(); }, child: Container( alignment: Alignment.centerRight, diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index 70df4568..5b0463ba 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -190,7 +190,7 @@ class _WebPage extends State with WidgetsBindingObserver { //给文章/活动点赞 _queryInformationLikes() async { BaseData baseData = await apiService.informationLikes( - widget.arguments["activityId"] ?? widget.arguments["articleId"]); + widget.arguments["activityId"] ?? widget.arguments["articleId"]).catchError((onError) {}); if (baseData != null && baseData.isSuccess) { if (article != null) { if (article.liked) { @@ -273,10 +273,14 @@ class _WebPage extends State with WidgetsBindingObserver { commentKey, article?.likes ?? activity?.likes ?? 0, widget.arguments["activityId"] ?? widget.arguments["articleId"], + 1, isKeyBoardShow, _reply, _delCommentTips, 12.sp, + requestApiFinish: (total){setState(() { + commentTotal = total; + });}, ), ], ), diff --git a/lib/web/web_view/comment_list.dart b/lib/web/web_view/comment_list.dart index 10dd6fd0..156776d5 100644 --- a/lib/web/web_view/comment_list.dart +++ b/lib/web/web_view/comment_list.dart @@ -22,10 +22,12 @@ class CommentList extends StatefulWidget { final Function delCommentTips; final double fontSize; final String relationalId; + final int relationalType; final int like; + final Function requestApiFinish; - CommentList(Key key, this.like, this.relationalId, - this.isKeyBoardShow, this.reply, this.delCommentTips, this.fontSize) + CommentList(Key key, this.like, this.relationalId,this.relationalType, + this.isKeyBoardShow, this.reply, this.delCommentTips, this.fontSize,{this.requestApiFinish}) : super(key: key); @override @@ -159,23 +161,23 @@ class CommentListState extends State { ), ), ), - if (memberList == null || memberList.length == 0) - Container( - width: double.infinity, - height: MediaQuery.of(context).size.height - kToolbarHeight - - MediaQuery.of(context).padding.top - 160.h, - alignment: Alignment.topCenter, - color: Color(0xFFF2F2F2), - padding: EdgeInsets.only(top: 22.h), - child: Text( - S.of(context).zanwupinglun, - style: TextStyle( - fontSize: widget.fontSize + 2, - fontWeight: FontWeight.bold, - color: Color(0xFFA0A0A0), - ), - ), - ), + // if (memberList == null || memberList.length == 0) + // Container( + // width: double.infinity, + // height: MediaQuery.of(context).size.height - kToolbarHeight + // - MediaQuery.of(context).padding.top - 160.h, + // alignment: Alignment.topCenter, + // color: Color(0xFFF2F2F2), + // padding: EdgeInsets.only(top: 22.h), + // child: Text( + // S.of(context).zanwupinglun, + // style: TextStyle( + // fontSize: widget.fontSize + 2, + // fontWeight: FontWeight.bold, + // color: Color(0xFFA0A0A0), + // ), + // ), + // ), ], ), ), @@ -197,6 +199,8 @@ class CommentListState extends State { //评论列表 queryMemberCommentList() async { + if(widget?.relationalId == null || widget.relationalId.isEmpty) + return; SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); if (apiService == null) apiService = ApiService( @@ -210,13 +214,17 @@ class CommentListState extends State { "pageNum": 1, "pageSize": 100, "relationalId": widget.relationalId, - "relationalType": 1, + "relationalType": widget.relationalType, }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { - commentTotal = baseData.data.size; - memberList = baseData.data.list; - contentHeight(); - setState(() {}); + setState(() { + memberList.clear(); + commentTotal = baseData.data.size; + widget.requestApiFinish(commentTotal); + memberList.addAll(baseData.data.list); + contentHeight(); + setState(() {}); + }); } }