216 lines
6.6 KiB
JavaScript
216 lines
6.6 KiB
JavaScript
const urlData = getQueryString();
|
|
let urlPrefix = getUrlPrefix()
|
|
let browser = checkVersion()
|
|
let env = EnvCheck();
|
|
if (env == 'test') {
|
|
new VConsole();
|
|
}
|
|
// 封裝layer消息提醒框
|
|
let layerIndex
|
|
var langReplace;
|
|
var localLang;
|
|
const showLoading = (content = langReplace(localLang.demoModule.layerIndex1)) => {
|
|
layer.open({
|
|
type: 2,
|
|
shadeClose: false,
|
|
content,
|
|
success(e) {
|
|
layerIndex = $(e).attr('index')
|
|
}
|
|
})
|
|
}
|
|
const hideLoading = (index) => {
|
|
layer.close(index)
|
|
}
|
|
const toastMsg = (content = langReplace(localLang.demoModule.layerIndex2), time = 2) => {
|
|
layer.open({
|
|
content,
|
|
time,
|
|
skin: 'msg'
|
|
})
|
|
}
|
|
var fields = {};
|
|
$(function () {
|
|
getInfoFromClient();
|
|
fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言
|
|
setTimeout(function () {
|
|
// 頁面全屏
|
|
if (browser.app) {
|
|
if (browser.android) {
|
|
window.androidJsObj.initShowNav(false)
|
|
} else {
|
|
window.webkit.messageHandlers.initShowNav.postMessage(0)
|
|
}
|
|
};
|
|
// 頂部返回事件
|
|
$('.back img').click(() => {
|
|
window.history.back();
|
|
})
|
|
fuzzyMatchUpdateQueryStringParameterFun(); // 判断语言
|
|
langReplace = window.lang.replace;
|
|
localLang = window.lang;
|
|
translateFun();
|
|
get()
|
|
}, 100);
|
|
|
|
});
|
|
function translateFun() {
|
|
langReplace = window.lang.replace;
|
|
localLang = window.lang;
|
|
$('.text2').text(langReplace(localLang.payonner.text2));
|
|
$('.text3').text(langReplace(localLang.payonner.text3));
|
|
$('.text4').text(langReplace(localLang.payonner.text4));
|
|
$('.text5').text(langReplace(localLang.payonner.text5));
|
|
$('.text7').attr('placeholder', langReplace(localLang.payonner.text7));
|
|
$('.text8').attr('placeholder', langReplace(localLang.payonner.text8));
|
|
$('.p1').text(langReplace(localLang.pTitle.p1));
|
|
$('.p2').text(langReplace(localLang.pTitle.p2));
|
|
|
|
}
|
|
// 获取
|
|
function get() {
|
|
showLoading();
|
|
networkRequest({
|
|
type: "GET",
|
|
url: urlPrefix + "/guild/usd/withdrawAccount/get",
|
|
data: { type: getQueryString().type },
|
|
success: function (res) {
|
|
if (res.code == 200) {
|
|
// 回显数据
|
|
if(res.data.country && res.data.country != ''){
|
|
let list = res.data.countryOptionalList.filter(item => item.value == res.data.country);
|
|
console.log(list)
|
|
$('.currencyType input').val(langReplace(localLang.payonner.text6)+list[0].currency);
|
|
}else{
|
|
$('.currencyType input').val(langReplace(localLang.payonner.text6));
|
|
}
|
|
fields = res.data.fields;
|
|
if (fields.country == '') {
|
|
$('.but .determine').hide();
|
|
$('.but .ok').show();
|
|
$('.box input').attr('disabled', false)
|
|
} else {
|
|
$('.but .determine').show();
|
|
$('.but .ok').hide();
|
|
$('.box input').attr('disabled', true)
|
|
}
|
|
$('.currencyType input').attr('disabled', true)
|
|
$('.country input').val(fields.country);
|
|
$('.payeeAccountNo input').val(fields.bank_account);
|
|
// 渲染国家
|
|
$('.pub .pub_in .countryPub').remove();
|
|
var str = '';
|
|
res.data.countryOptionalList.forEach(res => {
|
|
str += `
|
|
<div country='${res.value}' name="${res.name}" currency="${res.currency}" class="countryPub">${res.name}</div>
|
|
`
|
|
})
|
|
$('.pub .pub_in').append(str);
|
|
} else {
|
|
toastMsg(res.message);
|
|
}
|
|
hideLoading(layerIndex);
|
|
},
|
|
error: function (res) {
|
|
console.log(res, "报错啦");
|
|
hideLoading(layerIndex);
|
|
},
|
|
});
|
|
}
|
|
// 选择国家
|
|
$('.country').click(function () {
|
|
if(fields.country !='')return
|
|
$('.pub').show();
|
|
})
|
|
// 关闭选择国家
|
|
$('.pub').click(function (params) {
|
|
$('.pub').hide();
|
|
})
|
|
// 选中国家
|
|
var nameTitle;
|
|
var currency;
|
|
$('.pub .pub_in').on('click', '.countryPub', function name(params) {
|
|
$(this).addClass('act').siblings().removeClass('act');
|
|
nameTitle = $(this).attr('name');
|
|
var country = $(this).attr('country');
|
|
currency = $(this).attr('currency');
|
|
fields.country = country;
|
|
return false;
|
|
})
|
|
// 确认选中国家
|
|
$('.pub .pub_in .soure').click(function name(params) {
|
|
$('.country input').val(nameTitle);
|
|
$('.pub').hide();
|
|
$('.currencyType input').val(langReplace(localLang.payonner.text6) + currency);
|
|
})
|
|
// 确认绑定按钮
|
|
$('.but .ok').click(function (params) {
|
|
console.log(fields);
|
|
var obj = {}
|
|
obj.country = fields.country;
|
|
obj.bank_account = $('.payeeAccountNo input').val();
|
|
if (obj.country && obj.bank_account) {
|
|
fields = obj;
|
|
var objJson = {
|
|
uid: pubInfo.uid,
|
|
type: getQueryString().type,
|
|
fields,
|
|
}
|
|
update(JSON.stringify(objJson));
|
|
} else {
|
|
toastMsg(langReplace(localLang.payonner.text10));
|
|
}
|
|
})
|
|
// 绑定更新信息
|
|
function update(obj) {
|
|
showLoading();
|
|
networkRequest({
|
|
type: "post",
|
|
url: urlPrefix + "/guild/usd/withdrawAccount/bound",
|
|
contentType: 'application/json;charset=UTF-8',
|
|
data: obj,
|
|
success: function (res) {
|
|
if (res.code == 200) {
|
|
get();
|
|
toastMsg('success');
|
|
location.href = './salary_account.html'
|
|
} else {
|
|
toastMsg(res.message);
|
|
}
|
|
hideLoading(layerIndex);
|
|
},
|
|
error: function (res) {
|
|
hideLoading(layerIndex);
|
|
},
|
|
});
|
|
}
|
|
// 解绑
|
|
$('.but .determine').click(function () {
|
|
var objJson = {
|
|
uid: pubInfo.uid,
|
|
type: getQueryString().type,
|
|
}
|
|
unbound(JSON.stringify(objJson));
|
|
})
|
|
// 解绑
|
|
function unbound(obj) {
|
|
showLoading();
|
|
networkRequest({
|
|
type: "post",
|
|
url: urlPrefix + "/guild/usd/withdrawAccount/unbound",
|
|
contentType: 'application/json;charset=UTF-8',
|
|
data: obj,
|
|
success: function (res) {
|
|
if (res.code == 200) {
|
|
get();
|
|
toastMsg('success');
|
|
} else {
|
|
toastMsg(res.message);
|
|
}
|
|
hideLoading(layerIndex);
|
|
},
|
|
error: function (res) {
|
|
hideLoading(layerIndex);
|
|
},
|
|
});
|
|
} |