123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // KDPIDViewController.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/9.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPIDViewController.h"
- @interface KDPIDViewController ()
- {
- UILabel *pidLabel;
- UILabel *tipLabel;
- NSDictionary *pidDic;
- UIButton *copyButton;
- }
- @end
- @implementation KDPIDViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
- self.navBar.navTitleLabel.text=@"快手小店PID";
- self.view.backgroundColor=[UIColor colorWithHexString:LineColor];
-
- UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight+10, SCREEN_WIDTH, 51)];
- backV.backgroundColor=[UIColor whiteColor];
- [self.view addSubview:backV];
-
- pidLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-50, 51)];
- pidLabel.text=@"快手小店pid";
- [backV addSubview:pidLabel];
-
- pidLabel.textColor=[UIColor colorWithHexString:@"#999999"];
- pidLabel.font=[UIFont systemFontOfSize:14];
- [backV addSubview:pidLabel];
-
-
- copyButton=[[UIButton alloc]initWithFrame:CGRectMake(pidLabel.right, 0, 30, 51)];
- [copyButton setTitle:@"复制" forState:UIControlStateNormal];
- [copyButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
- copyButton.titleLabel.font=[UIFont systemFontOfSize:14];
- [backV addSubview:copyButton];
- [copyButton addTarget:self action:@selector(copyClickButton) forControlEvents:UIControlEventTouchUpInside];
-
-
- UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(10, backV.bottom+10, SCREEN_WIDTH-20, 40)];
-
- label.textColor=[UIColor colorWithHexString:@"#666666"];
- label.font=[UIFont systemFontOfSize:12];
- label.numberOfLines=0;
- label.attributedText=[KDPublicMethod sethanggaoWithStr:@"PID是您的专属推广位,用于同步订单获得收益,推广商品前请确保您已在快手小店上绑定了该PID。" linSpacing:3];
- tipLabel = label;
- [self.view addSubview:label];
-
-
- UIButton *bindButton=[[UIButton alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50-KDTabBottomHeight, SCREEN_WIDTH, 50)];
- [bindButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
- [bindButton setTitle:@"去绑定" forState:UIControlStateNormal];
- bindButton.titleLabel.font=[UIFont systemFontOfSize:14];
- [bindButton addTarget:self action:@selector(pidclickButton) forControlEvents:UIControlEventTouchUpInside];
- bindButton.backgroundColor=[UIColor whiteColor];
- [self.view addSubview:bindButton];
- [self getPIDNumber];
-
- }
- -(void)pidclickButton
- {
- if ([pidDic[@"status"] integerValue] == 2) {
- [self JumpKwaiURL:pidDic[@"kwai_url"]];
- }else{
- [MBProgressHUD showMessage:pidDic[@"pid"]];
- }
- }
- -(void)getPIDNumber
- {
- [LoadingView show];
- [KDPNetworkRequestHTTP postURL:PIDURL params:nil success:^(id _Nonnull json) {
- pidDic = json;
- [LoadingView dismiss];
- tipLabel.attributedText=[KDPublicMethod sethanggaoWithStr:json[@"message"] linSpacing:3];
- pidLabel.text=json[@"pid"];
- if ([json[@"status"] integerValue]==1) {
- copyButton.hidden =YES;
- }else{
- copyButton.hidden=NO;
- }
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- -(void) JumpKwaiURL:(NSString *)schemeUrl{
-
-
- NSURL *url= [NSURL URLWithString:schemeUrl];
- dispatch_async(dispatch_get_main_queue(), ^{
- [[UIApplication sharedApplication] openURL:url];
- });
-
-
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navigationController.navigationBar.hidden=YES;
- self.tabBarController.tabBar.hidden=YES;
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- self.tabBarController.tabBar.hidden=NO;
- }
- #pragma mark---复制
- -(void)copyClickButton
- {
- UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
- if (pidDic[@"pid"]) {
- pastboard.string =pidDic[@"pid"];
- [MBProgressHUD showMessage:@"复制成功"];
-
- }else {
- [MBProgressHUD showMessage:@"复制失败"];
- }
- }
- @end
|