ApplyShopVC.m 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. //
  2. // ApplyShopVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/2/14.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "ApplyShopVC.h"
  9. #import "BondViewController.h"
  10. #import "SelectClassVC.h"
  11. #import "CommodityClassModel.h"
  12. #import "TZImagePickerController.h"
  13. #import <Qiniu/QiniuSDK.h>
  14. #import "YBStorageObj.h"
  15. @import CoreLocation;
  16. @interface ApplyShopVC ()<UIPickerViewDelegate, UIPickerViewDataSource,TZImagePickerControllerDelegate,UITextFieldDelegate,UITextViewDelegate,CLLocationManagerDelegate>
  17. {
  18. UIScrollView *_backScroll;
  19. UITextField *idField;
  20. UITextField *nameField;
  21. UITextField *cardField;
  22. UITextField *sellerNameField;//经营者名字
  23. UITextField *sellerPhoneField;//经营者手机号
  24. UITextField *sellerAddressField;//经营者所在地区
  25. MyTextView *sellerAddDesField; //经营者详细地址
  26. UITextField *receiverField;//经营者名字
  27. UITextField *receiverPhoneField;//经营者手机号
  28. UITextField *receiverAddressField;//经营者所在地区
  29. MyTextView *receiverAddDesField; //经营者详细地址
  30. NSString *selType;
  31. NSString *recever_provinceStr;
  32. NSString *recever_cityStr;
  33. NSString *recever_districtStr;
  34. UIButton *classBtn;
  35. UITapGestureRecognizer *customerTap;
  36. UITapGestureRecognizer *rejectedTap;
  37. UITapGestureRecognizer *bondTap;
  38. BOOL phoneBool;
  39. BOOL rejectedBool;
  40. CGFloat customerHeight;
  41. CGFloat rejectedHeight;
  42. UIView *cityPickBack;
  43. UIPickerView *cityPicker;
  44. //省市区-数组
  45. NSArray *province;
  46. NSArray *city;
  47. NSArray *district;
  48. //省市区-字符串
  49. NSString *provinceStr;
  50. NSString *cityStr;
  51. NSString *districtStr;
  52. NSDictionary *areaDic;
  53. NSString *selectedProvince;
  54. UIButton *busImgBtn;
  55. UIButton *otherImgBtn;
  56. UIImage *_dsp_busImg;
  57. UIImage *_dsp_othetImg;
  58. NSString *businessImgUrl;
  59. NSString *otherImgUrl;
  60. NSString *imgType;
  61. NSString *normalProvince;
  62. NSString *normalCity;
  63. NSString *normalDistrict;
  64. CLLocationManager *_lbsManager;
  65. NSString *classId;
  66. }
  67. @property(nonatomic, strong)UIView *infoView;//信息确认
  68. @property(nonatomic, strong)UIView *classView;//经营类目
  69. @property(nonatomic, strong)UIView *contactView;//联系方式
  70. @property(nonatomic, strong)UIView *customerView;//客服信息
  71. @property(nonatomic, strong)UIView *rejectedView;//退货信息
  72. @property(nonatomic, strong)UIView *zizhiView;//资质
  73. @property(nonatomic, strong)UIView *bondView;//保证金
  74. @property(nonatomic, strong)UIView *rejectDetail;
  75. @property(nonatomic, strong)UITextField *phoneField;
  76. @property(nonatomic, strong)NSMutableArray *classArr;
  77. @end
  78. @implementation ApplyShopVC
  79. -(void)initData{
  80. rejectedHeight = 56 ;
  81. customerHeight = 56;
  82. self.classArr =[NSMutableArray array];
  83. selType = @"0";
  84. imgType = @"0";
  85. businessImgUrl = @"";
  86. otherImgUrl = @"";
  87. normalProvince = @"";
  88. normalCity = @"";
  89. normalDistrict = @"";
  90. NSBundle *bundle = [NSBundle mainBundle];
  91. NSString *plistPath = [bundle pathForResource:@"area" ofType:@"plist"];
  92. areaDic = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
  93. NSArray *components = [areaDic allKeys];
  94. NSArray *sortedArray = [components sortedArrayUsingComparator: ^(id obj1, id obj2) {
  95. if ([obj1 integerValue] > [obj2 integerValue]) {
  96. return (NSComparisonResult)NSOrderedDescending;
  97. }
  98. if ([obj1 integerValue] < [obj2 integerValue]) {
  99. return (NSComparisonResult)NSOrderedAscending;
  100. }
  101. return (NSComparisonResult)NSOrderedSame;
  102. }];
  103. NSMutableArray *provinceTmp = [[NSMutableArray alloc] init];
  104. for (int i=0; i<[sortedArray count]; i++) {
  105. NSString *index = [sortedArray objectAtIndex:i];
  106. NSArray *tmp = [[areaDic objectForKey: index] allKeys];
  107. [provinceTmp addObject: [tmp objectAtIndex:0]];
  108. }
  109. //---> //rk_3-7 修复首次加载问题
  110. province = [[NSArray alloc] initWithArray: provinceTmp];
  111. NSString *index = [sortedArray objectAtIndex:0];
  112. //NSString *selected = [province objectAtIndex:0];
  113. selectedProvince = [province objectAtIndex:0];
  114. NSDictionary *proviceDic = [NSDictionary dictionaryWithDictionary: [[areaDic objectForKey:index]objectForKey:selectedProvince]];
  115. NSArray *cityArray = [proviceDic allKeys];
  116. NSDictionary *cityDic = [NSDictionary dictionaryWithDictionary: [proviceDic objectForKey: [cityArray objectAtIndex:0]]];
  117. //city = [[NSArray alloc] initWithArray: [cityDic allKeys]];
  118. NSArray *citySortedArray = [cityArray sortedArrayUsingComparator: ^(id obj1, id obj2) {
  119. if ([obj1 integerValue] > [obj2 integerValue]) {
  120. return (NSComparisonResult)NSOrderedDescending;//递减
  121. }
  122. if ([obj1 integerValue] < [obj2 integerValue]) {
  123. return (NSComparisonResult)NSOrderedAscending;//上升
  124. }
  125. return (NSComparisonResult)NSOrderedSame;
  126. }];
  127. NSMutableArray *m_array = [[NSMutableArray alloc] init];
  128. for (int i=0; i<[citySortedArray count]; i++) {
  129. NSString *index = [citySortedArray objectAtIndex:i];
  130. NSArray *temp = [[proviceDic objectForKey: index] allKeys];
  131. [m_array addObject: [temp objectAtIndex:0]];
  132. }
  133. city = [NSArray arrayWithArray:m_array];
  134. //<-----------
  135. NSString *selectedCity = [city objectAtIndex: 0];
  136. district = [[NSArray alloc] initWithArray: [cityDic objectForKey: selectedCity]];
  137. [self location];
  138. }
  139. - (void)viewDidLoad {
  140. [super viewDidLoad];
  141. self.titleL.text = YZMsg(@"开通小店");
  142. [self initData];
  143. _backScroll = [[UIScrollView alloc]init];
  144. _backScroll.frame = CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-60);
  145. _backScroll.backgroundColor = RGB(17, 13, 35);
  146. [self.view addSubview:_backScroll];
  147. UITapGestureRecognizer *hideTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideTapClick)];
  148. [_backScroll addGestureRecognizer:hideTap];
  149. [_backScroll addSubview:self.infoView];
  150. [_backScroll addSubview:self.classView];
  151. [_backScroll addSubview:self.contactView];
  152. [_backScroll addSubview:self.customerView];
  153. [_backScroll addSubview:self.rejectedView];
  154. [_backScroll addSubview:self.zizhiView];
  155. [_backScroll addSubview:self.bondView];
  156. [self addBottomView];
  157. _backScroll.contentSize = CGSizeMake(_window_width, self.infoView.height+self.classView.height+self.contactView.height+self.customerView.height+self.rejectedView.height+self.zizhiView.height+self.bondView.height+60);
  158. //如果是拒绝进来的 就赋值
  159. if ([self.fromWhere isEqual:@"reject"]) {
  160. [self setApplyData:self.applyDic];
  161. }
  162. }
  163. -(void)hideTapClick{
  164. [self.view endEditing:YES];
  165. }
  166. #pragma mark ------信息界面--------
  167. -(UIView *)infoView{
  168. if (!_infoView) {
  169. _infoView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 290+15)];
  170. _infoView.backgroundColor = RGB(17, 13, 35);
  171. UILabel *taps = [[UILabel alloc]init];
  172. taps.frame = CGRectMake(12, 10, 190, 30);
  173. taps.font = [UIFont boldSystemFontOfSize:15];
  174. taps.text = YZMsg(@"信息确认");
  175. taps.textColor = RGB(150, 150, 150);
  176. [_infoView addSubview:taps];
  177. UIView *backView = [[UIView alloc]init];
  178. backView.frame = CGRectMake(20, taps.bottom+10, _window_width-40, 100);
  179. backView.backgroundColor = RGB(24, 21, 43);
  180. [_infoView addSubview:backView];
  181. NSArray *arr = @[YZMsg(@"账号ID:"),YZMsg(@"姓名:"),YZMsg(@"身份证号:")];
  182. for (int i = 0; i < arr.count; i++) {
  183. UILabel *titleLb = [[UILabel alloc]init];
  184. titleLb.frame = CGRectMake(10, i * 33, 120, 33);
  185. titleLb.textColor = RGB(150, 150, 150);
  186. titleLb.font = [UIFont systemFontOfSize:13];
  187. titleLb.text = arr[i];
  188. [backView addSubview:titleLb];
  189. UITextField *tf = [[UITextField alloc]init];
  190. tf.frame = CGRectMake(titleLb.right+10, i* 33, backView.width-titleLb.width-30, 33);
  191. tf.textColor = [UIColor whiteColor];
  192. tf.font = [UIFont systemFontOfSize:12];
  193. tf.textAlignment = NSTextAlignmentRight;
  194. [backView addSubview:tf];
  195. if (i == 0) {
  196. idField = tf;
  197. idField.userInteractionEnabled = NO;
  198. idField.text = [Config getOwnID];
  199. }else if (i == 1) {
  200. nameField = tf;
  201. nameField.text = minstr([self.presonDic valueForKey:@"real_name"]);
  202. nameField.userInteractionEnabled = NO;
  203. }else{
  204. cardField = tf;
  205. cardField.text = minstr([self.presonDic valueForKey:@"cer_no"]);
  206. cardField.userInteractionEnabled = NO;
  207. }
  208. }
  209. UILabel *explainLb = [[UILabel alloc]init];
  210. explainLb.frame = CGRectMake(12, backView.bottom+10, _window_width-24, _infoView.height-backView.height-60);
  211. explainLb.numberOfLines = 0;
  212. explainLb.lineBreakMode = NSLineBreakByWordWrapping;
  213. explainLb.font = [UIFont systemFontOfSize:11];
  214. explainLb.textColor = RGB(150, 150, 150);
  215. explainLb.text = [NSString stringWithFormat:@"%@ \n\n %@ \n\n %@",YZMsg(@"1.请确认上述账号ID、姓名、身份证号为本人信息。若非本人信息请停止操作。"),YZMsg(@"2.您同意授权本平台公司获取并保存账号ID、姓名、身份证号个人信息用于身份认证备案。"),YZMsg(@"3.您承诺通过本平台小店开展的经营活动为根据法律法规规定不需要办理市场主体登记的经营行为。")];
  216. [_infoView addSubview:explainLb];
  217. }
  218. return _infoView;
  219. }
  220. #pragma mark ------经营类目界面--------
  221. -(UIView *)classView{
  222. if (!_classView) {
  223. _classView = [[UIView alloc]initWithFrame:CGRectMake(0, self.infoView.bottom+5, _window_width, 56)];
  224. _classView.backgroundColor =RGB(24, 21, 43);
  225. UILabel *taps = [[UILabel alloc]init];
  226. taps.frame = CGRectMake(12, _classView.height/2-15, 150, 30);
  227. taps.font = [UIFont boldSystemFontOfSize:15];
  228. taps.text = YZMsg(@"经营类目");
  229. taps.textColor = RGB(150, 150, 150);
  230. [_classView addSubview:taps];
  231. classBtn = [UIButton buttonWithType:0];
  232. classBtn.frame = CGRectMake(_classView.width-110, _classView.height/2-15, 110, 30);
  233. [classBtn setTitleColor:RGB(150, 150, 150) forState:0];
  234. [classBtn setTitle:YZMsg(@"请选择") forState:0];
  235. [classBtn setImage:[UIImage imageNamed:@"shop_right"] forState:0];
  236. classBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  237. [classBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, - classBtn.imageView.image.size.width, 0, classBtn.imageView.image.size.width)];
  238. [classBtn setImageEdgeInsets:UIEdgeInsetsMake(0, classBtn.titleLabel.bounds.size.width, 0, -classBtn.titleLabel.bounds.size.width)];
  239. classBtn.tag = 30000;
  240. [classBtn addTarget:self action:@selector(selClass:) forControlEvents:UIControlEventTouchUpInside];
  241. [_classView addSubview:classBtn];
  242. }
  243. return _classView;
  244. }
  245. #pragma mark ------经营者联系方式界面--------
  246. -(UIView *)contactView{
  247. if (!_contactView) {
  248. _contactView = [[UIView alloc]initWithFrame:CGRectMake(0, self.classView.bottom+5, _window_width, 260)];
  249. _contactView.backgroundColor = RGB(24, 21, 43);
  250. UILabel *taps = [[UILabel alloc]init];
  251. taps.frame = CGRectMake(12, 10, 250, 30);
  252. taps.font = [UIFont boldSystemFontOfSize:15];
  253. taps.text = YZMsg(@"经营者联系方式");
  254. taps.textColor = RGB(150, 150, 150);
  255. [_contactView addSubview:taps];
  256. NSArray *arr = @[YZMsg(@"联系人"),YZMsg(@"手机号"),YZMsg(@"所在地区"),YZMsg(@"详细地址")];
  257. for (int i = 0; i < arr.count; i ++) {
  258. if (i < 3) {
  259. UITextField *tf = [[UITextField alloc]init];
  260. tf.frame = CGRectMake(12, taps.bottom + i* 50, _contactView.width-24, 50);
  261. tf.textColor = [UIColor whiteColor];
  262. tf.font = [UIFont systemFontOfSize:14];
  263. tf.placeholder = arr[i];
  264. tf.delegate = self;
  265. tf.returnKeyType = UIReturnKeyDone;
  266. NSMutableAttributedString*holderString = [[NSMutableAttributedString alloc] initWithString:arr[i] attributes:@{NSForegroundColorAttributeName:RGB(150, 150, 150)}];
  267. tf.attributedPlaceholder = holderString;
  268. // [tf setValue:RGB(150, 150, 150) forKeyPath:@"_placeholderLabel.textColor"];
  269. [_contactView addSubview:tf];
  270. UILabel *line = [[UILabel alloc]init];
  271. line.backgroundColor = RGB(49, 47, 66);
  272. line.frame = CGRectMake(12, tf.bottom+1, _contactView.width-24, 1);
  273. [_contactView addSubview:line];
  274. if (i == 0) {
  275. sellerNameField = tf;
  276. }else if (i == 1){
  277. sellerPhoneField = tf;
  278. }else if (i == 2){
  279. sellerAddressField = tf;
  280. sellerAddressField.userInteractionEnabled = NO;
  281. UIButton *selAddressBtn = [UIButton buttonWithType:0];
  282. selAddressBtn.frame = tf.frame;
  283. selAddressBtn.tag = 9999;
  284. [selAddressBtn addTarget:self action:@selector(addressClick:) forControlEvents:UIControlEventTouchUpInside];
  285. [_contactView addSubview:selAddressBtn];
  286. }
  287. }else{
  288. MyTextView *tv = [[MyTextView alloc]init];
  289. tv.backgroundColor = RGB(24, 21, 43);
  290. tv.frame =CGRectMake(5, taps.bottom+ 5+ i* 50, _contactView.width-24, 60);
  291. tv.textColor = [UIColor whiteColor];
  292. tv.font = [UIFont systemFontOfSize:14];
  293. tv.placeholder = arr[i];
  294. tv.placeholderColor = RGB(150, 150, 150);
  295. tv.delegate = self;
  296. tv.returnKeyType = UIReturnKeyDone;
  297. [_contactView addSubview:tv];
  298. sellerAddDesField = tv;
  299. }
  300. }
  301. }
  302. return _contactView;
  303. }
  304. #pragma mark ------客服信息界面--------
  305. -(UIView *)customerView{
  306. if (!_customerView) {
  307. _customerView = [[UIView alloc]initWithFrame:CGRectMake(0, self.contactView.bottom+5, _window_width, 56)];
  308. _customerView.backgroundColor = RGB(24, 21, 43);
  309. UILabel *taps = [[UILabel alloc]init];
  310. taps.frame = CGRectMake(12, _classView.height/2-15, 65, 30);
  311. if ([lagType isEqual:EN]) {
  312. taps.frame = CGRectMake(12, _classView.height/2-20, 85, 40);
  313. }
  314. taps.font = [UIFont boldSystemFontOfSize:15];
  315. taps.text = YZMsg(@"客服信息");
  316. taps.textColor = RGB(150, 150, 150);
  317. taps.numberOfLines = 0;
  318. taps.adjustsFontSizeToFitWidth = YES;
  319. [_customerView addSubview:taps];
  320. UILabel *taps2 = [[UILabel alloc]init];
  321. taps2.frame = CGRectMake(taps.right, _classView.height/2-15, 200, 30);
  322. taps2.font = [UIFont systemFontOfSize:12];
  323. taps2.text = YZMsg(@"(不填默认设置为联系人手机号)");
  324. taps2.textColor = RGB(150, 150, 150);
  325. taps2.numberOfLines = 0;
  326. [_customerView addSubview:taps2];
  327. UIImageView *rightImg = [[UIImageView alloc]init];
  328. rightImg.frame = CGRectMake(_customerView.width-40, _customerView.height/2-8, 16, 16);
  329. rightImg.image = [UIImage imageNamed:@"jiantou_down"];
  330. [_customerView addSubview:rightImg];
  331. customerTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(btnClick:)];
  332. [_customerView addGestureRecognizer:customerTap];
  333. if ([self.fromWhere isEqual:@"reject"]) {
  334. [self btnClick:customerTap];
  335. }
  336. }
  337. return _customerView;
  338. }
  339. #pragma mark ------退货界面--------
  340. -(UIView *)rejectedView{
  341. if (!_rejectedView) {
  342. _rejectedView = [[UIView alloc]initWithFrame:CGRectMake(0, self.customerView.bottom+5, _window_width, 56)];
  343. _rejectedView.backgroundColor = RGB(24, 21, 43);
  344. UILabel *taps = [[UILabel alloc]init];
  345. taps.frame = CGRectMake(12, _classView.height/2-15, 65, 30);
  346. if ([lagType isEqual:EN]) {
  347. taps.frame = CGRectMake(12, _classView.height/2-20, 85, 40);
  348. }
  349. taps.font = [UIFont boldSystemFontOfSize:15];
  350. taps.text = YZMsg(@"退货信息");
  351. taps.textColor = RGB(150, 150, 150);
  352. taps.numberOfLines = 0;
  353. taps.adjustsFontSizeToFitWidth = YES;
  354. [_rejectedView addSubview:taps];
  355. UILabel *taps2 = [[UILabel alloc]init];
  356. taps2.frame = CGRectMake(taps.right, _classView.height/2-15, 250, 30);
  357. taps2.font = [UIFont systemFontOfSize:12];
  358. taps2.text = YZMsg(@"(不填默认设置为经营地址、电话信息)");
  359. taps2.textColor = RGB(150, 150, 150);
  360. taps2.numberOfLines = 0;
  361. [_rejectedView addSubview:taps2];
  362. UIImageView *rightImg = [[UIImageView alloc]init];
  363. rightImg.frame = CGRectMake(_rejectedView.width-40, _rejectedView.height/2-8, 16, 16);
  364. rightImg.image = [UIImage imageNamed:@"jiantou_down"];
  365. [_rejectedView addSubview:rightImg];
  366. rejectedTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(btnClick:)];
  367. [_rejectedView addGestureRecognizer:rejectedTap];
  368. if ([self.fromWhere isEqual:@"reject"]) {
  369. [self btnClick:rejectedTap];
  370. }
  371. }
  372. return _rejectedView;
  373. }
  374. #pragma mark ------资质证明界面--------
  375. -(UIView *)zizhiView{
  376. if (!_zizhiView) {
  377. _zizhiView =[[UIView alloc]initWithFrame:CGRectMake(0, self.rejectedView.bottom+5, _window_width, 180)];
  378. _zizhiView.backgroundColor = RGB(24, 21, 43);
  379. UILabel *taps = [[UILabel alloc]init];
  380. taps.frame = CGRectMake(12, 10, 165, 30);
  381. taps.font = [UIFont boldSystemFontOfSize:15];
  382. taps.text = YZMsg(@"资质证明");
  383. taps.textColor = RGB(150, 150, 150);
  384. [_zizhiView addSubview:taps];
  385. NSArray *arr = @[YZMsg(@"营业执照"),YZMsg(@"其他证件")];
  386. for (int i = 0; i < arr.count; i ++) {
  387. UIButton *btn = [UIButton buttonWithType:0];
  388. btn.frame = CGRectMake(15+ i * 115, taps.bottom+10, 100, 75);
  389. [btn setBackgroundColor:RGB(31, 29, 50)];
  390. [btn setImage:[UIImage imageNamed:@"addComm"] forState:0];
  391. btn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  392. btn.imageView.clipsToBounds = YES;
  393. btn.titleLabel.font = [UIFont systemFontOfSize:14];
  394. btn.tag = 50000+i;
  395. [btn addTarget:self action:@selector(selectImageClick:) forControlEvents:UIControlEventTouchUpInside];
  396. [_zizhiView addSubview:btn];
  397. UILabel *lb = [[UILabel alloc]init];
  398. lb.frame = CGRectMake(btn.left, btn.bottom+10, btn.width, 20);
  399. lb.font = [UIFont systemFontOfSize:14];
  400. lb.textColor = RGB(150, 150, 150);
  401. lb.text = arr[i];
  402. lb.textAlignment = NSTextAlignmentCenter;
  403. lb.numberOfLines = 0;
  404. lb.adjustsFontSizeToFitWidth = YES;
  405. [_zizhiView addSubview:lb];
  406. if (i == 0) {
  407. busImgBtn = btn;
  408. }else{
  409. otherImgBtn = btn;
  410. }
  411. }
  412. }
  413. return _zizhiView;
  414. }
  415. #pragma mark ------缴纳保证金--------
  416. -(UIView *)bondView{
  417. if (!_bondView) {
  418. _bondView = [[UIView alloc]initWithFrame:CGRectMake(0, self.zizhiView.bottom+5, _window_width, 56)];
  419. _bondView.backgroundColor = RGB(24, 21, 43);
  420. UILabel *taps = [[UILabel alloc]init];
  421. taps.frame = CGRectMake(12, _bondView.height/2-15, 150, 30);
  422. taps.font = [UIFont boldSystemFontOfSize:15];
  423. taps.text = YZMsg(@"缴纳保证金");
  424. taps.textColor = RGB(150, 150, 150);
  425. [_bondView addSubview:taps];
  426. UIImageView *rightImg = [[UIImageView alloc]init];
  427. rightImg.frame = CGRectMake(_bondView.width-30, _bondView.height/2-8, 16, 16);
  428. rightImg.image = [UIImage imageNamed:@"shop_right"];
  429. [_bondView addSubview:rightImg];
  430. bondTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(btnClick:)];
  431. [_bondView addGestureRecognizer:bondTap];
  432. }
  433. return _bondView;
  434. }
  435. -(void)addBottomView{
  436. UIView *bottom = [[UIView alloc]initWithFrame:CGRectMake(0, _window_height-60, _window_width, 60)];
  437. bottom.backgroundColor = RGB(17, 13, 35);
  438. [self.view addSubview:bottom];
  439. UIButton *subBtn = [UIButton buttonWithType:0];
  440. subBtn.frame = CGRectMake(15, 10, _window_width-30, 40);
  441. [subBtn setBackgroundColor:Pink_Cor];
  442. [subBtn setTitle:YZMsg(@"提交") forState:0];
  443. [subBtn setTitleColor:[UIColor whiteColor] forState:0];
  444. subBtn.layer.cornerRadius = 5;
  445. subBtn.layer.masksToBounds = YES;
  446. [subBtn addTarget:self action:@selector(uploadMessage) forControlEvents:UIControlEventTouchUpInside];
  447. [bottom addSubview:subBtn];
  448. }
  449. #pragma mark------提交------------
  450. -(void)uploadMessage{
  451. classId = @"";
  452. if (self.classArr.count < 1) {
  453. [MBProgressHUD showError:YZMsg(@"请选择经营类目")];
  454. return;
  455. }else{
  456. for (CommodityClassModel *model in self.classArr) {
  457. classId = [classId stringByAppendingFormat:@"%@,",model.idStr];
  458. }
  459. NSRange range = NSMakeRange(classId.length-1, 1);
  460. classId = [classId stringByReplacingCharactersInRange:range withString:@""];
  461. }
  462. if ((!_dsp_busImg && [PublicObj checkNull:businessImgUrl]) ||
  463. (!_dsp_othetImg && [PublicObj checkNull:otherImgUrl])) {
  464. [MBProgressHUD hideHUD];
  465. [MBProgressHUD showError:YZMsg(@"请上传资质证明图")];
  466. return;
  467. }
  468. if (_dsp_busImg || _dsp_othetImg) {
  469. [self uploadImg];
  470. }else{
  471. [self subBtnClick];
  472. }
  473. }
  474. -(void)subBtnClick{
  475. NSMutableDictionary *dic = @{
  476. @"uid":[Config getOwnID],
  477. @"token":[Config getOwnToken],
  478. @"username":nameField.text,
  479. @"cardno":cardField.text,
  480. @"classid":classId,
  481. @"contact":sellerNameField.text,
  482. @"country_code":@"",
  483. @"phone":sellerPhoneField.text,
  484. @"province":provinceStr,
  485. @"city":cityStr,
  486. @"area":districtStr,
  487. @"address":sellerAddDesField.text,
  488. @"service_phone":_phoneField.text,
  489. @"receiver":receiverField.text,
  490. @"receiver_phone":receiverPhoneField.text,
  491. @"receiver_province":recever_provinceStr,
  492. @"receiver_city":recever_cityStr,
  493. @"receiver_area":recever_districtStr,
  494. @"receiver_address":receiverAddDesField.text,
  495. }.mutableCopy;
  496. [dic setObject:businessImgUrl forKey:@"certificate"];
  497. [dic setObject:otherImgUrl forKey:@"other"];
  498. [YBNetworking postWithUrl:@"Shop.shopApply" Dic:dic Suc:^(int code, id info, NSString *msg) {
  499. [MBProgressHUD hideHUD];
  500. if (code ==0) {
  501. [MBProgressHUD showError:msg];
  502. if (self.subEvent) {
  503. self.subEvent();
  504. }
  505. if ([self.fromWhere isEqual:@"reject"]) {
  506. [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:([self.navigationController.viewControllers count] -3)] animated:YES];
  507. }else{
  508. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  509. }
  510. }else{
  511. [MBProgressHUD showError:msg];
  512. }
  513. } Fail:^(id fail) {
  514. }];
  515. }
  516. #pragma mark------选择类目-----------
  517. -(void)selClass:(UIButton *)sender{
  518. YBWeakSelf;
  519. SelectClassVC *class = [[SelectClassVC alloc]init];
  520. class.havaSelArr = [self.classArr mutableCopy];
  521. class.classEvent = ^(NSMutableArray * _Nonnull arr) {
  522. weakSelf.classArr = [arr mutableCopy];
  523. [classBtn setTitle:YZMsg(@"已选择") forState:0];
  524. };
  525. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:class animated:YES];
  526. }
  527. -(void)btnClick:(UITapGestureRecognizer *)taps{
  528. //客服信息
  529. if (taps == customerTap) {
  530. phoneBool = !phoneBool;
  531. if (phoneBool) {
  532. _customerView.size = CGSizeMake(_window_width, 56 +50);
  533. [_customerView addSubview:self.phoneField];
  534. self.phoneField.hidden = NO;
  535. customerHeight = 56+50;
  536. }else{
  537. _customerView.size = CGSizeMake(_window_width, 56);
  538. self.phoneField.hidden = YES;
  539. customerHeight = 56;
  540. }
  541. [self reloadUIHeight];
  542. }else if (taps == rejectedTap){
  543. //退货信息
  544. rejectedBool = !rejectedBool;
  545. if (rejectedBool) {
  546. [_rejectedView addSubview:self.rejectDetail];
  547. _rejectedView.size =CGSizeMake(_window_width, 56 +self.rejectDetail.height);
  548. self.rejectDetail.hidden = NO;
  549. rejectedHeight = 56 +self.rejectDetail.height;
  550. }else{
  551. _rejectedView.size = CGSizeMake(_window_width, 56);
  552. rejectedHeight = 56 ;
  553. self.rejectDetail.hidden = YES;
  554. }
  555. [self reloadUIHeight];
  556. }else if (taps == bondTap){
  557. [self requstBondStatus];
  558. }
  559. }
  560. -(void)requstBondStatus{
  561. NSDictionary *dic = @{
  562. @"uid":[Config getOwnID],
  563. @"token":[Config getOwnToken],
  564. };
  565. [YBNetworking postWithUrl:@"Shop.getBond" Dic:dic Suc:^(int code, id info, NSString *msg) {
  566. if (code ==0) {
  567. NSDictionary *infos = [info firstObject];
  568. if ([minstr([infos valueForKey:@"bond_status"]) isEqual:@"1"]) {
  569. [MBProgressHUD showError:YZMsg(@"已缴纳保证金")];
  570. }else{
  571. BondViewController *bond = [[BondViewController alloc]init];
  572. bond.infoDic = infos;
  573. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:bond animated:YES];
  574. }
  575. }else{
  576. [MBProgressHUD showError:msg];
  577. }
  578. } Fail:^(id fail) {
  579. }];
  580. }
  581. -(UITextField *)phoneField{
  582. if (!_phoneField) {
  583. _phoneField = [[UITextField alloc]init];
  584. _phoneField.frame = CGRectMake(12, 50, _contactView.width-24, 50);
  585. _phoneField.textColor = [UIColor whiteColor];
  586. _phoneField.font = [UIFont systemFontOfSize:14];
  587. // _phoneField.placeholder =YZMsg(@"客服电话");
  588. NSMutableAttributedString*holderString = [[NSMutableAttributedString alloc] initWithString:YZMsg(@"客服电话") attributes:@{NSForegroundColorAttributeName:RGB(150, 150, 150)}];
  589. _phoneField.attributedPlaceholder = holderString;
  590. _phoneField.delegate =self;
  591. _phoneField.returnKeyType = UIReturnKeyDone;
  592. [_customerView addSubview:_phoneField];
  593. }
  594. return _phoneField;
  595. }
  596. #pragma mark ------退货信息界面--------
  597. -(UIView*)rejectDetail{
  598. if (!_rejectDetail) {
  599. _rejectDetail = [[UIView alloc]init];
  600. _rejectDetail.frame = CGRectMake(0, 56, _window_width, 200);
  601. NSArray *arr = @[YZMsg(@"收货人"),YZMsg(@"收货人手机号"),YZMsg(@"所在地区"),YZMsg(@"详细地址")];
  602. for (int i = 0; i < arr.count; i ++) {
  603. if (i < 3) {
  604. UITextField *tf = [[UITextField alloc]init];
  605. tf.frame = CGRectMake(12, i* 50, _contactView.width-24, 50);
  606. tf.textColor = [UIColor whiteColor];
  607. tf.font = [UIFont systemFontOfSize:14];
  608. tf.placeholder = arr[i];
  609. tf.delegate = self;
  610. tf.returnKeyType = UIReturnKeyDone;
  611. NSMutableAttributedString*holderString = [[NSMutableAttributedString alloc] initWithString:arr[i] attributes:@{NSForegroundColorAttributeName:RGB(150, 150, 150)}];
  612. tf.attributedPlaceholder = holderString;
  613. [_rejectDetail addSubview:tf];
  614. UILabel *line = [[UILabel alloc]init];
  615. line.backgroundColor = RGB(49, 47, 66);
  616. line.frame = CGRectMake(12, tf.bottom+1, _contactView.width-24, 1);
  617. [_rejectDetail addSubview:line];
  618. if (i == 0) {
  619. receiverField = tf;
  620. }else if (i == 1){
  621. receiverPhoneField = tf;
  622. }else if (i == 2){
  623. receiverAddressField = tf;
  624. receiverAddressField.userInteractionEnabled = NO;
  625. UIButton *selAddressBtn = [UIButton buttonWithType:0];
  626. selAddressBtn.frame = tf.frame;
  627. selAddressBtn.tag = 8888;
  628. [selAddressBtn addTarget:self action:@selector(addressClick:) forControlEvents:UIControlEventTouchUpInside];
  629. [_rejectDetail addSubview:selAddressBtn];
  630. }
  631. }else{
  632. MyTextView *tv = [[MyTextView alloc]init];
  633. tv.frame =CGRectMake(5, 5+ i* 50, _contactView.width-24, 60);
  634. tv.textColor = [UIColor whiteColor];
  635. tv.font = [UIFont systemFontOfSize:14];
  636. tv.placeholder = arr[i];
  637. tv.delegate = self;
  638. tv.returnKeyType = UIReturnKeyDone;
  639. tv.placeholderColor = RGB(150, 150, 150);
  640. tv.backgroundColor = RGB(24, 21, 43);
  641. receiverAddDesField = tv;
  642. [_rejectDetail addSubview:tv];
  643. }
  644. }
  645. }
  646. return _rejectDetail;
  647. }
  648. -(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  649. {
  650. [self.view endEditing:YES];
  651. }
  652. #pragma mark -------更新UI界面-------
  653. -(void)reloadUIHeight{
  654. self.customerView.frame = CGRectMake(0, self.contactView.bottom+5, _window_width, customerHeight);
  655. self.rejectedView.frame = CGRectMake(0, self.customerView.bottom+5, _window_width, rejectedHeight);
  656. self.zizhiView.frame = CGRectMake(0, self.rejectedView.bottom+5, _window_width, 180);
  657. self.bondView.frame =CGRectMake(0, self.zizhiView.bottom+5, _window_width, 56);
  658. _backScroll.contentSize = CGSizeMake(_window_width, self.infoView.height+self.classView.height+self.contactView.height+self.customerView.height+self.rejectedView.height+self.zizhiView.height+self.bondView.height+60);
  659. }
  660. #pragma mark ------选择地区------------
  661. -(void)addressClick:(UIButton *)sender{
  662. if (sender.tag == 9999) {
  663. selType = @"0";
  664. }else if(sender.tag == 8888){
  665. selType = @"1";
  666. }
  667. [self.view endEditing:YES];
  668. if (!cityPickBack) {
  669. cityPickBack = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  670. cityPickBack.backgroundColor = RGB_COLOR(@"#000000", 0.3);
  671. [self.view addSubview:cityPickBack];
  672. UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(0, _window_height-240, _window_width, 40)];
  673. titleView.backgroundColor = RGB_COLOR(@"#ececec", 1);
  674. [cityPickBack addSubview:titleView];
  675. UIButton *cancleBtn = [UIButton buttonWithType:0];
  676. cancleBtn.frame = CGRectMake(20, 0, 80, 40);
  677. cancleBtn.tag = 100;
  678. [cancleBtn setTitle:YZMsg(@"取消") forState:0];
  679. [cancleBtn setTitleColor:[UIColor grayColor] forState:0];
  680. [cancleBtn addTarget:self action:@selector(cityCancleOrSure:) forControlEvents:UIControlEventTouchUpInside];
  681. [titleView addSubview:cancleBtn];
  682. UIButton *sureBtn = [UIButton buttonWithType:0];
  683. sureBtn.frame = CGRectMake(_window_width-100, 0, 80, 40);
  684. sureBtn.tag = 101;
  685. [sureBtn setTitle:YZMsg(@"确定") forState:0];
  686. [sureBtn setTitleColor:Normal_Color forState:0];
  687. [sureBtn addTarget:self action:@selector(cityCancleOrSure:) forControlEvents:UIControlEventTouchUpInside];
  688. [titleView addSubview:sureBtn];
  689. cityPicker = [[UIPickerView alloc]initWithFrame:CGRectMake(0, _window_height-200, _window_width, 200)];
  690. cityPicker.backgroundColor = [UIColor whiteColor];
  691. cityPicker.delegate = self;
  692. cityPicker.dataSource = self;
  693. cityPicker.showsSelectionIndicator = YES;
  694. [cityPicker selectRow: 0 inComponent: 0 animated: YES];
  695. [cityPickBack addSubview:cityPicker];
  696. [self setLocationAddress];
  697. }else{
  698. cityPickBack.hidden = NO;
  699. }
  700. }
  701. - (void)cityCancleOrSure:(UIButton *)button{
  702. if (button.tag == 100) {
  703. //return;
  704. }else{
  705. NSInteger provinceIndex = [cityPicker selectedRowInComponent: 0];
  706. NSInteger cityIndex = [cityPicker selectedRowInComponent: 1];
  707. NSInteger districtIndex = [cityPicker selectedRowInComponent: 2];
  708. if([selType isEqual:@"0"]){
  709. provinceStr = [province objectAtIndex: provinceIndex];
  710. cityStr = [city objectAtIndex: cityIndex];
  711. districtStr = [district objectAtIndex:districtIndex];
  712. NSString *dizhi = [NSString stringWithFormat:@"%@ %@ %@",provinceStr,cityStr,districtStr];
  713. sellerAddressField.text = dizhi;
  714. }else if ([selType isEqual:@"1"]){
  715. recever_provinceStr = [province objectAtIndex: provinceIndex];
  716. recever_cityStr = [city objectAtIndex: cityIndex];
  717. recever_districtStr = [district objectAtIndex:districtIndex];
  718. NSString *dizhi = [NSString stringWithFormat:@"%@ %@ %@",recever_provinceStr,recever_cityStr,recever_districtStr];
  719. receiverAddressField.text = dizhi;
  720. }
  721. }
  722. cityPickBack.hidden = YES;
  723. }
  724. #pragma mark- Picker Data Source Methods
  725. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
  726. if (pickerView == cityPicker) {
  727. return 3;
  728. }
  729. return 0;
  730. }
  731. - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
  732. if (pickerView == cityPicker) {
  733. if (component == 0) {
  734. return [province count];
  735. }
  736. else if (component == 1) {
  737. return [city count];
  738. }
  739. else {
  740. return [district count];
  741. }
  742. }else{
  743. return 100;
  744. }
  745. }
  746. #pragma mark- Picker Delegate Methods
  747. - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
  748. if (pickerView == cityPicker) {
  749. if (component == 0) {
  750. return [province objectAtIndex: row];
  751. }
  752. else if (component == 1) {
  753. return [city objectAtIndex: row];
  754. }
  755. else {
  756. return [district objectAtIndex: row];
  757. }
  758. }else{
  759. return nil;
  760. }
  761. }
  762. - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
  763. if (pickerView == cityPicker) {
  764. if (component == 0) {
  765. selectedProvince = [province objectAtIndex: row];
  766. NSDictionary *tmp = [NSDictionary dictionaryWithDictionary: [areaDic objectForKey: [NSString stringWithFormat:@"%ld", row]]];
  767. NSDictionary *dic = [NSDictionary dictionaryWithDictionary: [tmp objectForKey: selectedProvince]];
  768. NSArray *cityArray = [dic allKeys];
  769. NSArray *sortedArray = [cityArray sortedArrayUsingComparator: ^(id obj1, id obj2) {
  770. if ([obj1 integerValue] > [obj2 integerValue]) {
  771. return (NSComparisonResult)NSOrderedDescending;//递减
  772. }
  773. if ([obj1 integerValue] < [obj2 integerValue]) {
  774. return (NSComparisonResult)NSOrderedAscending;//上升
  775. }
  776. return (NSComparisonResult)NSOrderedSame;
  777. }];
  778. NSMutableArray *array = [[NSMutableArray alloc] init];
  779. for (int i=0; i<[sortedArray count]; i++) {
  780. NSString *index = [sortedArray objectAtIndex:i];
  781. NSArray *temp = [[dic objectForKey: index] allKeys];
  782. [array addObject: [temp objectAtIndex:0]];
  783. }
  784. city = [[NSArray alloc] initWithArray: array];
  785. NSDictionary *cityDic = [dic objectForKey: [sortedArray objectAtIndex: 0]];
  786. district = [[NSArray alloc] initWithArray: [cityDic objectForKey: [city objectAtIndex: 0]]];
  787. [cityPicker selectRow: 0 inComponent: 1 animated: YES];
  788. [cityPicker selectRow: 0 inComponent: 2 animated: YES];
  789. [cityPicker reloadComponent: 1];
  790. [cityPicker reloadComponent: 2];
  791. } else if (component == 1) {
  792. NSString *provinceIndex = [NSString stringWithFormat: @"%ld", [province indexOfObject: selectedProvince]];
  793. NSDictionary *tmp = [NSDictionary dictionaryWithDictionary: [areaDic objectForKey: provinceIndex]];
  794. NSDictionary *dic = [NSDictionary dictionaryWithDictionary: [tmp objectForKey: selectedProvince]];
  795. NSArray *dicKeyArray = [dic allKeys];
  796. NSArray *sortedArray = [dicKeyArray sortedArrayUsingComparator: ^(id obj1, id obj2) {
  797. if ([obj1 integerValue] > [obj2 integerValue]) {
  798. return (NSComparisonResult)NSOrderedDescending;
  799. }
  800. if ([obj1 integerValue] < [obj2 integerValue]) {
  801. return (NSComparisonResult)NSOrderedAscending;
  802. }
  803. return (NSComparisonResult)NSOrderedSame;
  804. }];
  805. NSDictionary *cityDic = [NSDictionary dictionaryWithDictionary: [dic objectForKey: [sortedArray objectAtIndex: row]]];
  806. NSArray *cityKeyArray = [cityDic allKeys];
  807. district = [[NSArray alloc] initWithArray: [cityDic objectForKey: [cityKeyArray objectAtIndex:0]]];
  808. [cityPicker selectRow: 0 inComponent: 2 animated: YES];
  809. [cityPicker reloadComponent: 2];
  810. }
  811. }else{
  812. }
  813. }
  814. - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
  815. if (component == 0) {
  816. return 80;
  817. }
  818. else if (component == 1) {
  819. return 100;
  820. }
  821. else {
  822. return 115;
  823. }
  824. }
  825. - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {
  826. UILabel *myView = nil;
  827. if (pickerView == cityPicker) {
  828. if (component == 0) {
  829. myView = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, _window_width/3, 30)];
  830. myView.textAlignment = NSTextAlignmentCenter;
  831. myView.text = [province objectAtIndex:row];
  832. myView.font = [UIFont systemFontOfSize:14];
  833. myView.backgroundColor = [UIColor clearColor];
  834. }
  835. else if (component == 1) {
  836. myView = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, _window_width/3, 30)];
  837. myView.textAlignment = NSTextAlignmentCenter;
  838. myView.text = [city objectAtIndex:row];
  839. myView.font = [UIFont systemFontOfSize:14];
  840. myView.backgroundColor = [UIColor clearColor];
  841. }
  842. else {
  843. myView = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, _window_width/3, 30)];
  844. myView.textAlignment = NSTextAlignmentCenter;
  845. myView.text = [district objectAtIndex:row];
  846. myView.font = [UIFont systemFontOfSize:14];
  847. myView.backgroundColor = [UIColor clearColor];
  848. }
  849. }
  850. return myView;
  851. }
  852. -(void)selectImageClick:(UIButton *)sender{
  853. if (sender.tag == 50000) {
  854. imgType = @"0";
  855. TZImagePickerController *imagePC = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
  856. imagePC.preferredLanguage = [lagType isEqual:ZH_CN] ? @"zh-Hans":@"en";
  857. imagePC.modalPresentationStyle = 0;
  858. imagePC.showSelectBtn = YES;
  859. imagePC.allowCrop = NO;
  860. imagePC.allowPickingOriginalPhoto = NO;
  861. imagePC.oKButtonTitleColorNormal = Pink_Cor;
  862. imagePC.allowTakePicture = YES;
  863. imagePC.allowTakeVideo = NO;
  864. imagePC.allowPickingVideo = NO;
  865. imagePC.allowPickingMultipleVideo = NO;
  866. [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:imagePC animated:YES completion:nil];
  867. }else{
  868. imgType = @"1";
  869. TZImagePickerController *imagePC = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
  870. imagePC.preferredLanguage = [lagType isEqual:ZH_CN] ? @"zh-Hans":@"en";
  871. imagePC.modalPresentationStyle = 0;
  872. imagePC.showSelectBtn = YES;
  873. imagePC.allowCrop = NO;
  874. imagePC.allowPickingOriginalPhoto = NO;
  875. imagePC.oKButtonTitleColorNormal = Pink_Cor;
  876. imagePC.allowTakePicture = YES;
  877. imagePC.allowTakeVideo = NO;
  878. imagePC.allowPickingVideo = NO;
  879. imagePC.allowPickingMultipleVideo = NO;
  880. [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:imagePC animated:YES completion:nil];
  881. }
  882. }
  883. - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{
  884. NSLog(@"------多选择图片--:%@",photos);
  885. if ([imgType isEqual:@"0"]) {
  886. _dsp_busImg = photos[0];
  887. [busImgBtn setImage:photos[0] forState:0];
  888. // [self uploadImg];
  889. }else{
  890. _dsp_othetImg = photos[0];
  891. [otherImgBtn setImage:photos[0] forState:0];
  892. // [self uploadImg];
  893. }
  894. }
  895. -(void)uploadImg{
  896. [MBProgressHUD showMessage:@""];
  897. YBWeakSelf;
  898. [[YBStorageObj storageManeger]getCOSType:^(int code) {
  899. dispatch_async(dispatch_get_main_queue(), ^{
  900. if (code == 0) {
  901. [weakSelf startUpload];
  902. }
  903. });
  904. }];
  905. }
  906. -(void)startUpload{
  907. YBWeakSelf;
  908. dispatch_group_t group = dispatch_group_create();
  909. dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
  910. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  911. UIImage *busimage = busImgBtn.imageView.image;
  912. UIImage *otherimage =otherImgBtn.imageView.image;
  913. dispatch_group_async(group, queue, ^{
  914. NSData *imageData = UIImagePNGRepresentation(busimage);
  915. if (!imageData) {
  916. [MBProgressHUD hideHUD];
  917. [MBProgressHUD showError:YZMsg(@"图片错误")];
  918. return;
  919. }
  920. UIImage *herfImg = [UIImage imageWithData:imageData];
  921. NSString *imageName = [PublicObj getNameBaseCurrentTime:[NSString stringWithFormat:@"_shop_image0%@_cover.png", imgType]];
  922. [[YBStorageObj storageManeger]yb_storageImg:herfImg andName:imageName progress:^(CGFloat percent) {
  923. }complete:^(int code, NSString *key) {
  924. //图片成功
  925. businessImgUrl = key;
  926. dispatch_semaphore_signal(semaphore);
  927. }];
  928. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  929. });
  930. dispatch_group_async(group, queue, ^{
  931. NSData *imageData = UIImagePNGRepresentation(otherimage);
  932. if (!imageData) {
  933. [MBProgressHUD hideHUD];
  934. [MBProgressHUD showError:YZMsg(@"图片错误")];
  935. return;
  936. }
  937. UIImage *herfImg = [UIImage imageWithData:imageData];
  938. NSString *imageName = [PublicObj getNameBaseCurrentTime:[NSString stringWithFormat:@"_shop_image1%@_cover.png", imgType]];
  939. [[YBStorageObj storageManeger]yb_storageImg:herfImg andName:imageName progress:^(CGFloat percent) {
  940. }complete:^(int code, NSString *key) {
  941. //图片成功
  942. otherImgUrl = key;
  943. dispatch_semaphore_signal(semaphore);
  944. }];
  945. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  946. });
  947. dispatch_group_notify(group, queue, ^{
  948. dispatch_async(dispatch_get_main_queue(), ^{
  949. [self subBtnClick];
  950. });
  951. NSLog(@"任务完成执行");
  952. });
  953. }
  954. #pragma mark-------审核拒绝赋值-----------
  955. -(void)setApplyData:(NSDictionary *)dic{
  956. idField.text = minstr([dic valueForKey:@"uid"]);
  957. nameField.text = minstr([dic valueForKey:@"username"]);
  958. cardField.text = minstr([dic valueForKey:@"cardno"]);
  959. sellerNameField.text = minstr([dic valueForKey:@"contact"]);
  960. sellerPhoneField.text = minstr([dic valueForKey:@"phone"]);
  961. sellerAddressField.text =[NSString stringWithFormat:@"%@%@%@", minstr([dic valueForKey:@"province"]),minstr([dic valueForKey:@"city"]),minstr([dic valueForKey:@"area"])];
  962. provinceStr =minstr([dic valueForKey:@"province"]);
  963. cityStr = minstr([dic valueForKey:@"city"]);
  964. districtStr = minstr([dic valueForKey:@"area"]);
  965. sellerAddDesField.text =minstr([dic valueForKey:@"address"]);
  966. _phoneField.text = minstr([dic valueForKey:@"service_phone"]);
  967. receiverField.text = minstr([dic valueForKey:@"receiver"]);
  968. receiverPhoneField.text = minstr([dic valueForKey:@"receiver_phone"]);
  969. receiverAddressField.text =[NSString stringWithFormat:@"%@%@%@",minstr([dic valueForKey:@"receiver_province"]),minstr([dic valueForKey:@"receiver_city"]),minstr([dic valueForKey:@"receiver_area"])] ;
  970. recever_provinceStr = minstr([dic valueForKey:@"receiver_province"]);
  971. recever_cityStr = minstr([dic valueForKey:@"receiver_city"]);
  972. recever_districtStr = minstr([dic valueForKey:@"receiver_area"]);
  973. receiverAddDesField.text = minstr([dic valueForKey:@"receiver_address"]);
  974. [busImgBtn sd_setImageWithURL:[NSURL URLWithString:minstr([dic valueForKey:@"certificate_format"])] forState:0 completed:nil];
  975. [otherImgBtn sd_setImageWithURL:[NSURL URLWithString:minstr([dic valueForKey:@"other_format"])] forState:0 completed:nil];
  976. businessImgUrl =minstr([dic valueForKey:@"certificate"]);
  977. otherImgUrl = minstr([dic valueForKey:@"other"]);
  978. NSMutableArray *array = [NSMutableArray array];
  979. NSArray *class = [dic valueForKey:@"goods_classid"];
  980. for (NSDictionary *dic in class) {
  981. CommodityClassModel *model = [CommodityClassModel modelWithDic:dic];
  982. [array addObject:model];
  983. }
  984. self.classArr = array;
  985. }
  986. -(BOOL)textFieldShouldReturn:(UITextField *)textField
  987. {
  988. [textField resignFirstResponder];
  989. return YES;
  990. }
  991. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
  992. if ([text isEqualToString:@"\n"]) {
  993. [self.view endEditing:YES];
  994. return NO;//这里返回NO,就代表return键值失效,即页面上按下return,不会出现换行,如果为yes,则输入页面会换行
  995. }
  996. return YES;
  997. }
  998. -(void)setLocationAddress{
  999. int provinceIndex = 0;
  1000. int cityIndex = 0;
  1001. NSArray *components = [areaDic allKeys];
  1002. NSArray *sortedArray = [components sortedArrayUsingComparator: ^(id obj1, id obj2) {
  1003. if ([obj1 integerValue] > [obj2 integerValue]) {
  1004. return (NSComparisonResult)NSOrderedDescending;
  1005. }
  1006. if ([obj1 integerValue] < [obj2 integerValue]) {
  1007. return (NSComparisonResult)NSOrderedAscending;
  1008. }
  1009. return (NSComparisonResult)NSOrderedSame;
  1010. }];
  1011. NSMutableArray *provinceTmp = [[NSMutableArray alloc] init];
  1012. for (int i=0; i<[sortedArray count]; i++) {
  1013. NSString *index = [sortedArray objectAtIndex:i];
  1014. NSArray *tmp = [[areaDic objectForKey: index] allKeys];
  1015. [provinceTmp addObject: [tmp objectAtIndex:0]];
  1016. }
  1017. if (normalProvince.length > 0) {
  1018. selectedProvince = normalProvince;
  1019. for (int i = 0; i < province.count; i ++) {
  1020. if ([normalProvince isEqual:province[i]]) {
  1021. provinceIndex = i;
  1022. NSString *index = [sortedArray objectAtIndex:i];
  1023. NSDictionary *proviceDic = [NSDictionary dictionaryWithDictionary: [[areaDic objectForKey:index]objectForKey:normalProvince]];
  1024. NSArray *cityArray = [proviceDic allKeys];
  1025. // NSDictionary *cityDic = [NSDictionary dictionaryWithDictionary: [proviceDic objectForKey: [cityArray objectAtIndex:i]]];
  1026. NSArray *citySortedArray = [cityArray sortedArrayUsingComparator: ^(id obj1, id obj2) {
  1027. if ([obj1 integerValue] > [obj2 integerValue]) {
  1028. return (NSComparisonResult)NSOrderedDescending;//递减
  1029. }
  1030. if ([obj1 integerValue] < [obj2 integerValue]) {
  1031. return (NSComparisonResult)NSOrderedAscending;//上升
  1032. }
  1033. return (NSComparisonResult)NSOrderedSame;
  1034. }];
  1035. NSMutableArray *m_array = [[NSMutableArray alloc] init];
  1036. for (int i=0; i<[citySortedArray count]; i++) {
  1037. NSString *index = [citySortedArray objectAtIndex:i];
  1038. NSArray *temp = [[proviceDic objectForKey: index] allKeys];
  1039. [m_array addObject: [temp objectAtIndex:0]];
  1040. }
  1041. NSArray *cityArr = [NSArray arrayWithArray:m_array];
  1042. city =[NSArray arrayWithArray:m_array];
  1043. for (int j = 0; j < cityArr.count; j ++) {
  1044. if ([normalCity isEqual:cityArr[j]]) {
  1045. cityIndex = j;
  1046. NSString *keys = [NSString stringWithFormat:@"%d",cityIndex];
  1047. NSDictionary *dicssss = [NSDictionary dictionaryWithDictionary: [proviceDic objectForKey: keys]];
  1048. NSString *selectedCity = [cityArr objectAtIndex: j];
  1049. district = [[NSArray alloc] initWithArray: [dicssss objectForKey: selectedCity]];
  1050. NSArray * districtArr = [[NSArray alloc] initWithArray: [dicssss objectForKey: selectedCity]];
  1051. for (int k = 0; k <districtArr.count; k ++) {
  1052. if ([normalDistrict isEqual:districtArr[k]]) {
  1053. [cityPicker selectRow: provinceIndex inComponent: 0 animated: YES];
  1054. [cityPicker reloadComponent: 1];
  1055. [cityPicker selectRow: cityIndex inComponent: 1 animated: YES];
  1056. [cityPicker reloadComponent: 2];
  1057. [cityPicker selectRow: k inComponent: 2 animated: YES];
  1058. }
  1059. }
  1060. }
  1061. }
  1062. }
  1063. }
  1064. }
  1065. NSLog(@"province===:%@ \n city:%@ \ndistrict:%@",province,city,district);
  1066. }
  1067. -(void)location{
  1068. if (!_lbsManager) {
  1069. _lbsManager = [[CLLocationManager alloc] init];
  1070. [_lbsManager setDesiredAccuracy:kCLLocationAccuracyBest];
  1071. _lbsManager.delegate = self;
  1072. // 兼容iOS8定位
  1073. CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
  1074. if (kCLAuthorizationStatusDenied == status || kCLAuthorizationStatusRestricted == status) {
  1075. NSLog(@"请打开您的位置服务!");
  1076. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  1077. UIAlertController *alertContro = [UIAlertController alertControllerWithTitle:nil message:[NSString stringWithFormat:YZMsg(@"打开“定位服务”来允许“%@”确定您的位置"),[infoDictionary objectForKey:@"CFBundleDisplayName"]] preferredStyle:UIAlertControllerStyleAlert];
  1078. UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:YZMsg(@"设置") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1079. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  1080. }];
  1081. [alertContro addAction:cancleAction];
  1082. [cancleAction setValue:Normal_Color forKey:@"_titleTextColor"];
  1083. UIAlertAction *sureAction = [UIAlertAction actionWithTitle:YZMsg(@"取消") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1084. }];
  1085. [alertContro addAction:sureAction];
  1086. [sureAction setValue:[UIColor blackColor] forKey:@"_titleTextColor"];
  1087. [[[YBBaseAppDelegate sharedAppDelegate]topViewController]presentViewController:alertContro animated:YES completion:nil];
  1088. }else{
  1089. // 兼容iOS8定位
  1090. SEL requestSelector = NSSelectorFromString(@"requestWhenInUseAuthorization");
  1091. if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined && [_lbsManager respondsToSelector:requestSelector]) {
  1092. [_lbsManager requestWhenInUseAuthorization]; //调用了这句,就会弹出允许框了.
  1093. } else {
  1094. [_lbsManager startUpdatingLocation];
  1095. }
  1096. }
  1097. }
  1098. }
  1099. - (void)stopLbs {
  1100. [_lbsManager stopUpdatingHeading];
  1101. _lbsManager.delegate = nil;
  1102. _lbsManager = nil;
  1103. }
  1104. - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
  1105. if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied) {
  1106. [self stopLbs];
  1107. } else {
  1108. [_lbsManager startUpdatingLocation];
  1109. }
  1110. }
  1111. - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
  1112. {
  1113. [self stopLbs];
  1114. }
  1115. - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
  1116. {
  1117. //zl-----待修改
  1118. CLLocation *newLocatioin = locations[0];
  1119. // liveCity *cityU = [cityDefault myProfile];
  1120. // cityU.lat = [NSString stringWithFormat:@"%f",newLocatioin.coordinate.latitude];
  1121. // cityU.lng = [NSString stringWithFormat:@"%f",newLocatioin.coordinate.longitude];
  1122. CLGeocoder *geocoder = [[CLGeocoder alloc] init];
  1123. [geocoder reverseGeocodeLocation:newLocatioin completionHandler:^(NSArray *placemarks, NSError *error) {
  1124. if (!error)
  1125. {
  1126. CLPlacemark *placeMark = placemarks[0];
  1127. NSString *addr = [NSString stringWithFormat:@"%@%@%@",placeMark.administrativeArea,placeMark.locality,placeMark.subLocality];
  1128. NSLog(@"hhhhhhhh----:%@", addr);
  1129. normalProvince =placeMark.administrativeArea;
  1130. normalCity = placeMark.locality;
  1131. normalDistrict = placeMark.subLocality;
  1132. }
  1133. }];
  1134. [self stopLbs];
  1135. }
  1136. @end