Commit 578775ca794820b7d42a5737558a381ee0119fb1
1 parent
ca0d27b6
feat:课程学习增加vip权限控制
Showing
2 changed files
with
31 additions
and
32 deletions
lib/common/core/user_util.dart
... | ... | @@ -63,8 +63,8 @@ class UserUtil { |
63 | 63 | pushNamedAndRemoveUntil(AppRouteName.login, (route) => false, arguments: {'showPasswordPage': showPasswordLoginPage}); |
64 | 64 | } |
65 | 65 | |
66 | - // 是否有游戏权限 | |
67 | - static bool hasGamePermission() { | |
66 | + // 是否有权限 | |
67 | + static bool hasPermission() { | |
68 | 68 | return _userEntity?.valid ?? false; |
69 | 69 | } |
70 | 70 | ... | ... |
lib/pages/home/view.dart
1 | 1 | |
2 | -import 'package:flutter/foundation.dart'; | |
3 | 2 | import 'package:flutter/material.dart'; |
4 | -import 'package:flutter/services.dart'; | |
5 | 3 | import 'package:flutter_app_update/azhon_app_update.dart'; |
6 | 4 | import 'package:flutter_app_update/update_model.dart'; |
7 | 5 | import 'package:flutter_bloc/flutter_bloc.dart'; |
... | ... | @@ -69,11 +67,9 @@ class _HomePageView extends StatelessWidget { |
69 | 67 | Expanded( |
70 | 68 | child: GestureDetector( |
71 | 69 | onTap: () { |
72 | - if (UserUtil.isLogined()) { | |
70 | + _checkPermission(() { | |
73 | 71 | pushNamed(AppRouteName.courseUnit); |
74 | - } else { | |
75 | - pushNamed(AppRouteName.login); | |
76 | - } | |
72 | + }); | |
77 | 73 | }, |
78 | 74 | child: Column( |
79 | 75 | mainAxisAlignment: MainAxisAlignment.center, |
... | ... | @@ -105,30 +101,9 @@ class _HomePageView extends StatelessWidget { |
105 | 101 | 'WQF ModuleSelectPage BlocBuilder state: $userState'); |
106 | 102 | return GestureDetector( |
107 | 103 | onTap: () { |
108 | - //如果没登录先登录 | |
109 | - if (UserUtil.isLogined()) { | |
110 | - if (AppConfigHelper | |
111 | - .shouldHidePay()) { | |
112 | - pushNamed(AppRouteName.games); | |
113 | - } else { | |
114 | - if (UserUtil | |
115 | - .hasGamePermission()) { | |
116 | - pushNamed(AppRouteName.games); | |
117 | - } else { | |
118 | - showTwoActionDialog( | |
119 | - '提示', '忽略', '去续费', | |
120 | - '您的课程已到期,请快快续费继续学习吧!', | |
121 | - leftTap: () { | |
122 | - popPage(); | |
123 | - }, rightTap: () { | |
124 | - popPage(); | |
125 | - pushNamed(AppRouteName.shop); | |
126 | - }); | |
127 | - } | |
128 | - } | |
129 | - } else { | |
130 | - pushNamed(AppRouteName.login); | |
131 | - } | |
104 | + _checkPermission(() { | |
105 | + pushNamed(AppRouteName.games); | |
106 | + }); | |
132 | 107 | }, |
133 | 108 | child: Column( |
134 | 109 | mainAxisAlignment: MainAxisAlignment |
... | ... | @@ -168,6 +143,30 @@ class _HomePageView extends StatelessWidget { |
168 | 143 | }); |
169 | 144 | |
170 | 145 | |
146 | + _checkPermission(VoidCallback onAllowed) { | |
147 | + if (UserUtil.isLogined()) { | |
148 | + if (AppConfigHelper.shouldHidePay()) { | |
149 | + onAllowed(); | |
150 | + } else { | |
151 | + if (UserUtil.hasPermission()) { | |
152 | + onAllowed(); | |
153 | + } else { | |
154 | + showTwoActionDialog('提示', '忽略', '去续费', | |
155 | + '您的课程已到期,请快快续费继续学习吧!', leftTap: () { | |
156 | + popPage(); | |
157 | + }, rightTap: () { | |
158 | + popPage(); | |
159 | + pushNamed(AppRouteName.shop); | |
160 | + }); | |
161 | + } | |
162 | + } | |
163 | + } else { | |
164 | + //如果没登录先登录 | |
165 | + pushNamed(AppRouteName.login); | |
166 | + } | |
167 | + } | |
168 | + | |
169 | + | |
171 | 170 | ///Flutter侧处理升级对话框 |
172 | 171 | ///[forcedUpgrade] 是否强制升级 |
173 | 172 | _showUpdateDialog(BuildContext context, bool forcedUpgrade, | ... | ... |