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 inviteCode = ''; var typeStr = "1,3";//收益類型 1 直接邀請 2 間接邀請 3 直接邀請充值 4 間接邀請充值 var page = 1; var isLock = true; var obj = {}; var text = '直接'; // 初始化函數 $(function () { getInfoFromClient() setTimeout(function () { // 頁面全屏 if (browser.app) { if (browser.android) { window.androidJsObj.initShowNav(false) } else { window.webkit.messageHandlers.initShowNav.postMessage(0) } }; // 頂部返回事件 $('.back').click(() => { if (browser.android) { window.androidJsObj.closeWebView() } else { window.webkit.messageHandlers.closeWebView.postMessage(null) } }) getConfig(); getMySelf(); profitPage(); }, 100) }) // 獲取配置接口 function getConfig () { showLoading() networkRequest({ type: 'get', url: urlPrefix + '/user/invite/config', success (res) { if (res.code === 200) { // 直接邀請規則 res.data.inviteLevelReward.forEach((res, i) => { if (i == 0) { $(`.bg .rule .rule2 .table1_2`).html(`
${res.leftDiamond}鑽<30天內儲值<${res.rightDiamond}鑽
直接邀請對象+2魔法棒,妳+1魔法棒
`) } else { $(`.bg .rule .rule2 .table1_${i + 2}`).html(`
${res.leftDiamond}鉆<=30天內儲值${res.rightDiamond ? `<${res.rightDiamond}鉆` : ''}
每儲值${res.numUnit}鉆,妳+${res.rewardNum}鉆(${((res.rewardNum / res.numUnit) * 100).toFixed(2)}%)
`) } }) // 間接邀請規則 res.data.indirectLevelReward.forEach((res, i) => { $(`.bg .rule .rule2 .table2_${i + 2}`).html(`
${res.leftDiamond}鉆<=30天內儲值${res.rightDiamond ? `<${res.rightDiamond}鉆` : ''}
每儲值${res.numUnit}鉆,妳+${res.rewardNum}鉆(${((res.rewardNum / res.numUnit) * 100).toFixed(2)}%)
`) }) } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網路錯誤,請退出重進') } }) } console.log(); // 獲取收益接口 function getMySelf () { showLoading() networkRequest({ type: 'get', url: urlPrefix + '/user/invite/mySelf', success (res) { if (res.code === 200) { inviteCode = res.data.inviteCode; // 分享所需参数 obj = { qrCodeUrl: res.data.qRCodeUrl, text: '掃碼下載PiKO並填寫我的邀請碼\n立得 1000 鑽石!', invitationCode: `${res.data.inviteCode}`, shareTitle: 'Piko,與心動聲音不期而遇', shareText: '聊天玩遊戲交朋友,隨時隨地在Piko', shareImg: 'https://image.pekolive.com/piko_logo.png', toUrl: `${window.location.origin}/peko/activity/2024-invitationFission/share.html?inviteCode=${res.data.inviteCode}`, type: 1//1:分享好友2:直接保存圖片 } // 初始化复制 $.copy({ text: "復制成功", //分享提示文案 copyUrl: inviteCode, //自定義復制 tipTime: 1000, //分享提示消失時間 copyId: "#copy" //復制按鈕id }); $('.bg .myInfo .invitationCode').text(inviteCode); $('.bg .myIncome b').text(res.data.totalProfit); $('.bg .incomeBox .tab .directProfit span').html(` ${res.data.directProfit}`); $('.bg .incomeBox .tab .indirectProfit span').html(` ${res.data.indirectProfit}`); $('.code .codeImg').attr('src', res.data.qRCodeUrl); $('.bg .myInfo .tx').attr('src', res.data.avatar); } else { toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { hideLoading(layerIndex) toastMsg('網路錯誤,請退出重進') } }) } // 縮小二維碼 $('.code .rule_icon').click(function () { $('.openShare').show(); $('.code').hide(); }) // 放大二維碼 $('.openShare').click(function () { $('.code').show(); $('.openShare').hide(); }) // 分享調用 $('.bg .myInfo .skip').click(function () { obj.type = 1; if (browser.android) { window.androidJsObj.savePictureShare(JSON.stringify(obj)) } else { window.webkit.messageHandlers.savePictureShare.postMessage(JSON.stringify(obj)) } }) // 保存圖片 $('.code .but').click(function () { obj.type = 2; if (browser.android) { window.androidJsObj.savePictureShare(JSON.stringify(obj)) } else { window.webkit.messageHandlers.savePictureShare.postMessage(JSON.stringify(obj)) } }) // 復制邀請碼 $('.bg .myInfo .copy').click(function () { $.copy({ text: "復制成功", //分享提示文案 copyUrl: inviteCode, //自定義復制 tipTime: 1000, //分享提示消失時間 copyId: "#copy" //復制按鈕id }); }) // 切換收益大Tab $('.bg .incomeBox .tab div').click(function () { var i = $(this).index() + 1; text = i == 1 ? '直接' : '間接'; $(this).addClass('act').siblings().removeClass('act'); $('.bg .incomeBox .sTab div').eq(0).text(`${text}邀請收益記錄`); $('.bg .incomeBox .sTab div').eq(1).text(`${text}邀請用戶記錄`); $('.bg .incomeBox .sTab div').removeClass('tab1').removeClass('tab2'); $('.bg .incomeBox .sTab div').eq(0).addClass(`tab1`); page = 1; $('.bg .incomeBox ul li').remove(); typeStr = i == 1 ? "1,3" : "2,4"; profitPage(); }) // 小tab切換 $('.bg .incomeBox .sTab div').click(function () { var i = $(this).index() + 1; $('.bg .incomeBox .sTab div').removeClass('tab1').removeClass('tab2'); $(this).addClass(`tab${i}`); page = 1; typeStr = (i == 1 && text == '直接') ? "1,3" : (i == 2 && text == '直接') ? "1" : (i == 1 && text == '間接') ? "2,4" : "2"; $('.bg .incomeBox ul li').remove(); if (i == 1) { profitPage(); } else { userPage(); } }) // 滾動 $('.bg .incomeBox ul').scroll(function () { let scrollTop = $(this).scrollTop() let scrollHeight = $('.bg .incomeBox ul')[0].scrollHeight let ulHeight = $(this).innerHeight() if (scrollTop + ulHeight + 100 >= scrollHeight) { if (isLock) { // 請求下一頁 page = page + 1; profitPage(); isLock = false; } } }) // 獲取收益接口 function profitPage () { showLoading() networkRequest({ type: 'get', url: urlPrefix + '/userInviteFissionRewardRecord/profitPage', data: { pageNum: page, pageSize: 10, typeStr }, success (res) { if (res.code === 200) { var str = ''; if (text == '直接' && typeStr == "1,3") { $('.bg .incomeBox .tableTitle div').remove(); $('.bg .incomeBox .tableTitle').append(`
時間
收益
收益類型
直接邀請對象
`); } else if (text == '間接' && typeStr == "2,4") { $('.bg .incomeBox .tableTitle div').remove(); $('.bg .incomeBox .tableTitle').append(`
時間
收益
收益類型
間接邀請對象
`); } if (res.data.records.length == 0) { if (page == 1) { str += `
  • 暫無
    暫無
    暫無
    暫無
  • `} isLock = false; } else { console.log(text); if (text == '直接' && typeStr == "1,3") { res.data.records.forEach(res => { str += `
  • ${dateFormat(res.createTime, 'yyyy-MM-dd')}

    ${dateFormat(res.createTime, 'hh:mm:ss')}
    +${res.rewardNum}
    ${res.type == 1 && res.rewardType == 1 ? '邀請好友注冊' : res.type == 3 && res.rewardType == 1 ? '好友儲值返現' : res.type == 3 && res.rewardType == 2 ? '好友首次儲值' : '間接邀請儲值返現'}

    ${res.inviteNick}

    ID:${res.inviteErBanNo}
  • ` }); } else if (text == '間接' && typeStr == "2,4") { res.data.records.forEach(res => { str += `
  • ${dateFormat(res.createTime, 'yyyy-MM-dd')}

    ${dateFormat(res.createTime, 'hh:mm:ss')}
    +${res.rewardNum}
    ${res.type == 1 && res.rewardType == 1 ? '邀請好友注冊' : res.type == 3 && res.rewardType == 1 ? '好友儲值返現' : res.type == 3 && res.rewardType == 2 ? '好友首次儲值' : '間接邀請儲值返現'}

    ${res.inviteNick}

    ID:${res.inviteErBanNo}
  • ` }); } isLock = true; } $('.bg .incomeBox ul').append(str); } else { isLock = true; toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { isLock = true; hideLoading(layerIndex) toastMsg('網路錯誤,請退出重進') } }) } // 獲取收益接口 function userPage () { showLoading() networkRequest({ type: 'get', url: urlPrefix + '/userInviteFissionRewardRecord/userPage', data: { pageNum: page, pageSize: 10, type: typeStr }, success (res) { if (res.code === 200) { var str = ''; if (text == '直接' && typeStr == "1") { $('.bg .incomeBox .tableTitle div').remove(); $('.bg .incomeBox .tableTitle').append(`
    時間
    直接邀請對象
    30天內充值
    `); } else if (text == '間接' && typeStr == "2") { $('.bg .incomeBox .tableTitle div').remove(); $('.bg .incomeBox .tableTitle').append(`
    時間
    直接邀請對象
    間接邀請對象
    30天內充值
    `); } if (res.data.records.length == 0) { if (page == 1) { str += `
  • 暫無
    暫無
    暫無
    暫無
  • `} isLock = false; } else { if (text == '直接' && typeStr == "1") { res.data.records.forEach(res => { str += `
  • ${dateFormat(res.createTime, 'yyyy-MM-dd')}

    ${dateFormat(res.createTime, 'hh:mm:ss')}

    ${res.inviteNick}

    ID:${res.inviteErBanNo}
    ${res.charge30Amount ? res.charge30Amount : 0}
  • ` }); } else if (text == '間接' && typeStr == "2") { res.data.records.forEach(res => { str += `
  • ${dateFormat(res.createTime, 'yyyy-MM-dd')}

    ${dateFormat(res.createTime, 'hh:mm:ss')}

    ${res.inviteNick}

    ID:${res.inviteErBanNo}

    ${res.indirectNick}

    ID:${res.indirectErBanNo}
    ${res.charge30Amount ? res.charge30Amount : 0}
  • ` }); } isLock = true; } $('.bg .incomeBox ul').append(str); } else { isLock = true; toastMsg(res.message) } hideLoading(layerIndex) }, error (err) { isLock = true; hideLoading(layerIndex) toastMsg('網路錯誤,請退出重進') } }) }