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' }) } var accountType;//1 其它賬戶 2 中國大陸銀聯 4 馬來西亞銀行 8 新加坡銀行 var minValue;//最小提領金币数量 var golds;//当前剩余金币 var weekLimitCount;//本周剩余次数 var weekMaxValue;//本周剩余最大金额 $(function () { setTimeout(function () { getInfoFromClient() if (browser.app) { $('.back').hide(); } setTimeout(function () { getUser(); }, 100) }) }) // 提領配置接口接口 function getConfig () { showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/withdrawUser/config', data: { uid: pubInfo.uid }, success (res) { if (res.code === 200) { minValue = res.data.minValue; weekLimitCount = res.data.weekLimitCount; weekMaxValue = res.data.weekMaxValue; var str = `

收益金幣達到${res.data.minValue}或以上可以申請提領

提領金幣必須為1000的整倍數

每周可提領次數:${res.data.weekLimitCount}

提領手續費:${res.data.chargeRate}%

台幣提領,請聯繫客服微信:sd245376,如您使用Payoneer帳戶提領,Payoneer要求50美元起付,需要滿足55000金幣後發起,不滿足的提領將會被駁回

` $('.withdrawal').append(str); getAccounts(); } else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) { window.location.href = './login.html' } else { toastMsg(res.message) } console.log(); hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 用戶錢包接口 function query () { showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/purse/query', data: { uid: pubInfo.uid }, success (res) { if (res.code === 200) { $('.income p').text(`金幣 ${res.data.golds}`); golds = res.data.golds; getConfig(); } else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) { window.location.href = './login.html' } else { toastMsg(res.message) } console.log(); hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 用戶基本信息接口 function getUser () { showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/user/get', data: { uid: pubInfo.uid }, success (res) { if (res.code === 200) { $('.myInfo img').attr('src', res.data.avatar); $('.myInfo div p').text(res.data.nick); $('.myInfo div b').text("ID:" + res.data.erbanNo); query() } else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) { window.location.href = './login.html' } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 提領賬戶管理接口 function getAccounts () { showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/withdrawAccountDtl/getAccounts', data: { uid: pubInfo.uid }, success (res) { if (res.code === 200) { var str = ''; res.data.forEach(res => { str += `
  • ${res.accountName}${res.isBind == 0 ? "(未綁定)" : ''}
  • ` if (res.isPrev == 1) { accountType = res.accountType $('.account span').text(res.accountName); $('.account span').addClass('active'); } else { if (res.isBind == 1) { accountType = res.accountType $('.account span').text(res.accountName); $('.account span').addClass('active'); } } }); $('.accountPub .accountPub_in ul').append(str); // 跳轉綁定賬戶或選擇賬戶 $('.accountPub .accountPub_in ul li').click(function () { var isBind = $(this).attr('isBind');//是否綁定 0 否 1 是 if (isBind == 1) { var accountTypes = $(this).attr('accounttype');//1 其它賬戶 2 中國大陸銀聯 4 馬來西亞銀行 8 新加坡銀行 if (accountTypes == 1) { $('.switch .pub_in p').text('是否切換到其它賬戶提領 '); } else if (accountTypes == 2) { $('.switch .pub_in p').text('是否切換到中國大陸銀聯提領 '); } else if (accountTypes == 4) { $('.switch .pub_in p').text('是否切換到馬來西亞銀行提領 '); } else if (accountTypes == 8) { $('.switch .pub_in p').text('是否切換到新加坡銀行提領 '); } $('.switch .pub_in .ok').attr('accounttype', accountTypes); $('.switch .pub_in .ok').attr('text', $(this).text()); $('.switch').show(); } else { var accountTypes = $(this).attr('accounttype');//1 其它賬戶 2 中國大陸銀聯 4 馬來西亞銀行 8 新加坡銀行 if (accountTypes == 1) { $('.binding .pub_in p').text('需要先綁定賬戶資料'); } else if (accountTypes == 2) { $('.binding .pub_in p').text('需要先綁定中國大陸銀聯賬戶資料'); } else if (accountTypes == 4) { $('.binding .pub_in p').text('需要先綁定馬來西亞銀行賬戶資料'); } else if (accountTypes == 8) { $('.binding .pub_in p').text('需要先綁定新加坡銀行賬戶資料'); } $('.binding').show(); // 確認跳轉綁定頁面按鈕 $('.binding .pub_in .ok').click(function () { if (accountTypes == 1) { window.location.href = `./other.html?accountType=${accountTypes}`; } else if (accountTypes == 2) { window.location.href = `./chainBank.html?accountType=${accountTypes}`; } else if (accountTypes == 4) { window.location.href = `./malaysia.html?accountType=${accountTypes}`; } else if (accountTypes == 8) { window.location.href = `./singapore.html?accountType=${accountTypes}`; } }) } return false; }) if (golds < minValue) { $('.withdrawal input').attr('placeholder', '可提領金幣不足'); } else if ($('.account span').text() != '未绑定') { $(`.withdrawal input`).text('請輸入提領金幣數額'); $(`.withdrawal .withdrawalBox`).attr('click', 1); } } else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) { window.location.href = './login.html' } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 取消切换按钮 $('.switch .pub_in .close').click(function () { $('.switch').hide(); }) // 确认切换按钮 $('.switch .pub_in .ok').click(function () { accountType = $(this).attr('accounttype');//1 其它賬戶 2 中國大陸銀聯 4 馬來西亞銀行 8 新加坡銀行 $('.account span').text($(this).attr("text")); $('.account span').addClass('active'); $('.accountPub').hide(); $('.switch').hide(); calculate(); }) // 确定输入提領弹窗按钮 $('.goldPub .goldPub_in .but').click(function () { var num = $('.goldPub .goldPub_in input').val(); if (num == '') { toastMsg('請輸入提領金幣數額'); return } if (num < minValue) { toastMsg(`最少申請金幣为${minValue}`); return } if (num % 1000 != 0) { toastMsg(`提領金幣必須為1000的整倍數`); return } calculate(); return false; }) // 计算汇率接口 function calculate () { var num = $('.goldPub .goldPub_in input').val(); num.length == 0 ? num = $('.withdrawal input').val() : num; showLoading() networkRequest({ type: 'GET', url: urlPrefix + '/withdrawUserAccount/calculate', data: { uid: pubInfo.uid, accountType, goldNum: num, }, success (res) { if (res.code === 200) { $('.withdrawal .numBox b').addClass('active'); $('.withdrawal input').val(num); $('.withdrawal .numBox b').text(`${res.data.currency} ${res.data.currencyAmount}`); $('.goldPub').hide(); $('.goldPub .goldPub_in input').val(''); $('.butBig').addClass('butBigActive'); $('.butBig').attr('click', 1); } else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) { window.location.href = './login.html' } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) } // 关闭二次确认提領按钮 $('.withDrawalPub').click(function () { $('.withDrawalPub').hide(); return false; }) // 确定提領按钮 $('.butBig').click(function () { var num = $('.withdrawal input').val(); var status = $(this).attr("click"); if (status != 1) { return } if (weekLimitCount <= 0) { toastMsg('超出本周最大提领次数') return } $('.withDrawalPub .withDrawalPub_in p ').html(`確認通過 ${$('.account .active').text()} 提領 ${num}金幣?`) $('.withDrawalPub .withDrawalPub_in span b ').html(`${$('.withdrawal .numBox b').text()}`) $('.withDrawalPub').show(); }) // 二次确认提領按钮 $('.withDrawalPub .withDrawalPub_in .but').click(function () { var num = $('.withdrawal input').val(); showLoading() networkRequest({ type: 'POST', url: urlPrefix + '/withdrawUserAccount/apply', data: { uid: pubInfo.uid, accountType, goldNum: num, }, success (res) { if (res.code === 200) { getUser(); $('.withDrawalPub').hide(); } else if (res.code ? res.code == 1444 : JSON.parse(res).code == 401) { window.location.href = './login.html' } else { toastMsg(res.message) } console.log(); hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網絡錯誤,請退出重進') } }) return false; }) // 点击输入提領数额按钮 $('.withdrawal .withdrawalBox').click(function () { var status = $(this).attr('click'); if (status == 1) { $('.goldPub .goldPub_in .num').text(golds); $('.goldPub').show(); } }); // 防止提領输入事件冒泡 $('.goldPub .goldPub_in').click(function () { return false; }) // 取消输入提領弹窗 $('.goldPub').click(function () { $('.goldPub').hide(); }) // 點擊綁定賬戶 $('.account').click(function () { $('.accountPub').show(); }) // 關閉綁定賬戶彈窗 $('.accountPub').click(function () { $('.accountPub').hide(); }) // 關閉跳轉綁定頁面按鈕 $('.binding .pub_in .close').click(function () { $('.binding ').hide(); }) // 返回按鈕 $('.back').click(function () { window.history.go(-1) }) // 跳转提領规则页面 $('.income .rule').click(function () { window.location.href = './rule.html'; }) //返回页面 重新请求接口 var hiddenProperty = 'hidden' in document ? 'hidden' : 'webkitHidden' in document ? 'webkitHidden' : 'mozHidden' in document ? 'mozHidden' : null; var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange'); var onVisibilityChange = function () { if (!document[hiddenProperty]) { location.reload() } } document.addEventListener(visibilityChangeEvent, onVisibilityChange);