123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- //
- // YMAdolescentModelViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/22.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAdolescentModelViewModel.h"
- @interface YMAdolescentModelViewModel ()
- /// 青少年模式类型
- @property (nonatomic, assign, readwrite) YMAdolescentModelType adolescentModelType;
- /// 青少年模式操作文本
- @property (nonatomic, strong, readwrite) NSString *adolescentModelOperationText;
- /// 青少年模式密码操作文本
- @property (nonatomic, strong, readwrite) NSString *adolescentModelPasswordOperationText;
- @end
- @implementation YMAdolescentModelViewModel
- - (void)ym_initialize{
- [super ym_initialize];
-
- self.customNavTitle = @"青少年模式";
-
- self.adolescentModelType = [self.params integerValueForKey:ParamsCategoryType defaultValue:YMAdolescentModelTypeTips];
-
- self.adolescentModelSettingPassword = [self.params stringValueForKey:@"settingPassword" defaultValue:@""];
-
- switch (self.adolescentModelType) {
- case YMAdolescentModelTypeTips:
- {
- self.adolescentModelOperationText = @"开启青少年模式";
- }
- break;
- case YMAdolescentModelTypeSettingPassword:
- {
- self.adolescentModelOperationText = @"开启青少年模式";
- self.adolescentModelPasswordOperationText = @"设置密码";
- }
- break;
- case YMAdolescentModelTypeConfirmPassword:
- {
- self.adolescentModelOperationText = @"开启青少年模式";
- self.adolescentModelPasswordOperationText = @"确认密码";
- }
- break;
- case YMAdolescentModelTypeClosePassword:
- {
- self.adolescentModelOperationText = @"关闭青少年模式";
- self.adolescentModelPasswordOperationText = @"输入密码";
- }
- break;
- default:
- break;
- }
-
- }
- - (void)openAdolescentModel{
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"正在开启中..."];
- [LCHttpHelper requestWithURLString:SetAdolescent parameters:@{
- @"password":self.adolescentModelConfirmPassword
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- [LCSaveData saveYoungMode:YES];
- kAppDelegate.kadolescentStatus = 1;
- [[YMGlobalUtils getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)closeAdolescentModel{
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"正在关闭中..."];
- [LCHttpHelper requestWithURLString:SwitchAdolescent parameters:@{
- @"is_open":@(0),
- @"password":self.adolescentModelConfirmPassword
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- [LCSaveData saveYoungMode:NO];
- kAppDelegate.kadolescentStatus = 0;
- [[YMGlobalUtils getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper dismiss];
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- @end
|