123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //
- // 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 "AddressListViewController.h"
- #import "RCConnectionManager.h"
- #import "LoginViewController.h"
- #import "AppDelegate.h"
- #import "CustomNavViewController.h"
- #import "JPUSHService.h"
- #import "UserInfoManager.h"
- #import "AccountDeleteViewController.h"
- #import "UserInfoManager.h"
- @interface SettingViewController ()
- @property (nonatomic, strong) SettingBodyView *bodyView;
- @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;
- default:
- break;
- }
- }
- - (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)clearUMCount {
- [USER_MANAGER sendUMEvent:@"klx_logout"];
- [USER_MANAGER stopCountUMEvent];
- }
- - (void)clearSource {
- [self clearUMCount];
- USER_MANAGER.hasShowFlash = NO;
- [RCConnectionManager shareManager].isNeedJoin = NO;
- [RCConnectionManager shareManager].isNeedShowMessage = NO;
- [[RCIM sharedRCIM] logout];
- [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
- // 取消推送别名
- [JPUSHService deleteAlias:nil seq:0];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:TokenKey];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:Token_type];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:RefreshToken];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:RongTokenKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
- [KSNetworkingManager clearRequestHeader];
- LoginViewController *loginVC = [[LoginViewController alloc] init];
- CustomNavViewController *navCtrl = [[CustomNavViewController alloc] initWithRootViewController:loginVC];
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- appDelegate.window.rootViewController = navCtrl;
- }
- /*
- #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
|