@property (nonatomic,strong) UIButton *but;
@property (nonatomic,strong) UIButton *but1;
@property (strong, nonatomic) UIView *subView;

//客服QQ
-(void)qqAction
{
    self.but = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but.frame = self.view.bounds;
    self.but.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
    [self.but addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.but];
    
    self.but1 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but1.frame = self.view.bounds;
    self.but1.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
    [self.view addSubview:self.but1];
    
    [self.tabBarController.tabBar addSubview:self.but1];
    
    _subView = [[UIView alloc] initWithFrame:CGRectMake(20, screenHeight * 2, screenWidth - 40,200)];
    _subView.alpha = 0;
    _subView.layer.masksToBounds = YES;
    _subView.layer.cornerRadius = 3.0f;
    _subView.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
    [self.but addSubview:_subView];
    [UIView animateWithDuration:0.001 animations:^{
        CGRect frame = self.subView.frame;
        frame.origin.y = screenHeight / 2-110;
        self.subView.frame = frame;
        self.subView.alpha = 1;
        
        UIButton *closeBtn = [[UIButton alloc] init];
        closeBtn.frame = CGRectMake(_subView.bounds.size.width - 30, 0, 30, 30);
        [closeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [closeBtn setImage:[UIImage imageNamed:@"btn_关闭_灰色__none"] forState:UIControlStateNormal];
        [closeBtn addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
        [_subView addSubview:closeBtn];
        
        UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(14, 45, _subView.bounds.size.width, 30)];
        label1.text = @"钱富宝客服QQ:2797353115";
        label1.textAlignment = NSTextAlignmentLeft;
        label1.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
        label1.font = [UIFont systemFontOfSize:16];
        [_subView addSubview:label1];
        
        UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(14, 62, _subView.bounds.size.width - 28, 60)];
        label2.text = @"注:每周一至周五8:00到18:00正常上班,节假日休息。";
        label2.numberOfLines = 2;
        label2.textAlignment = NSTextAlignmentLeft;
        label2.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
        label2.font = [UIFont systemFontOfSize:16];
        [_subView addSubview:label2];
        
        UIButton *requestionBtn = [[UIButton alloc] init];
        requestionBtn.frame = CGRectMake(14, 150, _subView.bounds.size.width - 28, 43);
        [requestionBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [requestionBtn setTitle:@"立即咨询" forState:UIControlStateNormal];
        [requestionBtn addTarget:self action:@selector(requestionClick) forControlEvents:UIControlEventTouchUpInside];
        [requestionBtn setBackgroundColor:[UIColor colorWithRed:65/256.0 green:109/256.0 blue:218/256.0 alpha:1.0f]];
        requestionBtn.layer.masksToBounds = YES;
        requestionBtn.layer.cornerRadius = 3.0f;
        
        [_subView addSubview:requestionBtn];
        
    } completion:^(BOOL finished) {
    }];
    
}

#pragma mark 在线客服网页跳转的实现部分
-(void)requestionClick{
    
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
    UILabel *qqLabel = [[UILabel alloc] init];
    qqLabel.text = @"2797353115";
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",qqLabel.text]];
    NSLog(@"----------%@-------",qqLabel.text);
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    webView.delegate = self;
    [webView loadRequest:request];
    [self.view addSubview:webView];
    
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error
{
    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:@"未安装QQ程序" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles: nil];
    [alertView show];
}

#pramra mark 打电话

//电话
-(void)hotLineAlertView
{
    self.but = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but.frame = self.view.bounds;
    self.but.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
    [self.but addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.but];
    
    self.but1 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but1.frame = self.view.bounds;
    self.but1.backgroundColor = [UIColor colorWithWhite:0.019 alpha:0.400];
    [self.view addSubview:self.but1];
    
    [self.tabBarController.tabBar addSubview:self.but1];
    
    _subView = [[UIView alloc] initWithFrame:CGRectMake(20, screenHeight * 2, screenWidth - 40,200)];
    _subView.alpha = 0;
    _subView.layer.masksToBounds = YES;
    _subView.layer.cornerRadius = 3.0f;
    _subView.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
    [self.but addSubview:_subView];
    [UIView animateWithDuration:0.001 animations:^{
        CGRect frame = self.subView.frame;
        frame.origin.y = screenHeight / 2-110;
        self.subView.frame = frame;
        self.subView.alpha = 1;
        
        UIButton *closeBtn = [[UIButton alloc] init];
        closeBtn.frame = CGRectMake(_subView.bounds.size.width - 30, 0, 30, 30);
        [closeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [closeBtn setImage:[UIImage imageNamed:@"btn_关闭_灰色__none"] forState:UIControlStateNormal];
        [closeBtn addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
        [_subView addSubview:closeBtn];
        
        UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(14, 45, _subView.bounds.size.width, 30)];
        label1.text = @"钱富宝客服热线:400-607-1818";
        label1.textAlignment = NSTextAlignmentLeft;
        label1.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
        label1.font = [UIFont systemFontOfSize:16];
        [_subView addSubview:label1];
        
        UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(14, 62, _subView.bounds.size.width - 28, 60)];
        label2.text = @"注:每周一至周五8:00到18:00正常上班,节假日休息。";
        label2.numberOfLines = 2;
        label2.textAlignment = NSTextAlignmentLeft;
        label2.textColor = [UIColor colorWithRed:96/256.0 green:103/256.0 blue:127/256.0 alpha:1.0f];
        label2.font = [UIFont systemFontOfSize:16];
        [_subView addSubview:label2];
        
        UIButton *hotLineBtn = [[UIButton alloc] init];
        hotLineBtn.frame = CGRectMake(14, 150, _subView.bounds.size.width - 28, 43);
        [hotLineBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [hotLineBtn setTitle:@"拨打热线" forState:UIControlStateNormal];
        [hotLineBtn addTarget:self action:@selector(hotLineClick) forControlEvents:UIControlEventTouchUpInside];
        [hotLineBtn setBackgroundColor:[UIColor colorWithRed:65/256.0 green:109/256.0 blue:218/256.0 alpha:1.0f]];
        hotLineBtn.layer.masksToBounds = YES;
        hotLineBtn.layer.cornerRadius = 3.0f;
        
        [_subView addSubview:hotLineBtn];
        
    } completion:^(BOOL finished) {
    }];
    
}

-(void)closeView
{
    [_but removeFromSuperview];
    [_but1 removeFromSuperview];
}

- (void)btnClick:(UIButton *)but
{
    [_but removeFromSuperview];
    [_but1 removeFromSuperview];
}
//播打热线
-(void)hotLineClick
{
    [_but removeFromSuperview];
    [_but1 removeFromSuperview];
    
    NSString *number = @"400-607-1818";
    NSString *num = [[NSString alloc]initWithFormat:@"telprompt://%@",number];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:num]]; //拨号

}

IOS开发之—— 客服QQ(调用qq网页聊天),客服热线(拨打电话)的更多相关文章

  1. iOS开发UI篇—模仿ipad版QQ空间登录界面

    iOS开发UI篇—模仿ipad版QQ空间登录界面 一.实现和步骤 1.一般ipad项目在命名的时候可以加一个HD,标明为高清版 2.设置项目的文件结构,分为home和login两个部分 3.登陆界面的 ...

  2. ios开发中全局变量设置和调用方法

    ios开发中,全局变量设置和调用方法如下:在AppDelegate.h文件中设置全局变量:@interface ***AppDelegate{NSString *myName;}@property ( ...

  3. iOS开发:在Swift中调用oc库

    先列举这个工程中用到的oc源码库: MBProgressHUD:半透明提示器,Loading动画等 SDWebImage:图片下载和缓存的库 MJRefresh: 下拉刷新,上拉加载 Alamofir ...

  4. ios开发:如何用js调用ios

    本文转载至 :http://blog.chinaunix.net/uid-29415710-id-4058564.html - (BOOL)webView:(UIWebView *)webView s ...

  5. iOS开发——项目实战OC篇&类QQ黏性按钮(封装)

    类QQ粘性按钮(封装) 那个,先来说说原理吧: 这里原理就是,在界面设置两个控件一个按钮在上面,一个View在下面(同样大小),当我们拖动按钮的时候显示下面的View,view不移动,但是会根据按钮中 ...

  6. ios开发——实用技术篇Swift&Swift调用C、C++、Object

    Swift调用C.C++.Object 1.Swift调用C语言a,首先在项目中添加 CFile 文件命名为CHello,同时产生桥梁文件. b,创建之后的项目结构 b,在CHello.h文件中编写接 ...

  7. 网页客服思路以及QQ截图粘贴到聊天框功能

    功能: 1.客服需登录进入客服页面.用户无需登录,进入用户页面,直接获取sessionId作为id值. 2.用户进入页面并且发送消息时,客服才会获取到该用户,并在左侧列表显示. 3.点击用户名即可切换 ...

  8. 文顶顶iOS开发博客链接整理及部分项目源代码下载

    文顶顶iOS开发博客链接整理及部分项目源代码下载   网上的iOS开发的教程很多,但是像cnblogs博主文顶顶的博客这样内容图文并茂,代码齐全,示例经典,原理也有阐述,覆盖面宽广,自成系统的系列教程 ...

  9. iOS开发之再探多线程编程:Grand Central Dispatch详解

    Swift3.0相关代码已在github上更新.之前关于iOS开发多线程的内容发布过一篇博客,其中介绍了NSThread.操作队列以及GCD,介绍的不够深入.今天就以GCD为主题来全面的总结一下GCD ...

  10. IOS开发之记录用户登陆状态,ios开发用户登陆

    IOS开发之记录用户登陆状态,ios开发用户登陆 上一篇博客中提到了用CoreData来进行数据的持久化,CoreData的配置和使用步骤还是挺复杂的.但熟悉CoreData的使用流程后,CoreDa ...

随机推荐

  1. jquery1.0源码【1-60行】构造函数及全局$变量

    一.jquery源码1-60行 该部分代码主要完成jquery对象的创建,以及全局变量$与jQurey类的映射: /* * jQuery - New Wave Javascript * * Copyr ...

  2. rails开发demo(一)搭建环境

    环境 ubuntu 14.04 为了安装rails4.2 和 ruby 2.2.2,这是目前稳定的最新版本,需要先安装rvm sudo apt-get update sudo apt-get inst ...

  3. Memcache笔记04-Memcached机制深入了解

    Memcached机制深入了解 ①基于c/s架构 ,协议简单 c/s架构,此时memcached为服务器端,我们可以使用如PHP,c/c++等程序连接memcached服务器. memcached的服 ...

  4. SQLServer中char与varchar的区别

    今天写一个项目的用户登录部分 刚开始做,所以是数据库和程序一起写 一开始没注意 在定义表T_Person时吧PerID和PerPwd的类型设定都是char(20) 并且写入了几个数据,诸如 id:01 ...

  5. 用mciSendString做音乐播放器

    音乐操作类 public class clsMCI { public clsMCI() { // // TODO: 在此处添加构造函数逻辑 // } //定义API函数使用的字符串变量 [Marsha ...

  6. cocos2d-x之计时器初试

    bool HelloWorld::init() { if ( !Layer::init() ) { return false; } Size visibleSize = Director::getIn ...

  7. 通过java的Runtime.getRuntime()和System.getProperties()来获取系统的信息

    第一种,通过Runtime.getRuntime()来获取系统信息. 通过java来获取系统以下的信息: 主机名: OS 名称:         OS 版本: OS 制造商: OS 配置: 独立工作站 ...

  8. java帮助文档下载

    JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载JDK(Java Development Kit,Java开发包,Java开发工具)是一个写Java的applet和 ...

  9. 小结getBytes()默认编码导致的xml字符串中出现乱码

    遇到乱码第一印象想到的是如何统一编码,很少注意到这期间穿插的某些过程也是一大隐患.. sae上部署了一个spring写的微信小程序,手机总关注测试号点击菜单得到的文本消息却是乱码.. 聚焦发送消息的部 ...

  10. Android 系统架构

    Android 系统从下至上分为四层:Linux 内核.Android 核心库及Android 运行时环境(Android Runtime). 应用程序框架以及应用程序等. Linux 内核(Linu ...