Files
peko-h5/view/peko/modules/h5Income/js/chainBank.js
2023-07-11 15:27:08 +08:00

129 lines
3.7 KiB
JavaScript

let urlPrefix = getUrlPrefix()
let browser = checkVersion()
let env = EnvCheck();
if (env == 'test') {
new VConsole();
}
// 封装layer消息提醒框
let layerIndex
const showLoading = (content = '加載中...') => {
layer.open({
type: 2,
shadeClose: false,
content,
success (e) {
layerIndex = $(e).attr('index')
}
})
}
const hideLoading = (index) => {
layer.close(index)
}
const toastMsg = (content = '操作完成', time = 2) => {
layer.open({
content,
time,
skin: 'msg'
})
}
$(function () {
setTimeout(function () {
getInfoFromClient()
if (browser.app) {
$('.back').hide();
}
setTimeout(function () {
}, 100)
})
})
// 返回按钮
$('.back').click(function () {
window.history.go(-1)
})
function fileChangeZ (e) {
var filesList = document.querySelector('#frontImageUpload').files;
if (filesList.length == 0) {
return;
}
getUploadToken(1)
}
function fileChangeF (e) {
var filesList = document.querySelector('#backImageUpload').files;
if (filesList.length == 0) {
return;
}
getUploadToken(2)
}
// 上传身份证接口
function getUploadToken (type) {
const frontImage = document.getElementById('frontImageUpload').files[0];
const backImage = document.getElementById('backImageUpload').files[0];
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/qiniu/upload/getUploadToken',
success (res) {
if (res.code === 200) {
var frontImageKey = res.data.key;
var frontImageToken = res.data.token;
showLoading()
const observable = qiniu.upload(
type == 1 ? frontImage : backImage,
frontImageKey,
frontImageToken
);
observable.subscribe({
complete: (res) => {
console.log(res);
if (type == 1) {
$('.box3 .idBox .z .documents').attr('src', res.path);
} else {
$('.box3 .idBox .f .documents').attr('src', res.path);
}
hideLoading(layerIndex)
toastMsg("上傳成功")
},
});
} else {
toastMsg(res.message)
}
// hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網絡錯誤,請退出重進')
}
})
}
// 确认绑定按钮
$('.but').click(function () {
if (listenFun()) {
var filesList = document.querySelector('#frontImageUpload').files;
var backImageUpload = document.querySelector('#backImageUpload').files;
if (filesList.length == 0 || backImageUpload.length == 0) {
toastMsg('請上傳身份證照片')
return;
}
}
})
//监听是否完善信息
function listenFun () {
var num1 = $(".box1 div .name").val();
var num2 = $(".box1 div .card").val();
var num3 = $(".box2 div .bankCard").val();
var num4 = $(".box2 div .phone").val();
var num5 = $(".box2 div .address").val();
if (num1 != '' && num2 != '' && num3 != '' && num4 != '' && num5 != '') {
$('.but').addClass('active');
return true;
} else {
$('.but').removeClass('active');
return false;
}
}
// 监听所有输入框输入
$(".box1 div .name,.box1 div .card,.box2 div .bankCard,.box2 div .phone,.box2 div .address").on("keyup", function () {
listenFun()
});