小说绘上架版本

This commit is contained in:
xtfei2011
2021-02-07 11:24:08 +08:00
commit ee5c1c8b12
1762 changed files with 115892 additions and 0 deletions
@@ -0,0 +1,15 @@
//
// WXYZ_BindPhoneViewController.h
// WXReader
//
// Created by Andrew on 2018/7/27.
// Copyright © 2018年 Andrew. All rights reserved.
//
@interface WXYZ_BindPhoneViewController : TFBasicViewController
/// 绑定成功回调
@property (nonatomic, copy) void(^completionBlock)(void);
@end
@@ -0,0 +1,266 @@
//
// WXYZ_BindPhoneViewController.m
// WXReader
//
// Created by Andrew on 2018/7/27.
// Copyright © 2018年 Andrew. All rights reserved.
//
#import "WXYZ_BindPhoneViewController.h"
#import "TFAreaCodeViewController.h"
#import "TFValidationButton.h"
#import "UIView+LayoutCallback.h"
#import "NSObject+Observer.h"
@interface WXYZ_BindPhoneViewController ()
@property (nonatomic, weak) UITextField *accountTextField;
@property (nonatomic, weak) UITextField *codeTextField;
@property (nonatomic, weak) TFValidationButton *sendCodeButton;
@property (nonatomic, weak) UIButton *loginButton;
@end
@implementation WXYZ_BindPhoneViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initialize];
[self createSubviews];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
}
#pragma mark - 初始化
- (void)initialize {
[self setNavigationBarTitle:TFLocalizedString(@"绑定手机号")];
self.view.backgroundColor = kWhiteColor;
}
#pragma mark - UI
- (void)createSubviews {
UIView *leftView = ({
UIView *leftView = [[UIView alloc] init];
leftView.backgroundColor = kWhiteColor;
UILabel *zoneLabel = [[UILabel alloc] init];
zoneLabel.backgroundColor = kWhiteColor;
zoneLabel.textColor = kBlackColor;
zoneLabel.font = kFont18;
zoneLabel.text = [NSString stringWithFormat:@"%@%@", @"+", TFSystemInfoManager.zoneNumber];
[leftView addSubview:zoneLabel];
[zoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.centerY.equalTo(leftView);
}];
UIImageView *downImageView = [[UIImageView alloc] init];
downImageView.backgroundColor = kWhiteColor;
downImageView.image = [[UIImage imageNamed:@"public_dropDown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[leftView addSubview:downImageView];
[downImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(zoneLabel.mas_right).offset(kQuarterMargin);
make.centerY.equalTo(zoneLabel);
make.width.height.mas_equalTo(15.0);
}];
WS(weakSelf)
[leftView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
TFAreaCodeViewController *vc = [[TFAreaCodeViewController alloc] init];
vc.areaCodeBlock = ^(NSString * _Nonnull areaCode) {
TFSystemInfoManager.zoneNumber = areaCode;
zoneLabel.text = [NSString stringWithFormat:@"%@%@", @"+", TFSystemInfoManager.zoneNumber];
};
[weakSelf.navigationController pushViewController:vc animated:YES];
}]];
leftView;
});
[self.view addSubview:leftView];
leftView.frameBlock = ^(UIView * _Nonnull view) {
[view addBorderLineWithBorderWidth:1.0 borderColor:kGrayLineColor cornerRadius:0.0 borderType:UIBorderSideTypeBottom];
};
CGFloat width = SCREEN_WIDTH - 4 * kMargin;
CGFloat height = kGeometricWidth(width, 61.0, 334.0);
[leftView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(2 * kMargin);
make.top.equalTo(self.view).offset(PUB_NAVBAR_HEIGHT + kLineX(40.0));
make.size.mas_equalTo(CGSizeMake(90.0, height));
}];
UITextField *accountTextField = ({
UITextField *accountTextField = [[UITextField alloc] init];
self.accountTextField = accountTextField;
accountTextField.backgroundColor = [UIColor whiteColor];
accountTextField.font = kFont16;
accountTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
accountTextField.textColor = kBlackColor;
[accountTextField addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
accountTextField.keyboardType = UIKeyboardTypeNumberPad;
accountTextField.placeholder = TFLocalizedString(@"手机号");
accountTextField.frameBlock = ^(UIView * _Nonnull view) {
[view addBorderLineWithBorderWidth:kCellLineHeight borderColor:kGrayLineColor cornerRadius:0 borderType:UIBorderSideTypeBottom];
};
accountTextField;
});
[self.view addSubview:accountTextField];
[accountTextField mas_makeConstraints:^(MASConstraintMaker *make) {
if (leftView.hidden) {
make.left.equalTo(leftView);
} else {
make.left.equalTo(leftView.mas_right);
}
make.top.height.equalTo(leftView);
make.right.equalTo(self.view).offset(-2 * kMargin);
}];
NSString *maxText = [NSString stringWithFormat:@"(%@)%@", @"59", TFLocalizedString(@"后重新发送")];
CGFloat maxWidth = [TFViewHelper getDynamicWidthWithLabelFont:kMainFont labelHeight:height labelText:maxText maxWidth:SCREEN_WIDTH / 2.0 - 50.0];
UIView *rightView = ({
UIView *rightView = [[UIView alloc] init];
TFValidationButton *sendCodeButton = [[TFValidationButton alloc] initWithFrame:CGRectZero identify:@"login_timer"];
self.sendCodeButton = sendCodeButton;
sendCodeButton.enabled = NO;
[sendCodeButton.titleLabel setFont:kMainFont];
sendCodeButton.titleLabel.textAlignment = NSTextAlignmentCenter;
[sendCodeButton setTitleColor:kRedColor forState:UIControlStateNormal];
[sendCodeButton setTitleColor:kColorRGB(199, 199, 205) forState:UIControlStateDisabled];
[sendCodeButton addTarget:self action:@selector(sendCodeEvent:) forControlEvents:UIControlEventTouchUpInside];
[rightView addSubview:sendCodeButton];
[sendCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(rightView);
make.height.mas_equalTo(sendCodeButton.intrinsicContentSize.height);
make.width.mas_equalTo(maxWidth);
}];
UIView *lineView = [[UIView alloc] init];
lineView.backgroundColor = kGrayLineColor;
[rightView addSubview:lineView];
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(rightView);
make.size.mas_equalTo(CGSizeMake(1.0, kMargin));
make.centerY.equalTo(rightView);
}];
rightView;
});
[self.view addSubview:rightView];
rightView.frameBlock = ^(UIView * _Nonnull view) {
[view addBorderLineWithBorderWidth:1.0 borderColor:kGrayLineColor cornerRadius:0.0 borderType:UIBorderSideTypeBottom];
};
[rightView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.height.equalTo(accountTextField);
make.top.equalTo(accountTextField.mas_bottom).offset(kMargin);
make.width.mas_equalTo(maxWidth + kMargin);
}];
UITextField *codeTextField = ({
UITextField *codeTextField = [[UITextField alloc] init];
self.codeTextField = codeTextField;
codeTextField.backgroundColor = accountTextField.backgroundColor;
codeTextField.keyboardType = UIKeyboardTypeNumberPad;
codeTextField.font = accountTextField.font;
codeTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
codeTextField.textColor = accountTextField.textColor;
codeTextField.placeholder = TFLocalizedString(@"验证码");
[codeTextField addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
codeTextField.frameBlock = ^(UIView * _Nonnull view) {
[view addBorderLineWithBorderWidth:kCellLineHeight borderColor:kGrayLineColor cornerRadius:0 borderType:UIBorderSideTypeBottom];
};
codeTextField;
});
[self.view addSubview:codeTextField];
[codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(leftView);
make.top.equalTo(rightView);
make.height.equalTo(accountTextField);
make.right.equalTo(rightView.mas_left);
}];
UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
self.loginButton = loginButton;
loginButton.titleLabel.font = kFont15;
[loginButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
[loginButton setTitleColor:kGrayTextColor forState:UIControlStateDisabled];
[loginButton setTitle:TFLocalizedString(@"绑定") forState:UIControlStateNormal];
[loginButton addObserver:KEY_PATH(loginButton, enabled) complete:^(UIButton * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
obj.backgroundColor = [newVal boolValue] ? kRedColor : kColorRGB(229, 230, 231);
}];
loginButton.enabled = NO;
loginButton.frameBlock = ^(UIButton * _Nonnull button) {
button.layer.cornerRadius = (CGRectGetWidth(button.bounds) + CGRectGetHeight(button.bounds)) * 0.058;
};
[loginButton addTarget:self action:@selector(bindPhone) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:loginButton];
[loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(2 * kMargin);
make.right.equalTo(self.view).offset(-2 * kMargin);
make.top.equalTo(codeTextField.mas_bottom).offset(is_iPhone4 || is_iPhone5 ? 40 : 60);
make.height.equalTo(loginButton.mas_width).multipliedBy(44.0 / 334.0);
}];
}
#pragma mark - Event
- (void)textDidChange:(UITextField *)textField {
if (self.sendCodeButton.countdownState == NO) {
self.sendCodeButton.enabled = (self.accountTextField.text.length > 0);
}
self.loginButton.enabled = (self.accountTextField.text.length > 0 && self.codeTextField.text.length > 0);
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}
#pragma mark - 网络请求
- (void)sendCodeEvent:(TFValidationButton *)button
{
NSDictionary *params = @{
@"mobile" : [TFSystemInfoManager.zoneNumber stringByAppendingString:self.accountTextField.text]
};
WS(weakSelf)
[TFNetworkTools POST:Send_Verification_Code parameters:params model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
[button startTiming];
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"验证码已发送")];
[weakSelf.codeTextField becomeFirstResponder];
} else {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg ?: TFLocalizedString(@"发送失败")];
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[TFPromptManager showPromptWithError:error defaultText:TFLocalizedString(@"发送失败")];
}];
}
- (void)bindPhone {
self.view.userInteractionEnabled = NO;
NSDictionary *params = @{
@"mobile" : [TFSystemInfoManager.zoneNumber stringByAppendingString:self.accountTextField.text],
@"code" : self.codeTextField.text
};
WS(weakSelf)
[TFNetworkTools POST:Phone_Binding parameters:params model:TFUserInfoManager.class success:^(BOOL isSuccess, TFUserInfoManager * _Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"绑定成功")];
!weakSelf.completionBlock ?: weakSelf.completionBlock();
} else {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
weakSelf.view.userInteractionEnabled = YES;
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[TFPromptManager showPromptWithError:error defaultText:nil];
weakSelf.view.userInteractionEnabled = YES;
}];
}
@end
@@ -0,0 +1,16 @@
//
// WXYZ_CancelAccountViewController.h
// WXReader
//
// Created by Andrew on 2019/12/21.
// Copyright © 2019 Andrew. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@interface WXYZ_CancelAccountViewController : TFBasicViewController
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,266 @@
//
// WXYZ_CancelAccountViewController.m
// WXReader
//
// Created by Andrew on 2019/12/21.
// Copyright © 2019 Andrew. All rights reserved.
//
#import "WXYZ_CancelAccountViewController.h"
#import "TFWebViewController.h"
#import "AppDelegate.h"
#import "WXYZ_CancelAccountTableViewCell.h"
@interface WXYZ_CancelAccountViewController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) UIButton *agreementButton;
@property (nonatomic, strong) UIButton *applyButton;
@end
@implementation WXYZ_CancelAccountViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initialize];
[self createSubviews];
}
- (void)initialize
{
[self setNavigationBarTitle:TFLocalizedString(@"注销账号")];
}
- (void)createSubviews
{
self.dataSourceArray = [NSMutableArray arrayWithArray:@[
@[TFLocalizedString(@"账号安全"), TFLocalizedString(@"最好使用常用设备提交申请,注销申请审核后,注销操作立即生效。")],
@[TFLocalizedString(@"账号状态"), TFLocalizedString(@"申请注销的账号应为正常使用中的状态,应处于未封禁或未被审查的状态。")],
@[TFLocalizedString(@"账号财产已结清"), TFLocalizedString(@"申请注销的账号无有效状态的会员,没有余额等;且没有任何未结清、未完成的交易。")]
]];
self.mainTableView.delegate = self;
self.mainTableView.dataSource = self;
// self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET, 0);
[self.mainTableView setTableHeaderView:self.headerView];
self.mainTableView.tableFooterView = [self footerView];
[self.view addSubview:self.mainTableView];
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
make.width.mas_equalTo(SCREEN_WIDTH);
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - (PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET) - kMargin);
}];
self.applyButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.applyButton.alpha = 0.6;
self.applyButton.backgroundColor = kRedColor;
[self.applyButton setTitle:TFLocalizedString(@"申请注销") forState:UIControlStateNormal];
[self.applyButton addTarget:self action:@selector(applyClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.applyButton];
[self.applyButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_TABBAR_OFFSET);
make.left.mas_equalTo(0);
make.width.mas_equalTo(SCREEN_WIDTH);
make.height.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
}];
[self.mainTableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataSourceArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellName = @"WXYZ_CancelAccountTableViewCell";
WXYZ_CancelAccountTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (!cell) {
cell = [[WXYZ_CancelAccountTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
}
cell.titleString = [self.dataSourceArray objectAtIndex:indexPath.row][0];
cell.detailString = [self.dataSourceArray objectAtIndex:indexPath.row][1];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
//section头间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
CGFloat height = [TFViewHelper getDynamicHeightWithLabelFont:kBoldFont15 labelWidth:SCREEN_WIDTH labelText:TFLocalizedString(@"申请注销前,您的账号需要注意以下条款:") maxHeight:MAXFLOAT];
return height + kMargin;
}
//section头视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGFloat height = [TFViewHelper getDynamicHeightWithLabelFont:kBoldFont15 labelWidth:SCREEN_WIDTH labelText:TFLocalizedString(@"申请注销前,您的账号需要注意以下条款:") maxHeight:MAXFLOAT];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, height + kMargin)];
view.backgroundColor = [UIColor clearColor];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kHalfMargin, kMargin, SCREEN_WIDTH - kHalfMargin - kHalfMargin, height)];
titleLabel.numberOfLines = 2;
titleLabel.text = TFLocalizedString(@"申请注销前,您的账号需要注意以下条款:");
titleLabel.textColor = kBlackColor;
titleLabel.font = kBoldFont15;
[view addSubview:titleLabel];
return view;
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
- (UIView *)footerView {
UIView *view = nil;
if (SCREEN_HEIGHT <= 667.0) {
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kLabelHeight + kLabelHeight)];
} else {
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kLabelHeight + kHalfMargin)];
}
view.backgroundColor = [UIColor clearColor];
if (!self.agreementButton) {
self.agreementButton = [UIButton buttonWithType:UIButtonTypeCustom];
// self.agreementButton.frame = CGRectMake(kHalfMargin, kHalfMargin, 30, 30);
self.agreementButton.selected = NO;
self.agreementButton.adjustsImageWhenHighlighted = NO;
[self.agreementButton setImageEdgeInsets:UIEdgeInsetsMake(7, 0, 7, 14)];
[self.agreementButton setImage:[UIImage imageNamed:@"audio_download_unselect"] forState:UIControlStateNormal];
[self.agreementButton setImage:[UIImage imageNamed:@"audio_download_select"] forState:UIControlStateSelected];
[self.agreementButton addTarget:self action:@selector(agreementClick) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:self.agreementButton];
[self.agreementButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(view);
make.left.equalTo(view).offset(kHalfMargin);
make.width.height.mas_equalTo(30.0);
}];
WS(weakSelf)
NSString *prefix = TFLocalizedString(@"我已阅读并接受");
NSString *suffix = TFLocalizedString(@"《用户注销协议》");
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", prefix, suffix]];
text.lineSpacing = 5;
text.font = kMainFont;
[text setTextHighlightRange:NSMakeRange(prefix.length, suffix.length) color:kMainColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
TFWebViewController *vc = [[TFWebViewController alloc] init];
vc.navTitle = TFLocalizedString(@"用户注销协议");
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
vc.URLString = delegate.checkSettingModel.protocol_list.logoff ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Log_Off, TFLanguageManager.serverLocalized];
[weakSelf.navigationController pushViewController:vc animated:YES];
}];
[text setTextHighlightRange:NSMakeRange(0, 7) color:kBlackColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
[weakSelf agreementClick];
}];
YYLabel *tipsLabel = [[YYLabel alloc] init];
tipsLabel.numberOfLines = 0;
tipsLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 2 * kMargin;
tipsLabel.attributedText = text;
tipsLabel.textAlignment = NSTextAlignmentLeft;
tipsLabel.userInteractionEnabled = YES;
[view addSubview:tipsLabel];
[tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(view).offset(kMargin + 10);
make.centerY.equalTo(self.agreementButton);
make.width.mas_equalTo(SCREEN_WIDTH - (kMargin + kMargin));
}];
}
return view;
}
- (UIView *)headerView
{
if (!_headerView) {
NSString *str = TFLocalizedString(@"重要提醒:个人账号可以申请注销。为了避免被盗号或非本人操作所带来的损失,注销前需要确认账号所属,以及可能涉及的虚拟财产结算。");
_headerView = [[UIView alloc] init];
_headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, [TFViewHelper getDynamicHeightWithLabelFont:kMainFont labelWidth:(SCREEN_WIDTH - (kMargin + kHalfMargin)) labelText:str] + 80 + 2 * kMargin);
_headerView.backgroundColor = [UIColor whiteColor];
UIView *headerBackView = [[UIView alloc] init];
headerBackView.backgroundColor = kGrayViewColor;
headerBackView.layer.cornerRadius = 12;
[_headerView addSubview:headerBackView];
[headerBackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.top.mas_equalTo(kHalfMargin);
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
make.height.mas_equalTo(_headerView.mas_height).with.offset(- kHalfMargin);
}];
UIImageView *headerImageView = [[UIImageView alloc] init];
headerImageView.image = [UIImage imageNamed:@"cancel_account"];
[_headerView addSubview:headerImageView];
[headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kMargin);
make.centerX.mas_equalTo(_headerView.mas_centerX);
make.width.height.mas_equalTo(80);
}];
UILabel *headerLabel = [[UILabel alloc] init];
headerLabel.numberOfLines = 0;
headerLabel.font = kMainFont;
headerLabel.textColor = kColorRGB(96, 106, 100);
[_headerView addSubview:headerLabel];
[headerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin + kHalfMargin);
make.top.mas_equalTo(headerImageView.mas_bottom).with.offset(kHalfMargin);
make.width.mas_equalTo(SCREEN_WIDTH - 2 * (kMargin + kHalfMargin));
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:kMainFont labelWidth:(SCREEN_WIDTH - (kMargin + kHalfMargin)) labelText:str]);
}];
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithAttributedString:[[NSAttributedString alloc] initWithString:str]];
// [attributeString addAttribute:NSFontAttributeName value:kBoldMainFont range:NSMakeRange(0, 5)];
headerLabel.attributedText = attributeString;
}
return _headerView;
}
- (void)agreementClick
{
self.agreementButton.selected = !self.agreementButton.selected;
if (self.agreementButton.selected) {
self.applyButton.alpha = 1;
} else {
self.applyButton.alpha = 0.6;
}
}
- (void)applyClick
{
if (self.agreementButton.selected) {
WS(weakSelf)
[TFNetworkTools POST:Cancel_Account parameters:nil model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
if (isSuccess) {
[TFUserInfoManager logout];
weakSelf.agreementButton.selected = NO;
weakSelf.applyButton.alpha = 0.6;
[weakSelf.navigationController popToRootViewControllerAnimated:YES];
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"注销成功")];
}
} failure:nil];
}
}
@end
@@ -0,0 +1,12 @@
//
// WXYZ_UserDataViewController.h
// WXReader
//
// Created by Andrew on 2018/7/17.
// Copyright © 2018年 Andrew. All rights reserved.
//
@interface WXYZ_UserDataViewController : TFBasicViewController
@end
@@ -0,0 +1,309 @@
//
// WXYZ_UserDataViewController.m
// WXReader
//
// Created by Andrew on 2018/7/17.
// Copyright © 2018年 Andrew. All rights reserved.
//
#import "WXYZ_UserDataViewController.h"
#import "WXYZ_BindPhoneViewController.h"
#import "WXYZ_CancelAccountViewController.h"
#import "WXYZ_UserDataTableViewCell.h"
#import "TFWeChatPermissionsManager.h"
#import "TFTencentPermissionsManager.h"
#import "TFURLProtocol.h"
#import "WXYZ_ImagePicker.h"
#import "TFTextFieldAlertView.h"
#import "TFUserDataModel.h"
typedef NS_ENUM(NSUInteger, WXYZ_UserInfoStyle) {
WXYZ_UserInfoStyleName,
WXYZ_UserInfoStyleGender,
WXYZ_UserInfoStyleAvatar
};
@interface WXYZ_UserDataViewController () <UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate, DPImagePickerDelegate, TFWeChatPermissionsDelegate, TFTencentPermissionsDelegate>
@property (nonatomic, strong) TFUserDataModel *userDataModel;
@end
@implementation WXYZ_UserDataViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initialize];
[self createSubviews];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self netRequest];
[self setStatusBarDefaultStyle];
}
- (void)initialize
{
[TFURLProtocol startMonitor];
[self setNavigationBarTitle:TFLocalizedString(@"个人资料")];
#if TF_WeChat_Login_Mode
[TFWeChatPermissionsManager sharedManager].delegate = self;
#endif
#if TF_QQ_Login_Mode
[TFTencentPermissionsManager sharedManager].delegate = self;
#endif
}
- (void)createSubviews
{
self.mainTableViewGroup.delegate = self;
self.mainTableViewGroup.dataSource = self;
[self.view addSubview:self.mainTableViewGroup];
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
make.width.mas_equalTo(SCREEN_WIDTH);
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.userDataModel.panel_list.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.userDataModel.panel_list[section].count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
WXYZ_UserDataTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WXYZ_UserDataTableViewCell"];
if (!cell) {
cell = [[WXYZ_UserDataTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WXYZ_UserDataTableViewCell"];
}
cell.cellModel = self.userDataModel.panel_list[indexPath.section][indexPath.row];
cell.hiddenEndLine = (indexPath.row == self.userDataModel.panel_list[indexPath.section].count - 1);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
WS(weakSelf)
WXYZ_UserDataTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// 修改头像
if ([cell.cellModel.action isEqualToString:@"avatar"] && cell.cellModel.is_click) {
WXYZ_ImagePicker *picker = [WXYZ_ImagePicker sharedManager];
picker.editPhoto = YES;
picker.delegate = self;
[picker showInController:self];
return;
}
// 修改昵称
if ([cell.cellModel.action isEqualToString:@"nickname"] && cell.cellModel.is_click) {
TFTextFieldAlertView *alert = [[TFTextFieldAlertView alloc] init];
alert.alertTitle = TFLocalizedString(@"修改昵称");
alert.placeHoldTitle = cell.cellModel.desc ?: @"";
alert.endEditedBlock = ^(NSString *inputText) {
[weakSelf setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleName url:Set_NickName parametersKey:@"nickname" parametersValue:inputText editedImage:nil];
};
[alert showAlertView];
return;
}
if ([cell.cellModel.action isEqualToString:@"gender"] && cell.cellModel.is_click) {
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
if (is_iPad) {
UIPopoverPresentationController *popover = actionSheet.popoverPresentationController;
if (popover) {
popover.sourceView = self.view;
popover.sourceRect = self.view.bounds;
popover.permittedArrowDirections = UIPopoverArrowDirectionDown;
}
}
[actionSheet addAction:[UIAlertAction actionWithTitle:TFLocalizedString(@"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[weakSelf setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleGender url:Set_Gender parametersKey:@"gender" parametersValue:@"2" editedImage:nil];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:TFLocalizedString(@"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[weakSelf setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleGender url:Set_Gender parametersKey:@"gender" parametersValue:@"1" editedImage:nil];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:TFLocalizedString(@"取消") style:UIAlertActionStyleCancel handler:nil]];
[[TFViewHelper getWindowRootController] presentViewController:actionSheet animated:YES completion:nil];
return;
}
// 注销账号
if ([cell.cellModel.action isEqualToString:@"cancel"] && cell.cellModel.is_click) {
[self.navigationController pushViewController:[[WXYZ_CancelAccountViewController alloc] init] animated:YES];
return;
}
// 绑定手机号
if ([cell.cellModel.action isEqualToString:@"mobile"] && cell.cellModel.is_click) {
WXYZ_BindPhoneViewController *vc = [[WXYZ_BindPhoneViewController alloc] init];
WS(weakSelf)
vc.completionBlock = ^{
[weakSelf netRequest];
};
[self.navigationController pushViewController:vc animated:YES];
return;
}
// 绑定微信
if ([cell.cellModel.action isEqualToString:@"wechat"] && cell.cellModel.is_click) {
[self weChatBindingRequest];
}
// 绑定QQ
if ([cell.cellModel.action isEqualToString:@"QQ"] && cell.cellModel.is_click) {
[self qqBindingRequest];
}
}
//section头部间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return kHalfMargin;
}
//section头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
view.backgroundColor = kGrayViewColor;
return view;
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
//section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
view.backgroundColor = kGrayViewColor;
return view;
}
#pragma mark - DPImagePickerDelegate
- (void)imagePickerDidFinishPickingWithOriginalImage:(UIImage *)originalImage editedImage:(UIImage *)editedImage;
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusLoading promptTitle:TFLocalizedString(@"上传中")];
[self setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleAvatar url:Set_Avatar parametersKey:@"avatar" parametersValue:[TFViewHelper getBase64StringWithImageData:UIImagePNGRepresentation(editedImage)] editedImage:[TFViewHelper fixOrientation:editedImage]];
}
- (void)setUserInfoNetRequestWithStyle:(WXYZ_UserInfoStyle)style url:(NSString *)url parametersKey:(NSString *)parametersKey parametersValue:(NSString *)parametersValue editedImage:(UIImage *)editedImage
{
WS(weakSelf)
[TFNetworkTools POST:url parameters:@{parametersKey:parametersValue} model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
switch (style) {
case WXYZ_UserInfoStyleName:
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"修改成功")];
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_NickName_Changed object:parametersValue];
}
break;
case WXYZ_UserInfoStyleGender:
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"修改成功")];
}
break;
case WXYZ_UserInfoStyleAvatar:
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"修改成功")];
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Avatar_Changed object:editedImage];
}
break;
default:
break;
}
} else {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
}
[weakSelf netRequest];
} failure:nil];
}
- (void)weChatBindingRequest
{
if (![TFWeChatPermissionsManager isInstallWechat]) {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"您的手机没有安装微信")];
return ;
}
[[TFWeChatPermissionsManager sharedManager] weChatPermissionsType:TFWeChatPermissionsTypeBinding];
}
- (void)wechatResponseSuccess:(TFUserInfoManager *)userData
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"微信绑定成功")];
[self netRequest];
}
- (void)wechatResponseFail:(NSString *)error
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"绑定失败")];
}
- (void)qqBindingRequest
{
if (![TFTencentPermissionsManager isInstallTencent]) {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"您的手机没有安装QQ或TIM")];
return ;
}
[[TFTencentPermissionsManager sharedManager] tencentPermissionsType:TFTencentPermissionsTypeBinding];
}
- (void)tencentPermissionsSuccess:(TFUserInfoManager *)userData
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"QQ绑定成功")];
[self netRequest];
}
- (void)tencentPermissionsFail:(NSString *)error
{
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"绑定失败")];
}
- (void)netRequest
{
WS(weakSelf)
[TFNetworkTools POST:User_Data parameters:nil model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
TFUserDataModel *model = [TFUserDataModel modelWithDictionary:t_model[@"data"]];
weakSelf.userDataModel = model;
}
[weakSelf.mainTableViewGroup reloadData];
} failure:nil];
}
- (void)dealloc {
[TFURLProtocol stopMonitor];
}
@end
@@ -0,0 +1,21 @@
//
// WXYZ_CancelAccountTableViewCell.h
// WXReader
//
// Created by Andrew on 2019/12/23.
// Copyright © 2019 Andrew. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WXYZ_CancelAccountTableViewCell : TFBasicTableViewCell
@property (nonatomic, copy) NSString *titleString;
@property (nonatomic, copy) NSString *detailString;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,74 @@
//
// WXYZ_CancelAccountTableViewCell.m
// WXReader
//
// Created by Andrew on 2019/12/23.
// Copyright © 2019 Andrew. All rights reserved.
//
#import "WXYZ_CancelAccountTableViewCell.h"
@implementation WXYZ_CancelAccountTableViewCell
{
UIImageView *pointView;
UILabel *cellTitleLabel;
UILabel *cellDetailLabel;
}
- (void)createSubviews
{
[super createSubviews];
cellTitleLabel = [[UILabel alloc] init];
cellTitleLabel.textColor = kBlackColor;
cellTitleLabel.textAlignment = NSTextAlignmentLeft;
cellTitleLabel.font = kBoldMainFont;
cellTitleLabel.numberOfLines = 1;
[self.contentView addSubview:cellTitleLabel];
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(30);
}];
cellDetailLabel = [[UILabel alloc] init];
cellDetailLabel.textColor = kGrayTextColor;
cellDetailLabel.textAlignment = NSTextAlignmentLeft;
cellDetailLabel.font = kMainFont;
cellDetailLabel.numberOfLines = 0;
[self.contentView addSubview:cellDetailLabel];
[cellDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(cellTitleLabel.mas_left);
make.top.mas_equalTo(cellTitleLabel.mas_bottom);
make.right.mas_equalTo(cellTitleLabel.mas_right);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
pointView = [[UIImageView alloc] init];
pointView.image = [UIImage imageNamed:@"cancel_point"];
[self.contentView addSubview:pointView];
[pointView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(cellTitleLabel.mas_left);
make.centerY.mas_equalTo(cellTitleLabel.mas_centerY);
make.width.height.mas_equalTo(20);
}];
}
- (void)setTitleString:(NSString *)titleString
{
_titleString = titleString;
cellTitleLabel.text = titleString;
}
- (void)setDetailString:(NSString *)detailString
{
_detailString = detailString;
cellDetailLabel.text = detailString;
}
@end
@@ -0,0 +1,21 @@
//
// WXYZ_UserDataTableViewCell.h
// WXReader
//
// Created by Andrew on 2020/5/30.
// Copyright © 2020 Andrew. All rights reserved.
//
#import "TFBasicTableViewCell.h"
@class TFUserDataListModel;
NS_ASSUME_NONNULL_BEGIN
@interface WXYZ_UserDataTableViewCell : TFBasicTableViewCell
@property (nonatomic, strong) TFUserDataListModel *cellModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,118 @@
//
// WXYZ_UserDataTableViewCell.m
// WXReader
//
// Created by Andrew on 2020/5/30.
// Copyright © 2020 Andrew. All rights reserved.
//
#import "WXYZ_UserDataTableViewCell.h"
#import "TFUserDataModel.h"
@implementation WXYZ_UserDataTableViewCell
{
UILabel *cellTitleLabel;
UILabel *cellDetailTitleLabel;
UIImageView *connerImageView;
UIImageView *avatarImageView;
}
- (void)createSubviews
{
[super createSubviews];
cellTitleLabel = [[UILabel alloc] init];
cellTitleLabel.textColor = kBlackColor;
cellTitleLabel.font = kMainFont;
cellTitleLabel.textAlignment = NSTextAlignmentLeft;
[self.contentView addSubview:cellTitleLabel];
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.mas_equalTo(SCREEN_WIDTH / 2);
make.height.mas_equalTo(self.contentView.mas_height);
}];
connerImageView = [[UIImageView alloc] init];
connerImageView.image = [UIImage imageNamed:@"public_more"];
[self.contentView addSubview:connerImageView];
[connerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.centerY.mas_equalTo(self.contentView.mas_centerY);
make.width.mas_equalTo(10);
make.height.mas_equalTo(10);
}];
avatarImageView = [[UIImageView alloc] init];
avatarImageView.layer.cornerRadius = 25;
avatarImageView.clipsToBounds = YES;
[self.contentView addSubview:avatarImageView];
[avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.width.mas_equalTo(50);
make.height.mas_equalTo(CGFLOAT_MIN);
}];
cellDetailTitleLabel = [[UILabel alloc] init];
cellDetailTitleLabel.font = kFont12;
cellDetailTitleLabel.textAlignment = NSTextAlignmentRight;
cellDetailTitleLabel.textColor = kGrayTextColor;
[self.contentView addSubview:cellDetailTitleLabel];
[cellDetailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(cellTitleLabel.mas_right);
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
make.top.mas_equalTo(avatarImageView.mas_bottom);
make.height.mas_equalTo(CGFLOAT_MIN);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin);
}];
}
- (void)setCellModel:(TFUserDataListModel *)cellModel
{
_cellModel = cellModel;
if ([cellModel.action isEqualToString:@"avatar"]) {
[avatarImageView setImageWithURL:[NSURL URLWithString:cellModel.desc?:@""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
[avatarImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(50);
}];
cellDetailTitleLabel.text = @"";
[cellDetailTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(CGFLOAT_MIN);
}];
} else {
avatarImageView.image = nil;
[avatarImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(CGFLOAT_MIN);
}];
cellDetailTitleLabel.text = cellModel.desc?:@"";
[cellDetailTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30);
}];
}
cellTitleLabel.text = cellModel.title?:@"";
cellTitleLabel.textColor = [UIColor colorWithHexString:cellModel.title_color?:@""];
cellDetailTitleLabel.textColor = [UIColor colorWithHexString:cellModel.desc_color?:@""];
connerImageView.hidden = !cellModel.is_click;
if (cellModel.is_click) {
} else {
}
[cellDetailTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
if (cellModel.is_click) {
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
} else {
make.right.equalTo(connerImageView.mas_left).offset(10);
}
}];
}
@end