<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,target-densitydpi=high-dpi,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<title>你竟然还在用 try–catch-finally-思洋互动</title>
		<meta name="keywords" content="你竟然还在用 try–catch-finally">
	    <meta name="description" content="这是读者Alice上星期特意给我发来的信息，真令我动容。的确，上次的“我去”阅览量杠杠的，几个大号都转载了，包括CSDN，次条当天都1.5万阅览。但比如“还认为你有什么新特技，没...">
		<meta name="renderer" content="webkit" />
		<link href="/css/main.css?v=39" rel="stylesheet">
		<link href="/css/base.css?v=39" rel="stylesheet">
        <link href="/css/swiper-3.4.2.min.css" rel="stylesheet">
		<script type="text/javascript" src="/js/jquery.min.js"></script>
        <script type="text/javascript" src="/js/swiper-3.4.2.min.js"></script>
		<!--[if lt IE 9]>
            <script src="/js/html5shiv.min.js"></script>
            <script src="/js/respond.min.js"></script>
            <link href="/css/ie.css" rel="stylesheet">
        <![endif]-->
		<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?8914d517c927d8e794148d05e387fb17";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<link rel="canonical" href="https://www.ciya.cn/article/3673.html">
		</head>
	<body class="no-banner">
		<div class="container">
			<div class="header">
	<div class="header-top">
		<div class="w1700">
			<a href="https://www.ciya.cn/"><img src="/images/logo.png?v=2"></a>
		</div>
	</div>
	<div class="header_b">
		<header class="slide">
			<div id="navToggle" class="menu-handler">
				<span class="burger burger-1 trans"></span>
				<span class="burger burger-2 trans-fast"></span>
				<span class="burger burger-3 trans"></span>
			</div>
		</header>
	</div>
	<nav class="slide">
		<div class="w1700">
			<a class="index" href="/"></a>
			<ul>
								<li><a href="https://www.ciya.cn/case/12.html">项目案例</a></li>
								<li><a href="https://www.ciya.cn/website/9.html">网站建设</a></li>
								<li><a href="https://www.ciya.cn/marketing/10.html">网络营销</a></li>
								<li><a href="https://www.ciya.cn/media/11.html">新媒体</a></li>
								<li class="active"><a href="https://www.ciya.cn/news/16.html">动态</a></li>
								<li><a href="https://www.ciya.cn/about/8.html">关于</a></li>
								<li><a href="https://www.ciya.cn/contact/13.html">联系</a></li>
							</ul>
		</div>
	</nav>
</div>            <div class="content slide">
                <div class="position bgf1">
                    <div class="w1700">
                        <a href="https://www.ciya.cn/">首页 ></a>
                        <a href="https://www.ciya.cn/news/16.html">动态 ></a>
                        <a href="https://www.ciya.cn/news/35.html">网站知识</a>
                    </div>
                </div>
                <div class="case-type">
                    <div class="w1700">
                                                <a href="https://www.ciya.cn/news/32.html" >品牌合作</a>
                                                <a href="https://www.ciya.cn/news/31.html" >新闻动态</a>
                                                <a href="https://www.ciya.cn/news/38.html" >网站建设</a>
                                                <a href="https://www.ciya.cn/news/41.html" >网站制作</a>
                                                <a href="https://www.ciya.cn/news/40.html" >网站设计</a>
                                                <a href="https://www.ciya.cn/news/42.html" >运营推广</a>
                                                <a href="https://www.ciya.cn/news/35.html"  class="active">网站知识</a>
                                            </div>
                </div>
                <div class="padding-tb80">
                    <div class="w1700 clear">
                        <div class="fl xwxq-l">
                            <div class="noselettext">
                                <div class="xwxq-title mg-bt60 wow slideUp">
                                    <h1 class="mg-bt35">你竟然还在用 try–catch-finally</h1>
                                    <span>时间：2023-05-16</span>
                                </div>
                                <div class="edit2 mg-bt60 wow slideUp">
                                                                        <p>这是读者Alice上星期特意给我发来的信息，真令我动容。的确，上次的“我去”阅览量杠杠的，几个大号都转载了，包括CSDN，次条当天都1.5万阅览。但比如“还认为你有什么新特技，没想到用的是Java13”这类批评的声响也不在少数。<br />
不过我的心一直很大。从我写榜首篇文章至今，被喷的次数就好像头顶上茂密的发量一样，数也数不清。所以我决定再接再厉，带来新的一篇“我去”。<br />
这次不必长途review了，由于咱们公司也复工了。这次review的代码仍然是小王的，他编写的大部分代码都很美丽，严谨的一起注释也很到位，这令我十分满足。但当我看到他没用try-with-resources时，还是不由得破口大骂：“我擦，小王，你丫的居然还在用try–catch-finally！”<br />
来看看小王写的代码吧。<br />
publicclassTrycatchfinally{<br />
publicstaticvoidmain(String[]args){<br />
BufferedReaderbr=null;<br />
try{<br />
br=newBufferedReader(newFileReader(&#8220;/牛逼.txt&#8221;));<br />
Stringstr=null;<br />
while((str=br.readLine())!=null){<br />
System.out.println(str);<br />
}<br />
}catch(IOExceptione){<br />
e.printStackTrace();<br />
}finally{<br />
if(br!=null){<br />
try{<br />
br.close();<br />
}catch(IOExceptione){<br />
e.printStackTrace();<br />
}<br />
}<br />
}<br />
}<br />
}<br />
咦，感觉这段代码很完美无缺啊，try–catch-finally用得中规中矩，尤其是文件名牛逼.txt很亮。不必写注释都能明白这段代码是干嘛的：在try块中读取文件中的内容，并一行一行地打印到控制台。假设文件找不到或者出现IO读写过错，就在catch中捕获并打印过错的仓库信息。最后，在finally中封闭缓冲字符读取器目标BufferedReader，有用杜绝了资源未被封闭的情况下造成的严峻功能成果。<br />
在Java7之前，try–catch-finally的确是保证资源会被及时封闭的最佳办法，无论程序是否会抛出反常。<br />
可是呢，有经历的读者会从上面这段代码中发现2个严峻的问题：<br />
1）文件名“牛逼.txt”包含了中文，需求经过java.net.URLDecoder类的decode()办法对其转义，不然这段代码在运转时铁定要抛出文件找不到的反常。<br />
2）假设直接经过newFileReader(&#8220;牛逼.txt&#8221;)创立FileReader目标，“牛逼.txt”需求和项目的src在同一级目录下，不然同样会抛出文件找不到的反常。但大多数情况下，（装备）文件会放在resources目录下，便于编译后文件出现在classes目录下，<img class="aligncenter size-full wp-image-5006" src="https://zzzjtd.com/wp-content/uploads/2019/08/222.jpg" alt="Java" width="436" height="306" /><br />
为了处理以上2个问题，咱们需求对代码进行优化：<br />
publicclassTrycatchfinallyDecoder{<br />
publicstaticvoidmain(String[]args){<br />
BufferedReaderbr=null;<br />
try{<br />
Stringpath=TrycatchfinallyDecoder.class.getResource(&#8220;/牛逼.txt&#8221;).getFile();<br />
StringdecodePath=URLDecoder.decode(path,&#8221;utf-8&#8243;);<br />
br=newBufferedReader(newFileReader(decodePath));<br />
Stringstr=null;<br />
while((str=br.readLine())!=null){<br />
System.out.println(str);<br />
}<br />
}catch(IOExceptione){<br />
e.printStackTrace();<br />
}finally{<br />
if(br!=null){<br />
try{<br />
br.close();<br />
}catch(IOExceptione){<br />
e.printStackTrace();<br />
}<br />
}<br />
}<br />
}<br />
}<br />
运转这段代码，程序就能够将文件中的内容正确输出到控制台。但假设你对“整洁”这个词心生神往的话，会感觉这段代码十分臃肿，尤其是finally中的代码，就好像一个灌了12瓶雪花啤酒的大肚腩。<br />
网上看到一幅Python程序员调侃Java程序员的神图，直接copy过来（侵删），逗你一乐：<br />
何况，try–catch-finally至始至终存在一个严峻的危险：try中的br.readLine()有可能会抛出IOException，finally中的br.close()也有可能会抛出IOException。假设两处都不幸地抛出了IOException，那程序的调试使命就变得复杂了起来，到底是哪一处出了过错，就需求花一番功夫，这是咱们不愿意看到的成果。<br />
为了模拟上述情况，咱们来自定义一个类MyfinallyReadLineThrow，它有两个办法，分别是readLine()和close()，办法体都是自动抛出反常。<br />
classMyfinallyReadLineThrow{<br />
publicvoidclose()throwsException{<br />
thrownewException(&#8220;close&#8221;);<br />
}<br />
publicvoidreadLine()throwsException{<br />
thrownewException(&#8220;readLine&#8221;);<br />
}<br />
}<br />
然后咱们在main()办法中运用try-finally的方式调用MyfinallyReadLineThrow的readLine()和close()办法：<br />
publicclassTryfinallyCustomReadLineThrow{<br />
publicstaticvoidmain(String[]args)throwsException{<br />
MyfinallyReadLineThrowmyThrow=null;<br />
try{<br />
myThrow=newMyfinallyReadLineThrow();<br />
myThrow.readLine();<br />
}finally{<br />
myThrow.close();<br />
}<br />
}<br />
}<br />
运转上述代码后，过错仓库如下所示：<br />
Exceptioninthread&#8221;main&#8221;java.lang.Exception:closeatcom.cmower.dzone.trycatchfinally.MyfinallyOutThrow.close(TryfinallyCustomOutThrow.java:17)atcom.cmower.dzone.trycatchfinally.TryfinallyCustomOutThrow.main(TryfinallyCustomOutThrow.java:10)<br />
readLine()办法的反常信息居然被close()办法的仓库信息吃了，这必然会让咱们误认为要调查的目标是close()办法而不是readLine()——虽然它也是应该怀疑的目标。<br />
但自从有了try-with-resources，这些问题就迎刃而解了，只要需求开释的资源（比如BufferedReader）完成了AutoCloseable接口。有了处理方案之后，咱们来对之前的finally代码块进行减肥。<br />
try(BufferedReaderbr=newBufferedReader(newFileReader(decodePath));){<br />
Stringstr=null;<br />
while((str=br.readLine())!=null){<br />
System.out.println(str);<br />
}<br />
}catch(IOExceptione){<br />
e.printStackTrace();<br />
}<br />
你瞧，finally代码块消失了，取而代之的是把要开释的资源写在try后的()中。假设有多个资源（BufferedReader和PrintWriter）需求开释的话，能够直接在()中增加。<br />
try(BufferedReaderbr=newBufferedReader(newFileReader(decodePath));<br />
PrintWriterwriter=newPrintWriter(newFile(writePath))){<br />
Stringstr=null;<br />
while((str=br.readLine())!=null){<br />
writer.print(str);<br />
}<br />
}catch(IOExceptione){<br />
e.printStackTrace();<br />
}<br />
假设你想开释自定义资源的话，只要让它完成AutoCloseable接口，并供给close()办法即可。<br />
publicclassTrywithresourcesCustom{<br />
publicstaticvoidmain(String[]args){<br />
try(MyResourceresource=newMyResource();){<br />
}catch(Exceptione){<br />
e.printStackTrace();<br />
}<br />
}<br />
}classMyResourceimplementsAutoCloseable{<br />
@Overridepublicvoidclose()throwsException{<br />
System.out.println(&#8220;封闭自定义资源&#8221;);<br />
}<br />
}<br />
代码运转后输出的成果如下所示：<br />
封闭自定义资源<br />
是不是很奇特？咱们在try()中只是new了一个MyResource的目标，其他什么也没干，但偏偏close()办法中的输出句子执行了。想要知道为什么吗？来看看反编译后的字节码吧。<br />
classMyResourceimplementsAutoCloseable{<br />
MyResource(){<br />
}<br />
publicvoidclose()throwsException{<br />
System.out.println(&#8220;封闭自定义资源&#8221;);<br />
}<br />
}publicclassTrywithresourcesCustom{<br />
publicTrywithresourcesCustom(){<br />
}<br />
publicstaticvoidmain(String[]args){<br />
try{<br />
MyResourceresource=newMyResource();<br />
resource.close();<br />
}catch(Exceptionvar2){<br />
var2.printStackTrace();<br />
}<br />
}<br />
}<br />
咦，编译器居然自动为try-with-resources进行了变身，在try中调用了close()办法。<br />
接下来，咱们在自定义类中再增加一个out()办法，<br />
classMyResourceOutimplementsAutoCloseable{<br />
@Overridepublicvoidclose()throwsException{<br />
System.out.println(&#8220;封闭自定义资源&#8221;);<br />
}<br />
publicvoidout()throwsException{<br />
System.out.println(&#8220;缄默沉静王二，一枚有趣的程序员&#8221;);<br />
}<br />
}<br />
这次，咱们在try中调用一下out()办法：<br />
publicclassTrywithresourcesCustomOut{<br />
publicstaticvoidmain(String[]args){<br />
try(MyResourceOutresource=newMyResourceOut();){<br />
resource.out();<br />
}catch(Exceptione){<br />
e.printStackTrace();<br />
}<br />
}<br />
}<br />
再来看一下反编译的字节码：<br />
publicclassTrywithresourcesCustomOut{<br />
publicTrywithresourcesCustomOut(){<br />
}<br />
publicstaticvoidmain(String[]args){<br />
try{<br />
MyResourceOutresource=newMyResourceOut();<br />
try{<br />
resource.out();<br />
}catch(Throwablevar5){<br />
try{<br />
resource.close();<br />
}catch(Throwablevar4){<br />
var5.addSuppressed(var4);<br />
}<br />
throwvar5;<br />
}<br />
resource.close();<br />
}catch(Exceptionvar6){<br />
var6.printStackTrace();<br />
}<br />
}<br />
}<br />
这次，catch块中自动调用了resource.close()，而且有一段很要害的代码var5.addSuppressed(var4)。它有什么用途呢？当一个反常被抛出的时分，可能有其他反常由于该反常而被按捺住，从而无法正常抛出。这时能够经过addSuppressed()办法把这些被按捺的办法记录下来。被按捺的反常会出现在抛出的反常的仓库信息中，也能够经过getSuppressed()办法来获取这些反常。这样做的好处是不会丢失任何反常，方便咱们开发人员进行调试。<br />
哇，有没有想到咱们之前的那个比如——在try-finally中，readLine()办法的反常信息居然被close()办法的仓库信息吃了。现在有了try-with-resources，再来看看作用和readLine()办法一致的out()办法会不会被close()吃掉。<br />
在close()和out()办法中直接抛出反常：<br />
classMyResourceOutThrowimplementsAutoCloseable{<br />
@Overridepublicvoidclose()throwsException{<br />
thrownewException(&#8220;close()&#8221;);<br />
}<br />
publicvoidout()throwsException{<br />
thrownewException(&#8220;out()&#8221;);<br />
}<br />
}<br />
调用这2个办法：<br />
publicclassTrywithresourcesCustomOutThrow{<br />
publicstaticvoidmain(String[]args){<br />
try(MyResourceOutThrowresource=newMyResourceOutThrow();){<br />
resource.out();<br />
}catch(Exceptione){<br />
e.printStackTrace();<br />
}<br />
}<br />
}<br />
程序输出的成果如下所示：<br />
java.lang.Exception:out()<br />
atcom.cmower.dzone.trycatchfinally.MyResourceOutThrow.out(TrywithresourcesCustomOutThrow.java:20)atcom.cmower.dzone.trycatchfinally.TrywithresourcesCustomOutThrow.main(TrywithresourcesCustomOutThrow.java:6)Suppressed:java.lang.Exception:close()<br />
atcom.cmower.dzone.trycatchfinally.MyResourceOutThrow.close(TrywithresourcesCustomOutThrow.java:16)atcom.cmower.dzone.trycatchfinally.TrywithresourcesCustomOutThrow.main(TrywithresourcesCustomOutThrow.java:5)<br />
瞧，这次不会了，out()的反常仓库信息打印出来了，而且close()办法的仓库信息上加了一个要害字Suppressed。一望而知，不错不错，我喜欢。<br />
总结一下，在处理必须封闭的资源时，一直有限考虑运用try-with-resources，而不是try–catch-finally。前者发生的代码更加简练、清晰，发生的反常信息也更靠谱。答应我好不好？别再用try–catch-finally了。</p>


		
										                                </div>
                            </div>
                                                        <div class="wzbq wow slideUp mg-bt30">
                                <span>文章标签：</span>
                                <div class="bqnr">
                                                                                                             <a href="https://www.ciya.cn/tags/website-building/">网站建设</a>
                                                                                                                                                                                                                                                                                                                                                                    </div>
                            </div>
                                                        <div class="xwxq-bot bgf1 wow slideUp">
                                <div class="xwxq-fy clear">
                                    <a class="fl" href="/article/3674.html"><i></i>java反射机制精讲</a>
                                    <a class="fr" href="/article/3672.html"><i></i>springboot~引用地址jar包的办法</a>
                                </div>
                                <a class="fhlb" href="#"></a>
                            </div>
                        </div>
                        <div class="fr xwxq-r">
                            <div class="xwxq-tj-page bgf1 mg-bt40 wow slideUp">
                                <div class="xwxq-tj-warp bgfff">
                                    <div class="tjxw-title mg-bt30">
                                        <h3>最新案例</h3><span>LATEST CASES</span>
                                    </div>
                                    <div class="zxal">
                                        <div class="swiper-container">
                                            <div class="swiper-wrapper">
                                                                                                        <div class="imgscale li swiper-slide">
                                                        <a href="https://www.ciya.cn/article/409.html">
                                                            <div class="img100 mg-bt20"><img src="/upload/20211214/20211214103120.jpg" alt="广州呼吸研究院"/></div>
                                                            <p>广州呼吸研究院</p>
                                                        </a>
                                                    </div>
                                                                                                        <div class="imgscale li swiper-slide">
                                                        <a href="https://www.ciya.cn/article/433.html">
                                                            <div class="img100 mg-bt20"><img src="/upload/20211214/20211214102846.jpg" alt="融创集团"/></div>
                                                            <p>融创集团</p>
                                                        </a>
                                                    </div>
                                                                                                        <div class="imgscale li swiper-slide">
                                                        <a href="https://www.ciya.cn/article/268.html">
                                                            <div class="img100 mg-bt20"><img src="/upload/20211214/20211214102923.jpg" alt="粤海集团"/></div>
                                                            <p>粤海集团</p>
                                                        </a>
                                                    </div>
                                                                                                        <div class="imgscale li swiper-slide">
                                                        <a href="https://www.ciya.cn/article/414.html">
                                                            <div class="img100 mg-bt20"><img src="/upload/20211216/20211216115258.jpg" alt="恒大足球学校"/></div>
                                                            <p>恒大足球学校</p>
                                                        </a>
                                                    </div>
                                                                                                        <div class="imgscale li swiper-slide">
                                                        <a href="https://www.ciya.cn/article/477.html">
                                                            <div class="img100 mg-bt20"><img src="/upload/20211214/20211214102958.jpg" alt="侨鑫集团"/></div>
                                                            <p>侨鑫集团</p>
                                                        </a>
                                                    </div>
                                                                                                </div>
                                        </div>
                                        <div class="zxalDot text-center swiperDot"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="xwxq-tj-page bgf1 mg-bt40 wow slideUp">
                                <div class="xwxq-tj-warp bgfff">
                                    <div class="tjxw-title tjxw-title-line mg-bt20">
                                        <h3>热点新闻</h3><span>TOP NEWS</span>
                                    </div>
                                    <ul class="rdxw">
                                                                                <li><a href="https://www.ciya.cn/article/3559.html">1  java heap space(解决方法)</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/1222.html">2  如何在网站后台上传附件</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/1643.html">3  如何在网站后台上传PDF文件</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/1142.html">4  什么是流？</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/3543.html">5  java swing还有人用吗(swing为什么会被淘汰)</a></li>
                                                                            </ul>
                                </div>
                            </div>
                            <div class="xwxq-tj-page bgf1 wow slideUp">
                                <div class="xwxq-tj-warp bgfff">
                                    <div class="tjxw-title tjxw-title-line mg-bt20">
                                        <h3>最新动态</h3><span>NEWS</span>
                                    </div>
                                    <ul class="rdxw">
                                                                                <li><a href="https://www.ciya.cn/article/7318.html">1  商务网站的维护与更新：持续优化，保持竞争力</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7317.html">2  商务网站的社交媒体营销：扩大品牌影响力，吸引更多潜在客户</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7316.html">3  商务网站的广告投放：增加收益，提高知名度</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7315.html">4  商务网站的在线客户服务：提供优质客服，提升用户满意度</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7314.html">5  商务网站的支付系统集成：安全、便捷的交易方式</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7313.html">6  商务网站搜索引擎优化（SEO）：提升排名，增加流量</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7312.html">7  商务网站响应式设计：实现多设备兼容，提升用户体验</a></li>
                                                                                <li><a href="https://www.ciya.cn/article/7311.html">8  商务网站开发：选择合适的编程语言和技术栈</a></li>
                                                                            </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="footerbox">
	<div class="footer">
		<div class="w1700">
			<ul>
				<li>
					<span class="fttitle">思洋 · 广州总部</span>
					<div>
						<p>广州天河区珠江新城富力盈力大厦北塔2706</p>
						<p>020-38013166（网站咨询专线）</p>
					</div>
					<p>400-001-5281 （售后服务热线）</p>
				</li>
				<li>
					<span class="fttitle">思洋 · 深圳</span>
					<div>
						<p>深圳市坂田十二橡树庄园F1-7栋</p>
						<p>Site/ http://www.szciya.com </p>
						<p>E-mail/ itciya@vip.163.com</p>
					</div>
					<p>品牌服务专线：400-001-5281 </p>
				</li>
				<li>
					<span class="fttitle">思洋 · 湖南</span>
					<div>
						<p>长沙市天心区芙蓉中路三段398号新时空大厦5楼</p>
						<p>联系电话/ (+86 0731)88282200</p>
					</div>
					<p>品牌服务专线/ 400-966-8830</p>
				</li>
				<li class="lastli">
					<p class="mt10">旗下运营网站：</p>
					<div class="mt10">
						<img src="/images/ftlogo2.png">
						<img src="/images/gogo.png">
						<img src="/images/ftlogo3.png">
						<img src="/images/ftlogo4.png">
						<img src="/images/ftlogo11.png">
					</div>
				</li>
			</ul>
		</div>
	</div>
	<div class="ft_bottom">
		<div class="w1700">
			<p class="cop">Copyright © 2016 广州思洋文化传播有限公司，保留所有权利。 <a href="https://beian.miit.gov.cn/" target="_blank">粤ICP备09033321号</a>
			</p>
		</div>
	</div>
</div>
<div class="le-box active">
	<div class="t show780">
		<a href="tel:13570966600">
			<img src="/images/ml9-1.png?v=1" alt="" class="sow i">
			<img src="/images/ml9-1.png?v=1" alt="" class="iove i">
		</a>
	</div>
	<div class="t">
		<img src="/images/ml1-1.png?v=1" alt="" class="sow i">
		<img src="/images/ml1-1.png?v=1" alt="" class="iove i">
		<div class="iov">
			<div class="img">
				<img src="/images/qr.jpg" alt="与项目经理交流">
			</div>
			<div class="h">扫描二维码<br>与项目经理交流</div>
		</div>
	</div>
	<div class="t">
		<img src="/images/ml2-1.png?v=1" alt="" class="sow i">
		<img src="/images/ml2-1.png?v=1" alt="" class="iove i">
		<div class="iov">
			<div class="img">
				<img src="/images/qq001.jpg" alt="">
			</div>
			<div class="h">扫描二维码<br>与项目经理交流</div>
		</div>
	</div>
	<!--<div class="t">-->
		<!--<a href="http://wpa.qq.com/msgrd?v=3&amp;uin=1607245872&amp;site=ciya.cn&amp;menu=yes" target="_blank">-->
			<!--<img src="/images/ml2-1.png?v=1" alt="" class="sow i">-->
			<!--<img src="/images/ml2-1.png?v=1" alt="" class="iove i">-->
		<!--</a>-->
	<!--</div>-->
	<div class="t hide780">
		<a href="https://affim.baidu.com/unique_510425/chat?siteId=19536215&userId=510425&siteToken=8914d517c927d8e794148d05e387fb17" target="_blank">
			<img src="/images/ml3-1.png?v=1" alt="" class="sow i">
			<img src="/images/ml3-1.png?v=1" alt="" class="iove i">
		</a>
	</div>
</div>
<script>
	$(window).scroll(function(){
//		if($(window).scrollTop()>200){
//			$(".le-box").addClass("active");
//		}else{
//			$(".le-box").removeClass("active");
//		}
	})
</script>
<div class="wap_fx">
	<a href="tel:13570966600" class="phone"></a>
	<a href="mqqwpa://im/chat?chat_type=wpa&uin=1607245872&version=1&src_type=web&web_src=ciya.cn" target="_blank" class="qq"></a>
	<a href="javascript:;" class="wx2"></a>
	<a class="kef986" style="background:rgba(0,0,0,.6) url(/images/ml3-1.png?v=1) no-repeat center;background-size: cover;border-radius: 4px;" href="https://p.qiao.baidu.com/cps/chat?siteId=18513940&userId=510425&siteToken=e5e1bde478969b43bf99b7703a694c0b" target="_blank"></a>
</div>
<div class="wap-wxcode">
	<div class="middle-box">
		<div class="middle-inner">
			<div class="wap-wxcode-con">
				<img src="/images/ff_ewm.jpg" alt=""/>
				<div class="wap-wxcode-bot"><span class="wxname">ciya68</span><button class="copy-btn" data-clipboard-text="ciya68">点击复制</button></div>
				<div class="gb1002"></div>
			</div>
		</div>
	</div>
</div>
<input id="hide" type="hidden">
<script src="/js/clipboard.min.js"></script>
<script>
	$(function(){
		$(".wx2").click(function(){
			$(".wap-wxcode").show();
		});
		$(".gb1002").click(function(){
			$(".wap-wxcode").hide();
		});
		var copyBtn=new ClipboardJS('.copy-btn');
		copyBtn.on("success",function(e){
			// 复制成功
			// alert(e.text);
			showMessage('已成功复制微信号','success',2000)
			e.clearSelection();
		});
		copyBtn.on("error",function(e){
			//复制失败；
			showMessage('复制微信号失败','error',2000)
			console.log( e.action )
		});
		function showMessage(message,type,time) {
			let str = ''
			switch (type) {
				case 'success':
					str = '<div class="success-message" style="width: 100%;height: 50px;background-color: #030026;font-size:17px;text-align: center;color:#fff;position: fixed;left: 0%;bottom: 0%;line-height: 50px;z-index: 9999">\n' +
							'    <span class="mes-text">'+message+'</span></div>'
					break;
				case 'error':
					str = '<div class="error-message" style="width: 100%;height: 50px;background-color: #030026;font-size:17px;text-align: center;color: #fff;position: fixed;left: 0%;bottom: 0%;line-height: 50px;z-index: 9999">\n' +
							'    <span class="mes-text">'+message+'</span></div>'
			}
			$('body').append(str)
			setTimeout(function () {
				$('.'+type+'-message').remove()
			},time)
		}


		var ua = navigator.userAgent.toLowerCase();
		var isWeixin = ua.indexOf('micromessenger')!= -1;
		if(isWeixin){
			$(".kef986").hide();
		}

	})
</script>
            </div>
        </div>
		<script type="text/javascript" src="/js/trunk.js?v=2"></script>
        <script>
            var zxal=null;
            var len=$(".zxal .swiper-slide").length;
            if(len>1){
                zxal = new Swiper('.zxal .swiper-container',{
                    speed:600,
                    loop:true,
                    autoplay : 5000,
                    autoplayDisableOnInteraction : false,
                    pagination : '.zxalDot',
                    paginationClickable :true,
                })
            }else{
                $(".zxalDot").hide();
            }
        </script>
	</body>
</html>

