123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745 |
- //
- // YOUPAILCEditUserMsgVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/8/26.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCEditUserMsgVC.h"
- #import "YOUPAIZYSettingCell.h"
- #import "YOUPAILCImageCollectionCell.h"
- #import "YOUPAILCImageDeleteView.h"
- #import "YOUPAILCUpdateNickVC.h"
- #import "YOUPAILCUpdateCityVC.h"
- #import "PGDatePickManager.h"
- #import "LCTZImageConfigHelper.h"
- #import "YOUPAILZUpdateSignVC.h"
- #import "UIViewController+TFPresent.h"
- #import "YOUPAIZYEditUserShowAlertWindow.h"
- @interface YOUPAILCEditUserMsgVC ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,PGDatePickerDelegate,TZImagePickerControllerDelegate,YBImageBrowserDelegate,ZYEditUserShowAlertWindowDelegate>
- @property(nonatomic,strong)YOUPAILCUserModel* youpaipuserModel;
- @property(nonatomic,strong)UITableView* youpaiptableView;
- @property(nonatomic,strong)UIView *youpaipheaderView;
- @property(nonatomic,strong)NSMutableArray* youpaipimages;
- @property(nonatomic,copy)NSMutableArray* youpaipoldAlbum_list;
- @property(nonatomic,strong)UICollectionView *youpaipcollectionView;
- @property(nonatomic,assign)CGPoint youpaiplastPressPoint;
- @property(nonatomic,strong)NSMutableArray *youpaipcellAttributesArray;
- @property(nonatomic,strong)YOUPAILCImageDeleteView* youpaipdeleteView;
- @property (nonatomic, strong) UIButton *youpaipordinaryUserHeadImageBtn;/// 普通用户头像
- @property(nonatomic,assign)CGFloat youpaipKWidth;
- @property(nonatomic,strong)UIView *youpaipbaseView;
- @property (nonatomic, assign)NSInteger youpaipimageIndex; /// 图片下标
- @property (nonatomic, strong)YBImageBrowser *youpaipbrowser; ///图片预览
- @end
- @implementation YOUPAILCEditUserMsgVC
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- if (![self.youpaipoldAlbum_list isEqual:self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list]) {
- [self youpaifupdateUserPhotos];
- }
- }
- - (YOUPAILCImageDeleteView*)youpaipdeleteView{
- if (!_youpaipdeleteView) {
- _youpaipdeleteView = [[YOUPAILCImageDeleteView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, 50)];
- [self.view addSubview:_youpaipdeleteView];
- _youpaipdeleteView.hidden = YES;
- }
- return _youpaipdeleteView;
- }
- - (NSMutableArray *)youpaipcellAttributesArray{
- if (!_youpaipcellAttributesArray) {
- _youpaipcellAttributesArray = [NSMutableArray arrayWithCapacity:0];
- }
- return _youpaipcellAttributesArray;
- }
- - (UITableView *)youpaiptableView{
- if (!_youpaiptableView) {
- _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight) style:UITableViewStylePlain];
- _youpaiptableView.showsVerticalScrollIndicator = NO;
- _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- // _tableView.backgroundColor = DecColorFromRGB(246,246,246);
- _youpaiptableView.backgroundColor = [UIColor clearColor];
- _youpaiptableView.delegate = self;
- _youpaiptableView.dataSource = self;
- if (@available(iOS 15.0, *)) {
- _youpaiptableView.sectionHeaderTopPadding = 0;
- }
- }
- return _youpaiptableView;
- }
- -(void)youpaifaddImage
- {
- // if (self.userModel.userinfo.album_list.count == 6) {
- // [ZCHUDHelper showTitle:@"照片已达最大数量,不能再添加照片"];
- // }else{
- // [self youpaifopenAlbum];
- // }
- UIAlertController *alertV = [UIAlertController alertControllerWithTitle:@"" message:@"提交成功 审核通过后方可展示" preferredStyle:UIAlertControllerStyleAlert];
- [alertV addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
- [self presentViewController:alertV animated:YES completion:nil];
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"编辑资料";
- self.view.backgroundColor = LCBkgColor;
-
- self.youpaipKWidth = KScreenWidth - 28.0f;
- self.youpaipuserModel = [LCSaveModel getUserModel];
-
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifaddImage) title:@"提交审核" font:LCFont15 titleColor:ZYPinkColor highlightedColor:ZYPinkColor titleEdgeInsets:UIEdgeInsetsZero];
-
- self.youpaipimages = [NSMutableArray array];
- self.youpaipoldAlbum_list = [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list copy];
- [self.view addSubview:self.youpaiptableView];
- [self youpaifsetupHeaderView];
- [self youpaifredHidden];
- //长按可拖动排序 下面会出现垃圾篓删除
- //iOS下拉图片缩小为没有
- }
- -(void)youpaifredHidden{
-
- [LCHttpHelper requestWithURLString:UserCenter parameters:@{@"type":@"1"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
-
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- - (void)youpaifsetupHeaderView{
- // if(self.userModel.userinfo.is_anchor == 1){
- [self youpaifsetupAnchorHeaderView];
- // }else{
- // [self youpaifsetupOrdinaryHeaderView];
- // }
- }
- /// 普通用户headerView
- - (void)youpaifsetupOrdinaryHeaderView{
- self.youpaipheaderView = [[UIView alloc]initWithFrame:CGRectMake(0,0, KScreenWidth, 197.0f)];
- self.youpaipheaderView.backgroundColor = [UIColor clearColor];
- self.youpaiptableView.tableHeaderView = self.youpaipheaderView;
- self.youpaipordinaryUserHeadImageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- self.youpaipordinaryUserHeadImageBtn.layer.cornerRadius = 54.5f;
- self.youpaipordinaryUserHeadImageBtn.clipsToBounds = YES;
- self.youpaipordinaryUserHeadImageBtn.backgroundColor = LCBkgColor;
- self.youpaipordinaryUserHeadImageBtn.contentMode = UIViewContentModeScaleAspectFill;
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count > 0) {
- [self.youpaipordinaryUserHeadImageBtn setImage:nil forState:UIControlStateNormal];
- NSURL *url = [[LCTools getImageUrlWithAddress:self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[0]] urlWithImageScale:60];
- [self.youpaipordinaryUserHeadImageBtn sd_setImageWithURL:url forState:UIControlStateNormal];
- }else{
- [self.youpaipordinaryUserHeadImageBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_norheader"] forState:UIControlStateNormal];
- [self.youpaipordinaryUserHeadImageBtn setBackgroundImage:nil forState:UIControlStateNormal];
- }
- self.youpaipordinaryUserHeadImageBtn.tag = 0;
- [self.youpaipordinaryUserHeadImageBtn addTarget:self action:@selector(youpaifeditUserHeaderImage:) forControlEvents:UIControlEventTouchUpInside];
- [self.youpaipheaderView addSubview:self.youpaipordinaryUserHeadImageBtn];
- [self.youpaipordinaryUserHeadImageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.youpaipheaderView);
- make.width.height.offset(109.0f);
- }];
- }
- /// 女神headerView
- - (void)youpaifsetupAnchorHeaderView{
- self.youpaipheaderView = [[UIView alloc]initWithFrame:CGRectMake(0,0, KScreenWidth, 56.0f + (KScreenWidth - 48.0f) / 3.0f * 2.0f+30)];
- self.youpaipheaderView.backgroundColor = [UIColor clearColor];
- self.youpaiptableView.tableHeaderView = self.youpaipheaderView;
-
- // UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(16,30,KScreenWidth-32,self.headerView.frame.size.height - 48.0f)];
- // baseView.backgroundColor = [UIColor whiteColor];
- // baseView.layer.cornerRadius = 8;
- // baseView.layer.masksToBounds = YES;
- // [self.headerView addSubview:baseView];
-
-
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- CGFloat margin = 8.0;
- CGFloat itemWH = (KScreenWidth - 48.0f) / 3.0f;
- layout.scrollDirection = UICollectionViewScrollDirectionVertical;
- layout.itemSize = CGSizeMake(itemWH, itemWH);
- layout.minimumInteritemSpacing = margin;
- layout.minimumLineSpacing = margin;
- _youpaipcollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(14,24.0f,KScreenWidth-28.0f, self.youpaipheaderView.mj_h - 48.0f-30) collectionViewLayout:layout];
- _youpaipcollectionView.backgroundColor = [UIColor clearColor];
- _youpaipcollectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
- _youpaipcollectionView.layer.masksToBounds = NO;
- _youpaipcollectionView.dataSource = self;
- _youpaipcollectionView.delegate = self;
- _youpaipcollectionView.scrollEnabled = NO;
- [_youpaipcollectionView registerClass:[YOUPAILCImageCollectionCell class] forCellWithReuseIdentifier:@"YOUPAILCImageCollectionCell"];
-
- UILabel* txtTip = [[UILabel alloc]initWithFrame:CGRectMake(14,CGRectGetMaxY(_youpaipcollectionView.frame), KScreenWidth-28, 47)];
- txtTip.numberOfLines = 0;
- txtTip.font = [UIFont systemFontOfSize:11];
- txtTip.textColor = HexColorFromRGB(0x6C6B70) ;
- txtTip.text = @"1.拖拽相片可以更改排序,单击查看大图可删除相册\n2.照片涉黄或者审核不通过将被删除,严重者冻结账号";
- [UILabel changeLineSpaceForLabel:txtTip WithSpace:4.0];
- [self.youpaipheaderView addSubview:txtTip];
-
- [self.youpaipheaderView addSubview:_youpaipcollectionView];
- }
- #pragma mark - CollectionView
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return 6;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- YOUPAILCImageCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILCImageCollectionCell" forIndexPath:indexPath];
- CGFloat width = (KScreenWidth-64-8)/3;
- cell.youpaipimageView.image = [UIImage imageWithColor:HexColorFromRGB(0x31303A) size:CGSizeMake(width, (KScreenWidth-64-8)/3.0/3.0*4)];
- cell.youpaipitem = indexPath.item;
- cell.youpaipimagev.hidden = YES;
- cell.youpaiphasImage = NO;
- cell.youpaipdefaultImgV.hidden = NO;
-
- if (indexPath.item < self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count) {
- // 1通过,0待审核,2,未通过
- album_list_newModel *newModel = self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new[indexPath.item];
- cell.youpaipreviewStatus = newModel.youpaipstatus;
- cell.youpaipdefaultImgV.hidden = YES;
- [cell.youpaipimageView sd_setImageWithURL:[[LCTools getImageUrlWithAddress:self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[indexPath.item]] urlWithImageScale:60]];
- cell.youpaiphasImage = YES;
- if (indexPath.item == 0) {
- cell.youpaipimagev.hidden = NO;
-
- }
- }
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(youpaiflongPressHandel:)];
- [cell addGestureRecognizer:longPress];
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- YOUPAILCImageCollectionCell *cell = (YOUPAILCImageCollectionCell*)[self.youpaipcollectionView cellForItemAtIndexPath:indexPath];
- if (cell.youpaiphasImage) {
-
- if (cell.youpaipreviewStatus == review_zero|| cell.youpaipreviewStatus == review_two) {
- [ZCHUDHelper showTitle:@"图片正在审核中,不能重复操作"];
- }else{
-
- if (indexPath.item == 0) {
- YOUPAIZYEditUserShowAlertWindow *vc= [[YOUPAIZYEditUserShowAlertWindow alloc]init];
- vc.youpaipbtntitleArr = @[@"查看",@"更换",@"取消"];
- vc.youpaipdelegate = self;
- vc.isTouchDismiss = YES;
- [self TFPresentVC:vc completion:^{}];
- }else{
- YOUPAIZYEditUserShowAlertWindow *vc= [[YOUPAIZYEditUserShowAlertWindow alloc]init];
- vc.youpaipbtntitleArr = @[@"查看",@"设为头像",@"更换",@"删除",@"取消"];
- vc.youpaipdelegate = self;
- vc.isTouchDismiss = YES;
- [self TFPresentVC:vc completion:^{}];
- }
-
- }
-
- NSMutableArray *tempArr = [NSMutableArray array];
- for (int i=0; i<self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count; i++) {
- YBIBImageData *model = [YBIBImageData new];
- model.imageURL = [LCTools getImageUrlWithAddress:self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[i]];
- YOUPAILCImageCollectionCell *tmpCell = (YOUPAILCImageCollectionCell*)[self.youpaipcollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
- model.projectiveView = tmpCell.youpaipimageView ;
- [tempArr addObject:model];
- }
-
- // YBImageBrowserFunctionModel *fModel = [[YBImageBrowserFunctionModel alloc] init];
- // fModel.name = @"";
- // fModel.ID = @"removeImage";
-
- self.youpaipbrowser = [YBImageBrowser new];
- self.youpaipbrowser.dataSourceArray = tempArr;
- self.youpaipbrowser.currentPage = indexPath.item;
- // self.browser.fuctionDataArray = @[fModel];//nil;
- self.youpaipbrowser.delegate = self;
- // self.browser.toolBar.backgroundColor = LCBkgColor;
- // self.browser.toolBar.rightButton.titleLabel.font = LCFont(15.0f);
- // self.browser.toolBar.titleLabel.font = LCFont(17.0f);
- // self.browser.toolBar.titleLabel.textColor = [UIColor whiteColor];
- // [self.browser.toolBar.rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- // self.browser.toolBar.hideLeftBtn = NO;
-
- }else{
- [self youpaifopenAlbum:8];
- }
-
- }
- #pragma mark-底部alert弹框事件
- - (void)youpaifimSessionMoreWindowAction:(YOUPAIZYEditUserShowAlertWindow *)alert
- type:(NSString *)type
- tag:(NSInteger)tag
- andUserId:(NSString *)user_id{
-
- if ([type isEqualToString:@"look"]){//查看
- [self.youpaipbrowser show];
-
- }else if ([type isEqualToString:@"setprofile"]){//设为头像
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count>1) {
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count>self.youpaipimageIndex) {
-
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list exchangeObjectAtIndex:0 withObjectAtIndex:self.youpaipbrowser.currentPage];
- self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list = self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list;
- }
- [self.youpaipcollectionView reloadData];
- if (self.youpaipisChange) {
- if (self.youpaipupdateIconBlock) {
- self.youpaipupdateIconBlock(self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[0]);
- }
- }
-
-
- }
-
- }else if ([type isEqualToString:@"change"]){//更换
- [self youpaifopenAlbum:self.youpaipbrowser.currentPage];
-
- }
- else if ([type isEqualToString:@"delete"]){//删除
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count>1) {
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count>self.youpaipimageIndex) {
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list removeObjectAtIndex:self.youpaipbrowser.currentPage];
- }
- [self.youpaipcollectionView reloadData];
- NSMutableArray *tempArr = [NSMutableArray array];
- for (int i=0; i<self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count; i++) {
- YBIBImageData *model = [YBIBImageData new];
- model.imageURL = [LCTools getImageUrlWithAddress:self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[i]];
- YOUPAILCImageCollectionCell *tmpCell = (YOUPAILCImageCollectionCell*)[self.youpaipcollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
- model.projectiveView = tmpCell.youpaipimageView ;
- [tempArr addObject:model];
- }
- self.youpaipbrowser.dataSourceArray = tempArr;
- [self.youpaipbrowser reloadData];
- self.youpaipbrowser.currentPage = 0;
-
- }
- else{
- [ZCHUDHelper showTitle:@"再删除就没头像啦"];
- }
-
- }else if ([type isEqualToString:@"cancel"]){//取消
-
-
- }
-
-
-
-
- // }else{ /// 普通用户删除图片
- // if ([type isEqual:@"edit"]) {
- // if (self.userModel.userinfo.album_list.count>self.imageIndex) {
- // [self.userModel.userinfo.album_list removeObjectAtIndex:self.imageIndex];
- // }
- // [self.browser hide];
- // if (self.userModel.userinfo.album_list.count > 0) {
- // [self.ordinaryUserHeadImageBtn setImage:nil forState:UIControlStateNormal];
- // NSURL *url = [LCTools getImageUrlWithAddress:self.userModel.userinfo.album_list[0]];
- // [self.ordinaryUserHeadImageBtn sd_setBackgroundImageWithURL:url forState:UIControlStateNormal];
- // }else{
- // [self.ordinaryUserHeadImageBtn setImage:[UIImage imageNamed:@"vqu_images_ic_profile_norheader"] forState:UIControlStateNormal];
- // [self.ordinaryUserHeadImageBtn setBackgroundImage:nil forState:UIControlStateNormal];
- // }
- // }
- // }
-
- }
- - (void)youpaifeditUserHeaderImage:(UIButton *)sender{
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count > 0) {
- NSMutableArray *tempArr = [NSMutableArray array];
- for (int i=0; i < 1; i++) {
- YBIBImageData *model = [YBIBImageData new];
- model.imageURL = [LCTools getImageUrlWithAddress:self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[i]];
- YOUPAILCImageCollectionCell *tmpCell = (YOUPAILCImageCollectionCell*)[self.youpaipcollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
- model.projectiveView = tmpCell.youpaipimageView ;
- [tempArr addObject:model];
- }
- // YBImageBrowserFunctionModel *fModel = [[YBImageBrowserFunctionModel alloc] init];
- // fModel.name = @"删除";
- // fModel.ID = @"removeImage";
-
- self.youpaipbrowser = [YBImageBrowser new];
- self.youpaipbrowser.dataSourceArray = tempArr;
- self.youpaipbrowser.currentPage = 0;
- // self.browser.fuctionDataArray = @[fModel];//nil;
- self.youpaipbrowser.delegate = self;
- // self.browser.toolBar.backgroundColor = [UIColor whiteColor];
- // self.browser.toolBar.rightButton.titleLabel.font = LCFont(15.0f);
- // self.browser.toolBar.titleLabel.font = LCFont(17.0f);
- // self.browser.toolBar.titleLabel.textColor = HexColorFromRGB(0x333333);
- // [self.browser.toolBar.rightButton setTitleColor:HexColorFromRGB(0x333333) forState:UIControlStateNormal];
- // self.browser.toolBar.hideLeftBtn = NO;
- [self.youpaipbrowser show];
- }else{
- [self youpaifopenAlbum:8];
- }
- }
- #pragma mark - tableViewDelegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return 4;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 54.0f;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return 0.0001;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return 0.0001;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAIZYSettingCell* cell = [[YOUPAIZYSettingCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"commonCell"];
- cell.youpaipbaseView.frame = CGRectMake(0, 0, KScreenWidth, 54.0f);
- cell.youpaiparrowLabel.textColor = HexColorFromRGB(0xAAAAAA);
- cell.youpaiparrowLabel.font = LCFont(13.0f);
- cell.youpaipheadLabel.font = LCFont(15.0f);
- if (indexPath.row==0) {
- cell.youpaipheadLabel.text = @"昵称";
- // cell.arrowLabel.font = LCFont(15.0f);
- if ([self.youpaipuserModel.youpaipuserinfo.youpaipnickname isEqualToString:@""]) {
- cell.youpaiparrowLabel.text = @"请输入昵称";
- }else{
- cell.youpaiparrowLabel.text = self.youpaipuserModel.youpaipuserinfo.youpaipnickname;
- }
- }else if (indexPath.row==1){
- cell.youpaipheadLabel.text = @"生日";
- if ([self.youpaipuserModel.youpaipuserinfo.youpaipbirthday isEqualToString:@"0000-00-00"]) {
- cell.youpaiparrowLabel.text = @"请选择日期";
- }else{
- cell.youpaiparrowLabel.text = self.youpaipuserModel.youpaipuserinfo.youpaipbirthday;
- }
- }else if (indexPath.row==2){
- cell.youpaipheadLabel.text = @"城市";
- cell.youpaiparrowLabel.text = self.youpaipuserModel.youpaipuserinfo.youpaipcity;
- }else if (indexPath.row==3){
- cell.youpaipheadLabel.text = @"个人介绍";
- if (self.youpaipuserModel.youpaipuserinfo.youpaipsign.length == 0) {
- cell.youpaiparrowLabel.text = @"简单介绍一下自己吧…";
- }else{
- cell.youpaiparrowLabel.text = self.youpaipuserModel.youpaipuserinfo.youpaipsign;
- }
- }
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if (indexPath.row==0) {
- YOUPAILCUpdateNickVC* nickVC = [[YOUPAILCUpdateNickVC alloc]init];
- nickVC.youpaipnickName = self.youpaipuserModel.youpaipuserinfo.youpaipnickname;
- nickVC.youpaipblock = ^(NSString *nickname) {
- self.youpaipuserModel.youpaipuserinfo.youpaipnickname = nickname;
- [self.youpaiptableView reloadData];
- };
- [self.navigationController pushViewController:nickVC animated:YES];
-
- }else if (indexPath.row==1){
-
- PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
- datePickManager.isShadeBackground = true;
- datePickManager.cancelButtonFont = LCFont(15);
- datePickManager.confirmButtonFont = LCFont(15);
- datePickManager.cancelButtonTextColor = HexColorFromRGB(0x9F9DA5);
- datePickManager.confirmButtonTextColor = [UIColor whiteColor];
- datePickManager.headerViewBackgroundColor = LCBkgColor;
- datePickManager.headerHeight = 50;
-
- PGDatePicker *datePicker = datePickManager.datePicker;
- datePicker.backgroundColor = LCBkgColor;
- datePicker.rowHeight = 35;
- datePicker.middleTextColor = [UIColor whiteColor];
- datePicker.textColorOfSelectedRow = [UIColor whiteColor];
- datePicker.textColorOfOtherRow = [[UIColor whiteColor] colorWithAlphaComponent:0.2f];
- datePicker.textFontOfSelectedRow = LCFont(17);
- datePicker.textFontOfOtherRow = LCFont(17);
- datePicker.lineBackgroundColor = [UIColor clearColor];
-
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- NSDate* currentDate = [NSDate date];
- [dateFormatter setDateFormat:@"yyyy"];
- NSString* currentYear=[dateFormatter stringFromDate:currentDate] ;
- [dateFormatter setDateFormat:@"MM"];
- NSString* currentMonth=[dateFormatter stringFromDate:currentDate];
- [dateFormatter setDateFormat:@"dd"];
- NSString* currentDay=[dateFormatter stringFromDate:currentDate] ;
-
- NSString* maxDateStr = [NSString stringWithFormat:@"%zd-%@-%@",[currentYear integerValue]-18,currentMonth,currentDay];
- NSString* minDateStr = [NSString stringWithFormat:@"%zd-%@-%@",[currentYear integerValue]-50,currentMonth,currentDay];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- NSString* defaultDateStr;
- if ([self.youpaipuserModel.youpaipuserinfo.youpaipbirthday isEqualToString:@""]) {
- defaultDateStr = @"1999-03-15";
- }else{
- defaultDateStr = self.youpaipuserModel.youpaipuserinfo.youpaipbirthday;
- }
- NSDate *date = [dateFormatter dateFromString:defaultDateStr];//上次设置的日期
-
- [datePicker setDate:date];
- datePicker.maximumDate = [dateFormatter dateFromString:maxDateStr];
- datePicker.minimumDate = [dateFormatter dateFromString:minDateStr];
- datePicker.delegate = self;
- datePicker.datePickerType = PGDatePickerTypeLine;
- datePicker.isHiddenMiddleText = false;
- datePicker.datePickerMode = PGDatePickerModeDate;
- [self presentViewController:datePickManager animated:false completion:nil];
-
- }else if (indexPath.row==2){
- YOUPAILCUpdateCityVC* cityVC = [[YOUPAILCUpdateCityVC alloc]init];
- cityVC.youpaipcityName = self.youpaipuserModel.youpaipuserinfo.youpaipcity;
- cityVC.youpaipblock = ^(NSString *cityName) {
- self.youpaipuserModel.youpaipuserinfo.youpaipcity = cityName;
- [self youpaifupdateCity];
- };
- [self.navigationController pushViewController:cityVC animated:YES];
-
- }else if (indexPath.row == 3){
- YOUPAILZUpdateSignVC* cityVC = [[YOUPAILZUpdateSignVC alloc]init];
- cityVC.youpaipsign = self.youpaipuserModel.youpaipuserinfo.youpaipsign;
- cityVC.youpaipblock = ^(NSString *sign) {
- self.youpaipuserModel.youpaipuserinfo.youpaipsign = sign;
- [self youpaifupdateSign];
- };
- [self.navigationController pushViewController:cityVC animated:YES];
- }
- }
- - (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents{
- NSLog(@"dateComponents = %@", dateComponents);
- NSInteger year=[dateComponents year];
- NSInteger month=[dateComponents month];
- NSInteger day=[dateComponents day];
- NSString* birthday = [NSString stringWithFormat:@"%ld-%ld-%ld",year,month,day];
- self.youpaipuserModel.youpaipuserinfo.youpaipbirthday = birthday;
- [self youpaifupdateBirthday];
- }
- - (void)youpaifupdateCity{
- [LCHttpHelper requestWithURLString:UpdateUserMsg parameters:@{@"cityId":[LCTools getCityIDWithCityName:self.youpaipuserModel.youpaipuserinfo.youpaipcity]}
- needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILCUserModel* userModel = [LCSaveModel getUserModel];
- userModel.youpaipuserinfo.youpaipcity = self.youpaipuserModel.youpaipuserinfo.youpaipcity;
- [LCSaveModel saveUserModel:userModel];
-
- [self.youpaiptableView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- - (void)youpaifupdateBirthday{
- [LCHttpHelper requestWithURLString:UpdateUserMsg parameters:@{@"birthday":self.youpaipuserModel.youpaipuserinfo.youpaipbirthday}
- needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILCUserModel* userModel = [LCSaveModel getUserModel];
- userModel.youpaipuserinfo.youpaipbirthday = self.youpaipuserModel.youpaipuserinfo.youpaipbirthday;
- [LCSaveModel saveUserModel:userModel];
-
- [self.youpaiptableView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- - (void)youpaifupdateSign{
- [LCHttpHelper requestWithURLString:UpdateUserMsg parameters:@{@"signature":self.youpaipuserModel.youpaipuserinfo.youpaipsign}
- needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILCUserModel* userModel = [LCSaveModel getUserModel];
- userModel.youpaipuserinfo.youpaipsign = self.youpaipuserModel.youpaipuserinfo.youpaipsign;
- [LCSaveModel saveUserModel:userModel];
-
- [self.youpaiptableView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- - (void)youpaifupdateUserPhotos{
- NSString* albumStr = @"";
- if (self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count>0) {
- for (int i =0; i<self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count; i++) {
- NSString* str = self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[i];
- if (i==0) {
- albumStr = [NSString stringWithFormat:@"%@%@",albumStr,str];
- }else{
- albumStr = [NSString stringWithFormat:@"%@,%@",albumStr,str];
- }
- }
- }
-
- [LCHttpHelper requestWithURLString:UpdateUserMsg parameters:@{@"albums":albumStr} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILCUserModel* userModel = [LCSaveModel getUserModel];
- userModel.youpaipuserinfo.youpaipalbum_list = self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list;
- [LCSaveModel saveUserModel:userModel];
-
- }
- } failure:^(NSError *error) {
-
- }];
- }
- #pragma mark - 拖拽事件照片处理
- - (void)youpaiflongPressHandel:(UILongPressGestureRecognizer*)sender{
- YOUPAILCImageCollectionCell *cell = (YOUPAILCImageCollectionCell *)sender.view;
- if (!cell.youpaiphasImage) {
- return ;
- }
- NSIndexPath *cellIndexPath = [self.youpaipcollectionView indexPathForCell:cell];
- cell.transform = CGAffineTransformMakeScale(1.1, 1.1);
- [self.youpaipcollectionView bringSubviewToFront:cell];
- BOOL isChanged = NO;
- if (sender.state == UIGestureRecognizerStateBegan) {
- [self.youpaipcellAttributesArray removeAllObjects];
- for (int i = 0;i< self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list.count; i++) {
- [self.youpaipcellAttributesArray addObject:[self.youpaipcollectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]]];
- }
- self.youpaiplastPressPoint = [sender locationInView:self.youpaipcollectionView];
- }else if (sender.state == UIGestureRecognizerStateChanged){
- cell.center = [sender locationInView:self.youpaipcollectionView];
- if (cell.center.y-10>self.youpaiplastPressPoint.y) {
- [UIView animateWithDuration:0.25 animations:^{
- self.youpaipdeleteView.frame = CGRectMake(0, KScreenHeight-50, KScreenWidth, 50);
- }];
- }
- for (UICollectionViewLayoutAttributes *attributes in self.youpaipcellAttributesArray) {
- if (CGRectContainsPoint(attributes.frame, cell.center) && cellIndexPath != attributes.indexPath ) {
- isChanged = YES;
- //对数组中存放的元素重新排序
- NSString* photoStr = self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list[cellIndexPath.item];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list removeObjectAtIndex:cellIndexPath.item];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list insertObject:photoStr atIndex:attributes.indexPath.item];
-
- album_list_newModel *model = self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new[cellIndexPath.item];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new removeObjectAtIndex:cellIndexPath.item];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new insertObject:model atIndex:attributes.indexPath.item];
-
- [self.youpaipcollectionView moveItemAtIndexPath:cellIndexPath toIndexPath:attributes.indexPath];
-
-
-
- // if (attributes.indexPath.item == 0) {
- // cell.imagev.hidden = NO;
- // }else{
- // cell.imagev.hidden = YES;
- // }
-
- }
- }
- CGPoint viewPoint = [sender locationInView:self.view];
- if (viewPoint.y>=KScreenHeight-50) {
- self.youpaipdeleteView.youpaipstatu = 2;
- }else{
- self.youpaipdeleteView.youpaipstatu = 1;
- }
-
- }else if (sender.state == UIGestureRecognizerStateEnded) {
- if (!isChanged) {
- cell.center = [self.youpaipcollectionView layoutAttributesForItemAtIndexPath:cellIndexPath].center;
-
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- //
- // [self.collectionView reloadData];
- // });
-
-
- }
- cell.transform = CGAffineTransformIdentity;
- // if (self.deleteView.statu==2) {
- // if (self.userModel.userinfo.album_list.count>1) {
- // if (self.userModel.userinfo.album_list.count>cell.item) {
- // [self.userModel.userinfo.album_list removeObjectAtIndex:cell.item];
- // }
- // [self.collectionView reloadData];
- // }else{
- // [ZCHUDHelper showTitle:@"再删除就没头像啦"];
- // }
- // }
-
- [UIView animateWithDuration:0.25 animations:^{
- self.youpaipdeleteView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, 50);
- } completion:nil];
-
- }
- }
- - (void)youpaifopenAlbum:(NSInteger)index{
- TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 columnNumber:4 delegate:self];
- [LCTZImageConfigHelper setDefaultTZImageConfig:imagePickerVc];
- imagePickerVc.allowTakePicture = YES; // 在内部显示拍照按钮
- imagePickerVc.allowPickingVideo = NO;//是否允许选择视频
- imagePickerVc.allowPickingImage = YES;//是否允许选择照片
- imagePickerVc.allowPickingOriginalPhoto = NO;//是否选择原图
- imagePickerVc.showSelectedIndex = YES; //显示图片序号
- imagePickerVc.allowCrop = NO;//是否允许裁剪
-
- // // 裁剪框的尺寸
- // imagePickerVc.cropRect = CGRectMake(0, KScreenHeight/2-(KScreenWidth/3.0*4)/2, KScreenWidth,KScreenWidth/3.0*4);
- // 4. 照片排列按修改时间升序
- imagePickerVc.sortAscendingByModificationDate = YES;//按时间倒序排列图片
- // You can get the photos by block, the same as by delegate.
- // 你可以通过block或者代理,来得到用户选择的照片.
- [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
- [ZCHUDHelper showWithStatus:@"上传中..."];
- // [LCCommonHttp uploadImages:photos type:@"album" succress:^(NSArray *imageArray) {
- // [ZCHUDHelper dismiss];
- // for (NSDictionary* dict in imageArray) {
- // if ([[dict objectForKey:@"type"] isEqualToString:@"album"]) {
- // NSString* str = [dict objectForKey:@"url"];
- // [self.userModel.userinfo.album_list addObject:str];
- // [self.collectionView reloadData];
- // [self setupHeaderView];
- // }
- // }
- // }];
- // NSMutableArray *images = [NSMutableArray array];
- // for (UIImage *image in photos) {
- // NSData *data = UIImageJPEGRepresentation(image, 0.2f);
- // [images addObject:[UIImage imageWithData:data]];
- // }
- // 1通过,0待审核,2,未通过
-
- [LCCommonHttp uploadWithImages:photos Type:@"album" successBlock:^(NSArray<NSString *> *ossImagePaths) {
- [ZCHUDHelper dismiss];
- album_list_newModel *model = [album_list_newModel new];
- model.youpaipurl = ossImagePaths.firstObject;
- model.youpaipstatus = 1;
- if (index !=8) {
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list removeObjectAtIndex:index];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list insertObject:ossImagePaths.firstObject atIndex:index];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new removeObjectAtIndex:index];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new insertObject:model atIndex:index];
- }else{
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list addObjectsFromArray:ossImagePaths];
- [self.youpaipuserModel.youpaipuserinfo.youpaipalbum_list_new addObject:model];
- }
-
-
-
-
- [self.youpaipcollectionView reloadData];
- [self youpaifsetupHeaderView];
- }];
- }];
- [self presentViewController:imagePickerVc animated:YES completion:nil];
- }
- - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto {
- NSLog(@"%@",photos[0]);
- }
- @end
|