Files
peko-h5/view/peko/activity/invitation/js/index.js
2023-08-07 16:04:25 +08:00

82 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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'
})
}
let shareObj = {
type: 2,
data: {
msg: 'llllll',
title: '上piko开黑交友玩游戏',
imgUrl: 'https://api.pekolive.com/peko/modules/wxPubPay/images/logo.png',
desc: '邀请好友得金铲铲豪华大礼,快来加入吧!',
}
}
const getInviteList = () => {
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/inviteCode/getListV2',
success(res){
hideLoading(layerIndex)
if(res.code === 200){
userInfo = res.data.inviteUser
if(pubInfo.deviceInfo.app == 'pikoEnterprise'){
shareObj.data.link = shareObj.data.showUrl = `${urlPrefix}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid + '&enterprise=pikoEnterprise'
}else{
shareObj.data.link = shareObj.data.showUrl = `${urlPrefix}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid
}
$('.but').on('click', function () {
if (browser.app) {
if (browser.android) {
window.androidJsObj.openSharePage(JSON.stringify(shareObj));
} else if (browser.ios) {
window.webkit.messageHandlers.openSharePage.postMessage(JSON.stringify(shareObj));
}
}
});
}else{
toastMsg(res.message)
}
},
error(){
hideLoading(layerIndex)
toastMsg('網絡錯誤')
}
})
}
$(function(){
getInfoFromClient()
setTimeout(function(){
getInviteList()
}, 50)
})