Commit e26da9e000640e20c44940883918b359588a6872

Authored by 吴启风
1 parent 6770c637

feat: 隐藏审核账号受限内容

lib/common/core/user_util.dart
... ... @@ -9,8 +9,8 @@ import 'package:wow_english/utils/sp_util.dart';
9 9 import '../../utils/audio_player_util.dart';
10 10  
11 11 class UserUtil {
12   -
13 12 static const String _prefsKeyUserInfo = "key_user_info";
  13 + static const String _appReviewPhoneNumber = "18257199148";
14 14  
15 15 static UserEntity? _userEntity;
16 16  
... ... @@ -65,7 +65,8 @@ class UserUtil {
65 65 }*/
66 66 UmengCommonSdk.onProfileSignOff();
67 67 AudioPlayerUtil.getInstance().pause();
68   - pushNamedAndRemoveUntil(AppRouteName.login, (route) => false, arguments: {'showPasswordPage': showPasswordLoginPage});
  68 + pushNamedAndRemoveUntil(AppRouteName.login, (route) => false,
  69 + arguments: {'showPasswordPage': showPasswordLoginPage});
69 70 }
70 71  
71 72 // 是否有权限
... ... @@ -78,6 +79,11 @@ class UserUtil {
78 79 return getUserToken().isNotEmpty;
79 80 }
80 81  
  82 + // 是否为应用市场审核账号
  83 + static bool isAppReviewAccount() {
  84 + return getUser()?.phoneNum == _appReviewPhoneNumber;
  85 + }
  86 +
81 87 static String getUserToken() {
82 88 return _userEntity?.token ?? '';
83 89 }
... ...
lib/pages/home/view.dart
... ... @@ -169,7 +169,8 @@ class _HomePageView extends StatelessWidget {
169 169 },
170 170 child: Offstage(
171 171 offstage: AppConfigHelper.shouldHidePay() ||
172   - !UserUtil.isLogined(),
  172 + !UserUtil.isLogined() ||
  173 + UserUtil.isAppReviewAccount(),
173 174 child: const ShakeImage(),
174 175 ));
175 176 }),
... ...
lib/pages/section/bloc/section_bloc.dart
... ... @@ -5,9 +5,11 @@ import 'package:flutter/foundation.dart';
5 5 import 'package:flutter/material.dart';
6 6 import 'package:flutter_bloc/flutter_bloc.dart';
7 7 import 'package:flutter_screenutil/flutter_screenutil.dart';
  8 +import 'package:wow_english/common/core/user_util.dart';
8 9 import 'package:wow_english/common/request/dao/lesson_dao.dart';
9 10 import 'package:wow_english/common/request/exception.dart';
10 11 import 'package:wow_english/common/request/dao/listen_dao.dart';
  12 +import 'package:wow_english/pages/section/section_type.dart';
11 13 import 'package:wow_english/utils/audio_player_util.dart';
12 14 import 'package:wow_english/utils/loading.dart';
13 15 import 'package:wow_english/utils/toast_util.dart';
... ... @@ -73,7 +75,7 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> {
73 75 await LessonDao.courseSection(courseUnitId: event.courseUnitId);
74 76 if (courseSectionEntities != null) {
75 77 _courseSectionDatasMap[event.courseUnitId] =
76   - await LessonDao.courseSection(courseUnitId: event.courseUnitId);
  78 + _filterReviewContent(courseSectionEntities);
77 79 emitter(LessonDataLoadState());
78 80 }
79 81 });
... ... @@ -203,6 +205,31 @@ class SectionBloc extends Bloc<SectionEvent, SectionState> {
203 205 return null;
204 206 }
205 207  
  208 + List<CourseSectionEntity> _filterReviewContent(
  209 + List<CourseSectionEntity> courseSections) {
  210 + if (!UserUtil.isAppReviewAccount()) {
  211 + return courseSections;
  212 + }
  213 + return courseSections
  214 + .where((section) => section.courseType != SectionType.pictureBook.value)
  215 + .toList();
  216 + }
  217 +
  218 + CourseSectionEntity? _findNextVisibleCourseSection(
  219 + CourseSectionEntity currentSection) {
  220 + if (!UserUtil.isAppReviewAccount()) {
  221 + return findCourseSectionBySort(currentSection.sortOrder + 1);
  222 + }
  223 +
  224 + final currentUnitSections =
  225 + _courseSectionDatasMap[currentSection.courseUnitId];
  226 + final nextSections = currentUnitSections
  227 + ?.where((section) => section.sortOrder > currentSection.sortOrder)
  228 + .toList()
  229 + ?..sort((a, b) => a.sortOrder.compareTo(b.sortOrder));
  230 + return nextSections?.firstOrNull;
  231 + }
  232 +
206 233 ///根据courseLessonId查找对应的CourseUnitDetail
207 234 CourseUnitDetail? findCourseUnitDetailById(int courseLessonId) {
208 235 final curCourseSectionEntity = findCourseSectionById(courseLessonId);
... ... @@ -224,7 +251,9 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
224 251 try {
225 252 ///查找当前unit的下一个section
226 253 CourseSectionEntity? nextCourseSectionEntity =
227   - findCourseSectionBySort(curSectionSort + 1);
  254 + curCourseSectionEntity == null
  255 + ? findCourseSectionBySort(curSectionSort + 1)
  256 + : _findNextVisibleCourseSection(curCourseSectionEntity);
228 257 return checkCourseSectionLocked(
229 258 courseLessonId, nextCourseSectionEntity, emitter);
230 259 } catch (e) {
... ... @@ -251,6 +280,7 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
251 280 List<CourseSectionEntity>? tempSectionEntities =
252 281 await LessonDao.courseSection(courseUnitId: courseUnitId);
253 282 if (tempSectionEntities != null) {
  283 + tempSectionEntities = _filterReviewContent(tempSectionEntities);
254 284 _courseSectionDatasMap[courseUnitId] = tempSectionEntities;
255 285 emitter(LessonDataLoadState());
256 286 }
... ... @@ -356,8 +386,12 @@ class SectionBloc extends Bloc&lt;SectionEvent, SectionState&gt; {
356 386 if (courseSectionEntity == null) {
357 387 ///如果没下载过,请求数据
358 388 await loading(() async {
359   - _courseSectionDatasMap[courseUnitId] =
  389 + final courseSections =
360 390 await LessonDao.courseSection(courseUnitId: courseUnitId);
  391 + if (courseSections != null) {
  392 + _courseSectionDatasMap[courseUnitId] =
  393 + _filterReviewContent(courseSections);
  394 + }
361 395 emitter(LessonDataLoadState());
362 396 });
363 397 }
... ...