支付宝验证

This commit is contained in:
wyongk
2020-12-18 23:35:55 +08:00
parent 3a2a010469
commit d8e5723e8a
5 changed files with 219 additions and 20 deletions

View File

@@ -119,10 +119,10 @@
}
.real-name {
position: fixed;
width: 400px;
height: 400px;
width: auto;
height: auto;
left: 50%;
top: 50%;
top: 20%;
margin-left: -200px;
margin-top: -160px;
z-index: 3;
@@ -237,7 +237,7 @@
</form>
</div>
<div class="real-name">
<form>
<form id="id-cert">
<p>接主管部门要求,注册账号需要实名认证方可使用主要功能,请仔细阅读</p>
<p>1、为了你的帐号安全请勿使用他人手机号或身份信息</p>
<p>2、平台保护隐私未经法定程序其他个人和组织无法获取实名信息</p>
@@ -256,6 +256,8 @@
<button type="button" class="btn btn-danger quxiao" style="margin-left:20px;" onclick="$('.real-name').hide()">取消</button>
</p>
</form>
<h3 id="verify-info" style="display:none;text-align: center;">请打开 支付宝 扫码进行认证认证</h3>
<div id="qrcode"></div>
</div>
<div class="row">
@@ -431,8 +433,39 @@
<!-- 支付弹窗结束 -->
<div id="aliPayBox" style="display:none"></div>
<script type="text/javascript" src="https://static.runoob.com/assets/qrcode/qrcode.min.js"></script>
<script>
var t1 = null;
function ready( callback ) {
// 如果jsbridge已经注入则直接调用
if ( window.AlipayJSBridge ) {
callback && callback ();
} else {
// 如果没有注入则监听注入的事件
document . addEventListener ( 'AlipayJSBridgeReady' , callback , false );
}
}
// startBizService 接口仅在支付宝 10.0.15 及以上支持
// 需要接入者自行做下版本兼容处理
function startAPVerify ( options , callback ) {
AlipayJSBridge . call ( 'startBizService' , {
name : 'open-certify' ,
param : JSON . stringify ( options ),
}, callback );
}
/**
* 唤起认证流程
* 参数: certifyId、url 需要通过支付宝 openapi 开放平台网关接口获取
* 详细说明可查看文档下方的参数说明
**/
// 需要确保在 AlipayJSBridge ready 之后才调用
/** 表单序列化成json字符串的方法 */
function form2JsonString(formId) {
var paramArray = $('#' + formId).serializeArray();
@@ -524,15 +557,88 @@
alert("抱歉!请重新输入姓名!");
return;
}
var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
if(reg.test(id_code) === false)
{
alert("身份证输入不合法");
return false;
}
let data = {
cookie:document.cookie,
id_code: id_code,
name: name
}
$.ajax({
type: 'POST',
url: 'http://php-api.juip.com/api/Realname/index',
url: 'http://php-api.juip.com/api/test/aliverify',
dataType: "json",
contentType: "application/json",
data: JSON.stringify(data),
beforeSend: function(xhr) {
xhr.withCredentials = true;
},
crossDomain: true,
success: function (res) {
if (res.Code == 20000) {
alert('已经认证成功');
window.location.href='/User/Index';
return ;
}
if (res.Code == 10000) {
$('#id-cert').hide();
$('#verify-info').show();
new QRCode(document.getElementById("qrcode"), {
text: res.url,
width : 550,
height : 550
});
t1 = window.setInterval(get_verify_res,1500);
} else {
alert('请正确填写姓名和身份证号码。');
}
}
});
// let data = {
// cookie:document.cookie,
// id_code: id_code,
// name: name
// }
// $.ajax({
// type: 'POST',
// url: 'http://php-api.juip.com/api/Realname/index',
// dataType: "json",
// contentType: "application/json",
// data: JSON.stringify(data),
// beforeSend: function(xhr) {
// xhr.withCredentials = true;
// },
// crossDomain: true,
// success: function (res) {
// if (res.Code == 10000) {
// $('.real-name').hide();
// alert('实名认证成功。');
// } else {
// alert('请正确填写姓名和身份证号码。');
// }
// }
// });
}
function get_verify_res(){
let data = {
cookie:document.cookie
}
$.ajax({
type: 'POST',
url: 'http://php-api.juip.com/api/test/aliGetResult',
dataType: "json",
contentType: "application/json",
data: JSON.stringify(data),
@@ -542,13 +648,11 @@
crossDomain: true,
success: function (res) {
if (res.Code == 10000) {
$('.real-name').hide();
alert('实名认证成功。');
} else {
alert('请正确填写姓名和身份证号码。');
clearInterval(t1);
window.location.href='/User/Index';
}
}
});
});
}
function cash_out() {