提交 8c0a6049 authored 作者: maodou's avatar maodou

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

......@@ -145,11 +145,11 @@ abstract class CommonAPI {
'is_select':love
},
);
if (result.data is! Map && result.data['is_success'] == 1){
return true;
}
if (result.data is! Map || result.data['is_success'] == 0){
return false;
}
return true;
}
/// 10、上传文件
static Future <String> upload({
......
......@@ -37,16 +37,34 @@ abstract class LibraryAPI {
String sortField = '',
String sort = '',
String isFree = '',
String labelId = '',
required String categoryId
}) async {
Map<String,dynamic> params = {
'page' : page,
'limit' : limit,
'category_id':categoryId
};
if (sortField.isNotEmpty){
params['sort_field'] = sortField;
}
if (sort.isNotEmpty){
params['sort'] = sort;
}
if (isFree.isNotEmpty){
params['is_free'] = isFree;
}
if (sort.isNotEmpty){
params['sort'] = sort;
}
if (labelId.isNotEmpty){
params['label_id'] = labelId;
}
final result = await HttpService.to.post(
'/v1/book/category/getBookList',
params: {
'page': page,
'page_size': limit,
// 'sort_field':sortField,
// 'sort':sort,
// 'is_free':isFree
},
params: params
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
......
......@@ -24,7 +24,7 @@ class _BuildItemState extends State<BuildItem> {
});
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 15.w),
padding: EdgeInsets.symmetric(horizontal: 15.w),
height: 30.w,
color: Colors.white,
child: Row(
......@@ -74,7 +74,8 @@ class _BuildItemState extends State<BuildItem> {
Widget _buildSection(ChapterModel model){
return Container(
margin: const EdgeInsets.only(left: 60),
color: Colors.white,
padding: const EdgeInsets.only(left: 60),
child: Text(model.name??'',style:TextStyle(fontSize: 12,color: model.seen ==0? Colours.c3:Colours.c9,height: 1.6),),
);
}
......
......@@ -63,6 +63,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
}
bool result = await CommonAPI.love(
bookId: bookId, love: isCollection.toString());
print('================================$result');
if (result) {
_getBookDetails();
}
......
......@@ -56,7 +56,9 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
height: 2,
color: const Color(0xFFF9F9F9),
),
TabBar(
Container(
color: Colors.white,
child: TabBar(
labelColor: AppTheme.primary,
// isScrollable: true,
labelStyle: TextStyle(fontSize: 15.w,height: 1.4,fontWeight: Fonts.medium),
......@@ -68,14 +70,15 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
physics: const NeverScrollableScrollPhysics(),
controller: controller.tabController,
),
),
Expanded(
child: TabBarView(
controller: controller.tabController,
children: [
BookCategoryPage(chapters: controller.chapters,),
Container(
margin: EdgeInsets.only(left: 15.w,right: 15.w,top:12.w),
// color: Colors.lightBlue,
padding: EdgeInsets.only(left: 15.w,right: 15.w,top:12.w),
color: Colors.white,
child: Text(controller.bookDetails.content??'',style: TextStyle(fontSize: 12.w,height: 1.5,color: Colours.c3),),
),
BookInfoPage(model:controller.bookDetails,)
......@@ -87,7 +90,8 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
),
bottomNavigationBar: SafeArea(
child: Container(
margin: EdgeInsets.symmetric(horizontal: 15.w),
color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 15.w,vertical: 10.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
......
......@@ -10,7 +10,8 @@ class BookInfoPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 15.w,vertical: 18.w),
color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 15.w,vertical: 18.w),
child: Column(
children: [
// 评分容器
......
......@@ -7,9 +7,11 @@ import 'package:flutter_book/theme.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../models/index.dart';
import '../../models/shop.dart';
import '../../routes/index.dart';
import '../../utils/index.dart';
import '../../widgets/index.dart';
import '../book_shop/index.dart';
......
......@@ -41,30 +41,40 @@ class _BookPayPageState extends State<BookPayPage> {
boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
spreadRadius: 2.w,
blurRadius: 5.w,
offset: Offset(3.w, 0), // changes the position of the shadow
),
]
),
child: Column(
children: [
_buildPointWidget(),
GestureDetector(
child: _buildWidget(title: '优惠券',icon: 'assets/images/pay_coupon.png',),
onTap: (){
context.pushNamed(Routes.payCoupon);
},
),
Container(height: 0.5.w,color: Colours.cF0,margin: EdgeInsets.only(left: 10.w),),
_buildCouponWidget()
GestureDetector(
child: _buildWidget(title: '积分抵扣',icon: 'assets/images/pay_point.png',),
onTap: (){
context.pushNamed(Routes.creditPoints);
},
),
],
),
),
Container(
margin: const EdgeInsets.only(left: 10,right: 10,top: 10),
margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.w),
decoration: BoxDecoration(
borderRadius:BorderRadius.circular(8),
borderRadius:BorderRadius.circular(8.w),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
spreadRadius: 2.w,
blurRadius: 5.w,
offset: const Offset(3, 0), // changes the position of the shadow
),
]
......@@ -93,29 +103,33 @@ class _BookPayPageState extends State<BookPayPage> {
}
Widget _buildPointWidget(){
Widget _buildWidget({
required String title,
required String icon,
}){
return Container(
margin: EdgeInsets.only(left: 13,right: 13),
margin: EdgeInsets.only(left: 13.w,right: 13.w),
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
margin: const EdgeInsets.symmetric(vertical: 12),
margin: EdgeInsets.symmetric(vertical: 12.w),
// color: Colors.cyan,
width:20,
height:20,
child: Image.asset('assets/images/pay_coupon.png'),
width:20.w,
height:20.w,
child: Image.asset(icon),
),
const SizedBox(width: 7,),
const Text('优惠券',style: TextStyle(fontSize: 14,color: Colours.c3,height: 1.1)),
SizedBox(width: 7.w,),
Text(title,style: TextStyle(fontSize: 14.w,color: Colours.c3,height: 1.1)),
],
),
Container(
SizedBox(
// color: Colors.cyan,
width:5,
height:8,
width:5.w,
height:8.w,
child: Image.asset('assets/images/right_arrow.png'),
),
],
......@@ -123,33 +137,4 @@ class _BookPayPageState extends State<BookPayPage> {
);
}
Widget _buildCouponWidget(){
return Container(
margin: EdgeInsets.only(left: 13,right: 13),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
margin: const EdgeInsets.symmetric(vertical: 12),
// color: Colors.cyan,
width:20,
height:20,
child: Image.asset('assets/images/pay_point.png'),
),
const SizedBox(width: 7,),
const Text('积分抵扣',style: TextStyle(fontSize: 14,color: Colours.c3,height: 1.1)),
],
),
Container(
// color: Colors.cyan,
width:5,
height:8,
child: Image.asset('assets/images/right_arrow.png'),
),
],
),
);
}
}
......@@ -11,29 +11,32 @@ class CreditPointsPage extends StatelessWidget {
return false;
},
child: Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
centerTitle: true,
title: const Text('积分'),
backgroundColor: Colors.transparent,
),
body: Column(
body:Stack(
children: [
Image.asset(
'assets/images/point_bg.png',
fit: BoxFit.contain,
width: double.infinity,
),
SafeArea(
top: true,
child: Column(
children: [
// 积分卡片
Container(
color: AppTheme.primary.withOpacity(0.02),
padding: EdgeInsets.all(10.w),
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Container(
padding: EdgeInsets.only(left: 17.w,top: 18.w,bottom: 24.w,right: 17.w),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
offset: Offset(0, 3.w),
blurRadius: 4.w,
spreadRadius: 0,
),
],
borderRadius: BorderRadius.circular(8)
color: Colors.white.withOpacity(0.58),
borderRadius: BorderRadius.circular(8.w),
border: Border.all(width: 2.w,color: Colors.white)
),
height: 175.w,
child: Column(
......@@ -74,13 +77,14 @@ class CreditPointsPage extends StatelessWidget {
// 使用积分
Container(
// height: 105,
margin: EdgeInsets.symmetric(horizontal: 10.w),
padding: EdgeInsets.all(20.w),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
offset: Offset(0, 3.w),
offset: Offset(3.w, 0.w),
blurRadius: 4.w,
spreadRadius: 0,
),
......@@ -123,6 +127,9 @@ class CreditPointsPage extends StatelessWidget {
],
),
),
],
)
),
);
}
}
......@@ -43,7 +43,7 @@ class ForgetPwdController extends GetxController {
}
void setCanClick(){
if (phoneInput.text.length == 11 && codeInput.text.length == 6){
if (ValidatorTool.isValidPhoneNumber(phoneInput.text)&& codeInput.text.length == 6){
_enable = true;
}
else{
......
......@@ -55,7 +55,7 @@ class _ForgetPwdPageState extends State<ForgetPwdPage> {
GestureDetector(
child: Container(
padding: EdgeInsets.symmetric(vertical: 10.w),
color: Colors.yellow,
// color: Colors.yellow,
child: Text(controller.isCounting?'${controller.countDown}':'获取验证码',style: TextStyle(fontSize: 11.w,color: AppTheme.primary,height: 1.4),)),
onTap: (){
if (controller.isCounting == false){
......
part of library;
class LibraryContentController extends GetxController {
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
// 图书列表数据
List<CourseModel> books = [];
final int _limit = 20;
int _page = 1;
bool _noMore = false;
@override
void onClose() {
refreshController.dispose();
super.onClose();
}
/// 收藏 与 取消收藏
void love({
required String bookId,
required num isCollection
}) async {
if (isCollection == 0){
isCollection = 1;
}
else{
isCollection = 0;
}
bool result = await CommonAPI.love(bookId: bookId, love: isCollection.toString());
if (result) {
onRefresh();
}
}
/// 获取图书列表数据
Future<void> _getBooks([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await LibraryAPI.books(
page: _page,
limit: _limit, categoryId: '',
);
// 如果是刷新 清理数据
if (isRefresh) books.clear();
books.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getBooks(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getBooks();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
}
\ No newline at end of file
......@@ -2,17 +2,11 @@ part of library;
class LibraryController extends GetxController with GetTickerProviderStateMixin{
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
// 分类数据
List<CategoryModel> categories = [];
// 标签数据
List<LabelModel> labels = [];
// 图书列表数据
List<CourseModel> books = [];
// 广告数组
List<AdModel> ads = [];
......@@ -20,9 +14,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
late TabController tabController = TabController(length:categories.length, vsync: this);
final int _limit = 20;
int _page = 1;
bool _noMore = false;
late AnimationController _controller;
bool _show = false;
......@@ -62,33 +54,15 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
// 获取标签数据
_getLabels();
_getAds();
onRefresh();
super.onReady();
}
@override
void onClose() {
tabController.dispose();
refreshController.dispose();
super.onClose();
}
/// 收藏 与 取消收藏
void love({
required String bookId,
required num isCollection
}) async {
if (isCollection == 0){
isCollection = 1;
}
else{
isCollection = 0;
}
bool result = await CommonAPI.love(bookId: bookId, love: isCollection.toString());
if (result) {
onRefresh();
}
}
//
void selectLabel(LabelModel model){
for (LabelModel m in labels){
......@@ -118,52 +92,9 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
labels = await LibraryAPI.labels();
selectedLabel = labels.first;
selectedLabel.selected = true;
update();
update(['label']);
}
/// 获取图书列表数据
Future<void> _getBooks([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await LibraryAPI.books(
page: _page,
limit: _limit
);
// 如果是刷新 清理数据
if (isRefresh) books.clear();
books.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getBooks(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getBooks();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
}
\ No newline at end of file
......@@ -25,3 +25,5 @@ part 'widgets/cell.dart';
part 'widgets/content.dart';
part 'widgets/subject.dart';
part 'widgets/filter.dart';
part 'test.dart';
part 'content_controller.dart';
\ No newline at end of file
part of library;
class TestPage extends StatefulWidget {
const TestPage({Key? key}) : super(key: key);
@override
State<LibraryPage> createState() => _LibraryPageState();
}
class _TestPageState extends State<TestPage> with AutomaticKeepAliveClientMixin {
//AutomaticKeepAliveClientMixin
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('分类'),
bottom: PreferredSize(
preferredSize: Size.fromHeight(48.w),
child: Container(
child: Row(
children: [
// TabBar放在左侧
Expanded(
child: TabBar(
tabs: [
Tab(text: 'Tab 1'),
Tab(text: 'Tab 2'),
Tab(text: 'Tab 3'),
Tab(text: 'Tab 4'),
Tab(text: 'Tab 5'),
],
),
),
// 筛选按钮放在右侧
IconButton(
icon: Icon(Icons.filter_list),
onPressed: () {
// 处理筛选按钮点击事件
},
),
],
),
),
)
),
body: Column(
children: [
Container(
height: 43, // 设置标签栏的高度
color: Colors.cyan, // 设置标签栏的颜色
// child: // 添加你的横向滑动标签组件
),
Expanded(
child: CustomScrollView(
slivers: [
// // 横向滑动的标签
// SliverToBoxAdapter(
// child: Container(
// height: 43, // 设置标签栏的高度
// color: Colors.grey, // 设置标签栏的颜色
// // child: // 添加你的横向滑动标签组件
// ),
// ),
// 广告位
SliverToBoxAdapter(
child: Container(
height: 100, // 设置广告位的高度
color: Colors.grey, // 设置广告位的颜色
)
),
SliverFillRemaining(
child: TabBarView(
children: [
// Tab 1 对应的内容
Container(
color: Colors.red,
),
// Tab 2 对应的内容
Container(
color: Colors.green,
),
// Tab 3 对应的内容
Container(
color: Colors.blue,
),
Container(
color: Colors.blue,
),
Container(
color: Colors.blue,
),
],
),
),
],
),
),
],
),
);
}
@override
bool get wantKeepAlive => true;
}
......@@ -7,9 +7,8 @@ class LibraryPage extends StatefulWidget {
State<LibraryPage> createState() => _LibraryPageState();
}
class _LibraryPageState extends State<LibraryPage> with AutomaticKeepAliveClientMixin {
class _LibraryPageState extends State<LibraryPage> {
//AutomaticKeepAliveClientMixin
@override
Widget build(BuildContext context) {
return GetBuilder<LibraryController>(
......@@ -27,19 +26,97 @@ class _LibraryPageState extends State<LibraryPage> with AutomaticKeepAliveClient
),
],
),
body: Stack(
body: _buildBody(controller)
),
);
}
Widget _buildBody(LibraryController controller){
return Stack(
children: [
Column(
children: [
Container(
color: Colors.white,
width: double.infinity,
_buildTab(controller),
_buildLabel(),
GetBuilder<LibraryContentController>(
init: LibraryContentController(),
builder:(contentController)=> Expanded(
child: CustomPullScrollView(
controller: contentController.refreshController,
onRefresh: contentController.onRefresh,
onLoading: contentController.onLoading,
child: CustomScrollView(
slivers: [
// 广告位
SliverToBoxAdapter(
child: Container(
decoration: BoxDecoration(
border: Border.all(width: 0.5.w,color: Colours.cE5)
color: Colors.red,
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: BuildBanner(items: controller.ads,),
),
),
SliverFillRemaining(
child: TabBarView(
controller: controller.tabController,
children: List.generate(controller.categories.length, (index){
print('=======================================$index');
return LibraryContentPage(controller: contentController,);
})
),
),
],
),
),
),
),
],
),
Visibility(
visible: controller.show,
child: FilterPage(
controller: controller,
sureTap: (){
controller.setShow(controller.show);
},
resetTap: (){
},),
),
],
);
}
Widget _buildLabel(){
return Container(
height: 43.w,
color: Colours.cF9,
child: GetBuilder<LibraryController>(
init: LibraryController(),
// id: 'label',
builder:(controller) =>ListView.builder(
scrollDirection:Axis.horizontal ,
itemBuilder: (BuildContext context, int index){
return GestureDetector(
child: BuildLabelWidget(model: controller.labels[index],),
onTap: (){
controller.selectLabel( controller.labels[index]);
},
);
},
itemCount: controller.labels.length,
),
),
);
}
PreferredSizeWidget _buildTab(LibraryController controller){
return PreferredSize(
preferredSize: Size.fromHeight(48.w),
child: Container(
color: Colors.white,
child: Row(
children: [
// TabBar放在左侧
Expanded(
child: TabBar(
indicator: BoxDecoration(
......@@ -56,27 +133,14 @@ class _LibraryPageState extends State<LibraryPage> with AutomaticKeepAliveClient
}).toList(),
),
),
// 筛选按钮放在右侧
GestureDetector(
onTap: (){
controller.setShow(controller.show);
// showModalBottomSheet(
// context: context,
// isScrollControlled: true, // 设置为 true
// builder: (BuildContext context) {
// return Container(
// height: MediaQuery.of(context).size.height * 0.9, // 设置高度
// decoration: BoxDecoration(
// color: Colors.white, // 替换为你的背景颜色
// ),
// child: FilterPage(),
// );
// },
// );
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
alignment: Alignment.center,
// color: Colors.cyan,
height: 38.w,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
......@@ -100,57 +164,8 @@ class _LibraryPageState extends State<LibraryPage> with AutomaticKeepAliveClient
],
),
),
),
Container(
height: 43.w,
color: Colours.cF9,
child: ListView.builder(
scrollDirection:Axis.horizontal ,
itemBuilder: (BuildContext context, int index){
return GestureDetector(
child: BuildLabelWidget(model: controller.labels[index],),
onTap: (){
controller.selectLabel( controller.labels[index]);
},
);
},
itemCount: controller.labels.length,
),
),
Container(
color: Colors.transparent,
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: BuildBanner(items: controller.ads,),
),
Expanded(
child: TabBarView(
controller: controller.tabController,
children: List.generate(controller.categories.length, (index){
print('=======================================$index');
return LibraryContentPage(controller: controller,);
})
),
),
],
),
Visibility(
visible: controller.show,
child: FilterPage(
controller: controller,
sureTap: (){
controller.setShow(controller.show);
},
resetTap: (){
},),
),
],
)
),
);
}
@override
bool get wantKeepAlive => true;
// @override
// bool get wantKeepAlive => true;
}
part of library;
class LibraryContentPage extends StatefulWidget {
final LibraryController controller;
final LibraryContentController controller;
// final CategoryModel categoryModel;
const LibraryContentPage({
Key? key,
......@@ -16,24 +16,11 @@ class LibraryContentPage extends StatefulWidget {
class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
return CustomPullScrollView(
controller: widget.controller.refreshController,
onRefresh: widget.controller.onRefresh,
onLoading: widget.controller.onLoading,
child: ListView.builder(
return ListView.builder(
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
physics: const NeverScrollableScrollPhysics(),
itemCount: widget.controller.books.length,
itemBuilder: (BuildContext context, int index) {
// if (index == 0){
// return Container(
// color: Colors.transparent,
// padding: const EdgeInsets.symmetric(horizontal: 10),
// child: BuildBanner(items: widget.controller.ads,),
// );
// }
// else {
CourseModel model = widget.controller.books[index];
return GestureDetector(
onTap: (){
......@@ -44,8 +31,6 @@ class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticK
},),
);
}
// },
),
);
}
@override
......
part of library_content;
class LibraryContentController extends GetxController {
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
final int _limit = 10;
int _page = 1;
bool _noMore = false;
// 图书列表数据
List<CourseModel> books = [];
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
refreshController.dispose();
super.onClose();
}
/// 收藏 与 取消收藏
void love({
required String bookId,
required num isCollection
}) async {
if (isCollection == 0){
isCollection = 1;
}
else{
isCollection = 0;
}
bool result = await CommonAPI.love(bookId: bookId, love: isCollection.toString());
if (result) {
onRefresh();
}
}
/// 获取图书列表数据
Future<void> _getBooks([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await LibraryAPI.books(
page: _page,
limit: _limit
);
// 如果是刷新 清理数据
if (isRefresh) books.clear();
books.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getBooks(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getBooks();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
}
\ No newline at end of file
// part of library_content;
//
// class LibraryContentController extends GetxController {
//
// final CategoryModel categoryModel;
// late LabelModel labelModel;
// LibraryContentController(this.categoryModel, this.labelModel);
//
// final EasyRefreshController refreshController = EasyRefreshController(
// controlFinishLoad: true,
// controlFinishRefresh: true,
// );
//
// // 广告数组
// List<AdModel> ads = [];
//
// final int _limit = 10;
// int _page = 1;
// bool _noMore = false;
//
//
// // 图书列表数据
// List<CourseModel> books = [];
//
//
// @override
// void onReady() {
//
// super.onReady();
// }
//
//
// @override
// void onClose() {
// refreshController.dispose();
// super.onClose();
// }
//
//
// /// 收藏 与 取消收藏
// void love({
// required String bookId,
// required num isCollection
// }) async {
// if (isCollection == 0){
// isCollection = 1;
// }
// else{
// isCollection = 0;
// }
// bool result = await CommonAPI.love(bookId: bookId, love: isCollection.toString());
// if (result) {
// onRefresh();
// }
// }
//
// /// 获取图书列表数据
// Future<void> _getBooks([bool isRefresh = false]) async {
// if (isRefresh) _page = 1;
// // 网路请求
// final result = await LibraryAPI.books(
// page: _page,
// limit: _limit,
// categoryId: categoryModel.categoryId.toString(),
// labelId: labelModel.labelId.toString()
// );
// // 如果是刷新 清理数据
// if (isRefresh) books.clear();
// books.addAll(result);
// _page ++;
// _noMore = result.length < _limit;
// update();
//
// }
//
// void onRefresh() async {
// try {
// await _getBooks(true);
// refreshController.finishRefresh(IndicatorResult.success);
// refreshController.resetFooter();
// } catch (error) {
// refreshController.finishRefresh(IndicatorResult.fail);
// }
// }
//
// void onLoading() async {
// if (_noMore) {
// refreshController.finishLoad(IndicatorResult.noMore);
// return;
// }
// try {
// await _getBooks();
// refreshController.finishLoad();
// } catch (error) {
// refreshController.finishLoad(IndicatorResult.fail);
// }
// }
//
// }
\ No newline at end of file
library library_content;
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:go_router/go_router.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
import '../../routes/index.dart';
import '../../widgets/index.dart';
import '../course/index.dart';
import '../library/index.dart';
part 'view.dart';
part 'controller.dart';
\ No newline at end of file
// library library_content;
//
// import 'package:easy_refresh/easy_refresh.dart';
// import 'package:flutter/material.dart';
// import 'package:get/get.dart';
// import 'package:get/get_state_manager/src/simple/get_controllers.dart';
// import 'package:go_router/go_router.dart';
//
// import '../../apis/index.dart';
// import '../../models/index.dart';
// import '../../routes/index.dart';
// import '../../widgets/index.dart';
// import '../course/index.dart';
// import '../library/index.dart';
//
// part 'view.dart';
// part 'controller.dart';
\ No newline at end of file
part of library_content;
class LibraryContentPage extends StatefulWidget {
final CategoryModel categoryModel;
final LabelModel labelModel;
const LibraryContentPage({
Key? key,
required this.categoryModel,
required this.labelModel
}) : super(key: key);
@override
State<LibraryContentPage> createState() => _LibraryContentPageState();
}
class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
return GetBuilder<LibraryContentController>(
init: LibraryContentController(),
builder: (controller) => CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: ListView.builder(
itemCount: controller.books.length,
itemBuilder: (BuildContext context, int index) {
// if (index == 0){
// return Container(
// color: Colors.transparent,
// padding: const EdgeInsets.symmetric(horizontal: 10),
// child: BuildBanner(items: controller.ads,),
// );
// }
// else {
CourseModel model = controller.books[index];
return GestureDetector(
onTap: (){
context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()});
},
child: LibraryCell(model: model,onTap: (){
controller.love(bookId: model.bookId.toString(), isCollection: model.isCollection!);
},),
);
}
// },
),
),
);
}
@override
bool get wantKeepAlive => true;
}
// part of library_content;
//
// class LibraryContentPage extends StatefulWidget {
// final CategoryModel categoryModel;
// final LabelModel labelModel;
// final String tag;
// const LibraryContentPage({
// Key? key,
// required this.categoryModel,
// required this.labelModel,
// required this.tag
// }) : super(key: key);
//
// @override
// State<LibraryContentPage> createState() => _LibraryContentPageState();
// }
//
// class _LibraryContentPageState extends State<LibraryContentPage> {
// @override
// Widget build(BuildContext context) {
// return GetBuilder<LibraryContentController>(
// // tag: widget.tag,
// init: LibraryContentController(widget.categoryModel,widget.labelModel),
// builder: (controller) => CustomPullScrollView(
// controller: controller.refreshController,
// onRefresh: controller.onRefresh,
// onLoading: controller.onLoading,
// child: ListView.builder(
// itemCount: controller.books.length+1,
// itemBuilder: (BuildContext context, int index) {
// if (index == 0){
// return Container(
// color: Colors.red,
// padding: const EdgeInsets.symmetric(horizontal: 10),
// child: BuildBanner(items: controller.ads,),
// );
// }
// else {
// CourseModel model = controller.books[index-1];
// return GestureDetector(
// onTap: (){
// context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()});
// },
// child: LibraryCell(model: model,onTap: (){
// controller.love(bookId: model.bookId.toString(), isCollection: model.isCollection!);
// },),
// );
// }
// },
// ),
// ),
// );
// }
// // @override
// // bool get wantKeepAlive => true;
// }
......@@ -60,7 +60,7 @@ class LoginController extends GetxController {
}
void setCanClick(){
if (phoneInput.text.length == 11 && passwordInput.text.length == 6){
if (ValidatorTool.isValidPhoneNumber(phoneInput.text) && ValidatorTool.isValidPassword(passwordInput.text)){
_enable = true;
}
else{
......
......@@ -21,6 +21,7 @@ class _LoginPageState extends State<LoginPage> {
onTap: () => Tools.unfocus(),
child: Scaffold(
resizeToAvoidBottomInset: false,
extendBodyBehindAppBar: true,
appBar: CustomAppBar(
systemOverlayStyle: Theme.of(context).brightness == Brightness.light
? SystemUiOverlayStyle.dark
......
......@@ -71,19 +71,25 @@ class _MinePageState extends State<MinePage> {
child: SingleChildScrollView(
child: Column(
children: [
BuildUser(userInfo:controller.userInfo,onTap: () async{
Container(
margin: EdgeInsets.symmetric(horizontal: 10.w),
child: BuildUser(userInfo:controller.userInfo,onTap: () async{
final result = await context.pushNamed(Routes.userInfo,extra: controller.userInfo);
if (result == true){
controller.getInfo();
}
},),
),
Gaps.vGaps10,
BuildRead(items: controller.reads,onTap: (ReadModel model) async{
Container(
margin: EdgeInsets.symmetric(horizontal: 2.2.w),
child: BuildRead(items: controller.reads,onTap: (ReadModel model) async{
final result = await context.pushNamed(model.link??'');
if (result == true){
controller.getInfo();
}
}),
),
controller.ads.isNotEmpty?Gaps.vGaps10:const SizedBox(),
controller.ads.isNotEmpty?
Container(
......
......@@ -37,7 +37,8 @@ class BuildAccount extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: items.map((model){
return GestureDetector(
return Expanded(
child: GestureDetector(
onTap: (){
if (model.link != null){
context.pushNamed(model.link!);
......@@ -55,6 +56,7 @@ class BuildAccount extends StatelessWidget {
Gaps.vGaps5,
Text(model.name,style: TextStyle(fontSize:12.w,height: 1.6.w,color: Colours.c9),),
items.indexOf(model) == 0?Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(model.value.toString(),style: TextStyle(fontSize: 16.w,height: 1.6,fontWeight: Fonts.medium,color: AppTheme.primary,),),
Text('张',style: TextStyle(fontSize: 12.w,height:1.6.w,color: Colours.c3),)
......@@ -62,6 +64,7 @@ class BuildAccount extends StatelessWidget {
):Text(model.value.toString(),style: TextStyle(fontSize: 16.w,height:1.6.w,color: Colours.c3),)
],
),
),
);
} ).toList(),
),
......
......@@ -13,7 +13,7 @@ class BuildRead extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
return Container(
child: Stack(
children: [
Container(
......@@ -29,7 +29,7 @@ class BuildRead extends StatelessWidget {
left: 0,
right: 0,
child: Container(
padding: EdgeInsets.symmetric(vertical: 16.5.w),
padding: EdgeInsets.symmetric(vertical: 16.5.w,horizontal: 8),
color: Colors.transparent,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8),
......@@ -46,7 +46,8 @@ class BuildRead extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: items.map((model){
return GestureDetector(
return Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
if (model.link != null){
......@@ -65,6 +66,7 @@ class BuildRead extends StatelessWidget {
Text(model.name,style: TextStyle(fontSize: 13.w,height:1.6.w,color: Colours.c6))
],
),
),
);
}).toList(),
),
......
......@@ -47,8 +47,8 @@ class ResetPwdController extends GetxController {
final result = await AccountAPI.resetPassword(
phone: phone,
code: code,
password: pwdInput.text,
rePassword: pwd2Input.text
password: EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwdInput.text)),
rePassword: EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwd2Input.text))
);
if (result){
if (context.mounted){
......
......@@ -68,7 +68,7 @@ class _ResetPwdPageState extends State<ResetPwdPage> {
),
Container(
margin: EdgeInsets.only(left: 5.w,top: 5.w),
child: Text('密码必须是6-20个英文字母、数字或符号',style: TextStyle(fontSize: 10.w,color: Colours.c9),),
child: Text('密码必须是8-20个英文字母、数字或符号',style: TextStyle(fontSize: 10.w,color: Colours.c9),),
),
Gaps.vGaps40,
CustomGradientButton(
......
......@@ -42,6 +42,7 @@ import 'package:go_router/go_router.dart';
import '../models/index.dart';
import '../pages/order_evaluate/index.dart';
import '../pages/pay_coupon/index.dart';
import '../pages/user_about/index.dart';
import '../pages/user_terms/index.dart';
import '../pages/version/index.dart';
......
......@@ -42,6 +42,7 @@ abstract class Routes {
/// 书架模块
static const creditPoints = 'credit_points';
static const shop = 'shop';
static const payCoupon = 'pay_coupon';
......@@ -278,6 +279,15 @@ abstract class Routes {
child: const CreditPointsPage()
)
),
GoRoute(
path: '/$payCoupon',
name: payCoupon,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: const PayCouponPage()
)
),
GoRoute(
path: '/$search',
name: search,
......
......@@ -89,9 +89,11 @@ class ValidatorTool {
return phonePattern.hasMatch(value);
}
// 验证密码
// 密码
static bool isValidPassword(String value) {
RegExp passwordPattern = RegExp(r'^[A-Za-z0-9!@#\$%^&*()_+{}\[\]:;<>,.?~\\/-]{6,20}$');;
// RegExp passwordPattern = RegExp(r'^[A-Za-z0-9!@#\$%^&*()_+{}\[\]:;<>,.?~\\/-]{8,12}$');
// RegExp passwordPattern = RegExp(r'^(?=.*[A-Za-z])(?=.*\d)(?=.*[~@#%$*()_+{}\[\]:;<>,.?\\/-])[A-Za-z0-9~@#%$*()_+{}\[\]:;<>,.?\\/-]{8,12}$');
RegExp passwordPattern = RegExp(r'^\d{6}$');
return passwordPattern.hasMatch(value);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论