123 lines
4.3 KiB
JavaScript
123 lines
4.3 KiB
JavaScript
let browser = checkVersion()
|
||
let info = {}
|
||
// let betaUrl = 'https://beta.api.pekolive.com/peko/modules/inviteCode/share.html?uid=' + info.uid
|
||
// let realUrl = 'https://api.pekolive.com/peko/modules/inviteCode/share.html?uid=' + info.uid
|
||
let betaUrl, realUrl
|
||
// let link = (EnvCheck() == 'test') ? betaUrl : realUrl
|
||
// console.log(6, link);
|
||
if (EnvCheck() === 'test') {
|
||
new VConsole()
|
||
}
|
||
let share = {
|
||
title: '玩游戏交朋友,来piko',
|
||
// link: link,
|
||
desc: '人美声甜小姐姐在线连麦陪玩,有趣的人正在等你~',
|
||
imgUrl: 'https://api.pekolive.com/peko/modules/wxPubPay/images/logo.png'
|
||
}
|
||
let shareObj = {
|
||
type: 2,
|
||
data: {
|
||
msg: 'llllll',
|
||
// link: betaUrl,
|
||
title: share.title,
|
||
imgUrl: share.imgUrl,
|
||
desc: share.desc,
|
||
// showUrl: betaUrl
|
||
}
|
||
}
|
||
$(function () {
|
||
function getId() {
|
||
if (browser.app) {
|
||
if (browser.ios) {
|
||
var allcookies = document.cookie;
|
||
var $uid = allcookies.match(/\d+/);
|
||
info.uid = $uid[0]
|
||
window.webkit.messageHandlers.getTicket.postMessage(null);
|
||
// window.webkit.messageHandlers.getUid.postMessage(null);
|
||
} else if (browser.android) {
|
||
console.log(34, '安卓设备');
|
||
if (androidJsObj && typeof androidJsObj === 'object') {
|
||
console.log(36, '安卓设备');
|
||
info.uid = parseInt(window.androidJsObj.getUid());
|
||
info.ticket = window.androidJsObj.getTicket();
|
||
console.log(40, info.uid, info.ticket);
|
||
}
|
||
}
|
||
} else {
|
||
}
|
||
}
|
||
|
||
function getData() {
|
||
$.ajax({
|
||
type: 'GET',
|
||
url: '/inviteCode/getList?app=piko',
|
||
headers: {
|
||
pub_ticket: info.ticket,
|
||
pub_uid: info.uid
|
||
},
|
||
success(res) {
|
||
console.log(58, res);
|
||
let { inviteCode } = res.data
|
||
$('.code').html(inviteCode)
|
||
let list = res.data.inviteList
|
||
if (list.length) {
|
||
recordRender(list)
|
||
} else {
|
||
noRecordRender()
|
||
}
|
||
// noRecordRender()
|
||
betaUrl = 'https://beta.api.pekolive.com/peko/modules/inviteCode/share.html?inviteCode=' + res.data.inviteCode
|
||
realUrl = 'https://api.pekolive.com/peko/modules/inviteCode/share.html?inviteCode=' + res.data.inviteCode
|
||
shareObj.data.link = shareObj.data.showUrl = (EnvCheck() == 'test') ? betaUrl : realUrl
|
||
|
||
$('.invite-btn').on('click', function () {
|
||
var browser = checkVersion();
|
||
if (browser.app) {
|
||
if (browser.android) {
|
||
window.androidJsObj.openSharePage(JSON.stringify(shareObj));
|
||
} else if (browser.ios) {
|
||
window.webkit.messageHandlers.openSharePage.postMessage(JSON.stringify(shareObj));
|
||
}
|
||
}
|
||
});
|
||
}
|
||
})
|
||
}
|
||
// 不用分页
|
||
function recordRender(arr) {
|
||
console.log(73, arr);
|
||
let liStr = arr.map((item, index) => {
|
||
if(!item.nick){
|
||
item.nick = '未知'
|
||
}
|
||
// item.nick.length > 8 ? (item.nick.slice(0,8)+'...') : item.nick
|
||
return `<li class="invite-record-item">
|
||
<image src=${item.avatar} class="item-avatar"></image>
|
||
<div class="item-nickName">${item.nick.length > 8 ? (item.nick.slice(0, 8) + '...') : item.nick}</div>
|
||
<div class="item-time"><span class="time">${dateFormat(item.createTime, "yyyy-MM-dd hh:mm")}</span> <span>注册</span></div>
|
||
</li>`
|
||
}).join('')
|
||
$('.invite-record-list').html(liStr)
|
||
}
|
||
|
||
function noRecordRender() {
|
||
let str = `
|
||
<img src="./images/blankpage.png" alt="">
|
||
<span>暂无邀请记录</span>
|
||
`
|
||
$('.no-record').html(str)
|
||
}
|
||
getId()
|
||
setTimeout(() => {
|
||
getData();
|
||
|
||
}, 50)
|
||
|
||
|
||
|
||
|
||
})
|
||
|
||
function getMessage(key, value) {
|
||
info[key] = value;
|
||
} |