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/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/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/lib/community/community_course.dart b/lib/community/community_course.dart new file mode 100644 index 00000000..da083281 --- /dev/null +++ b/lib/community/community_course.dart @@ -0,0 +1,234 @@ +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/brand_data.dart'; +import 'package:huixiang/retrofit/data/category_select_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/login_tips_dialog.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 brands = []; + BrandData brandData; + List globaKeys = []; + List bannerData = []; + List classSelectList = []; + List classList = []; + List classTabList = []; + int checkIndex = 0; + + @override + void initState() { + super.initState(); + + eventBus.on().listen((event) { + print("object: CommunityCourse"); + if (event.type < 3) { + setState(() {}); + } + }); + classListAsync(); + } + + ///课程分类列表 + 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); + }); + } + } + } + + _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(classList), + + SizedBox(height: 28), + + ///课程导航栏 + ClassTitleTab(classSelectList,(index){ + checkIndex = index; + queryClassList(classSelectList[index].id); + }), + + ///课程列表 + ClassListView(classTabList), + + ]; + + // if (brands == null) return widgets; + // brands.forEach((value) { + // widgets.add( + // Container( + // key: globaKeys[brands.indexOf(value)], + // child: Container( + // child: Html( + // data: value.content, + // customImageRenders: { + // assetUriMatcher(): assetImageRender(), + // networkSourceMatcher(extension: "svg"): svgNetworkImageRender(), + // networkSourceMatcher(): networkImageRender( + // loadingWidget: () { + // return Container(); + // }, + // ), + // }, + // ), + // ), + // ), + // ); + // }); + return widgets; + } + + + @override + bool get wantKeepAlive => true; +} 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_list_view.dart b/lib/community/community_view/class_list_view.dart new file mode 100644 index 00000000..3879a322 --- /dev/null +++ b/lib/community/community_view/class_list_view.dart @@ -0,0 +1,165 @@ +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: 3, + //水平子Widget之间间距 + crossAxisSpacing: 11.w, + //垂直子Widget之间间距 + mainAxisSpacing: 16.w, + //子Widget宽高比例 0.59 + childAspectRatio: + 166 / (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}); + }, + child: classListItem(widget.classList[index]), + ); + }, + ); + } + + Widget classListItem(CourseList classList) { + return Container( + width: 106, + height: 189, + margin: EdgeInsets.symmetric( + // horizontal: 6.w, + vertical: 3, + ), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + alignment: Alignment(0.9, 0.9), + children: [ + Container( + color: Color.fromARGB(80, 0, 0, 0), + child: ClipRRect( + 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_like.png", + width: 16.w, + height: 16.h, + color: Colors.white, + ), + SizedBox(width: 5), + Text( + classList.likes.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, + ), + ), + ], + ), + ], + ), + ), + ], + ), + Container( + padding: EdgeInsets.only(left: 4, top: 3), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + classList.subject, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), + ), + SizedBox(height: 2), + Text( + "讲师:${classList.author.name}", + 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..fc3078bb --- /dev/null +++ b/lib/community/community_view/course_banner.dart @@ -0,0 +1,106 @@ + +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/view_widget/custom_image.dart'; + +class CourseBanner extends StatefulWidget { + + final List bannerData; + + CourseBanner(this.bannerData); + + @override + State createState() { + return _CourseBanner(); + } + +} + +class _CourseBanner extends State { + @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:文章) + 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; + } + } + + + +} + + + + + + diff --git a/lib/community/community_view/home_class.dart b/lib/community/community_view/home_class.dart new file mode 100644 index 00000000..2f4c13ad --- /dev/null +++ b/lib/community/community_view/home_class.dart @@ -0,0 +1,204 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; +import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.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:huixiang/view_widget/item_title.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class HomeClass extends StatefulWidget { + final List classList; + + HomeClass(this.classList); + @override + State createState() { + return _HomeClass(); + } +} + +class _HomeClass extends State { + ApiService apiService; + BMFCoordinate latLng; + + BMFMapController _mapController; + final TextEditingController editingController = TextEditingController(); + + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + ItemTitle( + text: "回乡小课堂", + imgPath: "assets/image/ketang.png", + ), + Container( + height: 189, + margin: EdgeInsets.only(top:10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + physics: BouncingScrollPhysics(), + padding: EdgeInsets.symmetric(horizontal: 10), + itemCount:widget.classList == null ? 0 : widget.classList.length, + itemBuilder: (context, position) { + return GestureDetector( + onTap: () { + Navigator.of(context).pushNamed('/router/class_details'); + }, + child: classItem(widget.classList[position]), + ); + }, + ), + ), + ], + ); + } + + Widget classItem(CourseList classList) { + return Container( + width: 168, + height: 189, + margin: EdgeInsets.symmetric( + horizontal: 6.w, + vertical: 3, + ), + color: Colors.white, + child: Column( + children: [ + Stack( + alignment: Alignment(0.9,0.9), + children: [ + Container( + color: Color.fromARGB(80, 0, 0, 0), + child: ClipRRect( + 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_like.png", + width: 16.w, + height: 16.h, + color: Colors.white, + ), + SizedBox(width:5), + Text( + classList.likes.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, + ), + ), + ], + ), + ], + ), + ), + ], + ), + Container( + padding: EdgeInsets.only(left: 3,top: 2), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height:2), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + height: 15.h, + width: 30.w, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(2), + border: Border.all( + width: 1, + color: Color(0xFFFF7A1A), + style: BorderStyle.solid, + ), + ), + child: Text( + ( classList?.tags != null && classList.tags.length > 0 )?classList.tags[0] : "", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFFFF7A1A), + ), + ), + ), + SizedBox(width:5), + Expanded(child: Text( + classList.subject, + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.medium, + color: Colors.black, + ), + ),), + ], + ), + SizedBox(height:3), + Text( + "讲师:${classList.author.name}", + 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 e8d60d7e..0ff917ce 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -284,6 +284,7 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ///积分商城 HomeIntegralStore(gooods, callback), + ///精选活动 FeaturedActivity(), ///积分商品头Tab diff --git a/lib/main.dart b/lib/main.dart index fbdd0f24..02623816 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(), }; 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/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/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 8df47f39..6ad80563 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -20,6 +20,8 @@ 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/course_list.dart'; import 'data/exchange_order.dart'; import 'data/follow_list.dart'; import 'data/goods.dart'; @@ -40,11 +42,11 @@ 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/"; @@ -389,4 +391,16 @@ 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); + } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index 3c96e516..63ddb880 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; @@ -1345,4 +1345,75 @@ 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 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; + } + }