MineViewController.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. //
  2. // MineViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/17.
  6. //
  7. #import "MineViewController.h"
  8. #import "MineNavView.h"
  9. #import "MineBodyView.h"
  10. #import "SettingViewController.h"
  11. #import "KSBaseWKWebViewController.h"
  12. #import "NetworkingCheckController.h"
  13. #import "DeviceCheckView.h"
  14. #import "UserInfoManager.h"
  15. #import "TeacherInfo.h"
  16. #import "VideoCourseViewController.h"
  17. #import "LiveListViewController.h"
  18. #import "MinePageViewController.h"
  19. #import "MyLiveCourseViewController.h"
  20. #import "MyStyleViewController.h"
  21. #import "MyBankCardViewController.h"
  22. #import "MyCourseViewController.h"
  23. #import "UserSettingViewController.h"
  24. #import "FeedbackViewController.h"
  25. @interface MineViewController ()
  26. @property (nonatomic, strong) MineNavView *navView;
  27. @property (nonatomic, strong) MineBodyView *bodyView;
  28. @property (nonatomic, strong) DeviceCheckView *checkView;
  29. @property (nonatomic, strong) TeacherInfo *mineInfo;
  30. @end
  31. @implementation MineViewController
  32. - (void)viewDidLoad {
  33. [super viewDidLoad];
  34. // Do any additional setup after loading the view.
  35. self.ks_prefersNavigationBarHidden = YES;
  36. [self configUI];
  37. }
  38. - (void)viewWillAppear:(BOOL)animated {
  39. [super viewWillAppear:animated];
  40. if ([self checkIsLoginToLoginView:YES]) {
  41. [self requsetUserMessage];
  42. [self requestUserMemo];
  43. [self queryAmountDetail];
  44. }
  45. }
  46. - (void)queryAmountDetail {
  47. [KSNetworkingManager teacherAccountDetail:KS_GET success:^(NSDictionary * _Nonnull dic) {
  48. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  49. double amount = [[dic dictionaryValueForKey:@"data"] doubleValueForKey:@"amountShare"];
  50. [self evaluateAmount:amount];
  51. }
  52. else {
  53. [self MBPShow:MESSAGEKEY];
  54. }
  55. } faliure:^(NSError * _Nonnull error) {
  56. }];
  57. }
  58. - (void)evaluateAmount:(double)amount {
  59. NSString *valueString = [NSString formatMoneyDoubleNum:amount];
  60. NSString *amountString = [NSString stringWithFormat:@"累计收益%@元",valueString];
  61. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:amountString attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:HexRGB(0x999999)}];
  62. [attr addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:12.0f weight:UIFontWeightMedium], NSForegroundColorAttributeName:HexRGB(0xff4e19)} range:[amountString rangeOfString:valueString]];
  63. self.bodyView.shareAmountLabel.attributedText = attr;
  64. }
  65. - (void)requestUserMemo {
  66. [[UserInfoManager shareInstance] requsetconfigCallback:^(BOOL success) {
  67. [self refreshBodyView:success];
  68. }];
  69. }
  70. - (void)refreshBodyView:(BOOL)isMember {
  71. self.bodyView.isMember = isMember;
  72. CGFloat contentMinHeight = [_bodyView getViewHeight];
  73. [self.bodyView mas_updateConstraints:^(MASConstraintMaker *make) {
  74. make.height.mas_equalTo(contentMinHeight);
  75. }];
  76. }
  77. - (void)requsetUserMessage {
  78. [KSNetworkingManager queryTeacherInfoRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
  79. if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
  80. self.mineInfo = [[TeacherInfo alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
  81. NSString *rongToken = UserDefault(RongTokenKey);
  82. if ([NSString isEmptyString:rongToken]) {
  83. [USER_MANAGER queryUserInfoConnectRongCloud:YES];
  84. }
  85. [self refreshView];
  86. }
  87. else {
  88. [self MBPShow:MESSAGEKEY];
  89. }
  90. } faliure:^(NSError * _Nonnull error) {
  91. }];
  92. }
  93. - (void)refreshView {
  94. [self.bodyView configMessage:self.mineInfo];
  95. }
  96. - (void)configUI {
  97. UIImage *bgImage = [UIImage imageNamed:@"login_head"];
  98. CGFloat height = bgImage.size.height / bgImage.size.width * kScreenWidth;
  99. UIImageView *imageView = [[UIImageView alloc] initWithImage:bgImage];
  100. imageView.frame = CGRectMake(0, 0, kScreenWidth, height);
  101. [self.view addSubview:imageView];
  102. [self.view addSubview:self.navView];
  103. [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.width.mas_equalTo(60);
  105. make.right.top.mas_equalTo(self.view);
  106. make.height.mas_equalTo(kNaviBarHeight);
  107. }];
  108. [self.view bringSubviewToFront:self.scrollView];
  109. [self.view bringSubviewToFront:self.navView];
  110. [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  111. make.top.mas_equalTo(self.view.mas_top);
  112. make.left.right.mas_equalTo(self.view);
  113. make.bottom.mas_equalTo(self.view.mas_bottom);
  114. }];
  115. self.scrollView.backgroundColor = [UIColor clearColor];
  116. UIView *headView = [[UIView alloc] init];
  117. headView.backgroundColor = [UIColor clearColor];
  118. [self.scrollView addSubview:headView];
  119. [headView mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.top.mas_equalTo(self.scrollView.mas_top);
  121. make.left.right.mas_equalTo(self.view);
  122. make.height.mas_equalTo(kNaviBarHeight);
  123. }];
  124. // bodyView;
  125. _bodyView = [MineBodyView shareInstance];
  126. [self.scrollView addSubview:_bodyView];
  127. CGFloat contentMinHeight = [_bodyView getViewHeight];
  128. CGFloat contentHeight = kScreenHeight - kTabBarHeight - kNaviBarHeight;
  129. CGFloat viewHeight = contentMinHeight > contentHeight ? contentMinHeight : contentHeight;
  130. [_bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.top.mas_equalTo(headView.mas_bottom);
  132. make.left.right.mas_equalTo(self.view);
  133. make.height.mas_equalTo(viewHeight);
  134. make.bottom.mas_equalTo(self.scrollView.mas_bottom);
  135. }];
  136. MJWeakSelf;
  137. [_bodyView operationCallback:^(MINEVIEWTYPE type) {
  138. [weakSelf operationAction:type];
  139. }];
  140. }
  141. - (void)operationAction:(MINEVIEWTYPE)type {
  142. switch (type) {
  143. case MINEVIEWTYPE_AUTH: // 达人认证
  144. {
  145. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  146. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  147. [self.navigationController pushViewController:webCtrl animated:YES];
  148. }
  149. break;
  150. case MINEVIEWTYPE_HOMEPAGE: // 我的主页
  151. {
  152. if (![self.mineInfo.entryStatus isEqualToString:@"PASS"]) { // 跳转达人认证
  153. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  154. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  155. [self.navigationController pushViewController:webCtrl animated:YES];
  156. }
  157. else {
  158. MinePageViewController *pageCtrl = [[MinePageViewController alloc] init];
  159. [self.navigationController pushViewController:pageCtrl animated:YES];
  160. }
  161. }
  162. break;
  163. case MINEVIEWTYPE_MIEN: // 个人风采
  164. {
  165. if (![self.mineInfo.entryStatus isEqualToString:@"PASS"]) { // 跳转达人认证
  166. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  167. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  168. [self.navigationController pushViewController:webCtrl animated:YES];
  169. }
  170. else { // 风采
  171. MyStyleViewController *styleCtrl = [[MyStyleViewController alloc] init];
  172. [self.navigationController pushViewController:styleCtrl animated:YES];
  173. }
  174. }
  175. break;
  176. case MINEVIEWTYPE_STARTBOARDCAST: // 开启直播
  177. {
  178. if ([self.mineInfo.liveFlag isEqualToString:@"1"]) {
  179. LiveListViewController *ctrl = [[LiveListViewController alloc] init];
  180. [self.navigationController pushViewController:ctrl animated:YES];
  181. }
  182. else { // 开通直播审核
  183. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  184. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/openLive"];
  185. [self.navigationController pushViewController:webCtrl animated:YES];
  186. }
  187. }
  188. break;
  189. case MINEVIEWTYPE_ORDER: // 商品订单
  190. {
  191. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  192. ctrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST,@"/#/goodsOrder"];
  193. [self.navigationController pushViewController:ctrl animated:YES];
  194. }
  195. break;
  196. case MINEVIEWTYPE_ACCOMPANY: // 陪练课设置
  197. {
  198. if (![self.mineInfo.entryStatus isEqualToString:@"PASS"]) { // 跳转达人认证
  199. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  200. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/teacherCert"];
  201. [self.navigationController pushViewController:webCtrl animated:YES];
  202. }
  203. else { // 设置页面
  204. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  205. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/practiceSetting"];
  206. [self.navigationController pushViewController:webCtrl animated:YES];
  207. }
  208. }
  209. break;
  210. case MINEVIEWTYPE_BOARDCASTCOURSE: // 直播课程
  211. {
  212. MyLiveCourseViewController *ctrl = [[MyLiveCourseViewController alloc] init];
  213. [self.navigationController pushViewController:ctrl animated:YES];
  214. }
  215. break;
  216. case MINEVIEWTYPE_VIDEOCOURSE: // 视频课
  217. {
  218. VideoCourseViewController *ctrl = [[VideoCourseViewController alloc] init];
  219. [self.navigationController pushViewController:ctrl animated:YES];
  220. }
  221. break;
  222. case MINEVIEWTYPE_EXTENDPLAN: // 推广计划
  223. {
  224. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  225. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/extendPlan"];
  226. [self.navigationController pushViewController:webCtrl animated:YES];
  227. }
  228. break;
  229. case MINEVIEWTYPE_CARD: // 我的银行卡
  230. {
  231. MyBankCardViewController *ctrl = [[MyBankCardViewController alloc] init];
  232. [self.navigationController pushViewController:ctrl animated:YES];
  233. }
  234. break;
  235. case MINEVIEWTYPE_NETWORKING: // 网络检测
  236. {
  237. NetworkingCheckController *checkVC = [[NetworkingCheckController alloc] init];
  238. [self.navigationController pushViewController:checkVC animated:YES];
  239. }
  240. break;
  241. case MINEVIEWTYPE_DEVICE: // 设备检测
  242. {
  243. [self.checkView showAlert];
  244. }
  245. break;
  246. case MINEVIEWTYPE_HELP: // 帮助
  247. {
  248. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  249. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/helpCenter"];
  250. [self.navigationController pushViewController:webCtrl animated:YES];
  251. }
  252. break;
  253. case MINEVIEWTYPE_FANS: // 我的粉丝
  254. {
  255. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  256. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/myFans"];
  257. [self.navigationController pushViewController:webCtrl animated:YES];
  258. }
  259. break;
  260. case MINEVIEWTYPE_FINISHCOURSE: // 我的课程
  261. {
  262. MyCourseViewController *ctrl = [[MyCourseViewController alloc] init];
  263. [self.navigationController pushViewController:ctrl animated:YES];
  264. }
  265. break;
  266. case MINEVIEWTYPE_UNFINISHCOURSE: // 我的课程
  267. {
  268. MyCourseViewController *ctrl = [[MyCourseViewController alloc] init];
  269. [self.navigationController pushViewController:ctrl animated:YES];
  270. }
  271. break;
  272. case MINEVIEWTYPE_USERSETTING: // 用户设置
  273. {
  274. UserSettingViewController *ctrl = [[UserSettingViewController alloc] init];
  275. [self.navigationController pushViewController:ctrl animated:YES];
  276. }
  277. break;
  278. case MINEVIEWTYPE_FEEDBACK: // 反馈
  279. {
  280. FeedbackViewController *ctrl = [[FeedbackViewController alloc] init];
  281. [self.navigationController pushViewController:ctrl animated:YES];
  282. }
  283. break;
  284. case MINEVIEWTYPE_MEMERCENTER:
  285. {
  286. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  287. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/memberCenter"];
  288. [self.navigationController pushViewController:webCtrl animated:YES];
  289. }
  290. break;
  291. case MINEVIEWTYPE_TRADERECORD:
  292. {
  293. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  294. webCtrl.url = [NSString stringWithFormat:@"%@%@", WEBHOST, @"/#/rechargeRecord"];
  295. [self.navigationController pushViewController:webCtrl animated:YES];
  296. }
  297. break;
  298. default:
  299. break;
  300. }
  301. }
  302. #pragma mark --- lazying
  303. - (MineNavView *)navView {
  304. if (!_navView) {
  305. _navView = [MineNavView shareInstance];
  306. MJWeakSelf;
  307. [_navView mineNavAction:^{
  308. [weakSelf settingAction];
  309. }];
  310. }
  311. return _navView;
  312. }
  313. - (DeviceCheckView *)checkView {
  314. if (!_checkView) {
  315. _checkView = [DeviceCheckView shareInstance];
  316. }
  317. return _checkView;
  318. }
  319. - (void)settingAction {
  320. SettingViewController *ctrl = [[SettingViewController alloc] init];
  321. [self.navigationController pushViewController:ctrl animated:YES];
  322. }
  323. - (void)dealloc {
  324. [[NSNotificationCenter defaultCenter] removeObserver:self];
  325. }
  326. /*
  327. #pragma mark - Navigation
  328. // In a storyboard-based application, you will often want to do a little preparation before navigation
  329. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  330. // Get the new view controller using [segue destinationViewController].
  331. // Pass the selected object to the new view controller.
  332. }
  333. */
  334. @end