<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta charset="UTF-8">
<title>人机验证</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>

</style>
<script type="text/javascript" src="https://static.howbuy.com/??/js/wap/tgmp/new/libs/jquery.min.3.0.0.js?v=18c4dc5"></script>
	<!-- 验证码程序依赖(必须)。请勿修改以下程序依赖，如使用本地缓存，或通过其他手段规避加载，会影响程序的正常使用。 -->
	<script src="https://turing.captcha.qcloud.com/TCaptcha.js"></script>
</head>
<body class="error_bg">
<input type="hidden" id="TencentCaptcha" class="c_btn" data-appid="2019146225" data-cbfn="callbackName" data-biz-state="data-biz-state" />
<input type="hidden" id="bizState" name="bizState" value="">
<input type="hidden" id="appid" name="appid" value="">
<input type="hidden" id="ret" name="ret" value="">
<input type="hidden" id="ticket" name="ticket" value="">
<input type="hidden" id="randstr" name="randstr" value="">

<input type="hidden" id="targetUrl" name="targetUrl" value="http://www.howbuy.com/subject/css/style.css">

</body>
<script type="text/javascript">
	$(function () {
		console.log('========= trigger ==============')
		$("#TencentCaptcha").trigger("click");

		console.log('=========== allURL ============')
		let hhh = window.location.href
		let split = hhh.split('targetUrl=');
		let param = split[1]
		$("#targetUrl").val(decodeURIComponent(param))
		console.log(param)
	})
	window.callbackName = function (res) {
		// 返回结果
		// ret         Int       验证结果，0：验证成功。2：用户主动关闭验证码。
		// ticket      String    验证成功的票据，当且仅当 ret = 0 时 ticket 有值。
		// CaptchaAppId       String    验证码应用ID。
		// bizState    Any       自定义透传参数。
		// randstr     String    本次验证的随机串，请求后台接口时需带上。
		console.log("callback:", res);
		// res（用户主动关闭验证码）= {ret: 2, ticket: null}
		// res（验证成功） = {ret: 0, ticket: "String", randstr: "String"}
		if (res.ret === 0) {
			$("#bizState").val(res.bizState);
			$("#appid").val(res.appid);
			$("#ret").val(res.ret);
			$("#ticket").val(res.ticket);
			$("#randstr").val(res.randstr);
			console.log('======== SUCCESS =======')
			var ticket = $("#ticket").val();
			console.log('ticket: ' + ticket)

			console.log('======= targetUrl =========')
			console.log(encodeURIComponent($("#targetUrl").val()))
			$.ajax({
				type: "POST",
				url: "/spider/captcha.htm",
				// url: "http://192.168.152.84:8300/spider/captcha.htm",
				dataType: "json",
				data:{
					tphone : $("#noid").val(),
					valCode : $("#ticket").val(),
					'bizState': $("#bizState").val(),
					'appid': $("#appid").val(),
					'ret': $("#ret").val(),
					'randstr': $("#randstr").val(),
					ticket: ticket,
					targetUrl: encodeURIComponent($("#targetUrl").val())
				},
				success: function(responseText) {
					var map = responseText;
					console.log('==========================')
					console.log(map)
					console.log(encodeURIComponent(map.targetUrl))
					// return
					location.href = "/spider/interval.htm?targetUrl=" + encodeURIComponent($("#targetUrl").val())
					/*$.ajax({
						type: "POST",
						url: "/spider/interval.htm",
						dataType: "json",
						data:{
							targetUrl : map.targetUrl
						},
						success: function(responseText) {

						}
					});*/
				}
			});
		}
	}
</script>
</html>
