个人信息修改

This commit is contained in:
lianxiang
2018-09-18 20:13:59 +08:00
parent 2c81fa6c7d
commit 27e27d5d12
42 changed files with 981 additions and 54 deletions
@@ -0,0 +1,13 @@
//
// AppVerionDescriptionVC.h
// GIGA
//
// Created by lianxiang on 2018/9/18.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "GiGaBaseViewController.h"
@interface AppVerionDescriptionVC : GiGaBaseViewController
@end
@@ -0,0 +1,133 @@
//
// AppVerionDescriptionVC.m
// GIGA
//
// Created by lianxiang on 2018/9/18.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "AppVerionDescriptionVC.h"
#import "AppVersionDescCell.h"
#import "GiGaBaseAPiRequest.h"
#import "VersionModel.h"
#import "AppVersionLogoCell.h"
@interface AppVerionDescriptionVC ()
@property (nonatomic,strong) NSMutableArray *versionsArr;
@property (nonatomic) int currntPage ;
@property (nonatomic) int totalPage ;
@end
@implementation AppVerionDescriptionVC
- (void)viewDidLoad {
[super viewDidLoad];
_currntPage = 1;
_totalPage = 1;
self.versionsArr = [[NSMutableArray alloc] init];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.frame = CGRectMake(0, 1, KMainW, self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self requstListDatas];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1 + self.versionsArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
AppVersionLogoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AppVersionLogoCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"AppVersionLogoCell" owner:self options:nil] lastObject];
}
return cell;
}
AppVersionDescCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AppVersionDescCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"AppVersionDescCell" owner:self options:nil] lastObject];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
return 173.f;
}else{
return 92 + 25 * self.versionsArr.count;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 0){
return 0.1;
}else if (section == 1){
return 12;
}
return 4;
}
-(void)requstListDatas{
GiGaBaseAPiRequest *reuqest = [GiGaBaseAPiRequest initWithRequestPath:kAPiAPPVersion method:RequestPostMethod parms:@{}];
[reuqest requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
GILog(@"%@",result.dic);
self->_currntPage = [result.dic[@"currPage"] intValue];
self->_totalPage = [result.dic[@"totalPage"] intValue];
NSDictionary *pagedic = result.dic[@"page"];
NSArray *listArr = pagedic[@"list"];
for (NSDictionary *dic in listArr) {
VersionModel *model = [[VersionModel alloc] initWithDictionary:dic error:nil];
[self.versionsArr addObject:model];
}
[self.tableView reloadData];
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#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
@@ -15,6 +15,7 @@
#import "UINavigationBar+Custom.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaUserManager.h"
#import "UIImageView+WebCache.h"
@interface GiGaMeViewController ()
@property (nonatomic,strong) GiGaUser *user;
@@ -39,6 +40,21 @@
self.tableView.bounces = NO;
self.tableView.frame = CGRectMake(0, 1, KMainW, self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self loadUserInfo];
NC_ADD_TARGET_NAME_OBJECT(self, @selector(userAvatorUpDate), kUserAvatorUpdateNoti, nil) ;
}
-(void)dealloc{
NC_REMOVE_NAME(self, kUserAvatorUpdateNoti, nil);
}
-(void)userAvatorUpDate{
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]] ) {
GiGaMineUserViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
NSURL *url = [NSURL URLWithString:user.headImgUrl];
[cell.userAvator sd_setImageWithURL:url];
}
}
@@ -18,8 +18,14 @@
#import "JYAddressPicker.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaUserJobViewCell.h"
#import <AVFoundation/AVFoundation.h>
#import "GIGaFileManager.h"
#import "GiGaUserDefault.h"
#import "GiGaNetManager.h"
#import "GiGaServerConfig.h"
#import "GiGaAPIResult.h"
@interface GiGaUserViewController ()<LYSDatePickerSelectDelegate>
@interface GiGaUserViewController ()<LYSDatePickerSelectDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property (nonatomic,strong) GiGaUser *user;
@property (nonatomic,strong) NSMutableArray *jobArr;
@property (nonatomic) BOOL jobSpread;
@@ -69,7 +75,6 @@
self.tableView.bounces = YES;
self.tableView.frame = CGRectMake(0, 1, KMainW,self.view.bounds.size.height - SAFE_NAV_HEIGHT);
[self.tableView registerClass: [GiGaUserJobViewCell class] forCellReuseIdentifier:@"GiGaUserJobViewCell"];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
@@ -95,21 +100,25 @@
GIGaUserInfoAvatorCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserInfoAvatorCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserInfoAvatorCell" owner:self options:nil] lastObject];
UITapGestureRecognizer *tapGestrue = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(userAvatorClick)];
[cell.userAvator addGestureRecognizer:tapGestrue];
}
[cell loadCellData:indexPath user:self.user];
return cell;
}else if (indexPath.section == 1 && indexPath.row < 2){
}else if (indexPath.section == 1 && indexPath.row ==0){
GIGaUserIDViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserIDViewCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserIDViewCell" owner:self options:nil] lastObject];
}
[cell loadCellData:indexPath user: self.user];
[cell loadCellData:indexPath user: self.user];
return cell;
}else if (indexPath.section == 1 && indexPath.row == 2){
}else if (indexPath.section == 1 && indexPath.row <= 2){
GIGaUserWeChatViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserWeChatViewCell"];
if(!cell){
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserWeChatViewCell" owner:self options:nil] lastObject];
@@ -139,6 +148,7 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserCityViewCell" owner:self options:nil] lastObject];
}
[cell loadCellData:indexPath user:self.user];
return cell;
}else if (indexPath.section == 3){
static NSString *cellID = @"GiGaUserJobViewCell";
@@ -148,13 +158,10 @@
}
[cell userSelectjobAction:^() {
self.jobSpread = !self.jobSpread;
[tableView reloadSections:[NSIndexSet indexSetWithIndex:3] withRowAnimation:UITableViewRowAnimationNone];
}];
[cell setButtnImage:self.jobSpread with:self.jobArr];
[cell userSelectjob:^(NSString *title) {
self.user.occupationCode = title;
[tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:3 inSection:2]] withRowAnimation:UITableViewRowAnimationNone];
@@ -162,7 +169,6 @@
return cell;
}
return nil;
}
@@ -182,19 +188,49 @@
}];
}else if (indexPath.section == 2 && indexPath.row == 2){
JYAddressPicker *addressPicker = [JYAddressPicker jy_showAt:self];
NSMutableArray *defalutvaluses = [NSMutableArray new];
if (self.user.provinceId && ![self.user.provinceId isKindOfClass:[NSNull class]]) {
[defalutvaluses addObject:self.user.provinceId];
}else{
[defalutvaluses addObject:@""];
}
if (self.user.cityId && ![self.user.cityId isKindOfClass:[NSNull class]]) {
[defalutvaluses addObject:self.user.cityId];
}else{
[defalutvaluses addObject:@""];
}
if (self.user.areaId && ![self.user.areaId isKindOfClass:[NSNull class]]) {
[defalutvaluses addObject:self.user.areaId];
}else{
[defalutvaluses addObject:@""];
}
JYAddressPicker *addressPicker = [JYAddressPicker jy_showAt:self defaultShow:defalutvaluses];
//JYAddressPicker *addressPicker = [JYAddressPicker jy_showAt:self];
weakify(self);
addressPicker.selectedItemBlock = ^(NSArray *addressArr) {
NSString *province = [addressArr objectAtIndex:0][@"name"];
NSString *provinceID = [addressArr objectAtIndex:0][@"id"];
NSString *city = [addressArr objectAtIndex:1][@"name"];
NSString *cityID = [addressArr objectAtIndex:1][@"id"];
NSString *county = [addressArr objectAtIndex:2][@"name"];
NSString *countyID = [addressArr objectAtIndex:2][@"id"];
NSString *addres = [NSString stringWithFormat:@"%@%@%@",province,city,county];
GILog(@"%@",addres);
GIGaUserCityViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
weakSelf.user.provinceName = province;
weakSelf.user.provinceId = provinceID;
weakSelf.user.cityName = city;
weakSelf.user.cityId = cityID;
weakSelf.user.areaName = county;
weakSelf.user.areaId = countyID;
[cell loadCellData:indexPath user:self.user];
};
@@ -249,10 +285,24 @@
#pragma mark - 保存用户信息
-(void)saveUserInfo{
GIGaUserWeChatViewCell *nickcell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:1]];
self.user.nickName = nickcell.weiXinCount.text;
GIGaUserWeChatViewCell *chatcell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:1]];
self.user.weixin = chatcell.weiXinCount.text;
if (!self.user.nickName || [self.user.nickName isKindOfClass:[NSNull class]]) {
self.user.nickName = @"";
}
int leng = [GiGaHelper convertToInt: self.user.nickName];
if ( leng >40 ) {
GIGA_ShowToast(@"用户名1-40字符长度")
return;
}
if (!self.user.weixin || [self.user.weixin isKindOfClass:[NSNull class]]) {
self.user.weixin = @"";
}
@@ -264,10 +314,21 @@
self.user.occupationCode = @"";
}
if (!self.user.provinceId|| [self.user.provinceId isKindOfClass:[NSNull class]]) {
self.user.provinceId = @"";
}
if (!self.user.cityId|| [self.user.cityId isKindOfClass:[NSNull class]]) {
self.user.cityId = @"";
}
if (!self.user.areaId|| [self.user.areaId isKindOfClass:[NSNull class]]) {
self.user.areaId = @"";
}
[self.view makeToastActivity:CSToastPositionCenter];
NSDictionary *param = @{
@"provinceId":@"1_11",
@"cityId":@"1_11",
@"areaId":@"1_11_8",
@"provinceId":self.user.provinceId,
@"cityId":self.user.cityId,
@"areaId":self.user.areaId,
@"nickName":self.user.nickName,
@"weixin":self.user.weixin,
@"sexCode":[NSString stringWithFormat:@"%d",self.user.sexCode],
@@ -278,13 +339,19 @@
GiGaBaseAPiRequest *api =[GiGaBaseAPiRequest initWithRequestPath:kFixUserInfo method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
[self.view hideToastActivity];
if (result.success) {
GIGA_ShowToast(@"修改成功");
[[GiGaUserManager shareUser] saveUser:self.user];
}else{
GIGA_ShowToast(result.dic[@"msg"]);
if (result.code == 401) {
//token失效
[GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self];
}
}
}];
}
#pragma mark - 获取职业数据
@@ -293,21 +360,158 @@
GiGaBaseAPiRequest *api =[GiGaBaseAPiRequest initWithRequestPath:kApiOccuption method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
if (result.success) {
GILog(@"%@",result.dic);
// GILog(@"%@",result.dic);
NSDictionary *dic = result.dic;
NSArray *josA = dic[@"list"];
for (NSDictionary *jobDic in josA ) {
[self.jobArr addObject:jobDic[@"dictLabel"]];
}
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:3] withRowAnimation:UITableViewRowAnimationNone];
}else{
NSString *msg = result.dic[@"msg"];
GIGA_ShowToast(msg);
}
}];
}
#pragma mark - 用户头像点击
-(void)userAvatorClick{
[self showCameraAndPhotoAlert];
}
-(void)showCameraAndPhotoAlert{
UIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:@"选择头像" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; imagePickerController.delegate = self; imagePickerController.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIAlertAction *cameraAction = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//权限判断应用是否有使用相机的权限
NSString *mediaType = AVMediaTypeVideo;//读取媒体类型
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];//读取设备授权状态
if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
NSString *errorStr = @"应用相机权限受限,请在设置中启用";
[self jxt_showAlertWithTitle:@"" message:errorStr appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"去开启");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
NSString *urlStr = @"App-Prefs:root=Photos";
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr] options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
// Fallback on earlier versions
}
}
}];
return;
}
// 设置数据源
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:imagePickerController animated:YES completion:nil]; }];
[alertSheet addAction:cameraAction];
}
//相册
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
//权限
UIAlertAction *photoAction = [UIAlertAction actionWithTitle:@"从手机相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerController animated:YES completion:nil];
}];
[alertSheet addAction:photoAction];
}else{
NSString *errorStr = @"应用相权册限受限,请在设置中启用";
[self jxt_showAlertWithTitle:@"" message:errorStr appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"去开启");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
NSURL *url = [NSURL URLWithString:@"prefs:root=Photos"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}
}];
}
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertSheet addAction:cancelAction];
[self presentViewController:alertSheet animated:YES completion:nil];
}
-(void)camreaAction{
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
GILog(@"info:%@",info);
[picker dismissViewControllerAnimated:YES completion:nil]
;
UIImage*img=[info objectForKey:UIImagePickerControllerEditedImage];
UIImage *samall = [GIGaFileManager thumbnailWithImageWithoutScale:img size:CGSizeMake(300, 300)];
NSString *userid = [GiGaUserDefault getCurentUserId];
[GIGaFileManager savaUserAvatorWith:userid image:samall];
GIGaUserInfoAvatorCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.userAvator.image = samall;
[self uploadImage:samall];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark upload image
-(void)uploadImage:(UIImage *)image{
[self.view makeToastActivity:CSToastPositionCenter];
NSString *url = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],kUploadAvator];
//NSString *userID = [GiGaUserDefault getCurentUserId];
//UIImage *avator =[GIGaFileManager getUserAvatorWith:userID];
NSData*imageData=UIImageJPEGRepresentation(image,1.0f);
[GiGaNetManager uploadImage:url imgData:imageData parms:@{@"file":@"file"} responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
[self.view hideToastActivity];
GiGaAPIResult *reullt = [[GiGaAPIResult alloc] initWithDictionary:responseDict];
if (error) {
GILog(@"eror:%@",error.localizedDescription);
return ;
}
if (reullt.success) {
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
NSString *newurl = responseDict[@"url"];
self.user.headImgUrl = newurl;
if (newurl) {
user.headImgUrl = newurl;
}
[[GiGaUserManager shareUser] saveUser:user];
NC_POST_NAME_OBJECT(kUserAvatorUpdateNoti, nil);
GIGA_ShowToast(@"👮‍♀️修改成功")
}else{
GIGA_ShowToast(reullt.message);
}
}];
}
@end
+24 -3
View File
@@ -11,6 +11,7 @@
#import "JXTAlertController.h"
#import "GiGaUserDefault.h"
#import "GiGaUserManager.h"
#import "AppVerionDescriptionVC.h"
@interface GiSysSettingsVC ()
@@ -56,12 +57,32 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 0) {
[self jxt_showAlertWithTitle:@"提示" message:@"确定清楚缓存?" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"取消");
alertMaker.addActionDefaultTitle(@"确定");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 1) {
GiGaSettingsViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.cachLabe.text = @"0M";
}
}];
}else if (indexPath.row == 1){
}else if (indexPath.row == 2){
}else if (indexPath.row == 3){
AppVerionDescriptionVC *verVC =[[AppVerionDescriptionVC alloc] init];
[self.navigationController pushViewController:verVC animated:YES];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 54;
return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
@@ -120,7 +141,7 @@
}
}];
}
//http://yts.s1.natapp.cc/mask/clearZear.html
-(void)userlogOut{
[[GiGaUserManager shareUser] loginOut];