Browse Source

更改

ff_new
w-R 3 years ago
parent
commit
771e84804d
  1. BIN
      assets/image/2x/ketang.png
  2. BIN
      assets/image/2x/ketang_like.png
  3. BIN
      assets/image/2x/ketang_message.png
  4. BIN
      assets/image/3x/ketang.png
  5. BIN
      assets/image/3x/ketang_like.png
  6. BIN
      assets/image/3x/ketang_message.png
  7. BIN
      assets/image/ketang.png
  8. BIN
      assets/image/ketang_like.png
  9. BIN
      assets/image/ketang_message.png
  10. 234
      lib/community/community_course.dart
  11. 9
      lib/community/community_page.dart
  12. 165
      lib/community/community_view/class_list_view.dart
  13. 71
      lib/community/community_view/class_title_tab.dart
  14. 106
      lib/community/community_view/course_banner.dart
  15. 204
      lib/community/community_view/home_class.dart
  16. 1
      lib/home/home_page.dart
  17. 2
      lib/main.dart
  18. 114
      lib/retrofit/data/category_select_list.dart
  19. 220
      lib/retrofit/data/course_list.dart
  20. 22
      lib/retrofit/retrofit_api.dart
  21. 73
      lib/retrofit/retrofit_api.g.dart

BIN
assets/image/2x/ketang.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

BIN
assets/image/2x/ketang_like.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

BIN
assets/image/2x/ketang_message.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

BIN
assets/image/3x/ketang.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/image/3x/ketang_like.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/image/3x/ketang_message.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

BIN
assets/image/ketang.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

BIN
assets/image/ketang_like.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

BIN
assets/image/ketang_message.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

234
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<StatefulWidget> createState() {
return _CommunityCourse();
}
}
class _CommunityCourse extends State<CommunityCourse>
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
final ScrollController scrollController = ScrollController();
final RefreshController refreshController = RefreshController();
ApiService apiService;
List<Brand> brands = [];
BrandData brandData;
List<GlobalKey> globaKeys = [];
List<BannerData> bannerData = [];
List<CategorySelectList> classSelectList = [];
List<CourseList> classList = [];
List<CourseList> classTabList = [];
int checkIndex = 0;
@override
void initState() {
super.initState();
eventBus.on<EventType>().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<List<CategorySelectList>> 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<PageInfo<CourseList>> 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<Widget> classChildItem() {
var widgets = <Widget>[
///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;
}

9
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:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/my_tab.dart'; import 'package:huixiang/view_widget/my_tab.dart';
import 'community_course.dart';
class CommunityPage extends StatefulWidget { class CommunityPage extends StatefulWidget {
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -22,8 +24,8 @@ class _CommunityPage extends State<CommunityPage>
"关注", "关注",
"推荐", "推荐",
"头条", "头条",
"课程",
"关于我们", "关于我们",
// "课程",
// "直播", // "直播",
]; ];
@ -96,7 +98,10 @@ class _CommunityPage extends State<CommunityPage>
return BrandPage(); return BrandPage();
}else if(e == "头条"){ }else if(e == "头条"){
return HotArticlePage(); return HotArticlePage();
} else { }else if(e == "课程"){
return CommunityCourse();
}
else {
return CommunityChildPage(e); return CommunityChildPage(e);
} }
}).toList(), }).toList(),

165
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<CourseList> classList;
ClassListView(this.classList);
@override
State<StatefulWidget> createState() {
return _ClassListView();
}
}
class _ClassListView extends State<ClassListView> {
@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,
),
),
],
),
),
],
),
);
}
}

71
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<CategorySelectList> classSelectList;
final Function notifyClassSelectList;
ClassTitleTab(this.classSelectList,this.notifyClassSelectList);
@override
State<StatefulWidget> createState() {
return _ClassTitleTab();
}
}
class _ClassTitleTab extends State<ClassTitleTab>
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(),
),
),
);
}
}

106
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> bannerData;
CourseBanner(this.bannerData);
@override
State<StatefulWidget> createState() {
return _CourseBanner();
}
}
class _CourseBanner extends State<CourseBanner> {
@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 0123
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;
}
}
}

204
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<CourseList> classList;
HomeClass(this.classList);
@override
State<StatefulWidget> createState() {
return _HomeClass();
}
}
class _HomeClass extends State<HomeClass> {
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,
),
),
],
),
),
],
),
);
}
}

1
lib/home/home_page.dart

@ -284,6 +284,7 @@ class _HomePage extends State<HomePage> with AutomaticKeepAliveClientMixin {
/// ///
HomeIntegralStore(gooods, callback), HomeIntegralStore(gooods, callback),
///
FeaturedActivity(), FeaturedActivity(),
///Tab ///Tab

2
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:tpns_flutter_plugin/tpns_flutter_plugin.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.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/guide_page.dart';
import 'home/home_view/activity_list.dart'; import 'home/home_view/activity_list.dart';
import 'main_page.dart'; import 'main_page.dart';
@ -307,4 +308,5 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/router/communityFollow': (context, {arguments}) => CommunityFollow(), '/router/communityFollow': (context, {arguments}) => CommunityFollow(),
'/router/releasePage': (context, {arguments}) => ReleasePage(), '/router/releasePage': (context, {arguments}) => ReleasePage(),
'/router/activity_list': (context, {arguments}) => ActivityList(), '/router/activity_list': (context, {arguments}) => ActivityList(),
'/router/class_details': (context, {arguments}) => ClassDetails(),
}; };

114
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<String, dynamic> toJson() {
final map = <String, dynamic>{};
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;
}
}

220
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<String> 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<String>() : [];
_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<String> _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<String> 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<String, dynamic> toJson() {
final map = <String, dynamic>{};
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<String> 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<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['name'] = _name;
map['avatar'] = _avatar;
return map;
}
set avatar(String value) {
_avatar = value;
}
}

22
lib/retrofit/retrofit_api.dart

@ -20,6 +20,8 @@ import 'package:retrofit/retrofit.dart';
import 'data/address.dart'; import 'data/address.dart';
import 'data/banner.dart'; import 'data/banner.dart';
import 'data/brand_data.dart'; import 'data/brand_data.dart';
import 'data/category_select_list.dart';
import 'data/course_list.dart';
import 'data/exchange_order.dart'; import 'data/exchange_order.dart';
import 'data/follow_list.dart'; import 'data/follow_list.dart';
import 'data/goods.dart'; import 'data/goods.dart';
@ -40,11 +42,11 @@ import 'data/wx_pay.dart';
part 'retrofit_api.g.dart'; part 'retrofit_api.g.dart';
const base_url = "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 baseUrl = "https://pos.platform.lotus-wallet.com/app/"; ///
// const base_url = "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 baseUrl = "http://192.168.10.236:8766/app/"; ///
// const base_url = "http://192.168.10.37:8766/app/"; // const base_url = "http://192.168.10.37:8766/app/";
// const baseUrl = "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") @GET("/member/socialInfo")
Future<BaseData<SocialInfo>> socialInfo(); Future<BaseData<SocialInfo>> socialInfo();
///
@GET("/course/categoryList")
Future<BaseData<List<CategorySelectList>>> categoryList();
///
@GET("/course/catalogList/{courseId}")
Future<BaseData> catalogList(@Path("courseId") String courseId);
///
@POST("/course/list")
Future<BaseData<PageInfo<CourseList>>> courseList(@Body() Map<String, dynamic> map);
} }

73
lib/retrofit/retrofit_api.g.dart

@ -9,7 +9,7 @@ part of 'retrofit_api.dart';
class _ApiService implements ApiService { class _ApiService implements ApiService {
_ApiService(this._dio, {this.baseUrl}) { _ApiService(this._dio, {this.baseUrl}) {
ArgumentError.checkNotNull(_dio, '_dio'); ArgumentError.checkNotNull(_dio, '_dio');
baseUrl ??= 'https://pos.platform.lotus-wallet.com/app/'; baseUrl ??= 'http://192.168.10.236:8766/app/';
} }
final Dio _dio; final Dio _dio;
@ -1345,4 +1345,75 @@ class _ApiService implements ApiService {
); );
return value; return value;
} }
@override
Future<BaseData<List<CategorySelectList>>> categoryList() async {
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'/course/categoryList',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<List<CategorySelectList>>.fromJson(
_result.data,
(json) => (json as List<dynamic>)
.map<CategorySelectList>((i) => CategorySelectList.fromJson(i as Map<String, dynamic>))
.toList());
return value;
}
@override
Future<BaseData<dynamic>> catalogList(courseId) async {
ArgumentError.checkNotNull(courseId, 'courseId');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
final _result = await _dio.request<Map<String, dynamic>>(
'/course/catalogList/$courseId',
queryParameters: queryParameters,
options: RequestOptions(
method: 'GET',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<dynamic>.fromJson(
_result.data,
(json) => json as dynamic,
);
return value;
}
@override
Future<BaseData<PageInfo<CourseList>>> courseList(map) async {
ArgumentError.checkNotNull(map, 'map');
const _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _data = <String, dynamic>{};
_data.addAll(map ?? <String, dynamic>{});
final _result = await _dio.request<Map<String, dynamic>>(
'/course/list',
queryParameters: queryParameters,
options: RequestOptions(
method: 'POST',
headers: <String, dynamic>{},
extra: _extra,
baseUrl: baseUrl),
data: _data);
final value = BaseData<PageInfo<CourseList>>.fromJson(
_result.data,
(json) => PageInfo<CourseList>.fromJson(
json,
(json) => CourseList.fromJson(json),
),
);
return value;
}
} }

Loading…
Cancel
Save