82 lines
2.3 KiB
JavaScript
82 lines
2.3 KiB
JavaScript
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: '上peko,开黑交友玩游戏',
|
||
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 == 'pekoEnterprise'){
|
||
shareObj.data.link = shareObj.data.showUrl = `${urlPrefix}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid + '&enterprise=pekoEnterprise'
|
||
}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)
|
||
}) |