123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- //
- // SettingViewController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/21.
- //
- #import "SettingViewController.h"
- #import "SettingBodyView.h"
- #import "KSBaseWKWebViewController.h"
- #import "FeedbackViewController.h"
- #import "AboutUsViewController.h"
- #import "UserInfoManager.h"
- #import "AddressListViewController.h"
- #import "UserAuthViewController.h"
- #import "LoginViewController.h"
- #import "AppDelegate.h"
- #import "CustomNavViewController.h"
- #import "JPUSHService.h"
- #import "AccountDeleteViewController.h"
- #import "UnbindTenantViewController.h"
- #import "TenantUnbindDetailViewController.h"
- #import "CoursewareDownloadManager.h"
- @interface SettingViewController ()
-
- @property (nonatomic, strong) SettingBodyView *bodyView;
- @property (nonatomic, strong) NSString *userSex;
- @end
- @implementation SettingViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self allocTitle:@"设置"];
- [self configUI];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self requestUserMemo];
- }
- - (void)requestUserMemo {
- [[UserInfoManager shareInstance] requsetconfigCallback:^(BOOL success) {
- [self refreshBodyView:success];
- }];
- }
- - (void)refreshBodyView:(BOOL)isMember {
- self.bodyView.isMember = isMember;
- }
- - (void)configUI {
- [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.view.mas_top);
- make.bottom.mas_equalTo(self.view.mas_bottom).offset(-iPhoneXSafeBottomMargin);
- }];
- self.bodyView = [SettingBodyView shareInstance];
- CGFloat viewHeight = KPortraitHeight - kNaviBarHeight - iPhoneXSafeBottomMargin;
- [self.scrollView addSubview:self.bodyView];
- [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.right.left.mas_equalTo(self.view);
- make.height.mas_equalTo(viewHeight);
- }];
- [self.scrollView setContentSize:CGSizeMake(kScreenWidth, viewHeight)];
- KSWeakSelf(weakSelf);
- [self.bodyView settingAction:^(SETTINGACTION type) {
- [weakSelf operationAction:type];
- }];
- }
- - (void)operationAction:(SETTINGACTION)type {
- switch (type) {
- case SETTINGACTION_ADDRESS:
- {
- AddressListViewController *ctrl = [[AddressListViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- break;
- case SETTINGACTION_ONLINECHECK:
- {
-
- }
- break;
- case SETTINGACTION_PRIVACY:
- {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/privacyProtocol"];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- break;
- case SETTINGACTION_FEEEDBACK:
- {
- FeedbackViewController *ctrl = [[FeedbackViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- break;
- case SETTINGACTION_ABOUTUS:
- {
- AboutUsViewController *aboutUs = [[AboutUsViewController alloc] init];
- [self.navigationController pushViewController:aboutUs animated:YES];
- }
- break;
- case SETTINGACTION_LOGOUT:
- {
- [self logoutAction];
- }
- break;
- case SETTINGACTION_DELETEACCOUNT:
- {
- [self toDelteAccountView];
- }
- break;
- case SETTINGACTION_MUSICCHECK:
- {
- // /#/review-list
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/review-list"];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- break;
- case SETTINGACTION_UNBIND:
- {
- [self checkUnbindStatus];
-
- }
- break;
- case SETTINGACTION_CLEARCACHE:
- {
- [self clearCache];
- }
- break;
- default:
- break;
- }
- }
- //
- - (void)clearCache {
- if (COURSEWARE_MANAGER.isDownloading) { // 如果在下载 取消
- [COURSEWARE_MANAGER cancleDownloadCourseware];
- }
-
- NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
- NSString *bundlePath = [documentsPath stringByAppendingPathComponent:@"CoursewarePath"];
- NSFileManager *fileManager = [NSFileManager defaultManager];
- BOOL isExist = [fileManager fileExistsAtPath:bundlePath];
- if (isExist) {
- BOOL isSuccess = [fileManager removeItemAtPath:bundlePath error:nil];
- if (isSuccess) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"清理完成"];
- }
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"清理完成"];
- }
- }
- /**
-
-
- */
- - (void)checkUnbindStatus {
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager unbindTenantDetailRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- NSDictionary *parm = [dic ks_dictionaryValueForKey:@"data"];
- if (parm) {
- NSString *reson = [parm ks_stringValueForKey:@"unbindReason"];
- [self showUnbindDetail:reson tenantName:[parm ks_stringValueForKey:@"tenantName"]];
- }
- else {
- [self toUnbindTenantView];
- }
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- - (void)toUnbindTenantView {
- UnbindTenantViewController *ctrl = [[UnbindTenantViewController alloc] init];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)showUnbindDetail:(NSString *)reson tenantName:(NSString *)tenantName {
- TenantUnbindDetailViewController *ctrl = [[TenantUnbindDetailViewController alloc] init];
- [ctrl configTenantName:tenantName desc:reson];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)toDelteAccountView {
- AccountDeleteViewController *detailView = [[AccountDeleteViewController alloc] init];
- [self.navigationController pushViewController:detailView animated:YES];
- }
- - (void)logoutAction {
- [KSNetworkingManager logoutRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- [self clearSource];
- } faliure:^(NSError * _Nonnull error) {
- [self clearSource];
- }];
- }
- - (void)clearSource {
- [APPLOGIN_MANAGER logoutAction];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|