酷店

KDPIDViewController.m 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // KDPIDViewController.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPIDViewController.h"
  9. @interface KDPIDViewController ()
  10. {
  11. UILabel *pidLabel;
  12. UILabel *tipLabel;
  13. NSDictionary *pidDic;
  14. UIButton *copyButton;
  15. }
  16. @end
  17. @implementation KDPIDViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
  21. self.navBar.navTitleLabel.text=@"快手小店PID";
  22. self.view.backgroundColor=[UIColor colorWithHexString:LineColor];
  23. UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight+10, SCREEN_WIDTH, 51)];
  24. backV.backgroundColor=[UIColor whiteColor];
  25. [self.view addSubview:backV];
  26. pidLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-50, 51)];
  27. pidLabel.text=@"快手小店pid";
  28. [backV addSubview:pidLabel];
  29. pidLabel.textColor=[UIColor colorWithHexString:@"#999999"];
  30. pidLabel.font=[UIFont systemFontOfSize:14];
  31. [backV addSubview:pidLabel];
  32. copyButton=[[UIButton alloc]initWithFrame:CGRectMake(pidLabel.right, 0, 30, 51)];
  33. [copyButton setTitle:@"复制" forState:UIControlStateNormal];
  34. [copyButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
  35. copyButton.titleLabel.font=[UIFont systemFontOfSize:14];
  36. [backV addSubview:copyButton];
  37. [copyButton addTarget:self action:@selector(copyClickButton) forControlEvents:UIControlEventTouchUpInside];
  38. UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(10, backV.bottom+10, SCREEN_WIDTH-20, 40)];
  39. label.textColor=[UIColor colorWithHexString:@"#666666"];
  40. label.font=[UIFont systemFontOfSize:12];
  41. label.numberOfLines=0;
  42. label.attributedText=[KDPublicMethod sethanggaoWithStr:@"PID是您的专属推广位,用于同步订单获得收益,推广商品前请确保您已在快手小店上绑定了该PID。" linSpacing:3];
  43. tipLabel = label;
  44. [self.view addSubview:label];
  45. UIButton *bindButton=[[UIButton alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50-KDTabBottomHeight, SCREEN_WIDTH, 50)];
  46. [bindButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
  47. [bindButton setTitle:@"去绑定" forState:UIControlStateNormal];
  48. bindButton.titleLabel.font=[UIFont systemFontOfSize:14];
  49. [bindButton addTarget:self action:@selector(pidclickButton) forControlEvents:UIControlEventTouchUpInside];
  50. bindButton.backgroundColor=[UIColor whiteColor];
  51. [self.view addSubview:bindButton];
  52. [self getPIDNumber];
  53. }
  54. -(void)pidclickButton
  55. {
  56. if ([pidDic[@"status"] integerValue] == 2) {
  57. [self JumpKwaiURL:pidDic[@"kwai_url"]];
  58. }else{
  59. [MBProgressHUD showMessage:pidDic[@"pid"]];
  60. }
  61. }
  62. -(void)getPIDNumber
  63. {
  64. [LoadingView show];
  65. [KDPNetworkRequestHTTP postURL:PIDURL params:nil success:^(id _Nonnull json) {
  66. pidDic = json;
  67. [LoadingView dismiss];
  68. tipLabel.attributedText=[KDPublicMethod sethanggaoWithStr:json[@"message"] linSpacing:3];
  69. pidLabel.text=json[@"pid"];
  70. if ([json[@"status"] integerValue]==1) {
  71. copyButton.hidden =YES;
  72. }else{
  73. copyButton.hidden=NO;
  74. }
  75. } failure:^(NSError * _Nonnull error) {
  76. [LoadingView dismiss];
  77. }];
  78. }
  79. -(void) JumpKwaiURL:(NSString *)schemeUrl{
  80. NSURL *url= [NSURL URLWithString:schemeUrl];
  81. dispatch_async(dispatch_get_main_queue(), ^{
  82. [[UIApplication sharedApplication] openURL:url];
  83. });
  84. }
  85. -(void)returnClickBtn
  86. {
  87. [self.navigationController popViewControllerAnimated:YES];
  88. }
  89. -(void)viewWillAppear:(BOOL)animated
  90. {
  91. [super viewWillAppear:animated];
  92. self.navigationController.navigationBar.hidden=YES;
  93. self.tabBarController.tabBar.hidden=YES;
  94. }
  95. -(void)viewWillDisappear:(BOOL)animated
  96. {
  97. [super viewWillDisappear:animated];
  98. self.tabBarController.tabBar.hidden=NO;
  99. }
  100. #pragma mark---复制
  101. -(void)copyClickButton
  102. {
  103. UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
  104. if (pidDic[@"pid"]) {
  105. pastboard.string =pidDic[@"pid"];
  106. [MBProgressHUD showMessage:@"复制成功"];
  107. }else {
  108. [MBProgressHUD showMessage:@"复制失败"];
  109. }
  110. }
  111. @end