联调鹊桥接口动效以及房间榜接口
This commit is contained in:
@@ -26,6 +26,10 @@ const toastMsg = (content = '操作完成', time = 2) => {
|
||||
skin: 'msg'
|
||||
})
|
||||
}
|
||||
var xiqueNum = 0;//当前剩余喜鹊数量
|
||||
var roomUid = 0;//房间uid
|
||||
var giftId = 0;//默认礼物id
|
||||
var xiqueBut = true;//投放喜鹊锁
|
||||
// 初始化函數
|
||||
$(function () {
|
||||
setTimeout(function () {
|
||||
@@ -48,19 +52,67 @@ $(function () {
|
||||
}
|
||||
})
|
||||
swiperFun();
|
||||
getConfig();
|
||||
getRecommendRoom();
|
||||
}, 100)
|
||||
})
|
||||
})
|
||||
// 接口
|
||||
function get () {
|
||||
// 初始化接口
|
||||
function getConfig () {
|
||||
showLoading()
|
||||
networkRequest({
|
||||
type: 'GET',
|
||||
url: urlPrefix + '/seekElfin/product/list',
|
||||
url: urlPrefix + '/act/2023Qixi/xique/getConfig',
|
||||
data: {},
|
||||
success (res) {
|
||||
if (res.code === 200) {
|
||||
|
||||
// 处理活动时间
|
||||
$('.header .titleHeader').text(`活動時間:${dateFormat(res.data.startTime, 'yyyy年MM月dd日')}-${dateFormat(res.data.endTime, 'yyyy年MM月dd日')}`)
|
||||
// 当前用户喜鹊
|
||||
xiqueNum = res.data.xiqueNum
|
||||
$('.page1 .magpieBridge .birdNum b').text(`我的喜鵲: ${res.data.xiqueNum}`)
|
||||
// 处理当前喜鹊进度状态值
|
||||
console.log(res.data.serverCurXiqueNum);
|
||||
console.log(res.data.serverMaxXiqueNum);
|
||||
var curXiqueNums = res.data.serverCurXiqueNum / res.data.serverMaxXiqueNum * 100;
|
||||
console.log(curXiqueNums);
|
||||
$('.page1 .magpieBridge .line .line_in').css('width', curXiqueNums >= 100 ? '100%' : `${curXiqueNums}%`);
|
||||
// 处理领取喜鹊头饰按钮状态
|
||||
if (res.data.devotedBtnStatus == 0) {//投入按钮状态(0=可投入,1=可领取,2=不能领取,-1=已领取)
|
||||
$('.page1 .magpieBridge .buting').hide();
|
||||
$('.page1 .magpieBridge .buterr').hide();
|
||||
$('.page1 .magpieBridge .butout').hide();
|
||||
$('.page1 .magpieBridge .but1').show();
|
||||
$('.page1 .magpieBridge .but10').show();
|
||||
} else if (res.data.devotedBtnStatus == 1) {//投入按钮状态(0=可投入,1=可领取,2=不能领取,-1=已领取)
|
||||
$('.page1 .magpieBridge .buting').show();
|
||||
$('.page1 .magpieBridge .but1').hide();
|
||||
$('.page1 .magpieBridge .but10').hide();
|
||||
} else if (res.data.devotedBtnStatus = 2) {
|
||||
$('.page1 .magpieBridge .buterr').show();
|
||||
$('.page1 .magpieBridge .but1').hide();
|
||||
$('.page1 .magpieBridge .but10').hide();
|
||||
} else if (res.data.devotedBtnStatus < 0) {
|
||||
$('.page1 .magpieBridge .butout').show();
|
||||
$('.page1 .magpieBridge .but1').hide();
|
||||
$('.page1 .magpieBridge .but10').hide();
|
||||
}
|
||||
// 处理任务状态
|
||||
res.data.dailyTaskList.forEach((res, i) => {
|
||||
$(`.page1 .task .box1 .task${i + 1} .p2`).text(`獎勵:喜鵲*${res.xiqueNum}`)
|
||||
if (res.btnStatus == 1) {//已完成
|
||||
$(`.page1 .task .box1 .task${i + 1} .but`).addClass('out');
|
||||
$(`.page1 .task .box1 .task${i + 1} .but`).text('已完成');
|
||||
$(`.page1 .task .box1 .task${i + 1} .but`).attr('click', 0);
|
||||
}
|
||||
if (i == 1) {
|
||||
$(`.page1 .task .box1 .task2 .p1`).text(`任意房間發送彈幕(${res.cur}/${res.need})`)
|
||||
}
|
||||
if (i == 2) {
|
||||
var percentage = res.cur / res.need * 100;
|
||||
$('.page1 .task .box1 .task3 .line .line_in').css('width', percentage >= 100 ? '100%' : `${percentage}%`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastMsg(res.message)
|
||||
}
|
||||
@@ -72,18 +124,26 @@ function get () {
|
||||
}
|
||||
})
|
||||
}
|
||||
// 播放svg
|
||||
function svgaFun () {
|
||||
player1 = new SVGA.Player('.star_in');
|
||||
parser1 = new SVGA.Parser('.star_in');
|
||||
parser1.load('./images/star.svga', function (videoItem) {
|
||||
player1.loops = 1;
|
||||
player1.clearsAfterStop = false;
|
||||
player1.setVideoItem(videoItem);
|
||||
player1.startAnimation();
|
||||
player1.setContentMode('AspectFill')
|
||||
player1.onFinished(() => {
|
||||
})
|
||||
// 获取房间接口
|
||||
function getRecommendRoom () {
|
||||
showLoading()
|
||||
networkRequest({
|
||||
type: 'GEt',
|
||||
url: urlPrefix + '/tab/home/one',
|
||||
data: { pub_ticket: pubInfo.ticket, pub_uid: pubInfo.uid },
|
||||
success (res) {
|
||||
if (res.code === 200) {
|
||||
roomUid = res.data;
|
||||
hideLoading(layerIndex)
|
||||
} else {
|
||||
hideLoading(layerIndex)
|
||||
toastMsg(res.message)
|
||||
}
|
||||
},
|
||||
error (err) {
|
||||
hideLoading(layerIndex)
|
||||
toastMsg('網絡錯誤,請退出重進')
|
||||
}
|
||||
})
|
||||
}
|
||||
// 定情信物礼物轮播
|
||||
@@ -107,7 +167,69 @@ $('.tabs div').click(function () {
|
||||
$('.page3').hide();
|
||||
$('.page4').hide();
|
||||
$(`.page${i}`).show();
|
||||
if (i == 3) {
|
||||
getRoomRank();
|
||||
}
|
||||
})
|
||||
// 房间榜单接口
|
||||
function getRoomRank () {
|
||||
$('.page3 ul li').remove();
|
||||
showLoading()
|
||||
networkRequest({
|
||||
type: 'GET',
|
||||
url: urlPrefix + '/act/2023Qixi/roomRank/getRank',
|
||||
data: {},
|
||||
success (res) {
|
||||
if (res.code === 200) {
|
||||
var top3 = res.data.rankList.slice(0, 3);
|
||||
var notTop3 = res.data.rankList.slice(3);
|
||||
// 处理前三
|
||||
if (top3.length < 3) {
|
||||
let arr = new Array(3 - top3.length).fill({
|
||||
avatar: './images/logo.png',
|
||||
nick: '虚位以待',
|
||||
score: "0"
|
||||
})
|
||||
top3.push(...arr)
|
||||
}
|
||||
top3.forEach((res, index) => {
|
||||
$(`.page3 .no${index + 1} .tx`).attr('src', res.avatar);
|
||||
$(`.page3 .no${index + 1} p`).text(res.nick);
|
||||
$(`.page3 .no${index + 1} b`).text(`情緣值:${unitProcessing(res.score, 10000, 1, 'w')}`);
|
||||
})
|
||||
// 非前三
|
||||
var str = '';
|
||||
notTop3.forEach((res, i) => {
|
||||
str += `
|
||||
<li>
|
||||
<div class="num">${res.ranking}</div>
|
||||
<img src="${res.avatar}" alt="" class="tx">
|
||||
<div class="name">${res.nick}</div>
|
||||
<div class="score">
|
||||
<img src="./images/loveIcon.png" alt="" class="loveIcon">
|
||||
<b>情緣值:${unitProcessing(res.score, 10000, 1, 'w')}</b>
|
||||
</div>
|
||||
</li>
|
||||
`
|
||||
})
|
||||
$('.page3 ul').append(str);
|
||||
// 处理自己榜单
|
||||
var meRank = res.data.meRank;
|
||||
$('.page3 .my .num').text(meRank.ranking == 0 ? '未上榜' : meRank.ranking);
|
||||
$('.page3 .my .tx').attr('src', meRank.avatar);
|
||||
$('.page3 .my .name').text(meRank.nick);
|
||||
$('.page3 .my .score b').text(`情緣值:${unitProcessing(meRank.score, 10000, 1, 'w')}`);
|
||||
} else {
|
||||
toastMsg(res.message)
|
||||
}
|
||||
hideLoading(layerIndex)
|
||||
},
|
||||
error (err) {
|
||||
hideLoading(layerIndex)
|
||||
toastMsg('網絡錯誤,請退出重進')
|
||||
}
|
||||
})
|
||||
}
|
||||
// 首页任务切换
|
||||
$('.page1 .task .tab div').click(function () {
|
||||
var i = $(this).index() + 1;
|
||||
@@ -183,4 +305,132 @@ $('.page4 .timeList div').click(function () {
|
||||
$('.endActivity .endActivity_in .but').click(function () {
|
||||
$('.endActivity').hide();
|
||||
bodyScroolFun(false);
|
||||
})
|
||||
//领取全服喜鹊奖励
|
||||
function getXiqueReward () {
|
||||
showLoading()
|
||||
networkRequest({
|
||||
type: 'GET',
|
||||
url: urlPrefix + '/act/2023Qixi/xique/getXiqueReward',
|
||||
data: {},
|
||||
success (res) {
|
||||
if (res.code === 200) {
|
||||
getConfig();
|
||||
toastMsg('领取成功');
|
||||
} else {
|
||||
toastMsg(res.message)
|
||||
}
|
||||
hideLoading(layerIndex)
|
||||
},
|
||||
error (err) {
|
||||
hideLoading(layerIndex)
|
||||
toastMsg('網絡錯誤,請退出重進')
|
||||
}
|
||||
})
|
||||
}
|
||||
// 领取喜鹊奖励按钮
|
||||
$('.page1 .magpieBridge .buting').click(function () {
|
||||
getXiqueReward();
|
||||
})
|
||||
// 领取喜鹊未参与按钮
|
||||
$('.page1 .magpieBridge .buterr').click(function () {
|
||||
toastMsg('您未参加搭建鹊桥活动,无法领取');
|
||||
})
|
||||
// 投放喜鹊接口
|
||||
function devotedXique (num) {
|
||||
// showLoading()
|
||||
networkRequest({
|
||||
type: 'GET',
|
||||
url: urlPrefix + '/act/2023Qixi/xique/devotedXique',
|
||||
data: { num },
|
||||
success (res) {
|
||||
if (res.code === 200) {
|
||||
getConfig();
|
||||
toastMsg('投放成功')
|
||||
xiqueBut = true;
|
||||
} else {
|
||||
toastMsg(res.message)
|
||||
xiqueBut = true;
|
||||
}
|
||||
hideLoading(layerIndex)
|
||||
xiqueBut = true;
|
||||
},
|
||||
error (err) {
|
||||
xiqueBut = true;
|
||||
hideLoading(layerIndex)
|
||||
toastMsg('網絡錯誤,請退出重進')
|
||||
}
|
||||
})
|
||||
}
|
||||
// 播放喜鹊svg
|
||||
function svgaFun () {
|
||||
player1 = new SVGA.Player('.xique');
|
||||
parser1 = new SVGA.Parser('.xique');
|
||||
parser1.load('./images/xique.svga', function (videoItem) {
|
||||
player1.loops = 1
|
||||
player1.clearsAfterStop = false;
|
||||
player1.setVideoItem(videoItem);
|
||||
player1.startAnimation();
|
||||
player1.setContentMode('AspectFill')
|
||||
player1.onFinished(() => {
|
||||
// $('.svga').hide()
|
||||
})
|
||||
})
|
||||
}
|
||||
// 投放按钮
|
||||
$('.page1 .magpieBridge .but1,.page1 .magpieBridge .but10').click(function () {
|
||||
var clas = $(this).attr('class')
|
||||
if (clas == 'but1') {
|
||||
if (xiqueNum < 1) {
|
||||
toastMsg('喜鹊数量不足,参加任务获得吧~')
|
||||
return
|
||||
}
|
||||
if (xiqueBut) {
|
||||
xiqueBut = false;
|
||||
svgaFun();
|
||||
setTimeout(function () {
|
||||
devotedXique(1);
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
} else {
|
||||
if (xiqueNum < 10) {
|
||||
toastMsg('喜鹊数量不足,参加任务获得吧~')
|
||||
return
|
||||
}
|
||||
if (xiqueBut) {
|
||||
xiqueBut = false;
|
||||
svgaFun();
|
||||
setTimeout(function () {
|
||||
devotedXique(10);
|
||||
}, 2000)
|
||||
}
|
||||
// devotedXique(10);
|
||||
}
|
||||
})
|
||||
// 去完成任务2按钮
|
||||
$('.page1 .task .box1 .task2 .but').click(function () {
|
||||
var click = $(this).attr('click');
|
||||
if (click != 0) {
|
||||
if (browser.ios) {
|
||||
window.webkit.messageHandlers.openRoom.postMessage(roomUid);
|
||||
} else if (browser.android) {
|
||||
if (androidJsObj && typeof androidJsObj === 'object') {
|
||||
window.androidJsObj.openRoom(roomUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// 去完成任务3按钮
|
||||
$('.page1 .task .box1 .task3 .but').click(function () {
|
||||
var click = $(this).attr('click');
|
||||
if (click != 0) {
|
||||
if (browser.ios) {
|
||||
window.webkit.messageHandlers.openRoomForGiftId.postMessage(JSON.stringify({ uid: roomUid, giftId: giftId }))
|
||||
} else if (browser.android) {
|
||||
if (androidJsObj && typeof androidJsObj === 'object') {
|
||||
window.androidJsObj.openRoomForGiftId(roomUid, giftId);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user