peko
This commit is contained in:
194
view/peko/modules/game/js/index.js
Normal file
194
view/peko/modules/game/js/index.js
Normal file
@@ -0,0 +1,194 @@
|
||||
let urlPrefix = getUrlPrefix()
|
||||
let browser = checkVersion()
|
||||
let env = EnvCheck();
|
||||
if (env == 'test') {
|
||||
new VConsole();
|
||||
}
|
||||
|
||||
// const productUrlNew = 'https://api.99park.cn'; // 正式环境
|
||||
// const testUrlNew = 'http://beta.99park.cn'; // 测试环境
|
||||
|
||||
const productUrlNew = 'https://yeying.api.shengxuanwangluo.com/'; // 正式环境
|
||||
const testUrlNew = 'https://yeying.api.shengxuanwangluo.com/'; // 测试环境
|
||||
//获取新域名前缀
|
||||
function getUrlPrefixNew() {
|
||||
if (!EnvCheck()) return undefined;
|
||||
return EnvCheck() === 'live' ? productUrlNew : testUrlNew;
|
||||
}
|
||||
const urlPrefixNew = getUrlPrefixNew()
|
||||
|
||||
// 封装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: '玩游戏交朋友,来大鹅',
|
||||
imgUrl: 'https://yeying.api.shengxuanwangluo.com/peko/modules/wxPubPay/images/logo.png',
|
||||
desc: '人美声甜小姐姐在线连麦陪玩,有趣的人正在等你~',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let inviteList = []
|
||||
let userInfo = {}
|
||||
const getInviteList = () => {
|
||||
showLoading()
|
||||
networkRequest({
|
||||
type: 'GET',
|
||||
url: urlPrefix + '/inviteCode/getListV2',
|
||||
success(res){
|
||||
hideLoading(layerIndex)
|
||||
if(res.code === 200){
|
||||
$('.invite-code span').html(res.data.inviteCode)
|
||||
inviteList = res.data.inviteList
|
||||
userInfo = res.data.inviteUser
|
||||
renderUserInfo()
|
||||
renderInviteList()
|
||||
|
||||
if(pubInfo.deviceInfo.app == 'pekoEnterprise'){
|
||||
shareObj.data.link = shareObj.data.showUrl = `${urlPrefixNew}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid + '&enterprise=pekoEnterprise'
|
||||
|
||||
$('.qr').qrcode(`${urlPrefixNew}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid + '&enterprise=pekoEnterprise')
|
||||
$('canvas').addClass('active')
|
||||
}else{
|
||||
shareObj.data.link = shareObj.data.showUrl = `${urlPrefixNew}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid
|
||||
|
||||
$('.qr').qrcode(`${urlPrefixNew}/peko/modules/game/register.html?inviteCode=` + res.data.inviteCode + '&shareUid=' + userInfo.uid)
|
||||
$('canvas').addClass('active')
|
||||
}
|
||||
|
||||
$('.share-btn').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('网络错误')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const getRule = () => {
|
||||
showLoading()
|
||||
networkRequest({
|
||||
type: 'GET',
|
||||
url: urlPrefix + '/inviteCode/getInviteTicketInfo',
|
||||
success(res){
|
||||
hideLoading(layerIndex)
|
||||
if(res.code === 200){
|
||||
if(res.data){
|
||||
$('.punctuation').html(';')
|
||||
$('.rule-wrap').addClass('rule-wrap-big')
|
||||
taskLimit = res.data.taskLimit
|
||||
tickets = res.data.tickets
|
||||
let desc = ''
|
||||
tickets.map((item, index) => {
|
||||
desc += `${item.ticketName}${item.ticketNum}张${index === tickets.length-1 ? '。' : ','}`
|
||||
})
|
||||
let str = `
|
||||
<p>4.每成功邀请${taskLimit}位好友注册且报名比赛,可获赠${desc}</p>
|
||||
`
|
||||
$('.rule-wrap').append(str)
|
||||
}
|
||||
}else{
|
||||
toastMsg(res.message)
|
||||
}
|
||||
},
|
||||
error(){
|
||||
hideLoading(layerIndex)
|
||||
toastMsg('网络错误')
|
||||
}
|
||||
})
|
||||
}
|
||||
const renderInviteList = () => {
|
||||
let str = ''
|
||||
inviteList.map( (item) => {
|
||||
if(!item.nick){
|
||||
item.nick = '未知'
|
||||
}
|
||||
str += `
|
||||
<li>
|
||||
<div class="item-avatar"><img src="${item.avatar ? item.avatar : `./images/default.png`}" alt=""></div>
|
||||
<div class="item-info">
|
||||
<p class="item-nickname">
|
||||
${item.nick.length > 11 ? item.nick.slice(0, 11) + `...` : item.nick}
|
||||
${
|
||||
item.gender ? `<img src="${item.gender === 1 ? `./images/male.png` : `./images/female.png`}" alt="">` : ''
|
||||
}
|
||||
</p>
|
||||
<div class="item-date"><span>${dateFormat(item.createTime, "yyyy-MM-dd hh:mm")}</span> 注册</div>
|
||||
</div>
|
||||
<div class="isActive ${item.hasLoginActived ? '' : 'inactive'}">${item.hasLoginActived ? '已登录激活' : '未登录激活'}</div>
|
||||
</li>
|
||||
`
|
||||
} )
|
||||
$('.invite-record-wrap').html(str)
|
||||
}
|
||||
|
||||
const renderUserInfo = () => {
|
||||
if(!userInfo.nick){
|
||||
userInfo.nick = '未知'
|
||||
}
|
||||
if(userInfo.nick.length > 10){
|
||||
userInfo.nick = userInfo.nick.slice(0, 10) + `...`
|
||||
}
|
||||
$('.personal-info .nickname').html(userInfo.nick)
|
||||
$('.personal-info-content .avatar img').attr('src', userInfo.avatar)
|
||||
$('.personal-info .platform-code .erbanNo').html(userInfo.erbanNo)
|
||||
}
|
||||
|
||||
$(function(){
|
||||
getInfoFromClient()
|
||||
setTimeout(function(){
|
||||
getInviteList()
|
||||
getRule()
|
||||
}, 50)
|
||||
|
||||
if (browser.app) {
|
||||
if (browser.android) {
|
||||
let channel = JSON.parse(pubInfo.deviceInfo).channel
|
||||
if (channel.indexOf('toutiao') != -1 || channel.indexOf('kuaishou') != -1) {
|
||||
$('.banner img').attr('src', './images/banner-yy.png')
|
||||
$('.avatar img').attr('src', './images/logo-yy.png')
|
||||
$('.appName').html('夜莺')
|
||||
}
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
$('body').show()
|
||||
}, 0)
|
||||
})
|
Reference in New Issue
Block a user