addHotVideoVC.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. //
  2. // addHotVideoVC.m
  3. // YBVideo
  4. //
  5. // Created by IOS1 on 2019/7/4.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "addHotVideoVC.h"
  9. #import "AFNetworking.h"
  10. #import "YBRechargeVC.h"
  11. #import "UphotOrderVC.h"
  12. @interface addHotVideoVC (){
  13. UIScrollView *backScrollView;
  14. NSMutableArray *moneyIteamArray;//金钱数组
  15. NSMutableArray *timeIteamArray;//时间数组
  16. NSMutableArray *payTypeArray;//支付方式数组
  17. UILabel *playNumsL;//预计提升播放量label
  18. UILabel *needMoneyL;//需要花费金钱
  19. UIButton *payButton;//支付按钮
  20. NSMutableArray *moneyArray;
  21. NSArray *payArray;
  22. NSArray *timeArray;
  23. UIView *enterMoneyView;
  24. UIView *moneyWhiteView;
  25. UITextField *moneyT;
  26. int baseCount;
  27. NSDictionary *selectPayDic;
  28. NSInteger selectMoney;
  29. int selectTime;
  30. }
  31. //支付宝
  32. @property(nonatomic,copy)NSString *aliapp_key_ios;
  33. @property(nonatomic,copy)NSString *aliapp_partner;
  34. @property(nonatomic,copy)NSString *aliapp_seller_id;
  35. //微信
  36. @property(nonatomic,copy)NSString *wx_appid;
  37. @end
  38. @implementation addHotVideoVC
  39. - (void)viewWillAppear:(BOOL)animated{
  40. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
  41. }
  42. - (void)viewWillDisappear:(BOOL)animated{
  43. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  44. }
  45. -(void)creatNavi {
  46. UIView *navi = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 64+statusbarHeight)];
  47. navi.backgroundColor = [UIColor whiteColor];
  48. [self.view addSubview:navi];
  49. UIButton *left_btn = [UIButton buttonWithType:UIButtonTypeCustom];
  50. left_btn.frame = CGRectMake(10, 22+statusbarHeight, 40, 40);
  51. left_btn.contentEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
  52. [left_btn setImage:[UIImage imageNamed:@"pubBlack_back"] forState:0];
  53. [left_btn addTarget:self action:@selector(clickLeftBtn) forControlEvents:UIControlEventTouchUpInside];
  54. [navi addSubview:left_btn];
  55. UILabel *midLabel = [[UILabel alloc]initWithFrame:CGRectMake(_window_width/2-80, 22+statusbarHeight, 160, 40)];
  56. midLabel.textAlignment = NSTextAlignmentCenter;
  57. midLabel.textColor = RGB_COLOR(@"#323232", 1);
  58. midLabel.font = [UIFont boldSystemFontOfSize:17];
  59. midLabel.text = YZMsg(@"上热门");
  60. [navi addSubview:midLabel];
  61. UIButton *right_btn = [UIButton buttonWithType:UIButtonTypeCustom];
  62. //right_btn.frame = CGRectMake(_window_width-50, 22+statusbarHeight, 40, 40);
  63. right_btn.contentEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
  64. [right_btn setTitle:YZMsg(@"明细") forState:0];
  65. [right_btn setTitleColor:[UIColor grayColor] forState:0];
  66. right_btn.titleLabel.font = [UIFont systemFontOfSize:14];
  67. [right_btn addTarget:self action:@selector(clickRightBtn) forControlEvents:UIControlEventTouchUpInside];
  68. [navi addSubview:right_btn];
  69. [right_btn mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.centerY.equalTo(midLabel);
  71. make.right.equalTo(navi.mas_right).offset(-10);
  72. }];
  73. }
  74. - (void)clickLeftBtn{
  75. [self.navigationController popViewControllerAnimated:YES];
  76. }
  77. -(void)clickRightBtn{
  78. UphotOrderVC *detailVc = [[UphotOrderVC alloc]init];
  79. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:detailVc animated:YES];
  80. }
  81. - (void)viewDidLoad {
  82. [super viewDidLoad];
  83. self.naviView.hidden = YES;
  84. self.view.backgroundColor = [UIColor whiteColor];
  85. moneyIteamArray = [NSMutableArray array];
  86. timeIteamArray = [NSMutableArray array];
  87. payTypeArray = [NSMutableArray array];
  88. [self creatNavi];
  89. [self requestData];
  90. }
  91. - (void)requestData{
  92. [YBNetworking postWithUrl:@"Popular.getInfo" Dic:nil Suc:^(int code, id info, NSString *msg) {
  93. if (code == 0) {
  94. NSDictionary *dic = [info firstObject];
  95. baseCount = [minstr([dic valueForKey:@"base"]) intValue];
  96. //支付宝的信息
  97. _aliapp_key_ios = [dic valueForKey:@"aliapp_key"];
  98. _aliapp_partner = [dic valueForKey:@"aliapp_partner"];
  99. _aliapp_seller_id = [dic valueForKey:@"aliapp_seller_id"];
  100. //微信的信息
  101. _wx_appid = [dic valueForKey:@"wx_appid"];
  102. [self creatUI:dic];
  103. }else{
  104. [self clickLeftBtn];
  105. }
  106. } Fail:^(id fail) {
  107. [self clickLeftBtn];
  108. }];
  109. }
  110. - (void)creatUI:(NSDictionary *)dic{
  111. backScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-ShowDiff-50)];
  112. backScrollView.backgroundColor = RGB_COLOR(@"#fafafa", 1);
  113. [self.view addSubview:backScrollView];
  114. // NSArray *array = @[@"待推广视频",@"投放金额",@"投放时长",@"预计播放量提升",@"请选择支付方式",minstr([dic valueForKey:@"tips"])];
  115. NSArray *array = @[YZMsg(@"待推广视频"),YZMsg(@"投放金额"),YZMsg(@"投放时长"),YZMsg(@"预计播放量提升"),minstr([dic valueForKey:@"tips"])];
  116. MASViewAttribute *viewTop = backScrollView.mas_top;
  117. for (int i = 0; i < array.count; i ++) {
  118. UIView *view = [[UIView alloc]init];
  119. [backScrollView addSubview:view];
  120. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.equalTo(backScrollView);
  122. make.top.equalTo(viewTop);
  123. make.width.mas_equalTo(_window_width);
  124. }];
  125. UILabel *label = [[UILabel alloc]init];
  126. label.text = array[i];
  127. label.numberOfLines = 0;
  128. label.textColor = RGB_COLOR(@"#969696", 1);
  129. label.font = [UIFont systemFontOfSize:12];
  130. [view addSubview:label];
  131. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.left.equalTo(view).offset(20);
  133. make.right.equalTo(view).offset(-20);
  134. make.top.equalTo(view).offset(14);
  135. make.bottom.equalTo(view).offset(-14);
  136. }];
  137. UIView *whiteView = [[UIView alloc]init];
  138. whiteView.backgroundColor = [UIColor whiteColor];
  139. [backScrollView addSubview:whiteView];
  140. moneyArray = [[dic valueForKey:@"moneylist"] mutableCopy];
  141. [moneyArray addObject:YZMsg(@"自定义")];
  142. timeArray = @[@"6",@"12",@"24"];
  143. payArray = [dic valueForKey:@"paylist"];
  144. selectMoney = [[moneyArray firstObject] integerValue];
  145. selectTime = 6;
  146. CGFloat whiteHeight = 0.0;
  147. if (i == 0) {
  148. whiteHeight = 100;
  149. }else if (i == 1){
  150. NSInteger count = moneyArray.count % 3 == 0 ? moneyArray.count / 3 : moneyArray.count / 3 + 1;
  151. whiteHeight = count * 55;
  152. }else if (i == 2 || i == 3){
  153. whiteHeight = 60;
  154. }else if (i == 4){
  155. whiteHeight = payArray.count * 50;
  156. }
  157. [whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.left.right.equalTo(view);
  159. make.top.equalTo(view.mas_bottom);
  160. make.height.mas_equalTo(whiteHeight);
  161. }];
  162. //视频信息
  163. if (i == 0) {
  164. UIImageView *thumbImgV = [[UIImageView alloc]init];
  165. thumbImgV.backgroundColor = RGB_COLOR(@"#FB483A", 1);
  166. thumbImgV.layer.cornerRadius = 5;
  167. thumbImgV.layer.masksToBounds = YES;
  168. thumbImgV.contentMode = UIViewContentModeScaleAspectFill;
  169. [thumbImgV sd_setImageWithURL:[NSURL URLWithString:minstr([_videoInfo valueForKey:@"thumb"])]];
  170. [whiteView addSubview:thumbImgV];
  171. [thumbImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.centerY.equalTo(whiteView);
  173. make.left.equalTo(whiteView).offset(20);
  174. make.width.height.mas_equalTo(75);
  175. }];
  176. UILabel *titleL = [[UILabel alloc]init];
  177. titleL.font = [UIFont systemFontOfSize:14];
  178. if (minstr([_videoInfo valueForKey:@"title"]).length > 0) {
  179. titleL.textColor = RGB_COLOR(@"#323232", 1);
  180. titleL.text = minstr([_videoInfo valueForKey:@"title"]);
  181. }else{
  182. titleL.text = YZMsg(@"当前视频未填写视频标题");
  183. titleL.textColor = RGB_COLOR(@"#969696", 1);
  184. }
  185. titleL.numberOfLines = 2;
  186. [whiteView addSubview:titleL];
  187. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.left.equalTo(thumbImgV.mas_right).offset(12);
  189. make.top.equalTo(thumbImgV);
  190. make.right.equalTo(whiteView).offset(-20);
  191. make.height.equalTo(thumbImgV).multipliedBy(0.5);
  192. }];
  193. UILabel *nameL = [[UILabel alloc]init];
  194. nameL.font = [UIFont systemFontOfSize:12];
  195. nameL.textColor = RGB_COLOR(@"#969696", 1);
  196. NSDictionary *userInfoDic = [_videoInfo valueForKey:@"userinfo"];
  197. nameL.text = minstr([userInfoDic valueForKey:@"user_nickname"]);
  198. [whiteView addSubview:nameL];
  199. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  200. make.left.equalTo(thumbImgV.mas_right).offset(12);
  201. make.top.equalTo(thumbImgV.mas_centerY);
  202. make.right.equalTo(whiteView).offset(-20);
  203. }];
  204. UILabel *timeL = [[UILabel alloc]init];
  205. timeL.font = [UIFont systemFontOfSize:10];
  206. timeL.textColor = RGB_COLOR(@"#969696", 1);
  207. timeL.text = minstr([_videoInfo valueForKey:@"addtime"]);
  208. [whiteView addSubview:timeL];
  209. [timeL mas_makeConstraints:^(MASConstraintMaker *make) {
  210. make.left.equalTo(thumbImgV.mas_right).offset(12);
  211. make.bottom.equalTo(thumbImgV);
  212. make.right.equalTo(whiteView).offset(-20);
  213. }];
  214. }
  215. if (i == 1 || i == 2) {
  216. NSArray *arr = i == 1 ? moneyArray : timeArray;
  217. CGFloat btnWidth = (_window_width - 76)/3;
  218. for (int j = 0; j < arr.count; j ++) {
  219. UIButton *btn = [UIButton buttonWithType:0];
  220. btn.layer.cornerRadius = 3;
  221. btn.layer.masksToBounds = YES;
  222. btn.layer.borderWidth = 1;
  223. btn.tag = i *1000 + j;
  224. [btn setTitleColor:RGB_COLOR(@"#969696", 1) forState:0];
  225. [btn setTitleColor:RGB_COLOR(@"#FB483A", 1) forState:UIControlStateSelected];
  226. btn.titleLabel.font = [UIFont systemFontOfSize:13];
  227. [btn addTarget:self action:@selector(selectButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  228. if (j == 0) {
  229. btn.selected = YES;
  230. btn.layer.borderColor = RGB_COLOR(@"#FB483A", 1).CGColor;
  231. }else{
  232. btn.layer.borderColor = RGB_COLOR(@"#dcdcdc", 1).CGColor;
  233. }
  234. [whiteView addSubview:btn];
  235. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  236. make.left.equalTo(whiteView).offset(20+j%3*(btnWidth + 18));
  237. make.height.mas_equalTo(33);
  238. make.top.equalTo(whiteView).offset(15+(j/3)*48);
  239. make.width.mas_equalTo(btnWidth);
  240. }];
  241. if (i == 1) {
  242. if (j == arr.count - 1) {
  243. [btn setTitle:arr[j] forState:0];
  244. }else{
  245. [btn setTitle:[NSString stringWithFormat:@"%@",arr[j]] forState:0];
  246. [btn setImage:[UIImage imageNamed:@"礼物-金币"] forState:0];
  247. [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, - btn.imageView.image.size.width-2, 0, btn.imageView.image.size.width)];
  248. [btn setImageEdgeInsets:UIEdgeInsetsMake(0, btn.titleLabel.bounds.size.width+2, 0, -btn.titleLabel.bounds.size.width)];
  249. }
  250. [moneyIteamArray addObject:btn];
  251. }else{
  252. [btn setTitle:[NSString stringWithFormat:@"%@%@",arr[j],YZMsg(@"小时")] forState:0];
  253. [timeIteamArray addObject:btn];
  254. }
  255. }
  256. }
  257. if (i == 3) {
  258. playNumsL = [[UILabel alloc]init];
  259. playNumsL.text = [NSString stringWithFormat:@"%ld+",selectTime * selectMoney * baseCount];
  260. playNumsL.font = [UIFont boldSystemFontOfSize:20];
  261. [whiteView addSubview:playNumsL];
  262. [playNumsL mas_makeConstraints:^(MASConstraintMaker *make) {
  263. make.center.equalTo(whiteView);
  264. }];
  265. }
  266. /*
  267. if (i == 4) {
  268. for (int j = 0; j < payArray.count; j ++) {
  269. UIButton *btn = [UIButton buttonWithType:0];
  270. [btn addTarget:self action:@selector(payTypeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  271. btn.tag = 3000 + j;
  272. [whiteView addSubview:btn];
  273. [btn mas_makeConstraints:^(MASConstraintMaker *make) {
  274. make.left.equalTo(whiteView).offset(20);
  275. make.right.equalTo(whiteView).offset(-20);
  276. make.top.equalTo(whiteView).offset(j * 50);
  277. make.height.mas_equalTo(50);
  278. }];
  279. UIImageView *payImgV = [[UIImageView alloc]init];
  280. [payImgV sd_setImageWithURL:[NSURL URLWithString:minstr([payArray[j] valueForKey:@"thumb"])]];
  281. [btn addSubview:payImgV];
  282. [payImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  283. make.left.equalTo(btn);
  284. make.centerY.equalTo(btn);
  285. make.width.height.mas_equalTo(16);
  286. }];
  287. UILabel *nameL = [[UILabel alloc]init];
  288. nameL.text = minstr([payArray[j] valueForKey:@"name"]);
  289. nameL.font = [UIFont boldSystemFontOfSize:13];
  290. [btn addSubview:nameL];
  291. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  292. make.left.equalTo(payImgV.mas_right).offset(5);
  293. make.centerY.equalTo(btn);
  294. }];
  295. UIImageView *selectImgV = [[UIImageView alloc]init];
  296. [selectImgV setImage:[UIImage imageNamed:@"hot_nor"]];
  297. [btn addSubview:selectImgV];
  298. [selectImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  299. make.right.equalTo(btn);
  300. make.centerY.equalTo(btn);
  301. make.width.height.mas_equalTo(16);
  302. }];
  303. [payTypeArray addObject:selectImgV];
  304. UIView *lineV = [[UIView alloc]init];
  305. lineV.backgroundColor = RGB_COLOR(@"#f5f5f5", 1);
  306. [btn addSubview:lineV];
  307. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  308. make.left.bottom.right.equalTo(btn);
  309. make.height.mas_equalTo(1);
  310. }];
  311. if ([minstr([payArray[j] valueForKey:@"id"]) isEqual:@"balance"]) {
  312. UILabel *coinL = [[UILabel alloc]init];
  313. coinL.text = [NSString stringWithFormat:@"¥%@",minstr([dic valueForKey:@"coin"])];
  314. coinL.font = [UIFont boldSystemFontOfSize:13];
  315. coinL.textColor = RGB_COLOR(@"#FB483A", 1);
  316. [btn addSubview:coinL];
  317. [coinL mas_makeConstraints:^(MASConstraintMaker *make) {
  318. make.left.equalTo(nameL.mas_right).offset(5);
  319. make.centerY.equalTo(btn);
  320. }];
  321. if ([minstr([dic valueForKey:@"coin"]) integerValue] < [moneyArray[0] integerValue]) {
  322. selectImgV.hidden = YES;
  323. }
  324. }
  325. }
  326. }
  327. */
  328. viewTop = whiteView.mas_bottom;
  329. if (i == 4) {
  330. [backScrollView layoutIfNeeded];
  331. backScrollView.contentSize = CGSizeMake(0, view.bottom+5);
  332. }
  333. }
  334. //底部试图
  335. UIView *bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, _window_height-50-ShowDiff, _window_width, 50+ShowDiff)];
  336. bottomView.backgroundColor = [UIColor whiteColor];
  337. [self.view addSubview:bottomView];
  338. UILabel *label1 = [[UILabel alloc]init];
  339. label1.text = YZMsg(@"待支付:");
  340. label1.font = [UIFont systemFontOfSize:13];
  341. [bottomView addSubview:label1];
  342. [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
  343. make.centerY.equalTo(bottomView);
  344. make.left.equalTo(bottomView).offset(20);
  345. }];
  346. needMoneyL = [[UILabel alloc]init];
  347. needMoneyL.text = [NSString stringWithFormat:@"%@",moneyArray[0]];
  348. needMoneyL.font = [UIFont systemFontOfSize:13];
  349. needMoneyL.textColor = RGB_COLOR(@"#FB483A", 1);
  350. [bottomView addSubview:needMoneyL];
  351. [needMoneyL mas_makeConstraints:^(MASConstraintMaker *make) {
  352. make.centerY.equalTo(bottomView);
  353. make.left.equalTo(label1.mas_right).offset(3);
  354. }];
  355. UIImageView *coinIV = [[UIImageView alloc]init];
  356. [coinIV setImage:[UIImage imageNamed:@"礼物-金币"]];
  357. [bottomView addSubview:coinIV];
  358. [coinIV mas_makeConstraints:^(MASConstraintMaker *make) {
  359. make.width.height.equalTo(@15);
  360. make.centerY.equalTo(needMoneyL);
  361. make.left.equalTo(needMoneyL.mas_right).offset(5);
  362. }];
  363. payButton = [UIButton buttonWithType:0];
  364. // [payButton setBackgroundColor:RGB_COLOR(@"#DCDCDC", 1)];
  365. [payButton setTitle:YZMsg(@"确认支付") forState:0];
  366. payButton.titleLabel.font = [UIFont systemFontOfSize:13];
  367. // payButton.userInteractionEnabled = NO;
  368. payButton.userInteractionEnabled = YES;
  369. [payButton setBackgroundColor:RGB_COLOR(@"#FB483A", 1)];
  370. payButton.titleLabel.adjustsFontSizeToFitWidth = YES;
  371. [payButton addTarget:self action:@selector(payButtonClick) forControlEvents:UIControlEventTouchUpInside];
  372. [bottomView addSubview:payButton];
  373. [payButton mas_makeConstraints:^(MASConstraintMaker *make) {
  374. make.top.right.equalTo(bottomView);
  375. make.width.mas_equalTo(100);
  376. make.height.mas_equalTo(50);
  377. }];
  378. }
  379. - (void)selectButtonClick:(UIButton *)sender{
  380. // if (sender.selected) {
  381. // return;
  382. // }
  383. if (sender.tag < 2000) {
  384. // q金钱按钮
  385. if (sender == [moneyIteamArray lastObject]) {
  386. [self showEnterMoneyView];
  387. }else{
  388. selectMoney = [moneyArray[sender.tag-1000] integerValue];
  389. playNumsL.text = [NSString stringWithFormat:@"%ld+",selectMoney * selectTime * baseCount];
  390. needMoneyL.text = [NSString stringWithFormat:@"%ld",selectMoney];
  391. for (UIButton *btn in moneyIteamArray) {
  392. if (sender == btn) {
  393. btn.selected = YES;
  394. btn.layer.borderColor = RGB_COLOR(@"#FB483A", 1).CGColor;
  395. }else{
  396. btn.selected = NO;
  397. btn.layer.borderColor = RGB_COLOR(@"#dcdcdc", 1).CGColor;
  398. }
  399. }
  400. }
  401. }else{
  402. selectTime = [timeArray[sender.tag - 2000] intValue];
  403. playNumsL.text = [NSString stringWithFormat:@"%ld+",selectMoney * selectTime * baseCount];
  404. //时间n安妮
  405. for (UIButton *btn in timeIteamArray) {
  406. if (sender == btn) {
  407. btn.selected = YES;
  408. btn.layer.borderColor = RGB_COLOR(@"#FB483A", 1).CGColor;
  409. }else{
  410. btn.selected = NO;
  411. btn.layer.borderColor = RGB_COLOR(@"#dcdcdc", 1).CGColor;
  412. }
  413. }
  414. }
  415. }
  416. - (void)payTypeButtonClick:(UIButton *)sender{
  417. UIImageView *imgV = payTypeArray[sender.tag - 3000];
  418. if (imgV.hidden) {
  419. return;
  420. }
  421. selectPayDic = payArray[sender.tag - 3000];
  422. for (UIImageView *img in payTypeArray) {
  423. if (imgV == img) {
  424. img.image = [UIImage imageNamed:@"hot_pay_sel"];
  425. }else{
  426. img.image = [UIImage imageNamed:@"hot_nor"];
  427. }
  428. }
  429. payButton.userInteractionEnabled = YES;
  430. [payButton setBackgroundColor:RGB_COLOR(@"#FB483A", 1)];
  431. }
  432. - (void)payButtonClick{
  433. NSDictionary *userInfoDic = [_videoInfo valueForKey:@"userinfo"];
  434. NSString *nameStr = minstr([userInfoDic valueForKey:@"user_nickname"]);
  435. NSString *hotStr;
  436. hotStr= [NSString stringWithFormat:YZMsg(@"帮%@进行热门投放,是否继续?"),nameStr];
  437. if ([nameStr isEqual:[Config getOwnNicename]]) {
  438. hotStr = YZMsg(@"进行热门投放,是否继续?");
  439. }
  440. NSString *msg = [NSString stringWithFormat:@"%@%@[rich]%@",YZMsg(@"您将支付"),needMoneyL.text,hotStr];
  441. NSDictionary *contentDic = @{@"title":@"",@"msg":msg,@"left":YZMsg(@"取消"),@"right":YZMsg(@"确认支付"),@"richImg":@"礼物-金币"};
  442. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  443. if (eventType == 1) {
  444. [self doBalancePay];
  445. }
  446. }];
  447. }
  448. - (void)showEnterMoneyView{
  449. if (!enterMoneyView) {
  450. enterMoneyView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
  451. enterMoneyView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
  452. [self.view addSubview:enterMoneyView];
  453. UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideMoney)];
  454. [enterMoneyView addGestureRecognizer:tap1];
  455. moneyWhiteView = [[UIView alloc]initWithFrame:CGRectMake(_window_width * 0.18, _window_height, _window_width*0.64, 170)];
  456. moneyWhiteView.backgroundColor = [UIColor whiteColor];
  457. moneyWhiteView.layer.cornerRadius = 10.0;
  458. moneyWhiteView.layer.masksToBounds = YES;
  459. [enterMoneyView addSubview:moneyWhiteView];
  460. UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nothingTap)];
  461. [moneyWhiteView addGestureRecognizer:tap2];
  462. UILabel *label = [[UILabel alloc]init];
  463. label.text = YZMsg(@"请输入要投放的金额");
  464. label.font = [UIFont systemFontOfSize:14];
  465. label.textColor = RGB_COLOR(@"#323232", 1);
  466. [moneyWhiteView addSubview:label];
  467. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  468. make.centerX.equalTo(moneyWhiteView);
  469. make.top.equalTo(moneyWhiteView);
  470. make.height.mas_equalTo(45);
  471. }];
  472. moneyT = [[UITextField alloc]init];
  473. moneyT.textAlignment = NSTextAlignmentCenter;
  474. moneyT.keyboardType = UIKeyboardTypeNumberPad;
  475. moneyT.layer.borderWidth = 1;
  476. moneyT.layer.borderColor = RGB_COLOR(@"#D2D2D2", 1).CGColor;
  477. [moneyWhiteView addSubview:moneyT];
  478. [moneyT mas_makeConstraints:^(MASConstraintMaker *make) {
  479. make.left.equalTo(moneyWhiteView).offset(25);
  480. make.right.equalTo(moneyWhiteView).offset(-25);
  481. make.top.equalTo(label.mas_bottom);
  482. make.height.mas_equalTo(40);
  483. }];
  484. UILabel *label2 = [[UILabel alloc]init];
  485. label2.text = YZMsg(@"金额不能低于100,且为10的倍数");
  486. label2.font = [UIFont systemFontOfSize:11];
  487. label2.textColor = RGB_COLOR(@"#646464", 1);
  488. label2.numberOfLines = 0;
  489. [moneyWhiteView addSubview:label2];
  490. [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
  491. make.left.right.equalTo(moneyT);
  492. make.top.equalTo(moneyT.mas_bottom).offset(5);
  493. }];
  494. UIButton *sureBtn = [UIButton buttonWithType:0];
  495. [sureBtn setBackgroundColor:RGB_COLOR(@"#FB483A", 1)];
  496. [sureBtn setTitle:YZMsg(@"确定") forState:0];
  497. sureBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  498. [sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
  499. [moneyWhiteView addSubview:sureBtn];
  500. [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  501. make.left.right.equalTo(moneyT);
  502. make.height.mas_equalTo(35);
  503. make.bottom.equalTo(moneyWhiteView).offset(-15);
  504. }];
  505. [enterMoneyView layoutIfNeeded];
  506. }
  507. enterMoneyView.hidden = NO;
  508. [UIView animateWithDuration:0.2 animations:^{
  509. moneyWhiteView.center = enterMoneyView.center;
  510. }];
  511. }
  512. - (void)hideMoney{
  513. [moneyT resignFirstResponder];
  514. [UIView animateWithDuration:0.2 animations:^{
  515. moneyWhiteView.y = _window_height;
  516. } completion:^(BOOL finished) {
  517. enterMoneyView.hidden = YES;
  518. }];
  519. }
  520. - (void)nothingTap{
  521. [moneyT resignFirstResponder];
  522. }
  523. - (void)sureBtnClick{
  524. if ([PublicObj checkNull:moneyT.text]) {
  525. [MBProgressHUD showError:YZMsg(@"金额不能为空")];
  526. return;
  527. }
  528. if ([moneyT.text intValue] < 100) {
  529. [MBProgressHUD showError:YZMsg(@"金额不能小于100")];
  530. return;
  531. }
  532. selectMoney = [moneyT.text integerValue]/10 * 10;
  533. playNumsL.text = [NSString stringWithFormat:@"%ld+",selectMoney * selectTime * baseCount];
  534. UIButton *sender = [moneyIteamArray lastObject];
  535. [sender setTitle:[NSString stringWithFormat:@"%ld",selectMoney] forState:0];
  536. [sender setImage:[UIImage imageNamed:@"礼物-金币"] forState:0];
  537. [sender setTitleEdgeInsets:UIEdgeInsetsMake(0, - sender.imageView.image.size.width-2, 0, sender.imageView.image.size.width)];
  538. [sender setImageEdgeInsets:UIEdgeInsetsMake(0, sender.titleLabel.bounds.size.width+2, 0, -sender.titleLabel.bounds.size.width)];
  539. needMoneyL.text = [NSString stringWithFormat:@" %ld",selectMoney];
  540. for (UIButton *btn in moneyIteamArray) {
  541. if (sender == btn) {
  542. btn.selected = YES;
  543. btn.layer.borderColor = RGB_COLOR(@"#FB483A", 1).CGColor;
  544. }else{
  545. btn.selected = NO;
  546. btn.layer.borderColor = RGB_COLOR(@"#dcdcdc", 1).CGColor;
  547. }
  548. }
  549. [self hideMoney];
  550. }
  551. - (void)doBalancePay{
  552. [MBProgressHUD showMessage:@""];
  553. NSDictionary *subdic = @{
  554. @"uid":[Config getOwnID],
  555. @"token":[Config getOwnToken],
  556. @"videoid":[_videoInfo valueForKey:@"id"],
  557. @"length":@(selectTime),
  558. @"money":@(selectMoney)
  559. };
  560. [YBNetworking postWithUrl:@"Popular.BalancePay" Dic:subdic Suc:^(int code, id info, NSString *msg) {
  561. [MBProgressHUD hideHUD];
  562. if (code == 0) {
  563. [MBProgressHUD showError:YZMsg(@"支付成功")];
  564. [self clickLeftBtn];
  565. }
  566. else if (code == 1005){
  567. [self balanceAlert];
  568. }
  569. else{
  570. [MBProgressHUD showError:msg];
  571. }
  572. } Fail:^(id fail) {
  573. [MBProgressHUD hideHUD];
  574. }];
  575. }
  576. -(void)balanceAlert {
  577. NSString *msg = [NSString stringWithFormat:@"%@",YZMsg(@"您账户余额不足,请充值后再次尝试")];
  578. NSDictionary *contentDic = @{@"title":@"",@"msg":msg,@"left":YZMsg(@"取消"),@"right":YZMsg(@"去充值"),@"richImg":@""};
  579. [YBAlertView showAlertView:contentDic complete:^(int eventType) {
  580. if (eventType == 1) {
  581. YBRechargeVC *chargeVC = [[YBRechargeVC alloc]init];
  582. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:chargeVC animated:YES];
  583. }
  584. }];
  585. }
  586. /*
  587. #pragma mark - Navigation
  588. // In a storyboard-based application, you will often want to do a little preparation before navigation
  589. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  590. // Get the new view controller using [segue destinationViewController].
  591. // Pass the selected object to the new view controller.
  592. }
  593. */
  594. @end