123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870 |
- //
- // PSRegisterBaseVC.m
- // shiku_im
- //
- // Created by flyeagleTang on 14-6-10.
- // Copyright (c) 2014年 Reese. All rights reserved.
- //
- #import "PSRegisterBaseVC.h"
- //#import "selectTreeVC.h"
- #import "selectValueVC.h"
- #import "selectProvinceVC.h"
- #import "ImageResize.h"
- #import "resumeData.h"
- #import "JXActionSheetVC.h"
- #import "JXCameraVC.h"
- #import "STAlertView.h"
- #define HEIGHT 56
- #define IMGSIZE 100
- @interface PSRegisterBaseVC ()<UITextFieldDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate,JXActionSheetVCDelegate,JXCameraVCDelegate>
- @property (nonatomic, strong) STAlertView *alert;
- @property (nonatomic,weak) UIButton *selectBtn;
- @property (nonatomic,weak) UIButton *selectBtn2;
- @end
- @implementation PSRegisterBaseVC
- @synthesize resumeId;
- @synthesize resume;
- @synthesize user;
- - (id)init
- {
- self = [super init];
- if (self) {
- // self.isGotoBack = !self.isRegister;
- self.isGotoBack = YES;
- if(self.isRegister){
- resume.telephone = user.telephone;
- // self.title = [NSString stringWithFormat:@"%@",Localized(@"JX_BaseInfo")];
- }
- else
- // self.title = Localized(@"JX_BaseInfo");
- self.heightFooter = 0;
- self.heightHeader = JX_SCREEN_TOP;
- //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
- [self createHeadAndFoot];
- self.tableBody.backgroundColor = [UIColor whiteColor];
- self.tableBody.scrollEnabled = YES;
- int h = 0;
- NSString* s;
-
- UILabel *titleLable = [[UILabel alloc] init];
- titleLable.text = @"欢迎来到即信";
- titleLable.textColor = [UIColor blackColor];
- titleLable.font = [UIFont systemFontOfSize:30 weight:(UIFontWeightRegular)];
- [titleLable sizeToFit];
- titleLable.frame = CGRectMake(JX_SCREEN_WIDTH/2- titleLable.frame.size.width/2, 0, titleLable.frame.size.width, titleLable.frame.size.height);
- [titleLable sizeToFit];
- [self.tableBody addSubview:titleLable];
- h = h + titleLable.frame.size.height+INSETS;
-
- UILabel *titleLable1 = [[UILabel alloc] init];
- titleLable1.text = @"完善信息, 个性化你的内容";
- titleLable1.textColor = [UIColor lightGrayColor];
- titleLable1.font = [UIFont systemFontOfSize:13 weight:(UIFontWeightThin)];
- [titleLable1 sizeToFit];
- titleLable1.frame = CGRectMake(JX_SCREEN_WIDTH/2- titleLable1.frame.size.width/2, h, titleLable1.frame.size.width, titleLable.frame.size.height);
- [titleLable1 sizeToFit];
- [self.tableBody addSubview:titleLable1];
- h = h + titleLable1.frame.size.height+INSETS;
-
- JXImageView* iv;
- iv = [[JXImageView alloc]init];
- iv.frame = self.tableBody.bounds;
- iv.delegate = self;
- iv.didTouch = @selector(hideKeyboard);
- [self.tableBody addSubview:iv];
- // [iv release];
-
- _head = [[JXImageView alloc]initWithFrame:CGRectMake((JX_SCREEN_WIDTH-IMGSIZE)/2, h, IMGSIZE, IMGSIZE)];
- _head.layer.cornerRadius = IMGSIZE/2;
- _head.layer.masksToBounds = YES;
- _head.didTouch = @selector(pickImage);
- _head.delegate = self;
- // _head.image = [[UIImage imageNamed:@"registered_default"] imageWithTintColor:THEMECOLOR];
- _head.image = [UIImage imageNamed:@"new_login_avatar"];
- if(self.isRegister)
- s = user.userId;
- else
- s = g_myself.userId;
- [g_server getHeadImageSmall:s userName:resume.name imageView:_head];
- [self.tableBody addSubview:_head];
- // [_head release];
- // h = INSETS*2+IMGSIZE;
- h = h + IMGSIZE;
-
- _headCheck = [[JXImageView alloc]initWithFrame:CGRectMake((JX_SCREEN_WIDTH-IMGSIZE/4)/2, h-IMGSIZE/8, IMGSIZE/4, IMGSIZE/4)];
- _headCheck.layer.cornerRadius = IMGSIZE/8;
- _headCheck.layer.masksToBounds = YES;
- _headCheck.didTouch = @selector(pickImage);
- _headCheck.delegate = self;
- // _head.image = [[UIImage imageNamed:@"registered_default"] imageWithTintColor:THEMECOLOR];
- _headCheck.image = [UIImage imageNamed:@"new_register_check"];
- _headCheck.hidden = YES;
- [self.tableBody addSubview:_headCheck];
- // [_head release];
- // h = INSETS*2+IMGSIZE;
- h = h +INSETS*2;
-
- NSString* workExp = [g_constant.workexp objectForKey:[NSNumber numberWithInt:resume.workexpId]];
- NSString* diploma = [g_constant.diploma objectForKey:[NSNumber numberWithInt:resume.diplomaId]];
- NSString* city = [g_constant getAddressForInt:resume.provinceId cityId:resume.cityId areaId:resume.areaId];
-
- iv = [self createButton:@"即信号" drawTop:NO drawBottom:YES must:YES click:nil];
- iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- _memberAccount = [self createTextField:iv default:@"" hint:@"您的吉利彩票会员账号"];
- [_memberAccount addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
- h+=iv.frame.size.height;
-
-
- iv = [self createButton:@"昵称" drawTop:NO drawBottom:YES must:YES click:nil];
- iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- _name = [self createTextField:iv default:@"" hint:@"请使用中文昵称"];
- h+=iv.frame.size.height;
- _name.delegate=self;
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFiledEditChanged:)name:UITextFieldTextDidChangeNotification object:_name];
-
-
- // iv = [self createButton:Localized(@"JX_Sex") drawTop:NO drawBottom:YES must:YES click:nil];
- // iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- // _sex = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:Localized(@"JX_Wuman"),Localized(@"JX_Man"),nil]];
- // _sex.frame = CGRectMake(JX_SCREEN_WIDTH -87 - 15,(HEIGHT-25)/2,87,25);
- // _sex.selectedSegmentIndex = resume.sex;
- // //样式
- //// _sex.segmentedControlStyle= UISegmentedControlStyleBar;
- // _sex.tintColor = THEMECOLOR;
- // _sex.layer.cornerRadius = 5;
- // _sex.layer.borderWidth = 1.5;
- // _sex.layer.borderColor = [THEMECOLOR CGColor];
- // _sex.clipsToBounds = YES;
- // //设置文字属性
- // _sex.selectedSegmentIndex = [user.sex boolValue];
- // _sex.apportionsSegmentWidthsByContent = NO;
- // [iv addSubview:_sex];
- //// [_sex release];
- // h+=iv.frame.size.height;
-
- // if (!resume.birthday) {
- // resume.birthday = [[NSDate date] timeIntervalSince1970];
- // }
-
-
- // iv = [self createButton:Localized(@"JX_BirthDay") drawTop:NO drawBottom:NO must:YES click:nil];
- // iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- // _birthday = [self createTextField:iv default:[TimeUtil getDateStr:resume.birthday] hint:Localized(@"JX_BirthDay")];
- // h+=iv.frame.size.height;
- iv = [self createButton:Localized(@"JX_Address") drawTop:NO drawBottom:NO must:YES click:@selector(onCity)];
- iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- _city = [self createLabel:iv default:city];
- h+=iv.frame.size.height;
-
- UIView *btn_linview=[[UIView alloc]init];
- btn_linview.backgroundColor=kRGBColor(246, 246, 246);
- [self.tableBody addSubview:btn_linview];
- [btn_linview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(h+2);
- make.left.mas_equalTo(40);
- make.right.mas_equalTo(-40);
- make.height.mas_equalTo(1);
-
- }];
-
-
- if(!self.isRegister){
- iv = [self createButton:Localized(@"JX_WorkingYear") drawTop:YES drawBottom:YES must:YES click:@selector(onWorkexp)];
- iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- _workexp = [self createLabel:iv default:workExp];
- h+=iv.frame.size.height;
-
- iv = [self createButton:Localized(@"JX_HighSchool") drawTop:NO drawBottom:YES must:YES click:@selector(onDiploma)];
- iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- _dip = [self createLabel:iv default:diploma];
- h+=iv.frame.size.height;
-
- iv = [self createButton:Localized(@"JX_Address") drawTop:NO drawBottom:NO must:YES click:@selector(onCity)];
- iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- _city = [self createLabel:iv default:city];
- h+=iv.frame.size.height;
- }
-
- // else {
- // if ([g_config.registerInviteCode intValue] != 0) {
- // iv = [self createButton:Localized(@"JX_InvitationCode") drawTop:YES drawBottom:NO must:YES click:nil];
- // iv.frame = CGRectMake(0, h, JX_SCREEN_WIDTH, HEIGHT);
- // _inviteCode = [self createTextField:iv default:nil hint:Localized(@"JX_EnterInvitationCode")];
- // h+=iv.frame.size.height;
- // }
- // }
-
-
- UIView *center_linview=[[UIView alloc]init];
- center_linview.backgroundColor=kRGBColor(246, 246, 246);
- [self.tableBody addSubview:center_linview];
- [center_linview mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.centerX.mas_equalTo(self.tableBody.mas_centerX);
- make.top.mas_equalTo(h+30);
- make.width.mas_equalTo(1);
- make.height.mas_equalTo(44);
-
- }];
-
-
- UIButton *button1=[[UIButton alloc]init];
- button1.tag=0;
- [button1 setBackgroundImage:[UIImage imageNamed:@"xianshengsel"] forState:UIControlStateNormal];
- [button1 setBackgroundImage:[UIImage imageNamed:@"xianshengnor"] forState:UIControlStateSelected];
- [self.tableBody addSubview:button1];
- [button1 addTarget:self action:@selector(btnCLick1:) forControlEvents:UIControlEventTouchUpInside];
- button1.selected=YES;
- self.selectBtn=button1;
- [button1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(center_linview.mas_centerY);
- make.right.mas_equalTo(center_linview.mas_left).mas_equalTo(-30);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(24);
- }];
-
-
- UIButton *btnNv=[[UIButton alloc]init];
- btnNv.tag=1;
- [btnNv setBackgroundImage:[UIImage imageNamed:@"nvshinor"] forState:UIControlStateNormal];
- [btnNv setBackgroundImage:[UIImage imageNamed:@"nvshisel"] forState:UIControlStateSelected];
- [btnNv addTarget:self action:@selector(btnCLick:) forControlEvents:UIControlEventTouchUpInside];
- [self.tableBody addSubview:btnNv];
- // self.selectBtn=btnNv;
- [btnNv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(center_linview.mas_centerY);
- make.left.mas_equalTo(center_linview.mas_right).mas_equalTo(30);
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(24);
- }];
-
-
-
- h+=INSETS;
- UIButton* _btn;
- if(self.isRegister)
- _btn = [UIFactory createCommonButton:@"请填写完上方信息" target:self action:@selector(onInsert)];
- else
- _btn = [UIFactory createCommonButton:Localized(@"JX_Update") target:self action:@selector(onUpdate)];
- _btn.layer.cornerRadius = 20;
- _btn.clipsToBounds = YES;
- _btn.custom_acceptEventInterval = .25f;
- _btn.frame = CGRectMake(15, h+90, JX_SCREEN_WIDTH-15*2, 40);
- [self.tableBody addSubview:_btn];
-
- _date = [[JXDatePicker alloc] initWithFrame:CGRectMake(0, JX_SCREEN_HEIGHT-200, JX_SCREEN_WIDTH, 200)];
- _date.date = [NSDate dateWithTimeIntervalSince1970:resume.birthday];
- _date.datePicker.datePickerMode = UIDatePickerModeDate;
- _date.delegate = self;
- _date.didChange = @selector(onDate:);
- _date.didSelect = @selector(onDate:);
- }
- return self;
- }
- - (void)btnCLick:(UIButton *)sender{
-
- self.selectBtn.selected=NO;
- sender.selected=YES;
- self.selectBtn=sender;
-
-
- }
- - (void)btnCLick1:(UIButton *)sender{
-
- self.selectBtn.selected=NO;
- sender.selected=YES;
- self.selectBtn=sender;
-
-
- }
- -(void)dealloc{
- // NSLog(@"PSRegisterBaseVC.dealloc");
- // [_image release];
- self.resumeId = nil;
- self.user = nil;
- self.resume = nil;
-
- [_date removeFromSuperview];
- // [_date release];
- // [super dealloc];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- [g_default removeObjectForKey:@"refushMsgHistoryxxx"];
-
-
-
- // Do any additional setup after loading the view.
- NSArray *buttons = nil;
- NSString *link = @"";
- if (link.length > 0) {
- buttons = @[@"查看更多",@"知道了"];
- } else {
- buttons = @[@"继续"];
- }
- UIImage *image = [UIImage imageNamed:@"new_register_alert_bg"];
- [_alert hide:NO];
- STAlertView *alert = [[STAlertView alloc] initWithTitle:@""
- image:image
- message:@"使用真实头像, 完成玩家验证可到客服领取奖励."
- buttonTitles:buttons];
- _alert = alert;
- alert.hideWhenTapOutside = NO;
- [alert setDidShowHandler:^{
- NSLog(@"显示了");
- }];
- [alert setDidHideHandler:^{
- NSLog(@"消失了");
- }];
- [alert setActionHandler:^(NSInteger index) {
-
- }];
- [alert show:YES];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- //=====================================start ============
- - (BOOL)textFieldShouldReturn:(UITextField *)textField{
- [textField resignFirstResponder];
-
- //过滤非汉字字符
- textField.text = [self filterCharactor:textField.text withRegex:@"[^\u4e00-\u9fa5]"];
-
- if (textField.text.length >= 24) {
- textField.text = [textField.text substringToIndex:24];
-
- }
- return NO;
- }
-
- - (void)textFiledEditChanged:(id)notification{
-
- UITextRange *selectedRange = _name.markedTextRange;
- UITextPosition *position = [_name positionFromPosition:selectedRange.start offset:0];
-
- if (!position) { //// 没有高亮选择的字
- //过滤非汉字字符
- _name.text = [self filterCharactor:_name.text withRegex:@"[^\u4e00-\u9fa5]"];
-
- if (_name.text.length >= 24) {
- _name.text = [_name.text substringToIndex:24];
- }
- }else { //有高亮文字
- //do nothing
- }
- }
-
- //根据正则,过滤特殊字符
- - (NSString *)filterCharactor:(NSString *)string withRegex:(NSString *)regexStr{
- NSString *searchText = string;
- NSError *error = NULL;
- NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regexStr options:NSRegularExpressionCaseInsensitive error:&error];
- NSString *result = [regex stringByReplacingMatchesInString:searchText options:NSMatchingReportCompletion range:NSMakeRange(0, searchText.length) withTemplate:@""];
- return result;
- }
- //=====================================end=============
- - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
- if(textField == _birthday){
- [self hideKeyboard];
- [g_window addSubview:_date];
- _date.hidden = NO;
- return NO;
- }else{
- _date.hidden = YES;
- return YES;
- }
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- if (textField == _memberAccount) {
- if (string.length == 0) {return YES;}
- if (![self validateNumber:string]) {return NO;}
- NSInteger existedLength = textField.text.length;
- NSInteger selectedLength = range.length;
- NSInteger replaceLength = string.length;
- if (existedLength - selectedLength + replaceLength > 30) {
- [g_App showAlert:@"会员账号不能超过30位哦"];
- return NO;
- }
- return YES;//YES,表示修改生效;NO,表示不做修改,textField的内容不变
- }
- return YES;
- }
- - (BOOL)validateNumber:(NSString*)number {
- BOOL res = YES;
- NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"];
- int i = 0;
- while (i < number.length) {
- NSString * string = [number substringWithRange:NSMakeRange(i, 1)];
- NSRange range = [string rangeOfCharacterFromSet:tmpSet];
- if (range.length == 0) {
- res = NO;
- break;
- }
- i++;
-
- }
- return res;
- }
- - (void) textFieldDidChange:(UITextField *)textField{
- if (textField == _memberAccount) {
- if (textField.text.length > 30) {
- textField.text = [textField.text substringToIndex:30];
- }
- }
- }
- - (IBAction)onDate:(id)sender {
- NSDate *selected = [_date date];
- _birthday.text = [TimeUtil formatDate:selected format:@"yyyy-MM-dd"];
- // _date.hidden = YES;
- }
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- [_wait stop];
-
- if( [aDownload.action isEqualToString:act_Config]){
-
- [g_config didReceive:dict];
-
- [user copyFromResume:resume];
- // [g_server registerUser:user inviteCode:_inviteCode.text workexp:resume.workexpId diploma:resume.diplomaId isSmsRegister:self.isSmsRegister toView:self];
- // 注册接口
- _memberAccount.text;
- [g_loginServer registerUserV1:user type:self.type inviteCode:_inviteCodeStr workexp:resume.workexpId diploma:resume.diplomaId isSmsRegister:self.isSmsRegister smsCode:self.smsCode password:self.password memberAccount:_memberAccount.text toView:self];
- }
-
- if( [aDownload.action isEqualToString:act_UploadHeadImage] ){
- _head.image = _image;
- // [_image release];
- _image = nil;
-
- if(self.isRegister){
- }else{
- [g_server delHeadImage:user.userId];
- [g_App showAlert:Localized(@"JXAlert_UpdateOK")];
- }
- [g_notify postNotificationName:kUpdateUserNotifaction object:self userInfo:nil];
- [g_notify postNotificationName:kRegisterNotifaction object:self userInfo:nil];
- [self actionQuit];
- }
- if( [aDownload.action isEqualToString:act_Register] || [aDownload.action isEqualToString:act_RegisterV1]){
- [g_default setBool:NO forKey:kTHIRD_LOGIN_AUTO];
- [g_server doLoginOK:dict user:user];
- self.user = g_server.myself;
- self.resumeId = [(NSDictionary *)[dict objectForKey:@"cv"] objectForKey:@"resumeId"];
- // [g_server autoLogin:self];
- [g_server getUser:[[dict objectForKey:@"userId"] stringValue] toView:self];
- }
- if([aDownload.action isEqualToString:act_UserGet]){
- if ([dict objectForKey:@"settings"]) {
- g_server.myself.chatRecordTimeOut = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"chatRecordTimeOut"]];
- g_server.myself.chatSyncTimeLen = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"chatSyncTimeLen"]];
- g_server.myself.groupChatSyncTimeLen = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"groupChatSyncTimeLen"]];
- g_server.myself.friendsVerify = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"friendsVerify"]];
- g_server.myself.isEncrypt = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"isEncrypt"]];
- g_server.myself.isTyping = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"isTyping"]];
- g_server.myself.isVibration = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"isVibration"]];
- g_server.myself.multipleDevices = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"multipleDevices"]];
- g_server.myself.isUseGoogleMap = [NSString stringWithFormat:@"%@",[(NSDictionary *)[dict objectForKey:@"settings"] objectForKey:@"isUseGoogleMap"]];
-
- }
-
-
- [g_server uploadHeadImage:user.userId image:_image toView:self];
-
- }
-
- if( [aDownload.action isEqualToString:act_resumeUpdate] ){
- if(_image)
- [g_server uploadHeadImage:g_myself.userId image:_image toView:self];
- else{
- g_myself.userNickname = _name.text;
- //g_myself.sex = [NSNumber numberWithInteger:_sex.selectedSegmentIndex];
- g_myself.sex = [NSNumber numberWithInteger:_selectBtn.tag];
- g_myself.birthday = _date.date;
- g_myself.cityId = [NSNumber numberWithInt:[_city.text intValue]];
- [g_App showAlert:Localized(@"JXAlert_UpdateOK")];
- [g_notify postNotificationName:kUpdateUserNotifaction object:self userInfo:nil];
- [self actionQuit];
- }
- }
- if ([aDownload.action isEqualToString:act_registerSDK] || [aDownload.action isEqualToString:act_registerSDKV1]) {
- [g_default setBool:YES forKey:kTHIRD_LOGIN_AUTO];
- g_server.openId = nil;
- [g_server doLoginOK:dict user:user];
- self.user = g_server.myself;
-
- self.resumeId = [(NSDictionary *)[dict objectForKey:@"cv"] objectForKey:@"resumeId"];
- [g_server getUser:[[dict objectForKey:@"userId"] stringValue] toView:self];
- }
- }
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- [_wait stop];
- if( [aDownload.action isEqualToString:act_UploadHeadImage] ){
- _head.image = _image;
- // [_image release];
- _image = nil;
-
- if(self.isRegister){
- }else{
- [g_server delHeadImage:user.userId];
- [g_App showAlert:Localized(@"JXAlert_UpdateOK")];
- }
- [g_notify postNotificationName:kUpdateUserNotifaction object:self userInfo:nil];
- [g_notify postNotificationName:kRegisterNotifaction object:self userInfo:nil];
- [self actionQuit];
- }
- return show_error;
- }
- -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
- [_wait stop];
- if( [aDownload.action isEqualToString:act_UploadHeadImage] ){
- _head.image = _image;
- // [_image release];
- _image = nil;
-
- if(self.isRegister){
- }else{
- [g_server delHeadImage:user.userId];
- [g_App showAlert:Localized(@"JXAlert_UpdateOK")];
- }
- [g_notify postNotificationName:kUpdateUserNotifaction object:self userInfo:nil];
- [g_notify postNotificationName:kRegisterNotifaction object:self userInfo:nil];
- [self actionQuit];
- }
- return show_error;
- }
- -(void) didServerConnectStart:(JXConnection*)aDownload{
- [_wait start];
- }
- -(JXImageView*)createButton:(NSString*)title drawTop:(BOOL)drawTop drawBottom:(BOOL)drawBottom must:(BOOL)must click:(SEL)click{
- JXImageView* btn = [[JXImageView alloc] init];
- btn.backgroundColor = [UIColor whiteColor];
- btn.userInteractionEnabled = YES;
- if(click)
- btn.didTouch = click;
- else
- btn.didTouch = @selector(hideKeyboard);
- btn.delegate = self;
- [self.tableBody addSubview:btn];
-
- // if(must){
- // UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(INSETS, 5, 20, HEIGHT-5)];
- // p.text = @"*";
- // p.font = g_factory.font18;
- // p.backgroundColor = [UIColor clearColor];
- // p.textColor = [UIColor redColor];
- // p.textAlignment = NSTextAlignmentCenter;
- // [btn addSubview:p];
- // }
-
- JXLabel* p = [[JXLabel alloc] initWithFrame:CGRectMake(15, 0, 130, HEIGHT)];
- p.text = title;
- p.font = g_factory.font16;
- p.backgroundColor = [UIColor clearColor];
- p.textColor = [UIColor blackColor];
- [btn addSubview:p];
-
- if(drawTop){
- UIView* line = [[UIView alloc] initWithFrame:CGRectMake(15,0,JX_SCREEN_WIDTH-15,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- if(drawBottom){
- UIView* line = [[UIView alloc]initWithFrame:CGRectMake(15,HEIGHT-LINE_WH,JX_SCREEN_WIDTH-15,LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [btn addSubview:line];
- }
-
- if(click){
- UIImageView* iv;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-15-7, (HEIGHT-13)/2, 7, 13)];
- iv.image = [UIImage imageNamed:@"new_icon_>"];
- [btn addSubview:iv];
- }
- return btn;
- }
- -(UITextField*)createTextField:(UIView*)parent default:(NSString*)s hint:(NSString*)hint{
- UITextField* p = [[UITextField alloc] initWithFrame:CGRectMake(60,INSETS,JX_SCREEN_WIDTH/2-15,HEIGHT-INSETS*2)];
- p.delegate = self;
- p.autocorrectionType = UITextAutocorrectionTypeNo;
- p.autocapitalizationType = UITextAutocapitalizationTypeNone;
- p.enablesReturnKeyAutomatically = YES;
- p.borderStyle = UITextBorderStyleNone;
- p.returnKeyType = UIReturnKeyDone;
- p.textAlignment=NSTextAlignmentLeft;
- p.clearButtonMode = UITextFieldViewModeWhileEditing;
- p.textAlignment = NSTextAlignmentRight;
- p.textColor = HEXCOLOR(0x666666);
- p.userInteractionEnabled = YES;
- p.text = s;
- p.placeholder = hint;
- p.font = g_factory.font16;
- [parent addSubview:p];
- return p;
- }
- -(UILabel*)createLabel:(UIView*)parent default:(NSString*)s{
- UILabel* p = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2 -30 ,INSETS,JX_SCREEN_WIDTH/2,HEIGHT-INSETS*2)];
- p.userInteractionEnabled = NO;
- p.text = s;
- p.font = g_factory.font15;
- p.textAlignment = NSTextAlignmentRight;
- [parent addSubview:p];
- // [p release];
- return p;
- }
- -(void)onWorkexp{
- if([self hideKeyboard])
- return;
-
- selectValueVC* vc = [selectValueVC alloc];
- vc.values = g_constant.workexp_name;
- vc.selNumber = resume.workexpId;
- vc.numbers = g_constant.workexp_value;
- vc.delegate = self;
- vc.didSelect = @selector(onSelWorkExp:);
- vc.quickSelect = YES;
- vc = [vc init];
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- -(void)onDiploma{
- if([self hideKeyboard])
- return;
-
- selectValueVC* vc = [selectValueVC alloc];
- vc.values = g_constant.diploma_name;
- vc.selNumber = resume.diplomaId;
- vc.numbers = g_constant.diploma_value;
- vc.delegate = self;
- vc.didSelect = @selector(onSelDiploma:);
- vc.quickSelect = YES;
- vc = [vc init];
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- -(void)onCity{
- if([self hideKeyboard])
- return;
-
- selectProvinceVC* vc = [selectProvinceVC alloc];
- vc.delegate = self;
- vc.didSelect = @selector(onSelCity:);
- vc.showCity = YES;
- vc.showArea = NO;
- vc.parentId = 1;
- vc = [vc init];
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- -(void)onSelCity:(selectProvinceVC*)sender{
- resume.cityId = sender.cityId;
- resume.provinceId = sender.provinceId;
- resume.areaId = sender.areaId;
- resume.countryId = 1;
- _city.text = sender.selValue;
- }
- -(void)onSelDiploma:(selectValueVC*)sender{
- resume.diplomaId = sender.selNumber;
- _dip.text = sender.selValue;
- }
- -(void)onSelWorkExp:(selectValueVC*)sender{
- resume.workexpId = sender.selNumber;
- _workexp.text = sender.selValue;
- }
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
- {
- _image = [ImageResize image:[info objectForKey:@"UIImagePickerControllerEditedImage"] fillSize:CGSizeMake(640, 640)];
- // [_image retain];
- _head.image = _image;
- // [picker.view removeFromSuperview];
-
- // 选完了
- _headCheck.hidden = NO;
-
- [picker dismissViewControllerAnimated:YES completion:nil];
- // [self dismissModalViewControllerAnimated:YES];
- // [picker release];
- }
- - (void) pickImage
- {
- [self hideKeyboard];
-
- JXActionSheetVC *actionVC = [[JXActionSheetVC alloc] initWithImages:@[] names:@[Localized(@"JX_ChoosePhoto"),Localized(@"JX_TakePhoto")]];
- actionVC.delegate = self;
- [self presentViewController:actionVC animated:NO completion:nil];
-
- UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
- ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- ipc.delegate = self;
- ipc.allowsEditing = YES;
- ipc.modalPresentationStyle = UIModalPresentationFullScreen;
- // [g_window addSubview:ipc.view];
- if (IS_PAD) {
- UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:ipc];
- [pop presentPopoverFromRect:CGRectMake((self.view.frame.size.width - 320) / 2, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- }else {
- [self presentViewController:ipc animated:YES completion:nil];
- }
- }
- - (void)actionSheet:(JXActionSheetVC *)actionSheet didButtonWithIndex:(NSInteger)index {
- if (index == 0) {
- UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
- ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- ipc.delegate = self;
- ipc.allowsEditing = YES;
- //选择图片模式
- ipc.modalPresentationStyle = UIModalPresentationCurrentContext;
- // [g_window addSubview:ipc.view];
- if (IS_PAD) {
- UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:ipc];
- [pop presentPopoverFromRect:CGRectMake((self.view.frame.size.width - 320) / 2, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- }else {
- [self presentViewController:ipc animated:YES completion:nil];
- }
-
- }else {
- JXCameraVC *vc = [JXCameraVC alloc];
- vc.cameraDelegate = self;
- vc.isPhoto = YES;
- vc = [vc init];
- [self presentViewController:vc animated:YES completion:nil];
- }
- }
- - (void)cameraVC:(JXCameraVC *)vc didFinishWithImage:(UIImage *)image {
- _image = [ImageResize image:image fillSize:CGSizeMake(640, 640)];
- // [_image retain];
- // 照相
- _headCheck.hidden = NO;
- _head.image = _image;
- }
- -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
- {
- // 取消
-
- _headCheck.hidden = YES;
- // [picker.view removeFromSuperview];
- [picker dismissViewControllerAnimated:YES completion:nil];
- // [picker release];
- // [self dismissModalViewControllerAnimated:YES];
- }
- -(void)onUpdate{
- if(![self getInputValue])
- return;
- // NSString* s = [g_server jsonFromObject:[resume setDataToDict]];
- // [g_server updateResume:resumeId nodeName:@"p" text:s toView:self];
- }
- -(void)onInsert{
- if(![self getInputValue])
- return;
-
- [g_server getSetting:self];
- }
- -(BOOL)getInputValue{
- if(_image==nil && self.isRegister){
- [g_App showAlert:Localized(@"JX_SetHead")];
- return NO;
- }
- if([_name.text length]<=0){
- [g_App showAlert:Localized(@"JX_InputName")];
- return NO;
- }
- if([_memberAccount.text length]<=0){
- [g_App showAlert:@"会员账号为必填项"];
- return NO;
- }
- if(!self.isRegister){
- if(resume.workexpId<=0){
- [g_App showAlert:Localized(@"JX_InputWorking")];
- return NO;
- }
- if(resume.diplomaId<=0){
- [g_App showAlert:Localized(@"JX_School")];
- return NO;
- }
- if(resume.cityId<=0){
- [g_App showAlert:Localized(@"JX_Live")];
- return NO;
- }
- }
-
- // else {
- // if ([g_config.registerInviteCode intValue] == 1) {
- // if ([_inviteCode.text length] <= 0) {
- // [g_App showAlert:Localized(@"JX_EnterInvitationCode")];
- // return NO;
- // }
- // }
- // }
- resume.name = _name.text;
- resume.birthday = [_date.date timeIntervalSince1970];
- resume.sex = _selectBtn.tag;// _sex.selectedSegmentIndex;
- return YES;
- }
- -(BOOL)hideKeyboard{
- BOOL b = _name.editing || _pwd.editing || _repeat.editing;
- _date.hidden = YES;
- [self.view endEditing:YES];
- return b;
- }
- //- (BOOL)textFieldShouldReturn:(UITextField *)textField
- //{
- // [self.view endEditing:YES];
- // return YES;
- //}
- @end
|