2023-07-11 15:27:08 +08:00
|
|
|
let urlPrefix = getUrlPrefix()
|
|
|
|
let browser = checkVersion()
|
2023-07-12 17:00:34 +08:00
|
|
|
var url = getQueryString();
|
2023-07-11 15:27:08 +08:00
|
|
|
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("上傳成功")
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
2023-08-18 19:27:54 +08:00
|
|
|
} else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) {
|
2023-07-18 17:32:28 +08:00
|
|
|
window.location.href = './login.html'
|
2023-07-11 15:27:08 +08:00
|
|
|
} 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()
|
2023-07-12 17:00:34 +08:00
|
|
|
});
|
|
|
|
//
|
|
|
|
// 保存绑定
|
|
|
|
function withdrawUserAccount (name, idCardNo, accountNo, contact, thirdAccountNo, address, frontPhoto, backPhoto) {
|
|
|
|
var obj = {
|
|
|
|
uid: pubInfo.uid,
|
|
|
|
accountType: url.accountType,
|
|
|
|
name,
|
|
|
|
idCardNo,
|
|
|
|
accountNo,
|
|
|
|
contact,
|
|
|
|
thirdAccountNo,
|
|
|
|
address,
|
|
|
|
frontPhoto,
|
|
|
|
backPhoto,
|
|
|
|
};
|
|
|
|
showLoading()
|
|
|
|
networkRequest({
|
|
|
|
type: 'POST',
|
|
|
|
url: urlPrefix + '/withdrawUserAccount/save',
|
|
|
|
contentType: 'application/json',
|
|
|
|
data: JSON.stringify(obj),
|
|
|
|
success (res) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
toastMsg('保存成功')
|
|
|
|
setTimeout(function () {
|
|
|
|
window.location.href = './withdrawal.html'
|
|
|
|
}, 500)
|
2023-08-18 19:27:54 +08:00
|
|
|
} else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) {
|
2023-07-18 17:32:28 +08:00
|
|
|
window.location.href = './login.html'
|
2023-07-12 17:00:34 +08:00
|
|
|
} else {
|
|
|
|
toastMsg(res.message)
|
|
|
|
}
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
},
|
|
|
|
error (err) {
|
|
|
|
hideLoading(layerIndex)
|
|
|
|
toastMsg('網絡錯誤,請退出重進')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
$('.but').click(function () {
|
|
|
|
var frontImageUpload = document.querySelector('#frontImageUpload').files;
|
|
|
|
var backImageUpload = document.querySelector('#backImageUpload').files;
|
|
|
|
if (listenFun()) {
|
|
|
|
if (frontImageUpload.length == 0 || backImageUpload.length == 0) {
|
|
|
|
toastMsg('請上傳身份證');
|
|
|
|
return;
|
|
|
|
}
|
2024-01-10 14:50:40 +08:00
|
|
|
|
|
|
|
$('.mainlandInfo').show();
|
2023-07-12 17:00:34 +08:00
|
|
|
}
|
2024-01-10 14:50:40 +08:00
|
|
|
})
|
2024-01-10 18:49:52 +08:00
|
|
|
// 二次取消
|
2024-01-10 14:50:40 +08:00
|
|
|
$('.mainlandInfo .mainlandInfo_in .close').click(function () {
|
|
|
|
$('.mainlandInfo').hide();
|
|
|
|
})
|
|
|
|
// 二次确认
|
|
|
|
$('.mainlandInfo .mainlandInfo_in .ok').click(function () {
|
|
|
|
withdrawUserAccount($('.box1 div .name').val(),
|
|
|
|
$('.box1 div .card').val(),
|
|
|
|
$('.box2 div .bankCard').val(),
|
|
|
|
$('.box2 div .phone').val(),
|
|
|
|
$('.box2 div .alipay').val(),
|
|
|
|
$('.box2 div .address').val(),
|
|
|
|
$('.box3 .idBox .z .documents').attr('src'),
|
|
|
|
$('.box3 .idBox .f .documents').attr('src')
|
|
|
|
);
|
|
|
|
$('.mainlandInfo').hide();
|
2023-07-12 17:00:34 +08:00
|
|
|
})
|