ReleaseViewController.m 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240
  1. //
  2. // ReleaseViewController.m
  3. // 拍卖
  4. //
  5. // Created by GuoMs on 16/8/5.
  6. // Copyright © 2016年 zcd. All rights reserved.
  7. //
  8. #import "ReleaseViewController.h"
  9. #import "BaseTableViewCell.h"
  10. #import "TimeTableViewCell.h"
  11. #import "CdescriptTableViewCell.h"
  12. #import "HeaderView.h"
  13. #import "BGHUDHelper.h"
  14. #import "TagsModel.h"
  15. #import "MapViewController.h"
  16. #import "DatePickerOfView.h"
  17. #import "AuctionHeaderView.h"
  18. //#import "BGOssManager.h"
  19. #import "AuctionGoodsModel.h"
  20. @interface ReleaseViewController ()<AddPhotoDelegate,UIActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate,MapChooseAddressControllerDelegate,QMapLocationViewDelegate>
  21. {
  22. CGSize _size;
  23. UIButton *_rightButton;
  24. NSMutableDictionary *editPhotoDic;//编辑
  25. QMapLocationView *_mapLocationView; //腾讯地图
  26. CAKeyframeAnimation * keyAnimaion;//删除图片动画
  27. UIButton *btn;//删除图片
  28. // BGOssManager *_ossManager;
  29. NSString *_uploadFilePath;
  30. NSString *_urlString;
  31. NSString *_timeString;//时间戳的字符串
  32. BOOL _fistTime;
  33. BOOL _fistDelay;
  34. BOOL _fistMax;
  35. }
  36. @property (strong, nonatomic) IBOutlet UITableView *releaseTabView;
  37. @property (nonatomic, strong) HeaderView *headerView;
  38. @property (nonatomic, copy) NSString *textData;
  39. @property (nonatomic, strong) UIImageView *addPhoto;
  40. @property (nonatomic, strong) NSMutableDictionary *editInfo;//编辑
  41. @property (nonatomic, strong) NSMutableDictionary *shopDic;//虚拟购物
  42. @property (nonatomic, strong) NSMutableDictionary *entiShopDic;//实体购物
  43. @property (nonatomic, strong) NSMutableArray *editArr;//存放修改前的数据 NSMutableArray
  44. @property (nonatomic, strong) NSMutableArray *shopAuctionArr;//实物竞拍头部商品信息
  45. @property (nonatomic, strong) AuctionHeaderView * auctionView;
  46. @property (nonatomic, strong) NSMutableArray *pictArr;//存储上传后的图片
  47. @property (nonatomic, copy) NSString * bzStr;//保证金
  48. @property (nonatomic, copy) NSString * addPriceStr;//加价幅度
  49. @property (nonatomic, copy) NSString * auctionTimeStr;//竞拍时长
  50. @property (nonatomic, copy) NSString * delayTimeStr;//延时时间
  51. @property (nonatomic, copy) NSString * maxDelayTimeStr;//最大延时
  52. @property (nonatomic, strong) AuctionGoodsModel * entityAuctionModel;//实物竞拍的模型
  53. @property (nonatomic, copy) NSString * nameStr;//商品名称
  54. @property (nonatomic, copy) NSString * priceStr;//实物商品价格
  55. @property (nonatomic, copy) NSString * urlStr;//实物商品网址链接
  56. @property (nonatomic, copy) NSString * expressPriceStr;//实物商品快递费
  57. @property (nonatomic, copy) NSString * desStr;//商品描述
  58. @property (nonatomic, copy) NSString * contactStr;//联系人
  59. @property (nonatomic, copy) NSString * mobileStr;//联系电话
  60. @property (nonatomic, copy) NSString * qpPriceStr;//起拍价
  61. @property (nonatomic, strong) UILabel * placehoderLabel;
  62. @property (nonatomic, strong) UIView *dateView;
  63. @property (nonatomic, strong) DatePickerOfView *datePicker;
  64. @end
  65. @implementation ReleaseViewController
  66. /**
  67. *****新增时候的商品照片
  68. **/
  69. -(UIImageView *)addPhoto{
  70. if (!_addPhoto) {
  71. self.addPhoto = [UIImageView new];
  72. }
  73. return _addPhoto;
  74. }
  75. /**
  76. *****存储虚拟购物数据
  77. **/
  78. -(NSMutableDictionary *)shopDic{
  79. if (!_shopDic) {
  80. self.shopDic = [NSMutableDictionary new];
  81. }
  82. return _shopDic;
  83. }
  84. /**
  85. *****存储实体购物数据
  86. **/
  87. -(NSMutableDictionary *)entiShopDic{
  88. if (!_entiShopDic) {
  89. self.entiShopDic = [NSMutableDictionary new];
  90. }
  91. return _entiShopDic;
  92. }
  93. /**
  94. *****存放修改前的数据
  95. **/
  96. - (NSMutableArray *)editArr{
  97. if (!_editArr) {
  98. self.editArr = [NSMutableArray new];
  99. }
  100. return _editArr;
  101. }
  102. //实物竞拍数据
  103. - (NSMutableArray *)shopAuctionArr
  104. {
  105. if (!_shopAuctionArr) {
  106. _shopAuctionArr = [NSMutableArray new];
  107. }
  108. return _shopAuctionArr;
  109. }
  110. - (NSMutableArray *)pictArr{
  111. if (!_pictArr) {
  112. self.pictArr = [NSMutableArray new];
  113. }
  114. return _pictArr;
  115. }
  116. - (void)viewDidAppear:(BOOL)animated{
  117. [super viewDidAppear:animated];
  118. [IQKeyboardManager sharedManager].enable = YES;
  119. [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
  120. }
  121. - (void)viewWillAppear:(BOOL)animated{
  122. [super viewWillAppear:animated];
  123. //开始定位
  124. [_mapLocationView startLocate];
  125. _fistMax = YES;
  126. _fistDelay = YES;
  127. _fistTime = YES;
  128. //处理 竞拍+悬浮+弹出发布界面UI问题
  129. //#if kSupportAuction
  130. // _tableView_Top_Constraint.constant = 64;//防止崩溃
  131. // _navBar_View.title_Lab.text = ASLocalizedString(@"商品");
  132. //#else
  133. // _tableView_Top_Constraint.constant = 0;
  134. //#endif
  135. // _navBar_View.hidden = !(kSupportAuction == 1);
  136. // [self.view layoutIfNeeded];
  137. }
  138. - (void)viewWillDisappear:(BOOL)animated
  139. {
  140. [super viewWillDisappear:animated];
  141. [IQKeyboardManager sharedManager].enable = NO;
  142. [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  143. }
  144. - (void)viewDidDisappear:(BOOL)animated{
  145. [super viewDidDisappear:animated];
  146. //停止定位
  147. [_mapLocationView stopLocate];
  148. }
  149. - (void)viewDidLoad
  150. {
  151. [super viewDidLoad];
  152. self.placehoderLabel = [[UILabel alloc] initWithFrame:CGRectMake(6, 5, 75, 25)];
  153. self.placehoderLabel.text = ASLocalizedString(@"请描述商品");
  154. self.placehoderLabel.textColor = kAppGrayColor3;
  155. self.placehoderLabel.font = kAppMiddleTextFont;
  156. self.view.backgroundColor = kWhiteColor;
  157. //头部
  158. self.headerView = [[[NSBundle mainBundle]loadNibNamed:@"HeaderView" owner:self options:nil]lastObject];
  159. self.headerView.isOTOShop = _isOTOShop;
  160. self.headerView.delegate = self;
  161. [self.releaseTabView registerNib:[UINib nibWithNibName:@"BaseTableViewCell" bundle:nil] forCellReuseIdentifier:@"BaseCell"];//带输入框的
  162. [self.releaseTabView registerNib:[UINib nibWithNibName:@"TimeTableViewCell" bundle:nil] forCellReuseIdentifier:@"timeCell"];
  163. [self.releaseTabView registerNib:[UINib nibWithNibName:@"CdescriptTableViewCell" bundle:nil] forCellReuseIdentifier:@"desCell"];
  164. self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(returnToMeVc) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  165. _rightButton = [[UIButton alloc]initWithFrame:CGRectMake(kScreenW-40, 5, 40, 30)];
  166. [_rightButton setTitle:ASLocalizedString(@"发布")forState:UIControlStateNormal];
  167. [_rightButton setTitleColor:kAppMainColor forState:UIControlStateNormal];
  168. _rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
  169. UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_rightButton];
  170. self.navigationItem.rightBarButtonItem = rightBarButtonItem;
  171. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  172. self.title = ASLocalizedString(@"虚拟商品拍卖设置");
  173. [self getLabelNetWorking];
  174. [self creatPickView];
  175. _mapLocationView = [QMapLocationView sharedInstance];
  176. [_rightButton addTarget:self action:@selector(releaseEditButton) forControlEvents:UIControlEventTouchUpInside];
  177. }
  178. else
  179. {
  180. self.releaseTabView.contentSize = CGSizeMake(kScreenW, kScreenH);
  181. if ([self.shopType isEqualToString:@"EditShopping"]){
  182. //self.title = ASLocalizedString(@"修改商品信息");
  183. self.navigationItem.title = ASLocalizedString(@"编辑购物商品");
  184. [_rightButton setTitle:ASLocalizedString(@"编辑")forState:UIControlStateNormal];
  185. [self editShop];
  186. [self.editArr addObject:self.model.name];
  187. [self.editArr addObject:self.model.price];
  188. if (self.model.url.length>0) {
  189. [self.editArr addObject:self.model.url];
  190. }
  191. if (self.BuguLive.appModel.open_podcast_goods == 0 && self.model.kd_cost.length >0) {
  192. [self.editArr addObject:self.model.kd_cost];
  193. }
  194. [self.editArr addObject:self.model.descrStr];
  195. [_rightButton addTarget:self action:@selector(EditShoppingButton) forControlEvents:UIControlEventTouchUpInside];
  196. self.placehoderLabel.hidden = YES;
  197. }
  198. else if ([self.shopType isEqualToString:@"EntityAuctionShopping"])
  199. {
  200. self.title = ASLocalizedString(@"星店商品拍卖设置");
  201. [self addShopGoodsData];
  202. [self.shopAuctionArr addObject:self.auctionGoodsModel.name];
  203. [self.shopAuctionArr addObject:self.auctionGoodsModel.price];
  204. [self.shopAuctionArr addObject:self.auctionGoodsModel.imgs];
  205. // [self addAuctionGoodsView];
  206. [_rightButton addTarget:self action:@selector(releaseButton) forControlEvents:UIControlEventTouchUpInside];
  207. }
  208. else{
  209. // self.title = ASLocalizedString(@"实物商品拍卖设置");
  210. self.title =self.BuguLive.appModel.open_podcast_goods == 1? ASLocalizedString(@"商品设置"): ASLocalizedString(@"产品设置");
  211. [self addShop];
  212. [_rightButton addTarget:self action:@selector(EntityShoppingEditButton) forControlEvents:UIControlEventTouchUpInside];
  213. }
  214. }
  215. // if (self.BuguLive.appModel.open_sts == 1)
  216. // {
  217. // _ossManager = [[BGOssManager alloc]initWithDelegate:self];
  218. // }
  219. //当悬浮 恢复、、发布VC 键盘下去
  220. // [self xw_addNotificationForName:@"GoodsPublishVCResign" block:^(NSNotification * _Nonnull notification) {
  221. // [self.view endEditing:YES];
  222. // }];
  223. }
  224. - (void)popVC
  225. {
  226. if ([self.shopType isEqualToString:@"EditShopping"] ||[self.shopType isEqualToString:@"EntityShopping"])
  227. {
  228. [self.navigationController popViewControllerAnimated:YES];
  229. }
  230. else if ([self.BuguLive.appModel.open_pai_module intValue] == 1)
  231. {
  232. // [[LiveCenterManager sharedInstance] showChangeAuctionLiveScreenSOfIsSmallScreen:NO nextViewController:nil delegateWindowRCNameStr:@"BGTabBarController" complete:^(BOOL finished) {
  233. // }];
  234. [self.navigationController popViewControllerAnimated:YES];
  235. }
  236. else
  237. {
  238. [self.navigationController popViewControllerAnimated:YES];
  239. }
  240. }
  241. #pragma mark -- 获取标签
  242. - (void)getLabelNetWorking
  243. {
  244. NSMutableDictionary *dict = [NSMutableDictionary new];
  245. [dict setValue:@"pai_podcast" forKey:@"ctl"];
  246. [dict setValue:@"tags" forKey:@"act"];
  247. [dict setObject:@"shop" forKey:@"itype"];
  248. FWWeakify(self)
  249. [self.httpsManager POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  250. FWStrongify(self)
  251. if ([responseJson toInt:@"status"] == 1) {
  252. NSArray * listArr = responseJson[@"data"][@"list"];
  253. NSArray * tagsArr = [TagsModel mj_objectArrayWithKeyValuesArray:listArr];
  254. if (tagsArr.count > 0)
  255. {
  256. self.headerView.tagsArr = tagsArr;
  257. UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 176)];
  258. [headerV addSubview:self.headerView];
  259. //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
  260. [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
  261. [self.headerView getPicturearr:self.pictArr block:^{
  262. }];
  263. self.releaseTabView.tableHeaderView = headerV;
  264. [self.releaseTabView reloadData];
  265. }else{
  266. self.headerView.frame = CGRectMake(0, 0, kScreenW, 120);
  267. UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
  268. [headerV addSubview:self.headerView];
  269. //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
  270. [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
  271. [self.headerView getPicturearr:self.pictArr block:^{
  272. }];
  273. self.releaseTabView.tableHeaderView = headerV;
  274. [self.releaseTabView reloadData];
  275. }
  276. }
  277. } FailureBlock:^(NSError *error) {
  278. }];
  279. }
  280. -(AuctionHeaderView *)auctionView
  281. {
  282. if (_auctionView == nil) {
  283. _auctionView = [[AuctionHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
  284. }
  285. return _auctionView;
  286. }
  287. - (void)addAuctionGoodsView
  288. {
  289. // self.auctionView = [[AuctionHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
  290. // self.auctionView.backgroundColor = kAppGrayColor3;
  291. // UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
  292. // [headerV addSubview:self.auctionView];
  293. __weak typeof (self) weakSelf = self;
  294. weakSelf.releaseTabView.tableHeaderView = weakSelf.auctionView;
  295. weakSelf.auctionView.model = weakSelf.entityAuctionModel;
  296. [weakSelf.releaseTabView reloadData];
  297. }
  298. - (void)addShopGoodsData
  299. {
  300. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  301. [mDict setObject:@"pai_podcast" forKey:@"ctl"];
  302. [mDict setObject:@"addpaidetail" forKey:@"act"];
  303. if (self.auctionGoodsModel.goodsId.length>0) {
  304. [mDict setObject:self.auctionGoodsModel.goodsId forKey:@"goods_id"];
  305. }
  306. else
  307. {
  308. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品ID不能为空")];
  309. return;
  310. }
  311. [mDict setObject:@"shop" forKey:@"itype"];
  312. FWWeakify(self)
  313. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  314. FWStrongify(self)
  315. if ([responseJson toInt:@"status"] == 1) {
  316. self.entityAuctionModel = [AuctionGoodsModel mj_objectWithKeyValues:[responseJson objectForKey:@"data"]];
  317. [self addAuctionGoodsView];
  318. }
  319. } FailureBlock:^(NSError *error) {
  320. }];
  321. }
  322. #pragma mark -- 新增实物商品
  323. - (void)addShop{
  324. self.headerView.frame = CGRectMake(0, 0, kScreenW, 120);
  325. UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
  326. [headerV addSubview:self.headerView];
  327. //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
  328. [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
  329. [self.headerView getPicturearr:self.pictArr block:^{
  330. }];
  331. self.releaseTabView.tableHeaderView = headerV;
  332. [self.releaseTabView reloadData];
  333. }
  334. #pragma mark -- 编辑商品
  335. - (void)editShop{
  336. self.pictArr = [self.model.imgs mutableCopy];
  337. NSLog(@"%@",self.pictArr);
  338. self.editInfo = [NSMutableDictionary new];
  339. if (self.pictArr.count > 0) {
  340. // for (int i = 0; i < self.pictArr.count; i++) {
  341. // NSLog(@"%@",self.pictArr[i]);
  342. // [_entiShopDic setObject:[NSString stringWithFormat:@"%@",self.pictArr[i]] forKey:[NSString stringWithFormat:@"%d",i]];
  343. // }
  344. [self.editInfo setObject:self.model.name forKey:@"name"];
  345. [self.editInfo setObject:self.model.price forKey:@"price"];
  346. if (self.model.url.length>0) {
  347. [self.editInfo setObject:self.model.url forKey:@"url"];
  348. }
  349. if (self.model.descrStr.length>0) {
  350. [self.editInfo setObject:self.model.descrStr forKey:@"description"];
  351. }
  352. if (self.BuguLive.appModel.open_podcast_goods == 0 && self.model.kd_cost.length >0) {
  353. [self.editInfo setObject:self.model.kd_cost forKey:@"kd_cost"];
  354. self.expressPriceStr = self.model.kd_cost;
  355. }
  356. NSLog(@"%@",self.editInfo);
  357. self.nameStr = self.model.name;
  358. self.priceStr = self.model.price;
  359. self.urlStr = self.model.url;
  360. self.desStr = self.model.descrStr;
  361. self.headerView.frame = CGRectMake(0, 0, kScreenW, 120);
  362. UIView *headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 120)];
  363. [headerV addSubview:self.headerView];
  364. if (!_isOTOShop) {
  365. //[self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:self.pictArr.count];
  366. [self.pictArr insertObject:[NSString stringWithFormat:@"me_addPhoto"] atIndex:0];
  367. }
  368. //[self.pictArr insertObject:[NSString stringWithFormat:@"addPhoto"] atIndex:self.pictArr.count];
  369. [self.headerView getPicturearr:self.pictArr block:^{
  370. }];
  371. self.releaseTabView.tableHeaderView = headerV;
  372. [self.releaseTabView reloadData];
  373. }
  374. }
  375. #pragma mark -- 发布重新编辑的商品
  376. - (void)EditShoppingButton{
  377. [self.view endEditing:YES];
  378. [self.editInfo setObject:@"shop" forKey:@"ctl"];
  379. [self.editInfo setObject:@"edit_goods" forKey:@"act"];
  380. [self.editInfo setObject:[NSString stringWithFormat:@"%@",self.model.ID] forKey:@"id"];
  381. if (self.pictArr.count == 1 && [self.pictArr containsObject:@"me_addPhoto"])
  382. {
  383. if (_isOTOShop) {
  384. [FanweMessage alert:ASLocalizedString(@"请上传图片")];
  385. }
  386. else
  387. {
  388. [FanweMessage alert:ASLocalizedString(@"至少上传一张图片(最多5张)")];
  389. }
  390. return;
  391. }
  392. if (_nameStr.length == 0) {
  393. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品名称不能为空")];
  394. return;
  395. }
  396. if (_priceStr.length == 0) {
  397. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品价格不能为空")];
  398. return;
  399. }
  400. else
  401. {
  402. NSString *priceRegex = @"^[0-9]+(\\.[0-9]{1,2})?$";
  403. NSPredicate *priceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",priceRegex];
  404. if (![priceTest evaluateWithObject:_priceStr]) {
  405. [self.view endEditing:YES];
  406. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请保证输入的商品价格小数点最多两位")];
  407. return;
  408. }
  409. }
  410. if (_urlStr.length == 0 ) {
  411. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入网址")];
  412. return;
  413. }
  414. if (self.BuguLive.appModel.open_podcast_goods == 0) {
  415. if (_expressPriceStr.length == 0) {
  416. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"快递费不能为空")];
  417. return;
  418. }
  419. else
  420. {
  421. [self.editInfo setObject:_expressPriceStr forKey:@"kd_cost"];
  422. }
  423. }
  424. if ([self.pictArr containsObject:@"me_addPhoto"] && !_isOTOShop)
  425. {
  426. [self.pictArr removeObject:@"me_addPhoto"];
  427. }
  428. NSError *parseError = nil;
  429. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.pictArr options:NSJSONWritingPrettyPrinted error:&parseError];
  430. NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  431. [self.editInfo setObject:JSONStr forKey:@"imgs"];
  432. [self.editInfo setObject:_nameStr forKey:@"name"];
  433. [self.editInfo setObject:_priceStr forKey:@"price"];
  434. [self.editInfo setObject:_urlStr forKey:@"url"];
  435. if (_desStr.length>0) {
  436. [self.editInfo setObject:_desStr forKey:@"description"];
  437. }
  438. NSMutableDictionary * editDic = self.editInfo.mutableCopy;
  439. [editDic setObject:@"shop" forKey:@"itype"];
  440. [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
  441. FWWeakify(self)
  442. [self.httpsManager POSTWithParameters:editDic SuccessBlock:^(NSDictionary *responseJson) {
  443. FWStrongify(self)
  444. [[BGHUDHelper sharedInstance] syncStopLoading];
  445. if ([responseJson toInt:@"status"] == 1)
  446. {
  447. [self popVC];
  448. }
  449. else
  450. {
  451. [self addPhotoWhenFailed];
  452. }
  453. } FailureBlock:^(NSError *error) {
  454. FWStrongify(self);
  455. [[BGHUDHelper sharedInstance] syncStopLoading];
  456. [self addPhotoWhenFailed];
  457. }];
  458. }
  459. #pragma mark -- 实体商品发布
  460. - (void)EntityShoppingEditButton{
  461. [self.view endEditing:YES];
  462. [self.entiShopDic setObject:@"shop" forKey:@"ctl"];
  463. [self.entiShopDic setObject:@"add_goods" forKey:@"act"];
  464. [self.entiShopDic setObject:[IMAPlatform sharedInstance].host.userId forKey:@"user_id"];
  465. if (self.pictArr.count == 1 && [_pictArr containsObject:@"me_addPhoto"]) {
  466. if (_isOTOShop) {
  467. [FanweMessage alert:ASLocalizedString(@"请上传图片")];
  468. }
  469. else
  470. {
  471. [FanweMessage alert:ASLocalizedString(@"至少上传一张图片(最多5张)")];
  472. }
  473. return;
  474. }else{
  475. if (_nameStr.length == 0) {
  476. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品名称不能为空")];
  477. return;
  478. }
  479. if (_priceStr.length == 0) {
  480. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品价格不能为空")];
  481. return;
  482. }
  483. else
  484. {
  485. NSString *priceRegex = @"^[0-9]+(\\.[0-9]{1,2})?$";
  486. NSPredicate *priceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",priceRegex];
  487. if (![priceTest evaluateWithObject:_priceStr]) {
  488. [self.view endEditing:YES];
  489. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请保证输入的商品价格小数点最多两位")];
  490. return;
  491. }
  492. }
  493. if (_urlStr.length == 0 ) {
  494. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入网址")];
  495. return;
  496. }
  497. if (self.BuguLive.appModel.open_podcast_goods == 0) {
  498. if (_expressPriceStr.length == 0 ) {
  499. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"快递费不能为空")];
  500. return;
  501. }
  502. else
  503. {
  504. [self.entiShopDic setObject:_expressPriceStr forKey:@"kd_cost"];
  505. }
  506. }
  507. // if (!_desStr || [_desStr isEqualToString:@""]) {
  508. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品描述不能为空")];
  509. // return;
  510. // }
  511. if ([self.pictArr containsObject:@"me_addPhoto"] && self.pictArr.count > 1)
  512. {
  513. [self.pictArr removeObject:@"me_addPhoto"];
  514. }
  515. NSError *parseError = nil;
  516. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.pictArr options:NSJSONWritingPrettyPrinted error:&parseError];
  517. NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  518. [self.entiShopDic setObject:JSONStr forKey:@"imgs"];
  519. [self.entiShopDic setObject:_nameStr forKey:@"name"];
  520. [self.entiShopDic setObject:_urlStr forKey:@"url"];
  521. [self.entiShopDic setObject:_priceStr forKey:@"price"];
  522. if (_desStr.length>0) {
  523. [self.entiShopDic setObject:_desStr forKey:@"description"];
  524. }
  525. NSMutableDictionary * entiDic = self.entiShopDic.mutableCopy;
  526. [entiDic setObject:@"shop" forKey:@"itype"];
  527. [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
  528. FWWeakify(self)
  529. [self.httpsManager POSTWithParameters:entiDic SuccessBlock:^(NSDictionary *responseJson) {
  530. FWStrongify(self)
  531. [[BGHUDHelper sharedInstance] syncStopLoading];
  532. if ([responseJson toInt:@"status"] == 1)
  533. {
  534. [self popVC];
  535. }
  536. else
  537. {
  538. [self addPhotoWhenFailed];
  539. }
  540. } FailureBlock:^(NSError *error) {
  541. FWStrongify(self)
  542. [[BGHUDHelper sharedInstance] syncStopLoading];
  543. [self addPhotoWhenFailed];
  544. }];
  545. }
  546. }
  547. - (void)addPhotoWhenFailed
  548. {
  549. if (!_isOTOShop)
  550. {
  551. if (![self.pictArr containsObject:@"me_addPhoto"] && self.pictArr.count != 5)
  552. {
  553. //[self.pictArr addObject:@"me_addPhoto"];
  554. [self.pictArr insertObject:@"me_addPhoto" atIndex:0];
  555. }
  556. }
  557. }
  558. #pragma mark -- 虚拟商品发布
  559. - (void)releaseEditButton{
  560. [self.view endEditing:YES];
  561. [self.shopDic setObject:@"0" forKey:@"is_true"];
  562. [self.shopDic setObject:@"pai_podcast" forKey:@"ctl"];
  563. [self.shopDic setObject:@"addpai" forKey:@"act"];
  564. //提交地理位置
  565. NSError *parseErr = nil;
  566. NSMutableDictionary *geoDic = [NSMutableDictionary new];
  567. if (self.BuguLive.addressJsonStr != nil) {
  568. [geoDic setObject:self.BuguLive.addressJsonStr forKey:@"district"];
  569. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:geoDic options:NSJSONWritingPrettyPrinted error:&parseErr];
  570. NSString *geograJSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  571. [self.shopDic setObject:geograJSONStr forKey:@"district"];
  572. }
  573. if (self.BuguLive.addressJsonStr != nil) {
  574. [geoDic setObject:self.BuguLive.addressJsonStr forKey:@"district"];
  575. }
  576. else if (_keyWordStr.length>0)
  577. {
  578. [geoDic setObject:_keyWordStr forKey:@"district"];
  579. }
  580. if (geoDic != nil) {
  581. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:geoDic options:NSJSONWritingPrettyPrinted error:&parseErr];
  582. NSString *geograJSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  583. [self.shopDic setObject:geograJSONStr forKey:@"district"];
  584. }
  585. else
  586. {
  587. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入地址")];
  588. return;
  589. }
  590. NSError *parseError1 = nil;
  591. if (self.pictArr.count == 1 && [self.pictArr containsObject:@"me_addPhoto"]) {
  592. [FanweMessage alert:ASLocalizedString(@"至少上传一张图片(最多5张)")];
  593. return;
  594. }else{
  595. if (_nameStr.length > 0) {
  596. [self.shopDic setObject:_nameStr forKey:@"name"];
  597. }
  598. else
  599. {
  600. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入商品名称")];
  601. return;
  602. }
  603. if (_contactStr.length > 0) {
  604. [self.shopDic setObject:_contactStr forKey:@"contact"];
  605. }
  606. else
  607. {
  608. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入联系人姓名")];
  609. return;
  610. }
  611. if (_mobileStr.length > 0) {
  612. if (_mobileStr.length < 1) {
  613. [self.view endEditing:YES];
  614. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手机号限制11位数!")];
  615. return;
  616. }
  617. [self.shopDic setObject:_mobileStr forKey:@"mobile"];
  618. }
  619. else
  620. {
  621. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入电话号码")];
  622. return;
  623. }
  624. if (_qpPriceStr.length < 1 ||[_qpPriceStr integerValue]== 0)
  625. {
  626. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍起拍价格不能为空或0")];
  627. return;
  628. }
  629. [self.shopDic setObject:_qpPriceStr forKey:@"qp_diamonds"];
  630. if (_bzStr.length < 1||[_bzStr integerValue]== 0)
  631. {
  632. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍保证金不能为空或0")];
  633. return;
  634. }
  635. [self.shopDic setObject:_bzStr forKey:@"bz_diamonds"];
  636. if (_addPriceStr.length < 1 || [_addPriceStr integerValue]== 0)
  637. {
  638. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"加价幅度不能为空或0")];
  639. return;
  640. }
  641. [self.shopDic setObject:_addPriceStr forKey:@"jj_diamonds"];
  642. if (_auctionTimeStr.floatValue < 24 && _auctionTimeStr.floatValue >0) {
  643. [self.shopDic setObject:_auctionTimeStr forKey:@"pai_time"];
  644. }
  645. else{
  646. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入有效的竞拍时间")];
  647. return;
  648. }
  649. if (_delayTimeStr.integerValue < 60 && _delayTimeStr.integerValue >0)
  650. {
  651. [self.shopDic setObject:_delayTimeStr forKey:@"pai_yanshi"];
  652. }else
  653. {
  654. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时值")];
  655. return;
  656. }
  657. if ([_maxDelayTimeStr integerValue ]< 10 && [_maxDelayTimeStr length]>0 && [_maxDelayTimeStr integerValue ]>=0)
  658. {
  659. [self.shopDic setObject:_maxDelayTimeStr forKey:@"max_yanshi"];
  660. }else
  661. {
  662. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入最大延时")];
  663. return;
  664. }
  665. if (_desStr.length > 0) {
  666. [self.shopDic setObject:_desStr forKey:@"description"];
  667. }
  668. else
  669. {
  670. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"描述不能为空")];
  671. return;
  672. }
  673. if ([self.pictArr containsObject:@"me_addPhoto"] && self.pictArr.count > 1)
  674. {
  675. [self.pictArr removeObject:@"me_addPhoto"];
  676. }
  677. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self.pictArr options:NSJSONWritingPrettyPrinted error:&parseError1];
  678. NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  679. [self.shopDic setObject:JSONStr forKey:@"imgs"];
  680. [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
  681. NSMutableDictionary * shopdic = self.shopDic.mutableCopy;
  682. [shopdic setObject:@"shop" forKey:@"itype"];
  683. FWWeakify(self)
  684. [self.httpsManager POSTWithParameters:shopdic SuccessBlock:^(NSDictionary *responseJson) {
  685. FWStrongify(self)
  686. [[BGHUDHelper sharedInstance] syncStopLoading];
  687. if ([responseJson toInt:@"status"] == 1)
  688. {
  689. [self popVC];
  690. if (_delegate && [_delegate respondsToSelector:@selector(onReleaseVCAuctionId:)])
  691. {
  692. [_delegate onReleaseVCAuctionId:[responseJson toInt:@"pai_id"]];
  693. }
  694. }
  695. else
  696. {
  697. [self addPhotoWhenFailed];
  698. if (![responseJson[@"error"] isEqualToString:@""])
  699. {
  700. if ([[responseJson toString:@"error"] rangeOfString:ASLocalizedString(@"直播间已关闭")].location != NSNotFound)
  701. {
  702. [self popVC];
  703. }
  704. }
  705. }
  706. } FailureBlock:^(NSError *error) {
  707. FWStrongify(self)
  708. [self addPhotoWhenFailed];
  709. }];
  710. }
  711. }
  712. #pragma mark -- 实物竞拍商品发布
  713. - (void)releaseButton{
  714. [self.view endEditing:YES];
  715. if ([BGUtils isBlankString:_bzStr]) {
  716. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍保证金")];
  717. return;
  718. }
  719. if (_addPriceStr.length == 0)
  720. {
  721. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入加价幅度")];
  722. return;
  723. }
  724. if (_auctionTimeStr.length == 0)
  725. {
  726. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍时间")];
  727. return;
  728. }
  729. if (_delayTimeStr.length == 0)
  730. {
  731. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时时间")];
  732. return;
  733. }
  734. if (_maxDelayTimeStr.length == 0)
  735. {
  736. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入最大延时")];
  737. return;
  738. }
  739. NSError *parseError1 = nil;
  740. [self.shopDic setObject:@"1" forKey:@"is_true"];
  741. [self.shopDic setObject:@"pai_podcast" forKey:@"ctl"];
  742. [self.shopDic setObject:@"addpai" forKey:@"act"];
  743. [self.shopDic setObject:_auctionGoodsModel.goodsId forKey:@"goods_id"];
  744. [self.shopDic setObject:_auctionGoodsModel.price forKey:@"qp_diamonds"];
  745. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:_auctionGoodsModel.imgs options:NSJSONWritingPrettyPrinted error:&parseError1];
  746. NSString *JSONStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  747. [self.shopDic setObject:JSONStr forKey:@"imgs"];
  748. [self.shopDic setObject:_auctionGoodsModel.name forKey:@"name"];
  749. if (_auctionGoodsModel.descStr.length>0) {
  750. [self.shopDic setObject:_auctionGoodsModel.descStr forKey:@"description"];
  751. }
  752. if (_entityAuctionModel.shop_id.length > 0)
  753. {
  754. [self.shopDic setObject:_entityAuctionModel.shop_id forKey:@"shop_id"];
  755. }
  756. if (_entityAuctionModel.shop_name.length > 0)
  757. {
  758. [self.shopDic setObject:_entityAuctionModel.shop_name forKey:@"shop_name"];
  759. }
  760. if (_auctionTimeStr.floatValue < 24 && _auctionTimeStr.floatValue >0) {
  761. [self.shopDic setObject:_auctionTimeStr forKey:@"pai_time"];
  762. }
  763. else{
  764. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入有效的竞拍时间")];
  765. return;
  766. }
  767. if (_delayTimeStr.integerValue < 60 && _delayTimeStr.integerValue >0) {
  768. [self.shopDic setObject:_delayTimeStr forKey:@"pai_yanshi"];
  769. }
  770. if ([_maxDelayTimeStr integerValue ]< 10 && [_maxDelayTimeStr integerValue ]>=0) {
  771. [self.shopDic setObject:_maxDelayTimeStr forKey:@"max_yanshi"];
  772. }
  773. NSMutableDictionary * dic = self.shopDic.mutableCopy;
  774. [dic setObject:@"shop" forKey:@"itype"];
  775. [[BGHUDHelper sharedInstance] syncLoading:ASLocalizedString(@"正在发布请等待")];
  776. FWWeakify(self)
  777. [self.httpsManager POSTWithParameters:dic SuccessBlock:^(NSDictionary *responseJson) {
  778. FWStrongify(self)
  779. [[BGHUDHelper sharedInstance] syncStopLoading];
  780. if ([responseJson toInt:@"status"] == 1)
  781. {
  782. [self popVC];
  783. if (_delegate && [_delegate respondsToSelector:@selector(onReleaseVCAuctionId:)])
  784. {
  785. [_delegate onReleaseVCAuctionId:[responseJson toInt:@"pai_id"]];
  786. }
  787. }
  788. else
  789. {
  790. if (![responseJson[@"error"] isEqualToString:@""])
  791. {
  792. [[BGHUDHelper sharedInstance] syncStopLoading];
  793. if ([[responseJson toString:@"error"] rangeOfString:ASLocalizedString(@"直播间已关闭")].location != NSNotFound)
  794. {
  795. [self popVC];
  796. }
  797. }
  798. }
  799. } FailureBlock:^(NSError *error) {
  800. }];
  801. }
  802. #pragma mark -- 标签的代理点击事件
  803. - (void)handleWithGoodsTag:(NSString *)goodsTag
  804. {
  805. if (goodsTag.length > 0)
  806. {
  807. [self.shopDic setObject:goodsTag forKey:@"tags"];
  808. }
  809. }
  810. #pragma mark -- 点击增加图片的代理方法
  811. - (void)handleToTapPhoto:(UITapGestureRecognizer *)tap{
  812. self.addPhoto = (UIImageView *)tap.view;
  813. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  814. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
  815. {
  816. picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  817. picker.delegate = self;
  818. picker.allowsEditing = YES;
  819. picker.modalPresentationStyle = UIModalPresentationFullScreen;
  820. }
  821. [self presentViewController:picker animated:YES completion:nil];
  822. // UIActionSheet *headImgSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  823. //// [headImgSheet addButtonWithTitle:ASLocalizedString(@"相机")];
  824. // [headImgSheet addButtonWithTitle:ASLocalizedString(@"从手机相册选择")];
  825. // [headImgSheet addButtonWithTitle:ASLocalizedString(@"取消")];
  826. // headImgSheet.cancelButtonIndex = headImgSheet.numberOfButtons-1;
  827. // headImgSheet.delegate = self;
  828. // [headImgSheet showInView:[UIApplication sharedApplication].keyWindow];
  829. }
  830. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  831. {
  832. if (buttonIndex == 0)
  833. {
  834. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  835. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
  836. {
  837. picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  838. picker.delegate = self;
  839. picker.allowsEditing = YES;
  840. picker.modalTransitionStyle = UIModalPresentationFullScreen;
  841. }
  842. [self presentViewController:picker animated:YES completion:nil];
  843. }else if (buttonIndex == 1){
  844. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  845. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
  846. {
  847. picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  848. picker.delegate = self;
  849. picker.allowsEditing = YES;
  850. picker.modalPresentationStyle = UIModalPresentationFullScreen;
  851. }
  852. [self presentViewController:picker animated:YES completion:nil];
  853. }
  854. }
  855. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
  856. NSString *mediaType = [info objectForKey:UIImagePickerControllerEditedImage];
  857. if (mediaType){
  858. UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
  859. if (!image)
  860. {
  861. image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
  862. }
  863. // if (self.BuguLive.appModel.open_sts == 1)
  864. // {
  865. // if ([_ossManager isSetRightParameter])
  866. // {
  867. // [self saveImage:image withName:@"1.png"];
  868. // _timeString = [_ossManager getObjectKeyString];
  869. // [_ossManager asyncPutImage:_timeString localFilePath:_uploadFilePath];
  870. // }
  871. // }else{
  872. UIImage *img = [info objectForKey:UIImagePickerControllerEditedImage];
  873. NSString *nameImage = [NSString stringWithFormat:@"currentImage%ld.jpg",self.addPhoto.tag];
  874. [self saveImage:img withName:nameImage];
  875. NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:nameImage];
  876. NSURL *fileUrl = [NSURL URLWithString:[NSString stringWithFormat:@"file:%@",fullPath]];
  877. [self pictureToNet:fileUrl];
  878. // }
  879. }
  880. [picker dismissViewControllerAnimated:YES completion:nil];
  881. }
  882. #pragma mark -- 上传图片
  883. //- (void)uploadImageWithUrlStr:(NSString *)imageUrlStr withUploadStateCount:(int)stateCount
  884. //{
  885. // if (stateCount == 0)
  886. // {
  887. // NSString *urlString = [NSString stringWithFormat:@"%@%@",_ossManager.oss_domain,_timeString];
  888. // NSLog(@"%@",urlString);
  889. // //#if kSupportAuction
  890. // // [imgdict addObject:urlString];
  891. // // NSLog(@"%@",imgdict);
  892. //
  893. // //#endif
  894. // if (self.isOTOShop)
  895. // {
  896. // if (self.addPhoto.tag < self.pictArr.count - 1 ) {//替换---已存在图片情况下
  897. // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:urlString];
  898. // }
  899. // else
  900. // {
  901. // [self.pictArr insertObject:urlString atIndex:self.pictArr.count - 1];
  902. // }
  903. // }
  904. // else
  905. // {
  906. // if (self.addPhoto.tag < self.pictArr.count - 1 && self.addPhoto.tag > 0) {//替换---已存在图片情况下
  907. // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:urlString];
  908. // }
  909. // else if (self.addPhoto.tag == 0 && self.pictArr.count == 5)
  910. // {
  911. // if ([self.pictArr.firstObject isEqual:@"me_addPhoto"])
  912. // {
  913. // [self.pictArr addObject:urlString];
  914. // [self.pictArr removeObject:@"me_addPhoto"];
  915. // }
  916. // else
  917. // {
  918. // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:urlString];
  919. // }
  920. // }
  921. // else{//增加
  922. // [self.pictArr addObject:urlString];
  923. // //[self.pictArr insertObject:urlString atIndex:self.pictArr.count - 1];
  924. // }
  925. // }
  926. // [self.headerView getPicturearr:self.pictArr block:^{
  927. // [self.headerView.getPhotoCollection reloadData];
  928. // }];
  929. // }else
  930. // {
  931. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"上传头像失败")];
  932. // }
  933. // //#if kSupportH5Shopping
  934. // // if ([self.shopType isEqualToString:@"EditShopping"]){
  935. // // [_entiShopDic setObject:urlString forKey:[NSString stringWithFormat:@"%ld",self.addPhoto.tag]];
  936. // //
  937. // // }else{
  938. // // [self.pictArr addObject:urlString];
  939. // // }
  940. // //#endif
  941. //
  942. //}
  943. #pragma mark -- 文件流上传图片
  944. - (void)pictureToNet:(NSURL *)pictureUrl
  945. {
  946. [[BGHUDHelper sharedInstance] syncLoading:nil];
  947. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  948. [parmDict setObject:@"pai_podcast" forKey:@"ctl"];
  949. [parmDict setObject:@"upload" forKey:@"act"];
  950. [parmDict setObject:[IMAPlatform sharedInstance].host.userId forKey:@"id"];
  951. [[NetHttpsManager manager] POSTWithDict:parmDict andFileUrl:pictureUrl SuccessBlock:^(NSDictionary *responseJson) {
  952. if ([responseJson toInt:@"status"] == 1)
  953. {
  954. NSLog(@"%@",self.pictArr);
  955. NSString * pictStr = [responseJson toString:@"server_full_path"];
  956. if (self.isOTOShop)
  957. {
  958. if (self.addPhoto.tag < self.pictArr.count - 1 ) {//替换---已存在图片情况下
  959. [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
  960. }
  961. else
  962. {
  963. //[self.pictArr addObject:pictStr];
  964. [self.pictArr insertObject:pictStr atIndex:self.pictArr.count - 1];
  965. }
  966. }
  967. else
  968. {
  969. if (self.addPhoto.tag < self.pictArr.count - 1 && self.addPhoto.tag > 0) {//替换---已存在图片情况下
  970. [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
  971. }
  972. else if (self.addPhoto.tag == 0 && self.pictArr.count == 5)
  973. {
  974. if ([self.pictArr.firstObject isEqual:@"me_addPhoto"])
  975. {
  976. [self.pictArr addObject:pictStr];
  977. [self.pictArr removeObject:@"me_addPhoto"];
  978. }
  979. else
  980. {
  981. [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
  982. }
  983. // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:pictStr];
  984. }
  985. else{//增加
  986. [self.pictArr addObject:pictStr];
  987. //[self.pictArr insertObject:urlString atIndex:self.pictArr.count - 1];
  988. }
  989. }
  990. // if (self.addPhoto.tag < self.pictArr.count - 1 && self.addPhoto.tag > 0)
  991. // { // 替换---已存在图片情况下
  992. // [self.pictArr replaceObjectAtIndex:self.addPhoto.tag withObject:[responseJson toString:@"server_full_path"]];
  993. // }
  994. // else
  995. // { // 增加
  996. // if (self.isOTOShop)
  997. // {
  998. // [self.pictArr insertObject:[responseJson toString:@"server_full_path"] atIndex:self.pictArr.count - 1];
  999. // }
  1000. // else
  1001. // {
  1002. // [self.pictArr addObject:[responseJson toString:@"server_full_path"]];
  1003. // }
  1004. // //[self.pictArr insertObject:[responseJson toString:@"server_full_path"] atIndex:self.pictArr.count - 1];
  1005. // //[self.pictArr addObject:[responseJson toString:@"server_full_path"]];
  1006. // }
  1007. [self.headerView getPicturearr:self.pictArr block:^{
  1008. [self.headerView.getPhotoCollection reloadData];
  1009. }];
  1010. [[BGHUDHelper sharedInstance] syncStopLoading];
  1011. }
  1012. [[BGHUDHelper sharedInstance] syncStopLoading];
  1013. } FailureBlock:^(NSError *error) {
  1014. [[BGHUDHelper sharedInstance] tipMessage:[NSString stringWithFormat:@"%@",error]];
  1015. [[BGHUDHelper sharedInstance] syncStopLoading];
  1016. }];
  1017. }
  1018. #pragma mark - 保存图片至沙盒
  1019. - (void) saveImage:(UIImage *)currentImage withName:(NSString *)imageName{
  1020. NSData *imageData = UIImageJPEGRepresentation(currentImage, 0.5);
  1021. NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
  1022. _uploadFilePath = fullPath;
  1023. [imageData writeToFile:fullPath atomically:NO];
  1024. }
  1025. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
  1026. [self dismissViewControllerAnimated:YES completion:nil];
  1027. }
  1028. #pragma mark - 返回上一级
  1029. - (void)returnToMeVc
  1030. {
  1031. NSString * str;
  1032. if (_isOTOShop )
  1033. {
  1034. if ([self.shopType isEqualToString:@"EditShopping"])
  1035. {
  1036. str = ASLocalizedString(@"确定放弃修改商品信息?");
  1037. }
  1038. else if ([self.shopType isEqualToString:@"EntityShopping"])
  1039. {
  1040. str = ASLocalizedString(@"确定放弃新增商品?");
  1041. }
  1042. }
  1043. else
  1044. {
  1045. str = ASLocalizedString(@"确定放弃新增竞拍商品?");
  1046. }
  1047. FWWeakify(self)
  1048. [FanweMessage alert:nil message:str destructiveAction:^{
  1049. FWStrongify(self)
  1050. #if kSupportAuction
  1051. [self.navigationController setNavigationBarHidden:YES animated:YES];
  1052. #endif
  1053. #if kSupportH5Shopping
  1054. #endif
  1055. [self popVC];
  1056. } cancelAction:^{
  1057. }];
  1058. }
  1059. #pragma mark - Table view data source
  1060. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  1061. {
  1062. if ([self.shopType isEqualToString:@"VirtualShopping"])
  1063. {
  1064. return 5;
  1065. }
  1066. else
  1067. {
  1068. return 2;
  1069. }
  1070. }
  1071. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  1072. #pragma mark --- 虚拟商品返回分区行数
  1073. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  1074. switch (section) {
  1075. case 0:
  1076. {
  1077. return 1;
  1078. }
  1079. break;
  1080. case 1:
  1081. {
  1082. return 4;
  1083. }
  1084. break;
  1085. case 2:
  1086. {
  1087. return 3;
  1088. }
  1089. break;
  1090. case 3:
  1091. {
  1092. return 3;
  1093. }
  1094. break;
  1095. case 4:
  1096. {
  1097. return 1;
  1098. }
  1099. break;
  1100. default:
  1101. break;
  1102. }
  1103. }
  1104. #pragma mark --- 实物竞拍返回分区行数
  1105. else if([self.shopType isEqualToString:@"EntityAuctionShopping"])
  1106. {
  1107. switch (section) {
  1108. case 0:
  1109. {
  1110. return 2;
  1111. }
  1112. break;
  1113. case 1:
  1114. {
  1115. return 3;
  1116. }
  1117. break;
  1118. default:
  1119. break;
  1120. }
  1121. }
  1122. //O2T
  1123. else{
  1124. #pragma mark --- 实物商品返回分区行数
  1125. switch (section) {
  1126. case 0:
  1127. {
  1128. if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop) {
  1129. return 3;
  1130. }
  1131. return 4;
  1132. }
  1133. break;
  1134. case 1:
  1135. {
  1136. return 1;
  1137. }
  1138. break;
  1139. default:
  1140. break;
  1141. }
  1142. }
  1143. return 0;
  1144. }
  1145. #pragma mark -- 返回区头的高度
  1146. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  1147. if ([self.shopType isEqualToString:@"EntityAuctionShopping"])
  1148. {
  1149. return 0.1f;
  1150. }
  1151. else if (section == 0) {
  1152. return 16.0f;
  1153. }
  1154. return 0.1f;
  1155. }
  1156. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  1157. #pragma mark --- 虚拟商品返回cell
  1158. if ([self.shopType isEqualToString:@"VirtualShopping"]) {//虚拟商品
  1159. if (indexPath.section == 4) {
  1160. //拍品描述
  1161. CdescriptTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"desCell" forIndexPath:indexPath];
  1162. cell.desTextView.delegate = self;
  1163. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1164. [cell.desTextView addSubview:self.placehoderLabel];
  1165. return cell;
  1166. }else if (indexPath.section == 3){
  1167. NSArray *aTitle = @[ASLocalizedString(@"竞拍时间"),ASLocalizedString(@"延时值"),ASLocalizedString(@"最大延时")];
  1168. NSArray *timeN = @[ASLocalizedString(@"小时"),ASLocalizedString(@"分钟"),ASLocalizedString(@"次")];
  1169. TimeTableViewCell *timeCell = [tableView dequeueReusableCellWithIdentifier:@"timeCell" forIndexPath:indexPath];
  1170. timeCell.textField.delegate = self;
  1171. [timeCell.textField addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
  1172. timeCell.nameLable.text = aTitle[indexPath.row];
  1173. timeCell.twoLable.text = timeN[indexPath.row];
  1174. timeCell.selectionStyle = UITableViewCellSelectionStyleNone;
  1175. if (indexPath.row == 0) {
  1176. timeCell.textField.keyboardType = UIKeyboardTypeDecimalPad;
  1177. timeCell.textField.tag = 6;
  1178. if (_fistTime) {
  1179. timeCell.textField.text = @"0.3";
  1180. _auctionTimeStr = timeCell.textField.text;
  1181. [self.shopDic setObject:timeCell.textField.text forKey:@"pai_time"];
  1182. }
  1183. }else if (indexPath.row == 1){
  1184. timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
  1185. timeCell.textField.tag = 7;
  1186. if (_fistDelay) {
  1187. timeCell.textField.text = @"3";
  1188. _delayTimeStr = timeCell.textField.text;
  1189. [self.shopDic setObject:timeCell.textField.text forKey:@"pai_yanshi"];
  1190. }
  1191. }else{
  1192. timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
  1193. timeCell.textField.tag = 8;
  1194. if (_fistMax) {
  1195. timeCell.textField.text = @"3";
  1196. _maxDelayTimeStr = timeCell.textField.text;
  1197. [self.shopDic setObject:timeCell.textField.text forKey:@"max_yanshi"];
  1198. }
  1199. }
  1200. return timeCell;
  1201. }else{
  1202. BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
  1203. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1204. cell.text_field.delegate = self;
  1205. [cell.text_field addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
  1206. if (indexPath.section == 0 ) {
  1207. cell.nameL.text = ASLocalizedString(@"拍品名称");
  1208. cell.text_field.tag = 0;
  1209. cell.text_field.placeholder = ASLocalizedString(@"请输入拍品名称");
  1210. }else if (indexPath.section == 1){
  1211. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1212. if (indexPath.row == 0) {
  1213. cell.nameL.text = ASLocalizedString(@"约会时间");
  1214. cell.text_field.text = ASLocalizedString(@"2016年7月18日 18 : 00");
  1215. cell.text_field.enabled = NO;
  1216. cell.text_field.placeholder = ASLocalizedString(@"点击选择约会时间");
  1217. cell.text_field.text = self.textData;
  1218. }else{
  1219. NSArray *arr = @[ASLocalizedString(@"约会地点"),ASLocalizedString(@"联系人"),ASLocalizedString(@"联系电话")];
  1220. NSArray *placeText = @[ASLocalizedString(@"点击设置约会地点"),ASLocalizedString(@"预置主播昵称"),ASLocalizedString(@"预置主播手机号")];
  1221. cell.text_field.placeholder = placeText[indexPath.row - 1];
  1222. cell.nameL.text = arr[indexPath.row - 1];
  1223. // cell.text_field.clearsOnBeginEditing = YES;
  1224. if (indexPath.row == 1) {
  1225. cell.text_field.enabled = NO;
  1226. if (_keyWordStr != nil && ![_keyWordStr isEqualToString:@""]) {
  1227. cell.text_field.text = _keyWordStr;
  1228. [self.shopDic setObject:cell.text_field.text forKey:@"place"];
  1229. }else{
  1230. if (self.BuguLive.locateName != nil && ![self.BuguLive.locateName isEqualToString:@""]) {
  1231. cell.text_field.text = [NSString stringWithFormat:@"%@",self.BuguLive.locateName];
  1232. [self.shopDic setObject:cell.text_field.text forKey:@"place"];
  1233. }else{
  1234. cell.text_field.text = ASLocalizedString(@"定位中。。。");
  1235. // [FanweMessage alert:ASLocalizedString(@"请在设置->隐私->定位服务->本App下选择使用期间")];
  1236. }
  1237. }
  1238. }else if (indexPath.row == 2){
  1239. cell.text_field.tag = 1;
  1240. }else{
  1241. cell.text_field.tag = 2;
  1242. cell.text_field.keyboardType = UIKeyboardTypeNumberPad;
  1243. }
  1244. }
  1245. }else {
  1246. // NSArray *placeText = @[ASLocalizedString(@"请输入起拍价"),ASLocalizedString(@"请输入保证金额度"),ASLocalizedString(@"请输入加价幅度")];
  1247. NSArray *titleArr = @[ASLocalizedString(@"起拍价"),ASLocalizedString(@"保证金"),ASLocalizedString(@"加价幅度")];
  1248. // cell.text_field.placeholder = placeText[indexPath.row];
  1249. cell.nameL.text = titleArr[indexPath.row];
  1250. if (indexPath.row == 0) {
  1251. cell.text_field.tag = 3;
  1252. cell.text_field.text = @"100";
  1253. _qpPriceStr = cell.text_field.text;
  1254. [self.shopDic setObject:cell.text_field.text forKey:@"qp_diamonds"];
  1255. }else if (indexPath.row == 1){
  1256. cell.text_field.tag = 4;
  1257. cell.text_field.text = @"100";
  1258. _bzStr = cell.text_field.text;
  1259. [self.shopDic setObject:cell.text_field.text forKey:@"bz_diamonds"];
  1260. }else{
  1261. cell.text_field.tag = 5;
  1262. cell.text_field.text = @"30";
  1263. _addPriceStr = cell.text_field.text;
  1264. [self.shopDic setObject:cell.text_field.text forKey:@"jj_diamonds"];
  1265. }
  1266. cell.text_field.keyboardType = UIKeyboardTypeNumberPad;
  1267. }
  1268. return cell;
  1269. }
  1270. }
  1271. else if ([self.shopType isEqualToString:@"EntityAuctionShopping"]) {
  1272. if (indexPath.section==0) {
  1273. BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
  1274. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1275. cell.text_field.delegate = self;
  1276. [cell.text_field addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
  1277. // NSArray *placeText = @[ASLocalizedString(@"请输入保证金额度"),ASLocalizedString(@"请输入加价幅度")];
  1278. NSArray *titleArr = @[ASLocalizedString(@"保证金"),ASLocalizedString(@"加价幅度")];
  1279. // cell.text_field.placeholder = placeText[indexPath.row];
  1280. cell.nameL.text = titleArr[indexPath.row];
  1281. if (indexPath.row == 0) {
  1282. cell.text_field.tag = 14;
  1283. // cell.text_field.placeholder = @"100";
  1284. // if ([cell.text_field.text isEqualToString:@""]) {
  1285. // _bzStr = cell.text_field.placeholder;
  1286. // [self.shopDic setObject:_bzStr forKey:@"bz_diamonds"];
  1287. // }
  1288. if (self.entityAuctionModel.bz_diamonds != nil) {
  1289. cell.text_field.text = self.entityAuctionModel.bz_diamonds;
  1290. cell.text_field.enabled = NO;
  1291. if (![cell.text_field.text isEqualToString:@""]) {
  1292. _bzStr = cell.text_field.text;
  1293. [self.shopDic setObject:_bzStr forKey:@"bz_diamonds"];
  1294. }
  1295. }
  1296. }else if (indexPath.row == 1){
  1297. cell.text_field.tag = 15;
  1298. // cell.text_field.placeholder = @"30";
  1299. // if ([cell.text_field.text isEqualToString:@""]) {
  1300. // _addPriceStr = cell.text_field.placeholder;
  1301. // [self.shopDic setObject:_addPriceStr forKey:@"jj_diamonds"];
  1302. // }
  1303. if (self.entityAuctionModel.jj_diamonds != nil) {
  1304. cell.text_field.text = self.entityAuctionModel.jj_diamonds;
  1305. cell.text_field.enabled = NO;
  1306. if (![cell.text_field.text isEqualToString:@""]) {
  1307. _addPriceStr = cell.text_field.text;
  1308. [self.shopDic setObject:_addPriceStr forKey:@"jj_diamonds"];
  1309. }
  1310. }
  1311. }
  1312. cell.text_field.keyboardType = UIKeyboardTypeNumberPad;
  1313. return cell;
  1314. }
  1315. else
  1316. {
  1317. NSArray *aTitle = @[ASLocalizedString(@"竞拍时间"),ASLocalizedString(@"延时值"),ASLocalizedString(@"最大延时")];
  1318. NSArray *timeN = @[ASLocalizedString(@"小时"),ASLocalizedString(@"分钟"),ASLocalizedString(@"次")];
  1319. TimeTableViewCell *timeCell = [tableView dequeueReusableCellWithIdentifier:@"timeCell" forIndexPath:indexPath];
  1320. timeCell.textField.delegate = self;
  1321. [timeCell.textField addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
  1322. timeCell.nameLable.text = aTitle[indexPath.row];
  1323. timeCell.twoLable.text = timeN[indexPath.row];
  1324. timeCell.selectionStyle = UITableViewCellSelectionStyleNone;
  1325. if (indexPath.row == 0) {
  1326. timeCell.textField.keyboardType = UIKeyboardTypeDecimalPad;
  1327. timeCell.textField.tag = 16;
  1328. if (_fistTime) {
  1329. timeCell.textField.placeholder = @"0.3";
  1330. [self.shopDic setObject:timeCell.textField.placeholder forKey:@"pai_time"];
  1331. }
  1332. // timeCell.textField.placeholder = @"1";
  1333. if (self.entityAuctionModel.pai_time != nil) {
  1334. timeCell.textField.placeholder = self.entityAuctionModel.pai_time;
  1335. if(![timeCell.textField.placeholder isEqualToString:@""]){
  1336. _auctionTimeStr = timeCell.textField.placeholder;
  1337. [self.shopDic setObject:_auctionTimeStr forKey:@"pai_time"];
  1338. }
  1339. }
  1340. }else if (indexPath.row == 1){
  1341. timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
  1342. timeCell.textField.tag = 17;
  1343. if (_fistDelay) {
  1344. timeCell.textField.placeholder = @"3";
  1345. [self.shopDic setObject:timeCell.textField.placeholder forKey:@"pai_yanshi"];
  1346. }
  1347. // timeCell.textField.placeholder = @"30";
  1348. if (self.entityAuctionModel.pai_yanshi != nil) {
  1349. timeCell.textField.placeholder = self.entityAuctionModel.pai_yanshi;
  1350. if (![timeCell.textField.placeholder isEqualToString:@""]) {
  1351. _delayTimeStr = timeCell.textField.placeholder;
  1352. [self.shopDic setObject:_delayTimeStr forKey:@"pai_yanshi"];
  1353. }
  1354. }
  1355. }else{
  1356. timeCell.textField.keyboardType = UIKeyboardTypeNumberPad;
  1357. timeCell.textField.tag = 18;
  1358. if (_fistMax) {
  1359. timeCell.textField.placeholder = @"3";
  1360. [self.shopDic setObject:timeCell.textField.placeholder forKey:@"max_yanshi"];
  1361. }
  1362. // timeCell.textField.placeholder = @"3";
  1363. if (self.entityAuctionModel.max_yanshi != nil) {
  1364. timeCell.textField.placeholder = self.entityAuctionModel.max_yanshi;
  1365. if (![timeCell.textField.placeholder isEqualToString:@""]) {
  1366. _maxDelayTimeStr = timeCell.textField.placeholder;
  1367. [self.shopDic setObject:_maxDelayTimeStr forKey:@"max_yanshi"];
  1368. }
  1369. }
  1370. }
  1371. return timeCell;
  1372. }
  1373. }
  1374. else{
  1375. #pragma mark --- 实体商品返回cell
  1376. if (indexPath.section == 0) {
  1377. BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
  1378. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1379. cell.text_field.delegate = self;
  1380. [cell.text_field addTarget:self action:@selector(changeTextField:) forControlEvents:UIControlEventEditingChanged];
  1381. NSArray *titleArr;
  1382. if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop) {
  1383. titleArr = @[ASLocalizedString(@"商品名称"),ASLocalizedString(@"商品价钱"),ASLocalizedString(@"商品链接")];
  1384. }
  1385. else
  1386. {
  1387. titleArr = @[ASLocalizedString(@"商品名称"),ASLocalizedString(@"商品价钱"),ASLocalizedString(@"商品链接"),ASLocalizedString(@"快递费")];
  1388. }
  1389. if ([self.shopType isEqualToString:@"EditShopping"]){
  1390. cell.nameL.text = titleArr[indexPath.row];
  1391. cell.text_field.placeholder = self.editArr[indexPath.row];
  1392. cell.text_field.text = self.editArr[indexPath.row];
  1393. }else{
  1394. NSArray *pholderArr = @[ASLocalizedString(@"请输入商品名称"),ASLocalizedString(@"请输入商品价钱(最多两位小数)"),ASLocalizedString(@"请输入商品链接"),ASLocalizedString(@"请输入快递费")];
  1395. cell.nameL.text = titleArr[indexPath.row];
  1396. cell.text_field.placeholder = pholderArr[indexPath.row];
  1397. }
  1398. if (indexPath.row == 0) {
  1399. cell.text_field.tag = 10;//商品名称
  1400. }else if (indexPath.row == 1){
  1401. cell.text_field.tag = 11;//商品价钱
  1402. cell.text_field.keyboardType = UIKeyboardTypeDecimalPad;
  1403. }else if (indexPath.row == 2){
  1404. cell.text_field.tag = 12;//商品链接
  1405. if ([self.shopType isEqualToString:@"EntityShopping"]) {
  1406. if (!_isOTOShop) {
  1407. cell.text_field.text = @"http://";
  1408. }
  1409. }
  1410. else if ([self.shopType isEqualToString:@"EditShopping"])
  1411. {
  1412. cell.text_field.text = self.model.url;
  1413. _urlString = cell.text_field.text;
  1414. }
  1415. }else if (indexPath.row == 3){
  1416. cell.text_field.keyboardType = UIKeyboardTypeDecimalPad;
  1417. cell.text_field.tag = 13;//商品快递费
  1418. }
  1419. return cell;
  1420. }else{
  1421. //实体拍品描述
  1422. CdescriptTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"desCell" forIndexPath:indexPath];
  1423. cell.shopCdescriptLable.text = ASLocalizedString(@"商品描述");
  1424. cell.desTextView.delegate = self;
  1425. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  1426. if ([self.shopType isEqualToString:@"EditShopping"]){
  1427. cell.desTextView.text = self.model.descrStr;
  1428. }
  1429. [cell.desTextView addSubview:self.placehoderLabel];
  1430. return cell;
  1431. }
  1432. }
  1433. }
  1434. - (void)changeTextField:(UITextField *)textField
  1435. {
  1436. switch (textField.tag) {
  1437. case 0:
  1438. {
  1439. if (textField.text.length >= 30)
  1440. {
  1441. [self.view endEditing:YES];
  1442. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于30个字符的名称")];
  1443. NSString *s = [textField.text substringToIndex:30];
  1444. textField.text = s;
  1445. }
  1446. _nameStr = textField.text;
  1447. }
  1448. break;
  1449. case 1:
  1450. {
  1451. _contactStr = textField.text;
  1452. }
  1453. break;
  1454. case 2:
  1455. {
  1456. _mobileStr = textField.text;
  1457. }
  1458. break;
  1459. case 3:
  1460. {
  1461. _qpPriceStr = textField.text;
  1462. }
  1463. break;
  1464. case 4:
  1465. {
  1466. _bzStr = textField.text;
  1467. }
  1468. break;
  1469. case 5:
  1470. {
  1471. _addPriceStr = textField.text;
  1472. }
  1473. break;
  1474. case 6:
  1475. {
  1476. _auctionTimeStr = textField.text;
  1477. }
  1478. break;
  1479. case 7:
  1480. {
  1481. _delayTimeStr = textField.text;
  1482. }
  1483. break;
  1484. case 8:
  1485. {
  1486. _maxDelayTimeStr = textField.text;
  1487. }
  1488. break;
  1489. case 9:
  1490. {
  1491. }
  1492. break;
  1493. case 10:
  1494. {
  1495. _nameStr = textField.text;
  1496. }
  1497. break;
  1498. case 11:
  1499. {
  1500. _priceStr = textField.text;
  1501. }
  1502. break;
  1503. case 12:
  1504. {
  1505. _urlStr = textField.text;
  1506. }
  1507. break;
  1508. case 13:
  1509. {
  1510. _expressPriceStr = textField.text;
  1511. }
  1512. break;
  1513. case 14:
  1514. {
  1515. _bzStr = textField.text;
  1516. }
  1517. break;
  1518. case 15:
  1519. {
  1520. _addPriceStr = textField.text;
  1521. }
  1522. break;
  1523. case 16:
  1524. {
  1525. _auctionTimeStr = textField.text;
  1526. }
  1527. break;
  1528. case 17:
  1529. {
  1530. _delayTimeStr = textField.text;
  1531. }
  1532. break;
  1533. case 18:
  1534. {
  1535. _maxDelayTimeStr = textField.text;
  1536. }
  1537. break;
  1538. default:
  1539. break;
  1540. }
  1541. }
  1542. - (void)chooseAddress:(CLLocationCoordinate2D)location address:(NSString *)address andProvinceString:(NSString *)provinceString andCityString:(NSString *)cityString andAreaString:(NSString *)areaString
  1543. {
  1544. self.keyWordStr = address;
  1545. [self.releaseTabView reloadData];
  1546. }
  1547. - (void)textViewDidChange:(UITextView *)textView
  1548. {
  1549. _desStr = textView.text;
  1550. }
  1551. - (void)textViewDidEndEditing:(UITextView *)textView{
  1552. if (textView.text.length > 0) {
  1553. _desStr = textView.text;
  1554. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  1555. [self.shopDic setObject:textView.text forKey:@"description"];
  1556. }
  1557. else{
  1558. [self.entiShopDic setObject:textView.text forKey:@"description"];
  1559. [self.editInfo setObject:textView.text forKey:@"description"];
  1560. }
  1561. }
  1562. }
  1563. - (void)textFieldDidEndEditing:(UITextField *)textField{
  1564. #pragma mark --- 虚拟商品输入框设置
  1565. switch (textField.tag) {
  1566. case 0:
  1567. {
  1568. if (textField.text.length >= 30)
  1569. {
  1570. [self.view endEditing:YES];
  1571. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于30个字符的名称")];
  1572. NSString *s = [textField.text substringToIndex:30];
  1573. textField.text = s;
  1574. }
  1575. [self.shopDic setObject:textField.text forKey:@"name"];
  1576. _nameStr = textField.text;
  1577. }
  1578. break;
  1579. case 1:
  1580. {
  1581. [self.shopDic setObject:textField.text forKey:@"contact"];
  1582. _contactStr = textField.text;
  1583. }
  1584. break;
  1585. case 2:
  1586. {
  1587. if (textField.text.length < 1)
  1588. {
  1589. [self.view endEditing:YES];
  1590. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入电话号码")];
  1591. return;
  1592. }
  1593. if (textField.text.length < 1) {
  1594. [self.view endEditing:YES];
  1595. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"手机号限制11位数!")];
  1596. return;
  1597. }
  1598. [self.shopDic setObject:textField.text forKey:@"mobile"];
  1599. _mobileStr = textField.text;
  1600. }
  1601. break;
  1602. case 3:
  1603. {
  1604. if (textField.text.length < 1 ||[textField.text integerValue]== 0)
  1605. {
  1606. [self.view endEditing:YES];
  1607. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍起拍价格不能为空或0")];
  1608. return;
  1609. }
  1610. [self.shopDic setObject:textField.text forKey:@"qp_diamonds"];
  1611. _qpPriceStr = textField.text;
  1612. }
  1613. break;
  1614. case 4:
  1615. {
  1616. if (textField.text.length < 1||[textField.text integerValue]== 0)
  1617. {
  1618. [self.view endEditing:YES];
  1619. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍保证金不能为空或0")];
  1620. return;
  1621. }
  1622. [self.shopDic setObject:textField.text forKey:@"bz_diamonds"];
  1623. _bzStr = textField.text;
  1624. }
  1625. break;
  1626. case 5:
  1627. {
  1628. if (textField.text.length < 1 || [textField.text integerValue]== 0)
  1629. {
  1630. [self.view endEditing:YES];
  1631. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"加价幅度不能为空或0")];
  1632. return;
  1633. }
  1634. [self.shopDic setObject:textField.text forKey:@"jj_diamonds"];
  1635. _addPriceStr = textField.text;
  1636. }
  1637. break;
  1638. case 6:
  1639. {
  1640. _fistTime = NO;
  1641. BOOL num = false ;
  1642. if ([textField.text floatValue] >= 0.0) {
  1643. num = YES;
  1644. }
  1645. if ([textField.text isEqualToString:@"0"] || [textField.text isEqualToString:@""] || num == false ||(textField.text.length > 2 && [textField.text hasSuffix:@"."])||(textField.text.length > 0 && [textField.text hasPrefix:@"."])) {
  1646. textField.text =@"";
  1647. }
  1648. if (textField.text.floatValue < 24 && textField.text.floatValue >0) {
  1649. [self.shopDic setObject:textField.text forKey:@"pai_time"];
  1650. }else{
  1651. textField.text =@"";
  1652. [self.view endEditing:YES];
  1653. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍时间")];
  1654. }
  1655. _auctionTimeStr = textField.text;
  1656. }
  1657. break;
  1658. case 7:
  1659. {
  1660. _fistDelay = NO;
  1661. if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1) ||(textField.text.length > 1 && [textField.text hasPrefix: @"0"])) {
  1662. textField.text =@"";
  1663. }
  1664. if (textField.text.integerValue < 60 && textField.text.integerValue >0) {
  1665. [self.shopDic setObject:textField.text forKey:@"pai_yanshi"];
  1666. }else{
  1667. textField.text =@"";
  1668. [self.view endEditing:YES];
  1669. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入最大延时时间")];
  1670. }
  1671. _delayTimeStr = textField.text;
  1672. }
  1673. break;
  1674. case 8:
  1675. {
  1676. _fistMax = NO;
  1677. if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1)
  1678. || (textField.text.length > 2 && [textField.text hasPrefix: @"0"])) {
  1679. [self.view endEditing:YES];
  1680. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
  1681. textField.text =@"";
  1682. }
  1683. if (textField.text.integerValue < 10 && textField.text.integerValue >=0) {
  1684. [self.shopDic setObject:textField.text forKey:@"max_yanshi"];
  1685. }else{
  1686. [self.view endEditing:YES];
  1687. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
  1688. textField.text =@"";
  1689. }
  1690. _maxDelayTimeStr = textField.text;
  1691. }
  1692. break;
  1693. case 10:
  1694. {
  1695. if (textField.text.length < 1)
  1696. {
  1697. [self.view endEditing:YES];
  1698. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入商品名称")];
  1699. return;
  1700. }
  1701. if ([self.shopType isEqualToString:@"EditShopping"]){
  1702. [self.editInfo setObject:textField.text forKey:@"name"];
  1703. }else{
  1704. [self.entiShopDic setObject:textField.text forKey:@"name"];
  1705. }
  1706. _nameStr = textField.text;
  1707. }
  1708. break;
  1709. case 11:
  1710. {
  1711. if (textField.text.length < 1)
  1712. {
  1713. [self.view endEditing:YES];
  1714. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入商品价格")];
  1715. _priceStr = @"";
  1716. return;
  1717. }
  1718. NSString *priceRegex = @"^[0-9]+(\\.[0-9]{1,2})?$";
  1719. NSPredicate *priceTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",priceRegex];
  1720. if (![priceTest evaluateWithObject:textField.text]) {
  1721. [self.view endEditing:YES];
  1722. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请保证输入的商品价格小数点最多两位")];
  1723. return;
  1724. }
  1725. if ([self.shopType isEqualToString:@"EditShopping"]){
  1726. [self.editInfo setObject:textField.text forKey:@"price"];
  1727. }else{
  1728. [self.entiShopDic setObject:textField.text forKey:@"price"];
  1729. }
  1730. _priceStr = textField.text;
  1731. }
  1732. break;
  1733. case 12:
  1734. {
  1735. if ([self.shopType isEqualToString:@"EditShopping"]){
  1736. [self.editInfo setObject:textField.text forKey:@"url"];
  1737. }else{
  1738. [self.entiShopDic setObject:textField.text forKey:@"url"];
  1739. }
  1740. _urlStr = textField.text;
  1741. }
  1742. break;
  1743. case 13:
  1744. {
  1745. if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop) {
  1746. return;
  1747. }
  1748. _expressPriceStr = textField.text;
  1749. if (textField.text.length < 1)
  1750. {
  1751. [self.view endEditing:YES];
  1752. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入快递费")];
  1753. return;
  1754. }
  1755. if ([self.shopType isEqualToString:@"EditShopping"]){
  1756. [self.editInfo setObject:textField.text forKey:@"kd_cost"];
  1757. }else{
  1758. [self.entiShopDic setObject:textField.text forKey:@"kd_cost"];
  1759. }
  1760. _expressPriceStr = textField.text;
  1761. }
  1762. break;
  1763. case 14:
  1764. {
  1765. if (textField.text.length < 1||[textField.text integerValue]== 0)
  1766. {
  1767. [self.view endEditing:YES];
  1768. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"竞拍保证金不能为空或0")];
  1769. textField.text=@"";
  1770. }
  1771. else
  1772. {
  1773. [self.shopDic setObject:textField.text forKey:@"bz_diamonds"];
  1774. }
  1775. _bzStr = textField.text;
  1776. }
  1777. break;
  1778. case 15:
  1779. {
  1780. if (textField.text.length < 1 || [textField.text integerValue]== 0)
  1781. {
  1782. [self.view endEditing:YES];
  1783. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"加价幅度不能为空或0")];
  1784. textField.text=@"";
  1785. }
  1786. else
  1787. {
  1788. [self.shopDic setObject:textField.text forKey:@"jj_diamonds"];
  1789. }
  1790. _addPriceStr = textField.text;
  1791. }
  1792. break;
  1793. case 16:
  1794. {
  1795. BOOL num = false ;
  1796. if ([textField.text floatValue] >= 0.0) {
  1797. num = YES;
  1798. }
  1799. if ([textField.text isEqualToString:@"0"] || [textField.text isEqualToString:@""] || num == false ||(textField.text.length > 2 && [textField.text hasSuffix:@"."])||(textField.text.length > 0 && [textField.text hasPrefix:@"."])) {
  1800. //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于24的合法字符")];
  1801. textField.text =@"";
  1802. }
  1803. if (textField.text.floatValue < 24 && textField.text.floatValue >0) {
  1804. [self.shopDic setObject:textField.text forKey:@"pai_time"];
  1805. }else{
  1806. [self.view endEditing:YES];
  1807. textField.text =@"";
  1808. //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于24的合法字符")];
  1809. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入竞拍时间")];
  1810. }
  1811. _auctionTimeStr = textField.text;
  1812. }
  1813. break;
  1814. case 17:
  1815. {
  1816. if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1) ||(textField.text.length > 1 && [textField.text hasPrefix: @"0"])) {
  1817. //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时时间")];
  1818. textField.text =@"";
  1819. }
  1820. if (textField.text.integerValue < 60 && textField.text.integerValue >0) {
  1821. [self.shopDic setObject:textField.text forKey:@"pai_yanshi"];
  1822. }else{
  1823. [self.view endEditing:YES];
  1824. textField.text =@"";
  1825. //[[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入小于60的合法字符")];
  1826. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"请输入延时时间")];
  1827. }
  1828. _delayTimeStr = textField.text;
  1829. }
  1830. break;
  1831. case 18:
  1832. {
  1833. if ( [textField.text isEqualToString:@""] || ([textField.text integerValue] == 0 && textField.text.length > 1)
  1834. || (textField.text.length > 2 && [textField.text hasPrefix: @"0"])) {
  1835. [self.view endEditing:YES];
  1836. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
  1837. textField.text =@"";
  1838. }
  1839. if (textField.text.integerValue < 10 && textField.text.integerValue >=0) {
  1840. [self.shopDic setObject:textField.text forKey:@"max_yanshi"];
  1841. }else{
  1842. [self.view endEditing:YES];
  1843. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"最大延时不超过9次合法字符")];
  1844. textField.text =@"";
  1845. }
  1846. _maxDelayTimeStr = textField.text;
  1847. }
  1848. break;
  1849. default:
  1850. break;
  1851. }
  1852. }
  1853. - (void)textFieldDidBeginEditing:(UITextField *)textField{
  1854. textField.placeholder = nil;
  1855. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  1856. [UIView animateWithDuration:0.5 animations:^{
  1857. // dateView.frame = CGRectMake(0, kScreenH + 260, kScreenW, 260);
  1858. self.dateView.frame = CGRectMake(0, kScreenH-64, kScreenW, kScreenH-64);
  1859. } completion:^(BOOL finished) {
  1860. }];
  1861. }
  1862. }
  1863. - (void)textViewDidBeginEditing:(UITextView *)textView{
  1864. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  1865. [UIView animateWithDuration:0.5 animations:^{
  1866. // dateView.frame = CGRectMake(0, kScreenH + 260, kScreenW, 260);
  1867. self.dateView.frame = CGRectMake(0, kScreenH-64, kScreenW, kScreenH-64);
  1868. } completion:^(BOOL finished) {
  1869. }];
  1870. }
  1871. }
  1872. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  1873. if (textField.tag == 0) {
  1874. NSString *comcatstr = [textField.text stringByReplacingCharactersInRange:range withString:string];
  1875. NSInteger caninputlen = 30 - comcatstr.length;
  1876. if (caninputlen >= 0)
  1877. {
  1878. return YES;
  1879. }
  1880. else
  1881. {
  1882. NSInteger len = string.length + caninputlen;
  1883. //防止当text.length + caninputlen < 0时,使得rg.length为一个非法最大正数出错
  1884. NSRange rg = {0,MAX(len,0)};
  1885. if (rg.length > 0)
  1886. {
  1887. NSString *s = [string substringWithRange:rg];
  1888. [textField setText:[textField.text stringByReplacingCharactersInRange:range withString:s]];
  1889. }
  1890. return NO;
  1891. }
  1892. }else if (textField.tag==2) {
  1893. if (![string isNumber]) {
  1894. return NO;
  1895. }
  1896. if (string.length == 0)
  1897. return YES;
  1898. NSInteger existedLength = textField.text.length;
  1899. NSInteger selectedLength = range.length;
  1900. NSInteger replaceLength = string.length;
  1901. if (existedLength - selectedLength + replaceLength > 11) {
  1902. return NO;
  1903. }
  1904. }
  1905. else if (textField.tag == 3 || textField.tag == 4 || textField.tag == 5 || textField.tag == 11 || textField.tag == 13 || textField.tag == 14 || textField.tag == 15)
  1906. {
  1907. if (string.length == 0)
  1908. return YES;
  1909. NSInteger existedLength = textField.text.length;
  1910. NSInteger selectedLength = range.length;
  1911. NSInteger replaceLength = string.length;
  1912. NSInteger number = 7;
  1913. if (textField.tag == 4 || textField.tag == 5 || textField.tag == 13 || textField.tag == 14 || textField.tag == 15) {
  1914. //设置竞拍保证金,加价幅度和快递费的最大金额限制
  1915. number = 5;
  1916. }
  1917. if (existedLength - selectedLength + replaceLength >number) {
  1918. [self.view endEditing:YES];
  1919. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"你输入的金额超过当前限制")];
  1920. return NO;
  1921. }
  1922. }
  1923. return YES;
  1924. }
  1925. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  1926. {
  1927. if (![text isEqualToString:@""])
  1928. {
  1929. self.placehoderLabel.hidden = YES;
  1930. }
  1931. if ([text isEqualToString:@""] && range.location == 0 && range.length == 1)
  1932. {
  1933. self.placehoderLabel.hidden = NO;
  1934. }
  1935. if (self.BuguLive.appModel.open_podcast_goods == 1 && _isOTOShop)
  1936. {
  1937. if (text.length == 0)
  1938. {
  1939. return YES;
  1940. }
  1941. NSInteger existedLength = textView.text.length;
  1942. NSInteger selectedLength = range.length;
  1943. NSInteger replaceLength = text.length;
  1944. if (existedLength - selectedLength + replaceLength > 25)
  1945. {
  1946. [self.view endEditing:YES];
  1947. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"商品描述不能超过25字")];
  1948. return NO;
  1949. }
  1950. }
  1951. return YES;
  1952. }
  1953. //- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  1954. //{
  1955. // if (textField.tag==2) {
  1956. // if (![string isNumber]) {
  1957. // return NO;
  1958. // }
  1959. // if (string.length == 0)
  1960. // return YES;
  1961. //
  1962. // NSInteger existedLength = textField.text.length;
  1963. // NSInteger selectedLength = range.length;
  1964. // NSInteger replaceLength = string.length;
  1965. // if (existedLength - selectedLength + replaceLength > 11) {
  1966. // return NO;
  1967. // }
  1968. // }
  1969. // return YES;
  1970. //}
  1971. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  1972. #pragma mark --- 虚拟商品返回行高
  1973. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  1974. if (indexPath.section == 4) {
  1975. return 150.0f;
  1976. }else{
  1977. return 44.0f;
  1978. }
  1979. }
  1980. else if ([self.shopType isEqualToString:@"EntityAuctionShopping"])
  1981. {
  1982. return 44.0f;
  1983. }
  1984. else{
  1985. if (indexPath.section == 0) {
  1986. return 44.0f;
  1987. }else{
  1988. return 150.0f;
  1989. }
  1990. }
  1991. #pragma mark --- 实体商品返回行高
  1992. }
  1993. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  1994. if ([self.shopType isEqualToString:@"VirtualShopping"]) {
  1995. //虚拟商品
  1996. #pragma mark --- 虚拟商品点击cell
  1997. if (indexPath.section == 1) {
  1998. if (indexPath.row == 0) {
  1999. //日记日期
  2000. [self.shopDic setObject:self.datePicker.timeLable.text forKey:@"date_time"];
  2001. [UIView animateWithDuration:0.5 animations:^{
  2002. // dateView.frame = CGRectMake(0, kScreenH - 260, kScreenW, 260);
  2003. self.dateView.frame = CGRectMake(0, 0, kScreenW, kScreenH-64);
  2004. } completion:^(BOOL finished) {
  2005. }];
  2006. [self.view endEditing:YES];
  2007. }else if (indexPath.row == 1){
  2008. [self.view endEditing:YES];
  2009. //腾讯地图
  2010. MapViewController *mapVc = [[MapViewController alloc]init];
  2011. mapVc.hidesBottomBarWhenPushed = YES;
  2012. mapVc.fromType = 0;
  2013. mapVc.delegate = self;
  2014. [self.navigationController pushViewController:mapVc animated:YES];
  2015. }
  2016. }
  2017. }
  2018. }
  2019. #pragma mark -- 回收键盘
  2020. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
  2021. [self.view resignFirstResponder];
  2022. }
  2023. #pragma mark -- 创建日期/获取当前时间点
  2024. - (void)creatPickView{
  2025. if (!self.dateView)
  2026. {
  2027. // dateView = [[UIView alloc]initWithFrame:CGRectMake(0,kScreenH + 260,kScreenW,260)];
  2028. // dateView.backgroundColor = [UIColor whiteColor];
  2029. // [self.view addSubview:dateView];
  2030. self.dateView = [[UIView alloc]initWithFrame:CGRectMake(0,kScreenH-64 ,kScreenW,kScreenH-64)];
  2031. self.dateView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
  2032. [self.view addSubview:self.dateView];
  2033. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap)];
  2034. [self.dateView addGestureRecognizer:tap];
  2035. self.datePicker = [[[NSBundle mainBundle]loadNibNamed:@"DatePickerOfView" owner:self options:nil]lastObject];
  2036. self.datePicker.frame = CGRectMake(0, kScreenH-260-64, kScreenW, 260);
  2037. [self.dateView addSubview:self.datePicker];
  2038. [self.datePicker.CBtn addTarget:self action:@selector(handleToSelectTime:) forControlEvents:UIControlEventTouchUpInside];
  2039. [self.datePicker.Qbtn addTarget:self action:@selector(handleToSelectTime:) forControlEvents:UIControlEventTouchUpInside];
  2040. }
  2041. }
  2042. #pragma mark -- 日历确定按钮点击事件
  2043. - (void)handleToSelectTime:(UIButton *)button
  2044. {
  2045. if (button == self.datePicker.Qbtn)
  2046. {
  2047. self.textData = self.datePicker.timeLable.text;
  2048. [self.shopDic setObject:self.textData forKey:@"date_time"];
  2049. }
  2050. self.dateView.frame = CGRectMake(0, kScreenH-64,kScreenW,kScreenH-64);
  2051. [_releaseTabView reloadData];
  2052. }
  2053. - (void)tap
  2054. {
  2055. self.dateView.frame = CGRectMake(0, kScreenH-64,kScreenW,kScreenH-64);
  2056. }
  2057. - (void)dealloc
  2058. {
  2059. [[NSNotificationCenter defaultCenter] removeObserver:self];
  2060. }
  2061. - (void)didReceiveMemoryWarning {
  2062. [super didReceiveMemoryWarning];
  2063. }
  2064. @end