| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240 |
- //
- // ReleaseViewController.m
- // 拍卖
- //
- // Created by GuoMs on 16/8/5.
- // Copyright © 2016年 zcd. All rights reserved.
- //
- #import "ReleaseViewController.h"
- #import "BaseTableViewCell.h"
- #import "TimeTableViewCell.h"
- #import "CdescriptTableViewCell.h"
- #import "HeaderView.h"
- #import "BGHUDHelper.h"
- #import "TagsModel.h"
- #import "MapViewController.h"
- #import "DatePickerOfView.h"
- #import "AuctionHeaderView.h"
- //#import "BGOssManager.h"
- #import "AuctionGoodsModel.h"
- @interface ReleaseViewController ()<AddPhotoDelegate,UIActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate,MapChooseAddressControllerDelegate,QMapLocationViewDelegate>
- {
- CGSize _size;
- UIButton *_rightButton;
- NSMutableDictionary *editPhotoDic;//编辑
- QMapLocationView *_mapLocationView; //腾讯地图
- CAKeyframeAnimation * keyAnimaion;//删除图片动画
- UIButton *btn;//删除图片
-
- // BGOssManager *_ossManager;
- NSString *_uploadFilePath;
- NSString *_urlString;
- NSString *_timeString;//时间戳的字符串
- BOOL _fistTime;
- BOOL _fistDelay;
- BOOL _fistMax;
-
- }
- @property (strong, nonatomic) IBOutlet UITableView *releaseTabView;
- @property (nonatomic, strong) HeaderView *headerView;
- @property (nonatomic, copy) NSString *textData;
- @property (nonatomic, strong) UIImageView *addPhoto;
- @property (nonatomic, strong) NSMutableDictionary *editInfo;//编辑
- @property (nonatomic, strong) NSMutableDictionary *shopDic;//虚拟购物
- @property (nonatomic, strong) NSMutableDictionary *entiShopDic;//实体购物
- @property (nonatomic, strong) NSMutableArray *editArr;//存放修改前的数据 NSMutableArray
- @property (nonatomic, strong) NSMutableArray *shopAuctionArr;//实物竞拍头部商品信息
- @property (nonatomic, strong) AuctionHeaderView * auctionView;
- @property (nonatomic, strong) NSMutableArray *pictArr;//存储上传后的图片
- @property (nonatomic, copy) NSString * bzStr;//保证金
- @property (nonatomic, copy) NSString * addPriceStr;//加价幅度
- @property (nonatomic, copy) NSString * auctionTimeStr;//竞拍时长
- @property (nonatomic, copy) NSString * delayTimeStr;//延时时间
- @property (nonatomic, copy) NSString * maxDelayTimeStr;//最大延时
- @property (nonatomic, strong) AuctionGoodsModel * entityAuctionModel;//实物竞拍的模型
- @property (nonatomic, copy) NSString * nameStr;//商品名称
- @property (nonatomic, copy) NSString * priceStr;//实物商品价格
- @property (nonatomic, copy) NSString * urlStr;//实物商品网址链接
- @property (nonatomic, copy) NSString * expressPriceStr;//实物商品快递费
- @property (nonatomic, copy) NSString * desStr;//商品描述
- @property (nonatomic, copy) NSString * contactStr;//联系人
- @property (nonatomic, copy) NSString * mobileStr;//联系电话
- @property (nonatomic, copy) NSString * qpPriceStr;//起拍价
- @property (nonatomic, strong) UILabel * placehoderLabel;
- @property (nonatomic, strong) UIView *dateView;
- @property (nonatomic, strong) DatePickerOfView *datePicker;
- @end
- @implementation ReleaseViewController
- /**
- *****新增时候的商品照片
- **/
- -(UIImageView *)addPhoto{
- if (!_addPhoto) {
- self.addPhoto = [UIImageView new];
- }
- return _addPhoto;
- }
- /**
- *****存储虚拟购物数据
- **/
- -(NSMutableDictionary *)shopDic{
- if (!_shopDic) {
- self.shopDic = [NSMutableDictionary new];
- }
- return _shopDic;
- }
- /**
- *****存储实体购物数据
- **/
- -(NSMutableDictionary *)entiShopDic{
- if (!_entiShopDic) {
- self.entiShopDic = [NSMutableDictionary new];
- }
- return _entiShopDic;
- }
- /**
- *****存放修改前的数据
- **/
- - (NSMutableArray *)editArr{
- if (!_editArr) {
- self.editArr = [NSMutableArray new];
- }
- return _editArr;
- }
- //实物竞拍数据
- - (NSMutableArray *)shopAuctionArr
- {
- if (!_shopAuctionArr) {
- _shopAuctionArr = [NSMutableArray new];
- }
- return _shopAuctionArr;
- }
- - (NSMutableArray *)pictArr{
- if (!_pictArr) {
- self.pictArr = [NSMutableArray new];
- }
- return _pictArr;
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [IQKeyboardManager sharedManager].enable = YES;
- [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
-
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- //开始定位
- [_mapLocationView startLocate];
- _fistMax = YES;
- _fistDelay = YES;
- _fistTime = YES;
- //处理 竞拍+悬浮+弹出发布界面UI问题
- //#if kSupportAuction
- // _tableView_Top_Constraint.constant = 64;//防止崩溃
- // _navBar_View.title_Lab.text = ASLocalizedString(@"商品");
- //#else
- // _tableView_Top_Constraint.constant = 0;
- //#endif
- // _navBar_View.hidden = !(kSupportAuction == 1);
- // [self.view layoutIfNeeded];
-
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [IQKeyboardManager sharedManager].enable = NO;
- [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
- }
- - (void)viewDidDisappear:(BOOL)animated{
- [super viewDidDisappear:animated];
- //停止定位
- [_mapLocationView stopLocate];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- self.placehoderLabel = [[UILabel alloc] initWithFrame:CGRectMake(6, 5, 75, 25)];
- self.placehoderLabel.text = ASLocalizedString(@"请描述商品");
- self.placehoderLabel.textColor = kAppGrayColor3;
- self.placehoderLabel.font = kAppMiddleTextFont;
-
- self.view.backgroundColor = kWhiteColor;
- //头部
- self.headerView = [[[NSBundle mainBundle]loadNibNamed:@"HeaderView" owner:self options:nil]lastObject];
- self.headerView.isOTOShop = _isOTOShop;
- self.headerView.delegate = self;
- [self.releaseTabView registerNib:[UINib nibWithNibName:@"BaseTableViewCell" bundle:nil] forCellReuseIdentifier:@"BaseCell"];//带输入框的
- [self.releaseTabView registerNib:[UINib nibWithNibName:@"TimeTableViewCell" bundle:nil] forCellReuseIdentifier:@"timeCell"];
- [self.releaseTabView registerNib:[UINib nibWithNibName:@"CdescriptTableViewCell" bundle:nil] forCellReuseIdentifier:@"desCell"];
- self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(returnToMeVc) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
- _rightButton = [[UIButton alloc]initWithFrame:CGRectMake(kScreenW-40, 5, 40, 30)];
- [_rightButton setTitle:ASLocalizedString(@"发布")forState:UIControlStateNormal];
- [_rightButton setTitleColor:kAppMainColor forState:UIControlStateNormal];
- _rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
- UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_rightButton];
- self.navigationItem.rightBarButtonItem = rightBarButtonItem;
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
- self.title = ASLocalizedString(@"虚拟商品拍卖设置");
- [self getLabelNetWorking];
- [self creatPickView];
- _mapLocationView = [QMapLocationView sharedInstance];
- [_rightButton addTarget:self action:@selector(releaseEditButton) forControlEvents:UIControlEventTouchUpInside];
- }
- else
- {
- self.releaseTabView.contentSize = CGSizeMake(kScreenW, kScreenH);
- if ([self.shopType isEqualToString:@"EditShopping"]){
- //self.title = ASLocalizedString(@"修改商品信息");
- self.navigationItem.title = ASLocalizedString(@"编辑购物商品");
- [_rightButton setTitle:ASLocalizedString(@"编辑")forState:UIControlStateNormal];
- [self editShop];
- [self.editArr addObject:self.model.name];
- [self.editArr addObject:self.model.price];
- if (self.model.url.length>0) {
- [self.editArr addObject:self.model.url];
- }
- if (self.BuguLive.appModel.open_podcast_goods == 0 && self.model.kd_cost.length >0) {
- [self.editArr addObject:self.model.kd_cost];
- }
- [self.editArr addObject:self.model.descrStr];
- [_rightButton addTarget:self action:@selector(EditShoppingButton) forControlEvents:UIControlEventTouchUpInside];
- self.placehoderLabel.hidden = YES;
- }
- else if ([self.shopType isEqualToString:@"EntityAuctionShopping"])
- {
- self.title = ASLocalizedString(@"星店商品拍卖设置");
- [self addShopGoodsData];
- [self.shopAuctionArr addObject:self.auctionGoodsModel.name];
- [self.shopAuctionArr addObject:self.auctionGoodsModel.price];
- [self.shopAuctionArr addObject:self.auctionGoodsModel.imgs];
- // [self addAuctionGoodsView];
-
- [_rightButton addTarget:self action:@selector(releaseButton) forControlEvents:UIControlEventTouchUpInside];
- }
- else{
- // self.title = ASLocalizedString(@"实物商品拍卖设置");
- self.title =self.BuguLive.appModel.open_podcast_goods == 1? ASLocalizedString(@"商品设置"): ASLocalizedString(@"产品设置");
- [self addShop];
- [_rightButton addTarget:self action:@selector(EntityShoppingEditButton) forControlEvents:UIControlEventTouchUpInside];
- }
- }
- // if (self.BuguLive.appModel.open_sts == 1)
- // {
- // _ossManager = [[BGOssManager alloc]initWithDelegate:self];
- // }
- //当悬浮 恢复、、发布VC 键盘下去
- // [self xw_addNotificationForName:@"GoodsPublishVCResign" block:^(NSNotification * _Nonnull notification) {
- // [self.view endEditing:YES];
- // }];
- }
- - (void)popVC
- {
- if ([self.shopType isEqualToString:@"EditShopping"] ||[self.shopType isEqualToString:@"EntityShopping"])
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- else if ([self.BuguLive.appModel.open_pai_module intValue] == 1)
- {
- // [[LiveCenterManager sharedInstance] showChangeAuctionLiveScreenSOfIsSmallScreen:NO nextViewController:nil delegateWindowRCNameStr:@"BGTabBarController" complete:^(BOOL finished) {
- // }];
- [self.navigationController popViewControllerAnimated:YES];
- }
- else
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- }
- #pragma mark -- 获取标签
- - (void)getLabelNetWorking
- {
- NSMutableDictionary *dict = [NSMutableDictionary new];
- [dict setValue:@"pai_podcast" forKey:@"ctl"];
- [dict setValue:@"tags" forKey:@"act"];
- [dict setObject:@"shop" forKey:@"itype"];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
- FWStrongify(self)
- if ([responseJson toInt:@"status"] == 1) {
- NSArray * listArr = responseJson[@"data"][@"list"];
- NSArray * tagsArr = [TagsModel mj_objectArrayWithKeyValuesArray:listArr];
- if (tagsArr.count > 0)
- {
- self.headerView.tagsArr = tagsArr;
- UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 176)];
- [headerV addSubview:self.headerView];
- //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
- [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
- [self.headerView getPicturearr:self.pictArr block:^{
-
- }];
- self.releaseTabView.tableHeaderView = headerV;
- [self.releaseTabView reloadData];
- }else{
- self.headerView.frame = CGRectMake(0, 0, kScreenW, 120);
- UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
- [headerV addSubview:self.headerView];
- //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
- [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
- [self.headerView getPicturearr:self.pictArr block:^{
-
- }];
- self.releaseTabView.tableHeaderView = headerV;
- [self.releaseTabView reloadData];
- }
- }
- } FailureBlock:^(NSError *error) {
-
- }];
-
- }
- -(AuctionHeaderView *)auctionView
- {
- if (_auctionView == nil) {
- _auctionView = [[AuctionHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
- }
- return _auctionView;
- }
- - (void)addAuctionGoodsView
- {
- // self.auctionView = [[AuctionHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
-
- // self.auctionView.backgroundColor = kAppGrayColor3;
- // UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
- // [headerV addSubview:self.auctionView];
- __weak typeof (self) weakSelf = self;
- weakSelf.releaseTabView.tableHeaderView = weakSelf.auctionView;
- weakSelf.auctionView.model = weakSelf.entityAuctionModel;
- [weakSelf.releaseTabView reloadData];
- }
- - (void)addShopGoodsData
- {
-
- NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
- [mDict setObject:@"pai_podcast" forKey:@"ctl"];
- [mDict setObject:@"addpaidetail" forKey:@"act"];
- if (self.auctionGoodsModel.goodsId.length>0) {
- [mDict setObject:self.auctionGoodsModel.goodsId forKey:@"goods_id"];
- }
- else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品ID不能为空")];
- return;
- }
- [mDict setObject:@"shop" forKey:@"itype"];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
- FWStrongify(self)
- if ([responseJson toInt:@"status"] == 1) {
- self.entityAuctionModel = [AuctionGoodsModel mj_objectWithKeyValues:[responseJson objectForKey:@"data"]];
- [self addAuctionGoodsView];
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
- }
- #pragma mark -- 新增实物商品
- - (void)addShop{
- self.headerView.frame = CGRectMake(0, 0, kScreenW, 120);
- UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
- [headerV addSubview:self.headerView];
- //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
- [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
- [self.headerView getPicturearr:self.pictArr block:^{
-
- }];
- self.releaseTabView.tableHeaderView = headerV;
- [self.releaseTabView reloadData];
-
- }
- #pragma mark -- 编辑商品
- - (void)editShop{
- self.pictArr = [self.model.imgs mutableCopy];
- NSLog(@"%@",self.pictArr);
- self.editInfo = [NSMutableDictionary new];
- if (self.pictArr.count > 0) {
- // for (int i = 0; i < self.pictArr.count; i++) {
- // NSLog(@"%@",self.pictArr[i]);
- // [_entiShopDic setObject:[NSString stringWithFormat:@"%@",self.pictArr[i]] forKey:[NSString stringWithFormat:@"%d",i]];
- // }
- [self.editInfo setObject:self.model.name forKey:@"name"];
- [self.editInfo setObject:self.model.price forKey:@"price"];
- if (self.model.url.length>0) {
- [self.editInfo setObject:self.model.url forKey:@"url"];
- }
- if (self.model.descrStr.length>0) {
- [self.editInfo setObject:self.model.descrStr forKey:@"description"];
- }
- if (self.BuguLive.appModel.open_podcast_goods == 0 && self.model.kd_cost.length >0) {
- [self.editInfo setObject:self.model.kd_cost forKey:@"kd_cost"];
- self.expressPriceStr = self.model.kd_cost;
- }
- NSLog(@"%@",self.editInfo);
- self.nameStr = self.model.name;
- self.priceStr = self.model.price;
- self.urlStr = self.model.url;
- self.desStr = self.model.descrStr;
- self.headerView.frame = CGRectMake(0, 0, kScreenW, 120);
- UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
- [headerV addSubview:self.headerView];
- if (!_isOTOShop) {
- //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
- [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
- }
- //[self.pictArr insertObject:[NSString stringWithFormat:@"addPhoto"] atIndex:self.pictArr.count];
- [self.headerView getPicturearr:self.pictArr block:^{
-
- }];
- self.releaseTabView.tableHeaderView = headerV;
- [self.releaseTabView reloadData];
- }
- }
- #pragma mark -- 发布重新编辑的商品
- - (void)EditShoppingButton{
- [self.view endEditing:YES];
- [self.editInfo setObject:@"shop" forKey:@"ctl"];
- [self.editInfo setObject:@"edit_goods" forKey:@"act"];
- [self.editInfo setObject:[NSString stringWithFormat:@"%@",self.model.ID] forKey:@"id"];
- if (self.pictArr.count == 1 && [self.pictArr containsObject:@"me_addPhoto"])
- {
- if (_isOTOShop) {
- [FanweMessage alert:ASLocalizedString(@"请上传图片")];
- }
- else
- {
- [FanweMessage alert:ASLocalizedString(@"至少上传一张图片(最多5张)")];
- }
- return;
- }
- if (_nameStr.length == 0) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品名称不能为空")];
- return;
- }
- if (_priceStr.length == 0) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品价格不能为空")];
- return;
- }
- else
- {
- NSString *priceRegex = @"^[0-9]+(\\.[0-9]{1,2})?$";
- NSPredicate *priceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",priceRegex];
- if (![priceTest evaluateWithObject:_priceStr]) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请保证输入的商品价格小数点最多两位")];
- return;
- }
- }
- if (_urlStr.length == 0 ) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入网址")];
- return;
- }
- if (self.BuguLive.appModel.open_podcast_goods == 0) {
- if (_expressPriceStr.length == 0) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"快递费不能为空")];
- return;
- }
- else
- {
- [self.editInfo setObject:_expressPriceStr forKey:@"kd_cost"];
- }
- }
-
- if ([self.pictArr containsObject:@"me_addPhoto"] && !_isOTOShop)
- {
- [self.pictArr removeObject:@"me_addPhoto"];
- }
- NSError *parseError = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.pictArr options:NSJSONWritingPrettyPrinted error:&parseError];
- NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [self.editInfo setObject:JSONStr forKey:@"imgs"];
-
- [self.editInfo setObject:_nameStr forKey:@"name"];
- [self.editInfo setObject:_priceStr forKey:@"price"];
- [self.editInfo setObject:_urlStr forKey:@"url"];
- if (_desStr.length>0) {
- [self.editInfo setObject:_desStr forKey:@"description"];
- }
- NSMutableDictionary * editDic = self.editInfo.mutableCopy;
- [editDic setObject:@"shop" forKey:@"itype"];
- [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:editDic SuccessBlock:^(NSDictionary *responseJson) {
- FWStrongify(self)
- [[BGHUDHelper sharedInstance] syncStopLoading];
-
- if ([responseJson toInt:@"status"] == 1)
- {
- [self popVC];
- }
- else
- {
- [self addPhotoWhenFailed];
- }
-
- } FailureBlock:^(NSError *error) {
- FWStrongify(self);
- [[BGHUDHelper sharedInstance] syncStopLoading];
- [self addPhotoWhenFailed];
-
- }];
-
- }
- #pragma mark -- 实体商品发布
- - (void)EntityShoppingEditButton{
- [self.view endEditing:YES];
- [self.entiShopDic setObject:@"shop" forKey:@"ctl"];
- [self.entiShopDic setObject:@"add_goods" forKey:@"act"];
- [self.entiShopDic setObject:[IMAPlatform sharedInstance].host.userId forKey:@"user_id"];
- if (self.pictArr.count == 1 && [_pictArr containsObject:@"me_addPhoto"]) {
- if (_isOTOShop) {
- [FanweMessage alert:ASLocalizedString(@"请上传图片")];
- }
- else
- {
- [FanweMessage alert:ASLocalizedString(@"至少上传一张图片(最多5张)")];
- }
- return;
- }else{
- if (_nameStr.length == 0) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品名称不能为空")];
- return;
- }
- if (_priceStr.length == 0) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品价格不能为空")];
- return;
- }
- else
- {
- NSString *priceRegex = @"^[0-9]+(\\.[0-9]{1,2})?$";
- NSPredicate *priceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",priceRegex];
- if (![priceTest evaluateWithObject:_priceStr]) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请保证输入的商品价格小数点最多两位")];
- return;
- }
- }
- if (_urlStr.length == 0 ) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入网址")];
- return;
- }
- if (self.BuguLive.appModel.open_podcast_goods == 0) {
- if (_expressPriceStr.length == 0 ) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"快递费不能为空")];
- return;
- }
- else
- {
- [self.entiShopDic setObject:_expressPriceStr forKey:@"kd_cost"];
- }
- }
- // if (!_desStr || [_desStr isEqualToString:@""]) {
- // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品描述不能为空")];
- // return;
- // }
-
- if ([self.pictArr containsObject:@"me_addPhoto"] && self.pictArr.count > 1)
- {
- [self.pictArr removeObject:@"me_addPhoto"];
- }
- NSError *parseError = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.pictArr options:NSJSONWritingPrettyPrinted error:&parseError];
- NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [self.entiShopDic setObject:JSONStr forKey:@"imgs"];
-
- [self.entiShopDic setObject:_nameStr forKey:@"name"];
- [self.entiShopDic setObject:_urlStr forKey:@"url"];
- [self.entiShopDic setObject:_priceStr forKey:@"price"];
- if (_desStr.length>0) {
- [self.entiShopDic setObject:_desStr forKey:@"description"];
- }
- NSMutableDictionary * entiDic = self.entiShopDic.mutableCopy;
- [entiDic setObject:@"shop" forKey:@"itype"];
- [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:entiDic SuccessBlock:^(NSDictionary *responseJson) {
- FWStrongify(self)
- [[BGHUDHelper sharedInstance] syncStopLoading];
-
- if ([responseJson toInt:@"status"] == 1)
- {
- [self popVC];
- }
- else
- {
- [self addPhotoWhenFailed];
- }
-
- } FailureBlock:^(NSError *error) {
- FWStrongify(self)
- [[BGHUDHelper sharedInstance] syncStopLoading];
- [self addPhotoWhenFailed];
- }];
- }
- }
- - (void)addPhotoWhenFailed
- {
- if (!_isOTOShop)
- {
- if (![self.pictArr containsObject:@"me_addPhoto"] && self.pictArr.count != 5)
- {
- //[self.pictArr addObject:@"me_addPhoto"];
- [self.pictArr insertObject:@"me_addPhoto" atIndex:0];
- }
- }
- }
- #pragma mark -- 虚拟商品发布
- - (void)releaseEditButton{
- [self.view endEditing:YES];
- [self.shopDic setObject:@"0" forKey:@"is_true"];
- [self.shopDic setObject:@"pai_podcast" forKey:@"ctl"];
- [self.shopDic setObject:@"addpai" forKey:@"act"];
- //提交地理位置
- NSError *parseErr = nil;
- NSMutableDictionary *geoDic = [NSMutableDictionary new];
- if (self.BuguLive.addressJsonStr != nil) {
-
- [geoDic setObject:self.BuguLive.addressJsonStr forKey:@"district"];
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:geoDic options:NSJSONWritingPrettyPrinted error:&parseErr];
- NSString *geograJSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [self.shopDic setObject:geograJSONStr forKey:@"district"];
- }
- if (self.BuguLive.addressJsonStr != nil) {
- [geoDic setObject:self.BuguLive.addressJsonStr forKey:@"district"];
- }
- else if (_keyWordStr.length>0)
- {
- [geoDic setObject:_keyWordStr forKey:@"district"];
- }
- if (geoDic != nil) {
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:geoDic options:NSJSONWritingPrettyPrinted error:&parseErr];
- NSString *geograJSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [self.shopDic setObject:geograJSONStr forKey:@"district"];
- }
- else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入地址")];
- return;
- }
- NSError *parseError1 = nil;
- if (self.pictArr.count == 1 && [self.pictArr containsObject:@"me_addPhoto"]) {
- [FanweMessage alert:ASLocalizedString(@"至少上传一张图片(最多5张)")];
- return;
- }else{
- if (_nameStr.length > 0) {
- [self.shopDic setObject:_nameStr forKey:@"name"];
- }
- else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入商品名称")];
- return;
- }
-
- if (_contactStr.length > 0) {
- [self.shopDic setObject:_contactStr forKey:@"contact"];
- }
- else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入联系人姓名")];
- return;
- }
-
- if (_mobileStr.length > 0) {
- if (_mobileStr.length < 1) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手机号限制11位数!")];
- return;
- }
- [self.shopDic setObject:_mobileStr forKey:@"mobile"];
- }
- else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入电话号码")];
- return;
- }
-
- if (_qpPriceStr.length < 1 ||[_qpPriceStr integerValue]== 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍起拍价格不能为空或0")];
- return;
- }
- [self.shopDic setObject:_qpPriceStr forKey:@"qp_diamonds"];
-
- if (_bzStr.length < 1||[_bzStr integerValue]== 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍保证金不能为空或0")];
- return;
- }
-
- [self.shopDic setObject:_bzStr forKey:@"bz_diamonds"];
-
- if (_addPriceStr.length < 1 || [_addPriceStr integerValue]== 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"加价幅度不能为空或0")];
- return;
- }
- [self.shopDic setObject:_addPriceStr forKey:@"jj_diamonds"];
- if (_auctionTimeStr.floatValue < 24 && _auctionTimeStr.floatValue >0) {
-
- [self.shopDic setObject:_auctionTimeStr forKey:@"pai_time"];
- }
- else{
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入有效的竞拍时间")];
- return;
- }
- if (_delayTimeStr.integerValue < 60 && _delayTimeStr.integerValue >0)
- {
-
- [self.shopDic setObject:_delayTimeStr forKey:@"pai_yanshi"];
- }else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时值")];
- return;
- }
- if ([_maxDelayTimeStr integerValue ]< 10 && [_maxDelayTimeStr length]>0 && [_maxDelayTimeStr integerValue ]>=0)
- {
-
- [self.shopDic setObject:_maxDelayTimeStr forKey:@"max_yanshi"];
-
- }else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入最大延时")];
- return;
- }
-
- if (_desStr.length > 0) {
- [self.shopDic setObject:_desStr forKey:@"description"];
- }
- else
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"描述不能为空")];
- return;
- }
-
-
- if ([self.pictArr containsObject:@"me_addPhoto"] && self.pictArr.count > 1)
- {
- [self.pictArr removeObject:@"me_addPhoto"];
- }
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.pictArr options:NSJSONWritingPrettyPrinted error:&parseError1];
- NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [self.shopDic setObject:JSONStr forKey:@"imgs"];
-
- [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
- NSMutableDictionary * shopdic = self.shopDic.mutableCopy;
- [shopdic setObject:@"shop" forKey:@"itype"];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:shopdic SuccessBlock:^(NSDictionary *responseJson) {
- FWStrongify(self)
- [[BGHUDHelper sharedInstance] syncStopLoading];
-
- if ([responseJson toInt:@"status"] == 1)
- {
- [self popVC];
- if (_delegate && [_delegate respondsToSelector:@selector(onReleaseVCAuctionId:)])
- {
- [_delegate onReleaseVCAuctionId:[responseJson toInt:@"pai_id"]];
- }
- }
- else
- {
- [self addPhotoWhenFailed];
- if (![responseJson[@"error"] isEqualToString:@""])
- {
- if ([[responseJson toString:@"error"] rangeOfString:ASLocalizedString(@"直播间已关闭")].location != NSNotFound)
- {
- [self popVC];
- }
- }
- }
-
- } FailureBlock:^(NSError *error) {
- FWStrongify(self)
- [self addPhotoWhenFailed];
-
- }];
- }
- }
- #pragma mark -- 实物竞拍商品发布
- - (void)releaseButton{
- [self.view endEditing:YES];
-
- if ([BGUtils isBlankString:_bzStr]) {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍保证金")];
- return;
- }
- if (_addPriceStr.length == 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入加价幅度")];
- return;
- }
- if (_auctionTimeStr.length == 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍时间")];
- return;
- }
- if (_delayTimeStr.length == 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时时间")];
- return;
- }
- if (_maxDelayTimeStr.length == 0)
- {
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入最大延时")];
- return;
- }
- NSError *parseError1 = nil;
- [self.shopDic setObject:@"1" forKey:@"is_true"];
- [self.shopDic setObject:@"pai_podcast" forKey:@"ctl"];
- [self.shopDic setObject:@"addpai" forKey:@"act"];
- [self.shopDic setObject:_auctionGoodsModel.goodsId forKey:@"goods_id"];
- [self.shopDic setObject:_auctionGoodsModel.price forKey:@"qp_diamonds"];
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:_auctionGoodsModel.imgs options:NSJSONWritingPrettyPrinted error:&parseError1];
- NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [self.shopDic setObject:JSONStr forKey:@"imgs"];
- [self.shopDic setObject:_auctionGoodsModel.name forKey:@"name"];
- if (_auctionGoodsModel.descStr.length>0) {
- [self.shopDic setObject:_auctionGoodsModel.descStr forKey:@"description"];
- }
- if (_entityAuctionModel.shop_id.length > 0)
- {
- [self.shopDic setObject:_entityAuctionModel.shop_id forKey:@"shop_id"];
- }
- if (_entityAuctionModel.shop_name.length > 0)
- {
- [self.shopDic setObject:_entityAuctionModel.shop_name forKey:@"shop_name"];
- }
-
- if (_auctionTimeStr.floatValue < 24 && _auctionTimeStr.floatValue >0) {
-
- [self.shopDic setObject:_auctionTimeStr forKey:@"pai_time"];
- }
- else{
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入有效的竞拍时间")];
- return;
- }
- if (_delayTimeStr.integerValue < 60 && _delayTimeStr.integerValue >0) {
-
- [self.shopDic setObject:_delayTimeStr forKey:@"pai_yanshi"];
- }
- if ([_maxDelayTimeStr integerValue ]< 10 && [_maxDelayTimeStr integerValue ]>=0) {
-
- [self.shopDic setObject:_maxDelayTimeStr forKey:@"max_yanshi"];
- }
-
- NSMutableDictionary * dic = self.shopDic.mutableCopy;
- [dic setObject:@"shop" forKey:@"itype"];
- [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
- FWWeakify(self)
- [self.httpsManager POSTWithParameters:dic SuccessBlock:^(NSDictionary *responseJson) {
- FWStrongify(self)
- [[BGHUDHelper sharedInstance] syncStopLoading];
-
- if ([responseJson toInt:@"status"] == 1)
- {
- [self popVC];
- if (_delegate && [_delegate respondsToSelector:@selector(onReleaseVCAuctionId:)])
- {
- [_delegate onReleaseVCAuctionId:[responseJson toInt:@"pai_id"]];
- }
- }
- else
- {
- if (![responseJson[@"error"] isEqualToString:@""])
- {
- [[BGHUDHelper sharedInstance] syncStopLoading];
- if ([[responseJson toString:@"error"] rangeOfString:ASLocalizedString(@"直播间已关闭")].location != NSNotFound)
- {
- [self popVC];
- }
- }
- }
-
- } FailureBlock:^(NSError *error) {
-
- }];
- }
- #pragma mark -- 标签的代理点击事件
- - (void)handleWithGoodsTag:(NSString *)goodsTag
- {
- if (goodsTag.length > 0)
- {
- [self.shopDic setObject:goodsTag forKey:@"tags"];
- }
- }
- #pragma mark -- 点击增加图片的代理方法
- - (void)handleToTapPhoto:(UITapGestureRecognizer *)tap{
- self.addPhoto = (UIImageView *)tap.view;
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
- {
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- picker.delegate = self;
- picker.allowsEditing = YES;
- picker.modalPresentationStyle = UIModalPresentationFullScreen;
- }
- [self presentViewController:picker animated:YES completion:nil];
- // UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
- //// [headImgSheet addButtonWithTitle:ASLocalizedString(@"相机")];
- // [headImgSheet addButtonWithTitle:ASLocalizedString(@"从手机相册选择")];
- // [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
- // headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
- // headImgSheet.delegate = self;
- // [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
- }
- - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- {
-
- if (buttonIndex == 0)
- {
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
- {
- picker.sourceType = UIImagePickerControllerSourceTypeCamera;
- picker.delegate = self;
- picker.allowsEditing = YES;
- picker.modalTransitionStyle = UIModalPresentationFullScreen;
- }
- [self presentViewController:picker animated:YES completion:nil];
- }else if (buttonIndex == 1){
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
- {
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- picker.delegate = self;
- picker.allowsEditing = YES;
- picker.modalPresentationStyle = UIModalPresentationFullScreen;
- }
- [self presentViewController:picker animated:YES completion:nil];
-
- }
- }
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
-
- NSString *mediaType = [info objectForKey:UIImagePickerControllerEditedImage];
-
- if (mediaType){
- UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
- if (!image)
- {
- image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
- }
- // if (self.BuguLive.appModel.open_sts == 1)
- // {
- // if ([_ossManager isSetRightParameter])
- // {
- // [self saveImage:image withName:@"1.png"];
- // _timeString = [_ossManager getObjectKeyString];
- // [_ossManager asyncPutImage:_timeString localFilePath:_uploadFilePath];
- // }
- // }else{
- UIImage *img = [info objectForKey:UIImagePickerControllerEditedImage];
- NSString *nameImage = [NSString stringWithFormat:@"currentImage%ld.jpg",self.addPhoto.tag];
- [self saveImage:img withName:nameImage];
- NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:nameImage];
- NSURL *fileUrl = [NSURL URLWithString:[NSString stringWithFormat:@"file:%@",fullPath]];
- [self pictureToNet:fileUrl];
-
- // }
- }
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark -- 上传图片
- //- (void)uploadImageWithUrlStr:(NSString *)imageUrlStr withUploadStateCount:(int)stateCount
- //{
- // if (stateCount == 0)
- // {
- // NSString *urlString = [NSString stringWithFormat:@"%@%@",_ossManager.oss_domain,_timeString];
- // NSLog(@"%@",urlString);
- // //#if kSupportAuction
- // // [imgdict addObject:urlString];
- // // NSLog(@"%@",imgdict);
- //
- // //#endif
- // if (self.isOTOShop)
- // {
- // if (self.addPhoto.tag < self.pictArr.count - 1 ) {//替换---已存在图片情况下
- // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:urlString];
- // }
- // else
- // {
- // [self.pictArr insertObject:urlString atIndex:self.pictArr.count - 1];
- // }
- // }
- // else
- // {
- // if (self.addPhoto.tag < self.pictArr.count - 1 && self.addPhoto.tag > 0) {//替换---已存在图片情况下
- // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:urlString];
- // }
- // else if (self.addPhoto.tag == 0 && self.pictArr.count == 5)
- // {
- // if ([self.pictArr.firstObject isEqual:@"me_addPhoto"])
- // {
- // [self.pictArr addObject:urlString];
- // [self.pictArr removeObject:@"me_addPhoto"];
- // }
- // else
- // {
- // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:urlString];
- // }
- // }
- // else{//增加
- // [self.pictArr addObject:urlString];
- // //[self.pictArr insertObject:urlString atIndex:self.pictArr.count - 1];
- // }
- // }
- // [self.headerView getPicturearr:self.pictArr block:^{
- // [self.headerView.getPhotoCollection reloadData];
- // }];
- // }else
- // {
- // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"上传头像失败")];
- // }
- // //#if kSupportH5Shopping
- // // if ([self.shopType isEqualToString:@"EditShopping"]){
- // // [_entiShopDic setObject:urlString forKey:[NSString stringWithFormat:@"%ld",self.addPhoto.tag]];
- // //
- // // }else{
- // // [self.pictArr addObject:urlString];
- // // }
- // //#endif
- //
- //}
- #pragma mark -- 文件流上传图片
- - (void)pictureToNet:(NSURL *)pictureUrl
- {
- [[BGHUDHelper sharedInstance] syncLoading:nil];
-
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"pai_podcast" forKey:@"ctl"];
- [parmDict setObject:@"upload" forKey:@"act"];
- [parmDict setObject:[IMAPlatform sharedInstance].host.userId forKey:@"id"];
-
- [[NetHttpsManager manager] POSTWithDict:parmDict andFileUrl:pictureUrl SuccessBlock:^(NSDictionary *responseJson) {
-
- if ([responseJson toInt:@"status"] == 1)
- {
- NSLog(@"%@",self.pictArr);
- NSString * pictStr = [responseJson toString:@"server_full_path"];
- if (self.isOTOShop)
- {
- if (self.addPhoto.tag < self.pictArr.count - 1 ) {//替换---已存在图片情况下
- [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
- }
- else
- {
- //[self.pictArr addObject:pictStr];
- [self.pictArr insertObject:pictStr atIndex:self.pictArr.count - 1];
- }
- }
- else
- {
- if (self.addPhoto.tag < self.pictArr.count - 1 && self.addPhoto.tag > 0) {//替换---已存在图片情况下
- [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
- }
- else if (self.addPhoto.tag == 0 && self.pictArr.count == 5)
- {
- if ([self.pictArr.firstObject isEqual:@"me_addPhoto"])
- {
- [self.pictArr addObject:pictStr];
- [self.pictArr removeObject:@"me_addPhoto"];
- }
- else
- {
- [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
- }
- // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
- }
- else{//增加
- [self.pictArr addObject:pictStr];
- //[self.pictArr insertObject:urlString atIndex:self.pictArr.count - 1];
- }
- }
- // if (self.addPhoto.tag < self.pictArr.count - 1 && self.addPhoto.tag > 0)
- // { // 替换---已存在图片情况下
- // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:[responseJson toString:@"server_full_path"]];
- // }
- // else
- // { // 增加
- // if (self.isOTOShop)
- // {
- // [self.pictArr insertObject:[responseJson toString:@"server_full_path"] atIndex:self.pictArr.count - 1];
- // }
- // else
- // {
- // [self.pictArr addObject:[responseJson toString:@"server_full_path"]];
- // }
- // //[self.pictArr insertObject:[responseJson toString:@"server_full_path"] atIndex:self.pictArr.count - 1];
- // //[self.pictArr addObject:[responseJson toString:@"server_full_path"]];
- // }
- [self.headerView getPicturearr:self.pictArr block:^{
- [self.headerView.getPhotoCollection reloadData];
- }];
- [[BGHUDHelper sharedInstance] syncStopLoading];
- }
-
- [[BGHUDHelper sharedInstance] syncStopLoading];
-
- } FailureBlock:^(NSError *error) {
-
- [[BGHUDHelper sharedInstance] tipMessage:[NSString stringWithFormat:@"%@",error]];
- [[BGHUDHelper sharedInstance] syncStopLoading];
-
- }];
- }
- #pragma mark - 保存图片至沙盒
- - (void) saveImage:(UIImage *)currentImage withName:(NSString *)imageName{
- NSData *imageData = UIImageJPEGRepresentation(currentImage, 0.5);
- NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
- _uploadFilePath = fullPath;
- [imageData writeToFile:fullPath atomically:NO];
- }
- - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark - 返回上一级
- - (void)returnToMeVc
- {
- NSString * str;
- if (_isOTOShop )
- {
- if ([self.shopType isEqualToString:@"EditShopping"])
- {
- str = ASLocalizedString(@"确定放弃修改商品信息?");
- }
- else if ([self.shopType isEqualToString:@"EntityShopping"])
- {
- str = ASLocalizedString(@"确定放弃新增商品?");
- }
- }
- else
- {
- str = ASLocalizedString(@"确定放弃新增竞拍商品?");
- }
-
- FWWeakify(self)
- [FanweMessage alert:nil message:str destructiveAction:^{
-
- FWStrongify(self)
- #if kSupportAuction
- [self.navigationController setNavigationBarHidden:YES animated:YES];
- #endif
-
- #if kSupportH5Shopping
-
- #endif
- [self popVC];
-
- } cancelAction:^{
-
- }];
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- if ([self.shopType isEqualToString:@"VirtualShopping"])
- {
- return 5;
- }
- else
- {
- return 2;
- }
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- #pragma mark --- 虚拟商品返回分区行数
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
- switch (section) {
- case 0:
- {
- return 1;
- }
- break;
- case 1:
- {
- return 4;
- }
- break;
- case 2:
- {
- return 3;
- }
- break;
- case 3:
- {
- return 3;
- }
- break;
- case 4:
- {
- return 1;
- }
- break;
-
- default:
- break;
- }
-
- }
- #pragma mark --- 实物竞拍返回分区行数
- else if([self.shopType isEqualToString:@"EntityAuctionShopping"])
- {
- switch (section) {
- case 0:
- {
- return 2;
- }
- break;
- case 1:
- {
- return 3;
- }
- break;
- default:
- break;
- }
- }
- //O2T
- else{
- #pragma mark --- 实物商品返回分区行数
- switch (section) {
- case 0:
- {
- if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop) {
- return 3;
- }
- return 4;
- }
- break;
- case 1:
- {
- return 1;
- }
- break;
- default:
- break;
- }
- }
- return 0;
- }
- #pragma mark -- 返回区头的高度
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- if ([self.shopType isEqualToString:@"EntityAuctionShopping"])
- {
- return 0.1f;
- }
- else if (section == 0) {
- return 16.0f;
- }
- return 0.1f;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- #pragma mark --- 虚拟商品返回cell
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {//虚拟商品
- if (indexPath.section == 4) {
- //拍品描述
- CdescriptTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"desCell" forIndexPath:indexPath];
- cell.desTextView.delegate = self;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell.desTextView addSubview:self.placehoderLabel];
- return cell;
- }else if (indexPath.section == 3){
-
- NSArray *aTitle = @[ASLocalizedString(@"竞拍时间"),ASLocalizedString(@"延时值"),ASLocalizedString(@"最大延时")];
- NSArray *timeN = @[ASLocalizedString(@"小时"),ASLocalizedString(@"分钟"),ASLocalizedString(@"次")];
- TimeTableViewCell *timeCell = [tableView dequeueReusableCellWithIdentifier:@"timeCell" forIndexPath:indexPath];
- timeCell.textField.delegate = self;
- [timeCell.textField addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
- timeCell.nameLable.text = aTitle[indexPath.row];
- timeCell.twoLable.text = timeN[indexPath.row];
- timeCell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (indexPath.row == 0) {
- timeCell.textField.keyboardType = UIKeyboardTypeDecimalPad;
- timeCell.textField.tag = 6;
- if (_fistTime) {
- timeCell.textField.text = @"0.3";
- _auctionTimeStr = timeCell.textField.text;
- [self.shopDic setObject:timeCell.textField.text forKey:@"pai_time"];
- }
- }else if (indexPath.row == 1){
- timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
- timeCell.textField.tag = 7;
- if (_fistDelay) {
- timeCell.textField.text = @"3";
- _delayTimeStr = timeCell.textField.text;
- [self.shopDic setObject:timeCell.textField.text forKey:@"pai_yanshi"];
- }
- }else{
- timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
- timeCell.textField.tag = 8;
- if (_fistMax) {
- timeCell.textField.text = @"3";
- _maxDelayTimeStr = timeCell.textField.text;
- [self.shopDic setObject:timeCell.textField.text forKey:@"max_yanshi"];
- }
- }
- return timeCell;
- }else{
- BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.text_field.delegate = self;
- [cell.text_field addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
- if (indexPath.section == 0 ) {
- cell.nameL.text = ASLocalizedString(@"拍品名称");
- cell.text_field.tag = 0;
- cell.text_field.placeholder = ASLocalizedString(@"请输入拍品名称");
- }else if (indexPath.section == 1){
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (indexPath.row == 0) {
- cell.nameL.text = ASLocalizedString(@"约会时间");
- cell.text_field.text = ASLocalizedString(@"2016年7月18日 18 : 00");
- cell.text_field.enabled = NO;
- cell.text_field.placeholder = ASLocalizedString(@"点击选择约会时间");
- cell.text_field.text = self.textData;
- }else{
- NSArray *arr = @[ASLocalizedString(@"约会地点"),ASLocalizedString(@"联系人"),ASLocalizedString(@"联系电话")];
- NSArray *placeText = @[ASLocalizedString(@"点击设置约会地点"),ASLocalizedString(@"预置主播昵称"),ASLocalizedString(@"预置主播手机号")];
- cell.text_field.placeholder = placeText[indexPath.row - 1];
- cell.nameL.text = arr[indexPath.row - 1];
- // cell.text_field.clearsOnBeginEditing = YES;
- if (indexPath.row == 1) {
- cell.text_field.enabled = NO;
- if (_keyWordStr != nil && ![_keyWordStr isEqualToString:@""]) {
- cell.text_field.text = _keyWordStr;
- [self.shopDic setObject:cell.text_field.text forKey:@"place"];
- }else{
- if (self.BuguLive.locateName != nil && ![self.BuguLive.locateName isEqualToString:@""]) {
- cell.text_field.text = [NSString stringWithFormat:@"%@",self.BuguLive.locateName];
- [self.shopDic setObject:cell.text_field.text forKey:@"place"];
- }else{
- cell.text_field.text = ASLocalizedString(@"定位中。。。");
- // [FanweMessage alert:ASLocalizedString(@"请在设置->隐私->定位服务->本App下选择使用期间")];
- }
-
- }
- }else if (indexPath.row == 2){
- cell.text_field.tag = 1;
- }else{
- cell.text_field.tag = 2;
- cell.text_field.keyboardType = UIKeyboardTypeNumberPad;
- }
- }
- }else {
- // NSArray *placeText = @[ASLocalizedString(@"请输入起拍价"),ASLocalizedString(@"请输入保证金额度"),ASLocalizedString(@"请输入加价幅度")];
- NSArray *titleArr = @[ASLocalizedString(@"起拍价"),ASLocalizedString(@"保证金"),ASLocalizedString(@"加价幅度")];
- // cell.text_field.placeholder = placeText[indexPath.row];
- cell.nameL.text = titleArr[indexPath.row];
- if (indexPath.row == 0) {
- cell.text_field.tag = 3;
- cell.text_field.text = @"100";
- _qpPriceStr = cell.text_field.text;
- [self.shopDic setObject:cell.text_field.text forKey:@"qp_diamonds"];
- }else if (indexPath.row == 1){
- cell.text_field.tag = 4;
- cell.text_field.text = @"100";
- _bzStr = cell.text_field.text;
- [self.shopDic setObject:cell.text_field.text forKey:@"bz_diamonds"];
- }else{
- cell.text_field.tag = 5;
- cell.text_field.text = @"30";
- _addPriceStr = cell.text_field.text;
- [self.shopDic setObject:cell.text_field.text forKey:@"jj_diamonds"];
- }
- cell.text_field.keyboardType = UIKeyboardTypeNumberPad;
-
- }
-
- return cell;
- }
- }
- else if ([self.shopType isEqualToString:@"EntityAuctionShopping"]) {
- if (indexPath.section==0) {
- BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.text_field.delegate = self;
- [cell.text_field addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
- // NSArray *placeText = @[ASLocalizedString(@"请输入保证金额度"),ASLocalizedString(@"请输入加价幅度")];
- NSArray *titleArr = @[ASLocalizedString(@"保证金"),ASLocalizedString(@"加价幅度")];
- // cell.text_field.placeholder = placeText[indexPath.row];
- cell.nameL.text = titleArr[indexPath.row];
- if (indexPath.row == 0) {
- cell.text_field.tag = 14;
- // cell.text_field.placeholder = @"100";
- // if ([cell.text_field.text isEqualToString:@""]) {
- // _bzStr = cell.text_field.placeholder;
- // [self.shopDic setObject:_bzStr forKey:@"bz_diamonds"];
- // }
- if (self.entityAuctionModel.bz_diamonds != nil) {
- cell.text_field.text = self.entityAuctionModel.bz_diamonds;
- cell.text_field.enabled = NO;
- if (![cell.text_field.text isEqualToString:@""]) {
- _bzStr = cell.text_field.text;
- [self.shopDic setObject:_bzStr forKey:@"bz_diamonds"];
- }
-
- }
- }else if (indexPath.row == 1){
- cell.text_field.tag = 15;
- // cell.text_field.placeholder = @"30";
- // if ([cell.text_field.text isEqualToString:@""]) {
- // _addPriceStr = cell.text_field.placeholder;
- // [self.shopDic setObject:_addPriceStr forKey:@"jj_diamonds"];
- // }
- if (self.entityAuctionModel.jj_diamonds != nil) {
- cell.text_field.text = self.entityAuctionModel.jj_diamonds;
- cell.text_field.enabled = NO;
- if (![cell.text_field.text isEqualToString:@""]) {
- _addPriceStr = cell.text_field.text;
- [self.shopDic setObject:_addPriceStr forKey:@"jj_diamonds"];
- }
- }
- }
- cell.text_field.keyboardType = UIKeyboardTypeNumberPad;
- return cell;
- }
- else
- {
- NSArray *aTitle = @[ASLocalizedString(@"竞拍时间"),ASLocalizedString(@"延时值"),ASLocalizedString(@"最大延时")];
- NSArray *timeN = @[ASLocalizedString(@"小时"),ASLocalizedString(@"分钟"),ASLocalizedString(@"次")];
- TimeTableViewCell *timeCell = [tableView dequeueReusableCellWithIdentifier:@"timeCell" forIndexPath:indexPath];
- timeCell.textField.delegate = self;
- [timeCell.textField addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
- timeCell.nameLable.text = aTitle[indexPath.row];
- timeCell.twoLable.text = timeN[indexPath.row];
- timeCell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (indexPath.row == 0) {
- timeCell.textField.keyboardType = UIKeyboardTypeDecimalPad;
- timeCell.textField.tag = 16;
- if (_fistTime) {
- timeCell.textField.placeholder = @"0.3";
- [self.shopDic setObject:timeCell.textField.placeholder forKey:@"pai_time"];
- }
- // timeCell.textField.placeholder = @"1";
- if (self.entityAuctionModel.pai_time != nil) {
- timeCell.textField.placeholder = self.entityAuctionModel.pai_time;
- if(![timeCell.textField.placeholder isEqualToString:@""]){
- _auctionTimeStr = timeCell.textField.placeholder;
- [self.shopDic setObject:_auctionTimeStr forKey:@"pai_time"];
- }
- }
- }else if (indexPath.row == 1){
- timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
- timeCell.textField.tag = 17;
- if (_fistDelay) {
-
- timeCell.textField.placeholder = @"3";
- [self.shopDic setObject:timeCell.textField.placeholder forKey:@"pai_yanshi"];
- }
- // timeCell.textField.placeholder = @"30";
- if (self.entityAuctionModel.pai_yanshi != nil) {
- timeCell.textField.placeholder = self.entityAuctionModel.pai_yanshi;
- if (![timeCell.textField.placeholder isEqualToString:@""]) {
- _delayTimeStr = timeCell.textField.placeholder;
- [self.shopDic setObject:_delayTimeStr forKey:@"pai_yanshi"];
- }
- }
- }else{
- timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
- timeCell.textField.tag = 18;
- if (_fistMax) {
- timeCell.textField.placeholder = @"3";
- [self.shopDic setObject:timeCell.textField.placeholder forKey:@"max_yanshi"];
- }
- // timeCell.textField.placeholder = @"3";
- if (self.entityAuctionModel.max_yanshi != nil) {
- timeCell.textField.placeholder = self.entityAuctionModel.max_yanshi;
- if (![timeCell.textField.placeholder isEqualToString:@""]) {
- _maxDelayTimeStr = timeCell.textField.placeholder;
- [self.shopDic setObject:_maxDelayTimeStr forKey:@"max_yanshi"];
- }
- }
- }
- return timeCell;
- }
- }
- else{
- #pragma mark --- 实体商品返回cell
- if (indexPath.section == 0) {
- BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.text_field.delegate = self;
- [cell.text_field addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
- NSArray *titleArr;
- if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop) {
- titleArr = @[ASLocalizedString(@"商品名称"),ASLocalizedString(@"商品价钱"),ASLocalizedString(@"商品链接")];
- }
- else
- {
- titleArr = @[ASLocalizedString(@"商品名称"),ASLocalizedString(@"商品价钱"),ASLocalizedString(@"商品链接"),ASLocalizedString(@"快递费")];
- }
- if ([self.shopType isEqualToString:@"EditShopping"]){
- cell.nameL.text = titleArr[indexPath.row];
- cell.text_field.placeholder = self.editArr[indexPath.row];
- cell.text_field.text = self.editArr[indexPath.row];
- }else{
- NSArray *pholderArr = @[ASLocalizedString(@"请输入商品名称"),ASLocalizedString(@"请输入商品价钱(最多两位小数)"),ASLocalizedString(@"请输入商品链接"),ASLocalizedString(@"请输入快递费")];
- cell.nameL.text = titleArr[indexPath.row];
- cell.text_field.placeholder = pholderArr[indexPath.row];
- }
- if (indexPath.row == 0) {
- cell.text_field.tag = 10;//商品名称
- }else if (indexPath.row == 1){
- cell.text_field.tag = 11;//商品价钱
- cell.text_field.keyboardType = UIKeyboardTypeDecimalPad;
- }else if (indexPath.row == 2){
- cell.text_field.tag = 12;//商品链接
- if ([self.shopType isEqualToString:@"EntityShopping"]) {
- if (!_isOTOShop) {
- cell.text_field.text = @"http://";
- }
- }
- else if ([self.shopType isEqualToString:@"EditShopping"])
- {
- cell.text_field.text = self.model.url;
- _urlString = cell.text_field.text;
- }
- }else if (indexPath.row == 3){
- cell.text_field.keyboardType = UIKeyboardTypeDecimalPad;
- cell.text_field.tag = 13;//商品快递费
- }
- return cell;
- }else{
- //实体拍品描述
- CdescriptTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"desCell" forIndexPath:indexPath];
- cell.shopCdescriptLable.text = ASLocalizedString(@"商品描述");
- cell.desTextView.delegate = self;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if ([self.shopType isEqualToString:@"EditShopping"]){
- cell.desTextView.text = self.model.descrStr;
- }
- [cell.desTextView addSubview:self.placehoderLabel];
- return cell;
-
- }
- }
- }
- - (void)changeTextField:(UITextField *)textField
- {
- switch (textField.tag) {
- case 0:
- {
- if (textField.text.length >= 30)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于30个字符的名称")];
- NSString *s = [textField.text substringToIndex:30];
- textField.text = s;
- }
- _nameStr = textField.text;
- }
- break;
- case 1:
- {
- _contactStr = textField.text;
- }
- break;
- case 2:
- {
- _mobileStr = textField.text;
- }
- break;
- case 3:
- {
- _qpPriceStr = textField.text;
- }
- break;
- case 4:
- {
- _bzStr = textField.text;
- }
- break;
- case 5:
- {
- _addPriceStr = textField.text;
- }
- break;
- case 6:
- {
- _auctionTimeStr = textField.text;
- }
- break;
- case 7:
- {
- _delayTimeStr = textField.text;
- }
- break;
- case 8:
- {
- _maxDelayTimeStr = textField.text;
- }
- break;
- case 9:
- {
-
- }
- break;
- case 10:
- {
- _nameStr = textField.text;
- }
- break;
- case 11:
- {
- _priceStr = textField.text;
- }
- break;
- case 12:
- {
- _urlStr = textField.text;
- }
- break;
- case 13:
- {
- _expressPriceStr = textField.text;
- }
- break;
- case 14:
- {
- _bzStr = textField.text;
- }
- break;
- case 15:
- {
- _addPriceStr = textField.text;
- }
- break;
- case 16:
- {
- _auctionTimeStr = textField.text;
- }
- break;
- case 17:
- {
- _delayTimeStr = textField.text;
- }
- break;
- case 18:
- {
- _maxDelayTimeStr = textField.text;
- }
- break;
- default:
- break;
- }
- }
- - (void)chooseAddress:(CLLocationCoordinate2D)location address:(NSString *)address andProvinceString:(NSString *)provinceString andCityString:(NSString *)cityString andAreaString:(NSString *)areaString
- {
- self.keyWordStr = address;
- [self.releaseTabView reloadData];
- }
- - (void)textViewDidChange:(UITextView *)textView
- {
- _desStr = textView.text;
- }
- - (void)textViewDidEndEditing:(UITextView *)textView{
- if (textView.text.length > 0) {
- _desStr = textView.text;
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
- [self.shopDic setObject:textView.text forKey:@"description"];
- }
- else{
- [self.entiShopDic setObject:textView.text forKey:@"description"];
- [self.editInfo setObject:textView.text forKey:@"description"];
- }
- }
- }
- - (void)textFieldDidEndEditing:(UITextField *)textField{
- #pragma mark --- 虚拟商品输入框设置
- switch (textField.tag) {
- case 0:
- {
- if (textField.text.length >= 30)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于30个字符的名称")];
- NSString *s = [textField.text substringToIndex:30];
- textField.text = s;
- }
- [self.shopDic setObject:textField.text forKey:@"name"];
- _nameStr = textField.text;
- }
- break;
- case 1:
- {
-
- [self.shopDic setObject:textField.text forKey:@"contact"];
- _contactStr = textField.text;
- }
- break;
- case 2:
- {
- if (textField.text.length < 1)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入电话号码")];
- return;
- }
-
- if (textField.text.length < 1) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手机号限制11位数!")];
- return;
- }
-
- [self.shopDic setObject:textField.text forKey:@"mobile"];
- _mobileStr = textField.text;
- }
- break;
- case 3:
- {
- if (textField.text.length < 1 ||[textField.text integerValue]== 0)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍起拍价格不能为空或0")];
- return;
- }
-
- [self.shopDic setObject:textField.text forKey:@"qp_diamonds"];
-
- _qpPriceStr = textField.text;
- }
- break;
- case 4:
- {
- if (textField.text.length < 1||[textField.text integerValue]== 0)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍保证金不能为空或0")];
- return;
- }
-
- [self.shopDic setObject:textField.text forKey:@"bz_diamonds"];
-
- _bzStr = textField.text;
- }
- break;
- case 5:
- {
- if (textField.text.length < 1 || [textField.text integerValue]== 0)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"加价幅度不能为空或0")];
- return;
- }
- [self.shopDic setObject:textField.text forKey:@"jj_diamonds"];
- _addPriceStr = textField.text;
-
- }
- break;
- case 6:
- {
- _fistTime = NO;
- BOOL num = false ;
- if ([textField.text floatValue] >= 0.0) {
- num = YES;
- }
- if ([textField.text isEqualToString:@"0"] || [textField.text isEqualToString:@""] || num == false ||(textField.text.length > 2 && [textField.text hasSuffix:@"."])||(textField.text.length > 0 && [textField.text hasPrefix:@"."])) {
- textField.text =@"";
- }
-
- if (textField.text.floatValue < 24 && textField.text.floatValue >0) {
-
- [self.shopDic setObject:textField.text forKey:@"pai_time"];
- }else{
- textField.text =@"";
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍时间")];
- }
- _auctionTimeStr = textField.text;
- }
- break;
- case 7:
- {
- _fistDelay = NO;
- if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1) ||(textField.text.length > 1 && [textField.text hasPrefix: @"0"])) {
- textField.text =@"";
- }
-
- if (textField.text.integerValue < 60 && textField.text.integerValue >0) {
-
- [self.shopDic setObject:textField.text forKey:@"pai_yanshi"];
-
- }else{
- textField.text =@"";
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入最大延时时间")];
- }
- _delayTimeStr = textField.text;
-
- }
- break;
- case 8:
- {
- _fistMax = NO;
- if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1)
- || (textField.text.length > 2 && [textField.text hasPrefix: @"0"])) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
- textField.text =@"";
- }
- if (textField.text.integerValue < 10 && textField.text.integerValue >=0) {
-
- [self.shopDic setObject:textField.text forKey:@"max_yanshi"];
- }else{
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
- textField.text =@"";
- }
- _maxDelayTimeStr = textField.text;
- }
- break;
- case 10:
- {
- if (textField.text.length < 1)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入商品名称")];
- return;
- }
- if ([self.shopType isEqualToString:@"EditShopping"]){
-
- [self.editInfo setObject:textField.text forKey:@"name"];
- }else{
-
- [self.entiShopDic setObject:textField.text forKey:@"name"];
- }
- _nameStr = textField.text;
- }
- break;
- case 11:
- {
- if (textField.text.length < 1)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入商品价格")];
- _priceStr = @"";
- return;
- }
- NSString *priceRegex = @"^[0-9]+(\\.[0-9]{1,2})?$";
- NSPredicate *priceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",priceRegex];
- if (![priceTest evaluateWithObject:textField.text]) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请保证输入的商品价格小数点最多两位")];
- return;
- }
- if ([self.shopType isEqualToString:@"EditShopping"]){
-
- [self.editInfo setObject:textField.text forKey:@"price"];
- }else{
-
- [self.entiShopDic setObject:textField.text forKey:@"price"];
- }
- _priceStr = textField.text;
- }
- break;
- case 12:
- {
- if ([self.shopType isEqualToString:@"EditShopping"]){
- [self.editInfo setObject:textField.text forKey:@"url"];
- }else{
- [self.entiShopDic setObject:textField.text forKey:@"url"];
- }
- _urlStr = textField.text;
- }
- break;
- case 13:
- {
- if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop) {
- return;
- }
- _expressPriceStr = textField.text;
- if (textField.text.length < 1)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入快递费")];
- return;
- }
- if ([self.shopType isEqualToString:@"EditShopping"]){
-
- [self.editInfo setObject:textField.text forKey:@"kd_cost"];
- }else{
-
- [self.entiShopDic setObject:textField.text forKey:@"kd_cost"];
- }
- _expressPriceStr = textField.text;
- }
- break;
- case 14:
- {
- if (textField.text.length < 1||[textField.text integerValue]== 0)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍保证金不能为空或0")];
-
- textField.text=@"";
- }
- else
- {
- [self.shopDic setObject:textField.text forKey:@"bz_diamonds"];
- }
- _bzStr = textField.text;
- }
- break;
- case 15:
- {
- if (textField.text.length < 1 || [textField.text integerValue]== 0)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"加价幅度不能为空或0")];
- textField.text=@"";
- }
- else
- {
- [self.shopDic setObject:textField.text forKey:@"jj_diamonds"];
- }
- _addPriceStr = textField.text;
- }
- break;
- case 16:
- {
- BOOL num = false ;
- if ([textField.text floatValue] >= 0.0) {
- num = YES;
- }
- if ([textField.text isEqualToString:@"0"] || [textField.text isEqualToString:@""] || num == false ||(textField.text.length > 2 && [textField.text hasSuffix:@"."])||(textField.text.length > 0 && [textField.text hasPrefix:@"."])) {
- //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于24的合法字符")];
- textField.text =@"";
- }
-
- if (textField.text.floatValue < 24 && textField.text.floatValue >0) {
-
- [self.shopDic setObject:textField.text forKey:@"pai_time"];
- }else{
- [self.view endEditing:YES];
- textField.text =@"";
- //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于24的合法字符")];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍时间")];
- }
- _auctionTimeStr = textField.text;
- }
- break;
- case 17:
- {
- if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1) ||(textField.text.length > 1 && [textField.text hasPrefix: @"0"])) {
- //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时时间")];
- textField.text =@"";
- }
-
- if (textField.text.integerValue < 60 && textField.text.integerValue >0) {
-
- [self.shopDic setObject:textField.text forKey:@"pai_yanshi"];
- }else{
- [self.view endEditing:YES];
- textField.text =@"";
- //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于60的合法字符")];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时时间")];
- }
- _delayTimeStr = textField.text;
- }
- break;
- case 18:
- {
- if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1)
- || (textField.text.length > 2 && [textField.text hasPrefix: @"0"])) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
- textField.text =@"";
- }
- if (textField.text.integerValue < 10 && textField.text.integerValue >=0) {
-
- [self.shopDic setObject:textField.text forKey:@"max_yanshi"];
- }else{
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
- textField.text =@"";
- }
- _maxDelayTimeStr = textField.text;
- }
- break;
- default:
- break;
- }
-
- }
- - (void)textFieldDidBeginEditing:(UITextField *)textField{
- textField.placeholder = nil;
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
-
- [UIView animateWithDuration:0.5 animations:^{
- // dateView.frame = CGRectMake(0, kScreenH + 260, kScreenW, 260);
- self.dateView.frame = CGRectMake(0, kScreenH-64, kScreenW, kScreenH-64);
- } completion:^(BOOL finished) {
- }];
- }
-
- }
- - (void)textViewDidBeginEditing:(UITextView *)textView{
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
-
- [UIView animateWithDuration:0.5 animations:^{
- // dateView.frame = CGRectMake(0, kScreenH + 260, kScreenW, 260);
- self.dateView.frame = CGRectMake(0, kScreenH-64, kScreenW, kScreenH-64);
- } completion:^(BOOL finished) {
- }];
- }
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
- if (textField.tag == 0) {
- NSString *comcatstr = [textField.text stringByReplacingCharactersInRange:range withString:string];
-
- NSInteger caninputlen = 30 - comcatstr.length;
-
- if (caninputlen >= 0)
- {
- return YES;
- }
- else
- {
- NSInteger len = string.length + caninputlen;
- //防止当text.length + caninputlen < 0时,使得rg.length为一个非法最大正数出错
- NSRange rg = {0,MAX(len,0)};
-
- if (rg.length > 0)
- {
- NSString *s = [string substringWithRange:rg];
-
- [textField setText:[textField.text stringByReplacingCharactersInRange:range withString:s]];
- }
- return NO;
- }
-
-
- }else if (textField.tag==2) {
- if (![string isNumber]) {
- return NO;
- }
- if (string.length == 0)
- return YES;
-
- NSInteger existedLength = textField.text.length;
- NSInteger selectedLength = range.length;
- NSInteger replaceLength = string.length;
- if (existedLength - selectedLength + replaceLength > 11) {
- return NO;
- }
- }
- else if (textField.tag == 3 || textField.tag == 4 || textField.tag == 5 || textField.tag == 11 || textField.tag == 13 || textField.tag == 14 || textField.tag == 15)
- {
- if (string.length == 0)
- return YES;
- NSInteger existedLength = textField.text.length;
- NSInteger selectedLength = range.length;
- NSInteger replaceLength = string.length;
- NSInteger number = 7;
- if (textField.tag == 4 || textField.tag == 5 || textField.tag == 13 || textField.tag == 14 || textField.tag == 15) {
- //设置竞拍保证金,加价幅度和快递费的最大金额限制
- number = 5;
- }
- if (existedLength - selectedLength + replaceLength >number) {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"你输入的金额超过当前限制")];
- return NO;
- }
- }
- return YES;
-
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- if (![text isEqualToString:@""])
- {
- self.placehoderLabel.hidden = YES;
- }
- if ([text isEqualToString:@""] && range.location == 0 && range.length == 1)
- {
- self.placehoderLabel.hidden = NO;
- }
-
- if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop)
- {
- if (text.length == 0)
- {
- return YES;
- }
- NSInteger existedLength = textView.text.length;
- NSInteger selectedLength = range.length;
- NSInteger replaceLength = text.length;
- if (existedLength - selectedLength + replaceLength > 25)
- {
- [self.view endEditing:YES];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品描述不能超过25字")];
- return NO;
- }
- }
- return YES;
- }
- //- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
- //{
- // if (textField.tag==2) {
- // if (![string isNumber]) {
- // return NO;
- // }
- // if (string.length == 0)
- // return YES;
- //
- // NSInteger existedLength = textField.text.length;
- // NSInteger selectedLength = range.length;
- // NSInteger replaceLength = string.length;
- // if (existedLength - selectedLength + replaceLength > 11) {
- // return NO;
- // }
- // }
- // return YES;
- //}
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- #pragma mark --- 虚拟商品返回行高
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
- if (indexPath.section == 4) {
- return 150.0f;
- }else{
- return 44.0f;
- }
-
- }
- else if ([self.shopType isEqualToString:@"EntityAuctionShopping"])
- {
- return 44.0f;
- }
- else{
-
- if (indexPath.section == 0) {
- return 44.0f;
- }else{
- return 150.0f;
- }
- }
- #pragma mark --- 实体商品返回行高
-
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if ([self.shopType isEqualToString:@"VirtualShopping"]) {
- //虚拟商品
- #pragma mark --- 虚拟商品点击cell
- if (indexPath.section == 1) {
- if (indexPath.row == 0) {
- //日记日期
- [self.shopDic setObject:self.datePicker.timeLable.text forKey:@"date_time"];
- [UIView animateWithDuration:0.5 animations:^{
- // dateView.frame = CGRectMake(0, kScreenH - 260, kScreenW, 260);
- self.dateView.frame = CGRectMake(0, 0, kScreenW, kScreenH-64);
- } completion:^(BOOL finished) {
-
- }];
- [self.view endEditing:YES];
- }else if (indexPath.row == 1){
- [self.view endEditing:YES];
- //腾讯地图
- MapViewController *mapVc = [[MapViewController alloc]init];
- mapVc.hidesBottomBarWhenPushed = YES;
- mapVc.fromType = 0;
- mapVc.delegate = self;
- [self.navigationController pushViewController:mapVc animated:YES];
- }
-
- }
- }
-
- }
- #pragma mark -- 回收键盘
- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
- [self.view resignFirstResponder];
- }
- #pragma mark -- 创建日期/获取当前时间点
- - (void)creatPickView{
- if (!self.dateView)
- {
- // dateView = [[UIView alloc]initWithFrame:CGRectMake(0,kScreenH + 260,kScreenW,260)];
- // dateView.backgroundColor = [UIColor whiteColor];
- // [self.view addSubview:dateView];
- self.dateView = [[UIView alloc]initWithFrame:CGRectMake(0,kScreenH-64 ,kScreenW,kScreenH-64)];
- self.dateView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
- [self.view addSubview:self.dateView];
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
- [self.dateView addGestureRecognizer:tap];
-
- self.datePicker = [[[NSBundle mainBundle]loadNibNamed:@"DatePickerOfView" owner:self options:nil]lastObject];
- self.datePicker.frame = CGRectMake(0, kScreenH-260-64, kScreenW, 260);
- [self.dateView addSubview:self.datePicker];
- [self.datePicker.CBtn addTarget:self action:@selector(handleToSelectTime:) forControlEvents:UIControlEventTouchUpInside];
- [self.datePicker.Qbtn addTarget:self action:@selector(handleToSelectTime:) forControlEvents:UIControlEventTouchUpInside];
- }
- }
- #pragma mark -- 日历确定按钮点击事件
- - (void)handleToSelectTime:(UIButton *)button
- {
- if (button == self.datePicker.Qbtn)
- {
- self.textData = self.datePicker.timeLable.text;
- [self.shopDic setObject:self.textData forKey:@"date_time"];
- }
- self.dateView.frame = CGRectMake(0, kScreenH-64,kScreenW,kScreenH-64);
- [_releaseTabView reloadData];
- }
- - (void)tap
- {
- self.dateView.frame = CGRectMake(0, kScreenH-64,kScreenW,kScreenH-64);
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|