tijian_tieying/web/dccdc/Views/wxapp/rgyy2.cshtml
2025-02-20 12:14:39 +08:00

173 lines
6.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/jquery-1.12.4.min.js"></script>
<script src="../Scripts/jweixin-1.2.0.js"></script>
<link href="../css/bootstrap.min.css" rel="stylesheet" />
<script src="../ligerUI/js/ligerui.min.js"></script>
<link href="../ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
<style>
.file {
position: relative;
display: inline-block;
background: #D0EEFF;
border: 1px solid #99D3F5;
border-radius: 4px;
padding: 4px 12px;
overflow: hidden;
color: #1E88C7;
text-decoration: none;
text-indent: 0;
line-height: 20px;
}
.file input {
font-size: 31px;
position: absolute;
right: 0;
top: 0;
opacity: 0;
}
.file:hover {
background: #AADFFD;
border-color: #78C3F3;
color: #004974;
text-decoration: none;
}
</style>
<script type="text/javascript">
$.ajax({
url: "getConfig.ashx", type: "post", dataType: "json", data: {},
//async: false, //默认是异步 需要改成同步必须先配置好 才能继续进行wx.ready
success: function (data) {
if (data.state == "1") {
//绑定票据
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来若要查看传入的参数可以在pc端打开参数信息会通过log打出仅在pc端时才会打印。
appId: data.message.appId, // 必填,公众号的唯一标识
timestamp: data.message.timestamp, // 必填,生成签名的时间戳
nonceStr: data.message.nonceStr, // 必填,生成签名的随机串
signature: data.message.signature, // 必填签名见附录1
jsApiList: ["scanQRCode"] // 必填需要使用的JS接口列表所有JS接口列表见附录2
});
}
else {
alert(data.message);
}
},
beforeSend: function () {
}
})
//配置完成才会执行 不需要获取配置ajax同步
wx.ready(function () {
//检测js接口
wx.checkJsApi({
jsApiList: ['scanQRCode'],
success: function (res) {
}
});
// 9.1.2 扫描二维码并返回结果
$("#btnScan").click(function () {
wx.scanQRCode({
needResult: 1,
scanType: ["barCode"], // 可以指定扫二维码还是一维码,默认二者都有"qrCode", "barCode"
success: function (res) {
//$("#result").html(JSON.stringify(res));
$("#result").val(res.resultStr);
},
fail: function () {
alert("调用微信扫码错误");
}
});
})
});
wx.error(function (res) {
alert(res.errMsg);
})
</script>
<script type="text/javascript">
var filebase64 = "";
$(function () {
$(".file").on("change", "input[type='file']", function () {
var filePath = $(this).val();
if (filePath.indexOf("jpg") != -1 || filePath.indexOf("png") != -1) {
$(".fileerrorTip").html("").hide();
var arr = filePath.split('\\');
var fileName = arr[arr.length - 1];
$(".showFileName").html(fileName);
} else {
$(".showFileName").html("");
$(".fileerrorTip").html("您未上传文件,或者您上传文件类型有误!").show();
return false
}
})
$('input[type=file]').on('change', function () {
var reader = new FileReader();
reader.onload = function (e) {
filebase64 = reader.result;
console.log(reader.result); //或者 e.target.result都是一样的都是base64码
}
if (this.files[0]) {
reader.readAsDataURL(this.files[0]);
//filses就是input[type=file]文件列表files[0]就是第一个文件这里就是将选择的第一个图片文件转化为base64的码
}
else {
filebase64 = "";
}
})
$("#save").click(function () {
if (filebase64 == "") {
$.ligerDialog.error("请先选择证件!");
return;
}
$.ajax({
url: "@Url.Action("setImg")", type: "post", dataType: "json", data: { id: "@ViewBag.id", imgData: filebase64 },
success: function (d) {
$.ligerDialog.closeWaitting();
if (d.State == "0") {
$.ligerDialog.error("操作失败!");
}
else {
$.ligerDialog.success("操作成功!");
}
},
beforeSend: function () {
$.ligerDialog.waitting("正在进行请稍后……");
}
});
})
})
</script>
</head>
<body>
<div style="text-align:center">
<h2 style="margin-top:10px">拍照或相册上传</h2>
<div style="margin-top:10px">@ViewBag.id</div>
<a href="javascript:;" class="file" style="margin-top:10px">
选择证件
<input type="file" accept="image/*">
<div>
<span class="fileerrorTip"></span>
<span class="showFileName"></span>
</div>
</a>
<div style="margin-top:10px">
<input type="button" id="save" value="上传证件" class="btn btn-primary" />
</div>
</div>
</body>
</html>