修复bug

This commit is contained in:
Dragon
2024-02-27 20:16:07 +08:00
parent e3f6712622
commit e533052973
6 changed files with 162 additions and 585 deletions

View File

@@ -4,6 +4,12 @@ body {
background: #F36121;
}
.rabbit {
z-index: 999;
width: 0.8rem;
height: 0.8rem;
}
.back {
position: fixed;
top: 0.93333rem;
@@ -289,6 +295,8 @@ body {
color: #DE2A21;
font-size: 0.24rem;
font-weight: 400;
position: absolute;
z-index: 2;
}
.page1 ul li .wishIng {
@@ -362,10 +370,11 @@ body {
}
.page2 .listBox li {
width: 100%;
width: 99.5%;
height: 2.13333rem;
background: #804030;
overflow: hidden;
margin: 0 auto 0;
}
.page2 .listBox li .num {
@@ -386,6 +395,8 @@ body {
background: url(../images/no1.png) no-repeat;
background-size: 100% 100%;
margin-right: 0.32rem;
margin-top: 0.74667rem;
margin-left: 0.37333rem;
}
.page2 .listBox li .num2 {
@@ -394,6 +405,8 @@ body {
background: url(../images/no2.png) no-repeat;
background-size: 100% 100%;
margin-right: 0.32rem;
margin-top: 0.74667rem;
margin-left: 0.37333rem;
}
.page2 .listBox li .num3 {
@@ -402,6 +415,8 @@ body {
background: url(../images/no3.png) no-repeat;
background-size: 100% 100%;
margin-right: 0.32rem;
margin-top: 0.74667rem;
margin-left: 0.37333rem;
}
.page2 .listBox li .tx {
@@ -451,15 +466,15 @@ body {
}
.page2 .listBox .li1 {
background: linear-gradient(270deg, rgba(255, 204, 0, 0) 0%, #FFD82C 100%);
background: linear-gradient(270deg, rgba(255, 204, 0, 0.1) 0%, rgba(255, 216, 44, 0.5) 100%);
}
.page2 .listBox .li2 {
background: linear-gradient(270deg, rgba(109, 139, 209, 0) 0%, #83CCFF 100%);
background: linear-gradient(270deg, rgba(109, 139, 209, 0.1) 0%, rgba(131, 204, 255, 0.5) 100%);
}
.page2 .listBox .li3 {
background: linear-gradient(270deg, rgba(163, 102, 46, 0) 0%, #DF893F 100%);
background: linear-gradient(270deg, rgba(163, 102, 46, 0.1) 0%, rgba(223, 137, 63, 0.5) 100%);
}
.page2 .my {
@@ -859,6 +874,11 @@ body {
display: none;
}
.rule .rule_in .ruleText p {
margin-bottom: 0.10667rem;
line-height: 0.45rem;
}
.record {
display: none;
position: fixed;

View File

@@ -8,6 +8,12 @@ body {
background: #F36121;
}
.rabbit {
z-index: 999;
width: px2rem(60);
height: px2rem(60);
}
// 返回按钮
.back {
position: fixed;
@@ -294,6 +300,8 @@ body {
color: #DE2A21;
font-size: px2rem(18);
font-weight: 400;
position: absolute;
z-index: 2;
}
}
@@ -371,10 +379,11 @@ body {
}
li {
width: 100%;
width: 99.5%;
height: px2rem(160);
background: #804030;
overflow: hidden;
margin: 0 auto 0;
.num {
width: px2rem(73);
@@ -394,6 +403,8 @@ body {
background: url(../images/no1.png) no-repeat;
background-size: 100% 100%;
margin-right: px2rem(24);
margin-top: px2rem(56);
margin-left: px2rem(28);
}
.num2 {
@@ -402,6 +413,8 @@ body {
background: url(../images/no2.png) no-repeat;
background-size: 100% 100%;
margin-right: px2rem(24);
margin-top: px2rem(56);
margin-left: px2rem(28);
}
.num3 {
@@ -410,6 +423,8 @@ body {
background: url(../images/no3.png) no-repeat;
background-size: 100% 100%;
margin-right: px2rem(24);
margin-top: px2rem(56);
margin-left: px2rem(28);
}
.tx {
@@ -461,15 +476,15 @@ body {
}
.li1 {
background: linear-gradient(270deg, rgba(255, 204, 0, 0) 0%, #FFD82C 100%);
background: linear-gradient(270deg, rgba(255, 204, 0, 0.1) 0%, rgba(255, 216, 44, 0.5) 100%);
}
.li2 {
background: linear-gradient(270deg, rgba(109, 139, 209, 0) 0%, #83CCFF 100%);
background: linear-gradient(270deg, rgba(109, 139, 209, 0.1) 0%, rgba(131, 204, 255, 0.5) 100%);
}
.li3 {
background: linear-gradient(270deg, rgba(163, 102, 46, 0) 0%, #DF893F 100%);
background: linear-gradient(270deg, rgba(163, 102, 46, 0.1) 0%, rgba(223, 137, 63, 0.5) 100%);
}
}
@@ -871,6 +886,11 @@ body {
&::-webkit-scrollbar {
display: none;
}
p{
margin-bottom: px2rem(8);
line-height: 0.45rem;
}
}
}

View File

@@ -155,7 +155,15 @@
<div class="rule_in">
<img src="./images/ruleTitle.png" alt="" class="ruleTitle">
<div class="ruleText">
规则
<p>1.購買魔法棒參與許願1個魔法棒=100鑽</p>
<p>2.許願獎勵:每輪投入滿足規定的魔法棒數量後立即開獎,獎勵將會自動發放至獲獎者背包;</p>
<p>3.許願開獎:玩家參與過其中任意物品的許願,開獎後將會有小秘書通知,也可以在【中獎記錄】查看自己的中獎記錄,以及曾經投入過的物品被誰帶走;</p>
<p>4.許願榜單許願榜單分為日榜和總榜日榜每日00:00更新</p>
<p>5.中獎概率:玩家投入魔法棒數量/規定開獎數量=玩家概率。(提示高概率不代表一定中獎哦);</p>
<p>6.活動結束時間另行通知,請留意小秘書公告;</p>
<p>7.如有作弊行為,官方有權清除作弊者所得的所有獎勵;</p>
<p>8.有任何疑問請聯繫客服LINE:pekoyuyin、app內搜索ID10001、WeChat:sd245376</p>
<p>9.本活動最終解釋權歸官方所有並與Apple inc/Google公司無關</p>
</div>
</div>
</div>
@@ -169,7 +177,7 @@
<div class="tab2"></div>
</div>
<ul class="ul1">
<li class="liAct">
<!-- <li class="liAct">
<div class="left">
<p>00:00:00</p>
<i>2024-02-23</i>
@@ -179,10 +187,10 @@
<i>8888鉆石</i>
</div>
</li>
<li></li>
<li></li> -->
</ul>
<ul class="ul2">
<li class="liAct">
<!-- <li class="liAct">
<div class="left">
<p>00:00:00</p>
<i>2024-02-23</i>
@@ -209,7 +217,7 @@
<p>我是用户昵</p>
<i>获得</i>
</div>
</li>
</li> -->
</ul>
</div>
</div>
@@ -240,4 +248,5 @@
<script src="../../common/js/layer.js"></script>
<script src="../../common/js/vconsole.min.js"></script>
<script src="../../common/js/route-constant.js"></script>
<script src="./js/wow.js"></script>
<script src="./js/index.js"></script>

View File

@@ -78,7 +78,7 @@ function getConfig () {
<div class="schedule">許願進度</div>
<div class="line">
<div class="line_in">
<img style="width: ${res.process / res.max * 100 >= 100 ? '100' : res.process / res.max}%;" src="./images/line.png" alt="">
<img style="width: ${res.process / res.max * 100 >= 100 ? '100' : res.process / res.max * 100}%;" src="./images/line.png" alt="">
</div>
<p>${res.process}/${res.max}</p>
</div>
@@ -101,12 +101,11 @@ function getConfig () {
})
}
// 刷新接口
$('.page1 .update').click(function(){
$('.page1 .update').click(function () {
getConfig();
})
// 购买魔法棒接口
// 榜单接口
function getRank (type) {
$('.page2 .listBox li').remove()
showLoading()
networkRequest({
type: 'get',
@@ -117,7 +116,7 @@ function getRank (type) {
var str = '';
res.data.rankList.forEach((res, i) => {
str += `
<li class='li1${i + 1}'>
<li class='li${i + 1}'>
<div class="num num${i + 1}">${i + 1 > 3 ? res.ranking : ''}</div>
<img src="${res.avatar}" alt="" class="tx">
<div class="name">${res.nick}</div>
@@ -128,7 +127,13 @@ function getRank (type) {
</li>
`
})
$('.page2 .listBox li').remove()
$('.page2 .listBox').append(str);
// 处理自己
$('.page2 .my .num').text(res.data.meRank.ranking == 0? '未上榜' : res.data.meRank.ranking);
$('.page2 .my .tx').attr('src',res.data.meRank.avatar);
$('.page2 .my .name').text(res.data.meRank.nick);
$('.page2 .my .right p').text(res.data.meRank.score);
} else {
toastMsg(res.message)
}
@@ -173,7 +178,6 @@ var page = 1;
var isLock = true;
// 中奖记录接口
function listLuckyRecord (page) {
$('.record .record_in .ul1 li').remove();
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/listLuckyRecord',
@@ -182,10 +186,10 @@ function listLuckyRecord (page) {
if (res.code === 200) {
if (res.data.length == 0) {
isLock = false;
}
var str = '';
res.data.forEach((res, i) => {
str += `
} else {
var str = '';
res.data.forEach((res, i) => {
str += `
<li class="${i % 2 == 0 ? '' : 'liAct'}">
<div class="left">
<p>${dateFormat(res.createTime, 'hh:mm:ss')}</p>
@@ -197,9 +201,11 @@ function listLuckyRecord (page) {
</div>
</li>
`
})
$('.record .record_in .ul1').append(str);
isLock = true;
})
$('.record .record_in .ul1 li').remove();
$('.record .record_in .ul1').append(str);
isLock = true;
}
} else {
toastMsg(res.message)
}
@@ -214,7 +220,6 @@ function listLuckyRecord (page) {
}
// 参与记录
function listRoundRecord (page) {
$('.record .record_in .ul2 li').remove();
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/listRoundRecord',
@@ -223,11 +228,11 @@ function listRoundRecord (page) {
if (res.code === 200) {
if (res.data.length == 0) {
isLock = false;
}
var str = '';
res.data.forEach((res, i) => {
str += `
<li class="liAct">
} else {
var str = '';
res.data.forEach((res, i) => {
str += `
<li class="${res.luckyUser ? '' : 'liAct'}">
<div class="left">
<p>${dateFormat(res.createTime, 'hh:mm:ss')}</p>
<i>${dateFormat(res.createTime, 'yyyy-MM-dd')}</i>
@@ -242,9 +247,11 @@ function listRoundRecord (page) {
</div>
</li>
`
})
$('.record .record_in .ul2').append(str);
isLock = true;
})
$('.record .record_in .ul2 li').remove();
$('.record .record_in .ul2').append(str);
isLock = true;
}
} else {
toastMsg(res.message)
}
@@ -262,6 +269,10 @@ $('.header .record_icon').click(function () {
page = 1;
isLock = true;
showLoading();
$('.record .record_in .recordtab div').removeClass('act2').removeClass('act1');
$('.record .record_in .recordtab div').eq(0).addClass('act1');
$('.record .record_in .ul1,.record .record_in .ul2').hide();
$('.record .record_in .ul1').show();
listLuckyRecord(page);
$('.record').show();
bodyScroolFun(true);
@@ -289,10 +300,9 @@ $('.record .record_in .ul1').scroll(function () {
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (isLock) {
// 请求下一页
if (canNext) {
listLuckyRecord(page++)
isLock = false;
}
page = page + 1;
listLuckyRecord(page)
isLock = false;
}
}
})
@@ -304,10 +314,9 @@ $('.record .record_in .ul2').scroll(function () {
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (isLock) {
// 请求下一页
if (canNext) {
listRoundRecord(page++)
isLock = false;
}
page = page + 1;
listRoundRecord(page)
isLock = false;
}
}
})
@@ -368,7 +377,7 @@ function magicStick (type, num) {
magicStickNum += num;
} else {
}
magicStickNum <= 1 ? magicStickNum = 1 : magicStickNum = magicStickNum;
magicStickNum <= 0 ? magicStickNum = 0 : magicStickNum = magicStickNum;
magicStickNum >= 99999999 ? magicStickNum = 99999999 : magicStickNum = magicStickNum;
$('.magicStick .magicStick_in .magicSticks b').text(magicStickNum * 100);
$('.magicStick .magicStick_in input').val(magicStickNum);
@@ -410,6 +419,9 @@ $('.magicStick').click(function () {
})
// 确认购买魔法棒按钮
$('.magicStick .magicStick_in .but').click(function () {
if (magicStickNum <= 0) {
return toastMsg('購買數量不能小於1')
}
buyStick(magicStickNum)
bodyScroolFun(false);
})
@@ -457,7 +469,7 @@ function wishing (type, num) {
wishingNum += num;
} else {
}
wishingNum <= 1 ? wishingNum = 1 : wishingNum = wishingNum;
wishingNum <= 0 ? wishingNum = 0 : wishingNum = wishingNum;
wishingNum >= 99999999 ? wishingNum = 99999999 : wishingNum = wishingNum;
$('.wishingPop .wishingPop_in input').val(wishingNum);
}
@@ -492,9 +504,11 @@ $('.wishingPop').click(function () {
})
// 许愿按钮
var roundId;
var configId;
$('.page1 ul').on('click', 'li .wishIngBut', function () {
var stockNum = $(this).attr('stockNum');
roundId = $(this).attr('roundId');
configId = $(this).attr('configId');
if (stockNum == 0) {
toastMsg('该礼物库存不足,无法进行许愿');
return;
@@ -504,35 +518,38 @@ $('.page1 ul').on('click', 'li .wishIngBut', function () {
// 确认许愿按钮
$('.wishingPop .wishingPop_in .but').click(function () {
console.log(wishingNum < mymagicStickNum);
if (wishingNum <= 0) {
return toastMsg('許願數量不能小於1')
}
if (wishingNum > mymagicStickNum) {
$('.magicStick .magicStick_in h3').text('可用魔法棒不足,请购买');
$('.magicStick').show();
bodyScroolFun(true);
} else {
promise(wishingNum, roundId);
promise(wishingNum, configId);
bodyScroolFun(false);
}
})
// 许愿接口
function promise (num, roundId) {
function promise (num, configId) {
showLoading()
networkRequest({
type: 'post',
url: urlPrefix + '/promiseStar/promise',
data: { num, roundId },
data: { num, promiseId: configId },
success (res) {
if (res.code === 200) {
wishingNum = 1;
$('.wishingPop .wishingPop_in input').val(wishingNum)
toastMsg('参与许愿成功')
getConfig();
}else if(res.code === 5003){
} else if (res.code === 5003) {
$('.magicStick .magicStick_in h3').text('可用魔法棒不足,请购买');
$('.magicStick').show();
} else {
toastMsg(res.message)
}
getConfig();
hideLoading(layerIndex)
},
error (err) {

View File

@@ -1,535 +0,0 @@
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'
})
}
var mymagicStickNum = 0;//魔法棒数量
var getRankType = 1;//1=今日奖励榜2=次数总榜
// 初始化函數
$(function () {
getInfoFromClient()
setTimeout(function () {
// 頁面全屏
if (browser.app) {
if (browser.android) {
window.androidJsObj.initShowNav(false)
} else {
window.webkit.messageHandlers.initShowNav.postMessage(0)
}
};
// 頂部返回事件
$('.back').click(() => {
if (browser.android) {
window.androidJsObj.closeWebView()
} else {
window.webkit.messageHandlers.closeWebView.postMessage(null)
}
})
getConfig();
}, 100)
})
// 配置接口
function getConfig () {
$('.page1 ul li').remove()
// showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/getConfig',
success (res) {
if (res.code === 200) {
mymagicStickNum = res.data.userStickNum;
$('.page1 .top .centon').text(mymagicStickNum)
var str = '';
res.data.roundList.forEach(res => {
str += `
<li>
<div class="giftBox">
<img src="${res.giftImg}" alt="" class="giftImg">
</div>
<div class="giftInfo">
<b>${res.giftName}</b>
<img src="./images/diamond.png" alt="" class="diamond">
<i>${res.giftPrice}</i>
</div>
<div class="inventory">庫存${res.stockNum}</div>
<div class="schedule">許願進度</div>
<div class="line">
<div class="line_in">
<img style="width: ${res.process / res.max * 100 >= 100 ? '100' : res.process / res.max}%;" src="./images/line.png" alt="">
</div>
<p>${res.process}/${res.max}</p>
</div>
<div class="wishIng">已許願${res.userInputNum}次</div>
<img src="./images/wishIngBut.png" alt="" class="wishIngBut" roundId=${res.roundId} stockNum=${res.stockNum}>
</li>
`
});
$('.page1 ul').append(src);
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網路錯誤,請退出重進')
}
})
}
// 刷新接口
$('.page1 .update').click(function(){
getConfig();
})
// 购买魔法棒接口
function getRank (type) {
$('.page2 .listBox li').remove()
showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/getRank',
data: { type },
success (res) {
if (res.code === 200) {
var str = '';
res.data.rankList.forEach((res, i) => {
str += `
<li class='li1${i + 1}'>
<div class="num num${i + 1}">${i + 1 > 3 ? res.ranking : ''}</div>
<img src="${res.avatar}" alt="" class="tx">
<div class="name">${res.nick}</div>
<div class="right">
<p>${res.score}次</p>
<b>許願獲獎次數</b>
</div>
</li>
`
})
$('.page2 .listBox').append(str);
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網路錯誤,請退出重進')
}
})
}
// Tab切换
$('.header .tabBox').on('click', ' div', function () {
var i = $(this).index() + 1;
$('.header .tabBox div').removeClass('act1').removeClass('act2');
$(this).addClass(`act${i}`);
$('.page1,.page2').hide();
$(`.page${i}`).show();
if (i == 2) {
getRank(getRankType);
}
})
// 榜单切换
$('.page2 .listTab div').click(function () {
var i = $(this).index() + 1;
$(this).parent('.listTab').removeClass('tab1').removeClass('tab2');
$(this).parent('.listTab').addClass(`tab${i}`)
getRankType = i;
getRank(getRankType);
})
// 打开活动规则弹窗
$('.header .rule_icon').click(function () {
$('.rule').show();
bodyScroolFun(true);
})
// 关闭活动规则弹窗
$('.rule').click(function () {
$('.rule').hide();
bodyScroolFun(false);
})
var page = 1;
var isLock = true;
// 中奖记录接口
function listLuckyRecord (page) {
$('.record .record_in .ul1 li').remove();
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/listLuckyRecord',
data: { page, pageSize: 10 },
success (res) {
if (res.code === 200) {
if (res.data.length == 0) {
isLock = false;
}
var str = '';
res.data.forEach((res, i) => {
str += `
<li class="${i % 2 == 0 ? '' : 'liAct'}">
<div class="left">
<p>${dateFormat(res.createTime, 'hh:mm:ss')}</p>
<i>${dateFormat(res.createTime, 'yyyy-MM-dd')}</i>
</div>
<div class="right">
<p>獲得:${res.gift.giftName}</p>
<i>${res.gift.goldPrice}鉆石)</i>
</div>
</li>
`
})
$('.record .record_in .ul1').append(str);
isLock = true;
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
isLock = true;
hideLoading(layerIndex)
toastMsg('網路錯誤,請退出重進')
}
})
}
// 参与记录
function listRoundRecord (page) {
$('.record .record_in .ul2 li').remove();
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/listRoundRecord',
data: { page, pageSize: 10 },
success (res) {
if (res.code === 200) {
if (res.data.length == 0) {
isLock = false;
}
var str = '';
res.data.forEach((res, i) => {
str += `
<li class="liAct">
<div class="left">
<p>${dateFormat(res.createTime, 'hh:mm:ss')}</p>
<i>${dateFormat(res.createTime, 'yyyy-MM-dd')}</i>
</div>
<div class="center">
<p>許願:${res.gift.giftName}</p>
<i>${res.luckyUser ? '已结束' : '進行中'}</i>
</div>
<div class="right">
<p>${res.luckyUser ? res.luckyUser.nick : ''}</p>
<i>${res.luckyUser ? '獲得' : ''}</i>
</div>
</li>
`
})
$('.record .record_in .ul2').append(str);
isLock = true;
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
isLock = true;
hideLoading(layerIndex)
toastMsg('網路錯誤,請退出重進')
}
})
}
// 打开参与记录按钮
$('.header .record_icon').click(function () {
page = 1;
isLock = true;
showLoading();
listLuckyRecord(page);
$('.record').show();
bodyScroolFun(true);
})
// 切换参与记录按钮
$('.record .record_in .recordtab div').click(function () {
var i = $(this).index() + 1;
$('.record .record_in .recordtab div').removeClass('act1').removeClass('act2');
$(this).addClass(`act${i}`);
$('.record .record_in .ul2,.record .record_in .ul1').hide();
console.log(i);
if (i == 1) {
listLuckyRecord(page)
} else {
listRoundRecord(page)
}
$(`.record .record_in .ul${i}`).show();
return false;
})
// 监听滚动1
$('.record .record_in .ul1').scroll(function () {
let scrollTop = $(this).scrollTop()
let scrollHeight = $('.record .record_in .ul1')[0].scrollHeight
let ulHeight = $(this).innerHeight()
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (isLock) {
// 请求下一页
if (canNext) {
listLuckyRecord(page++)
isLock = false;
}
}
}
})
// 监听滚动2
$('.record .record_in .ul2').scroll(function () {
let scrollTop = $(this).scrollTop()
let scrollHeight = $('.record .record_in .ul2')[0].scrollHeight
let ulHeight = $(this).innerHeight()
if (scrollTop + ulHeight + 100 >= scrollHeight) {
if (isLock) {
// 请求下一页
if (canNext) {
listRoundRecord(page++)
isLock = false;
}
}
}
})
// 关闭参与记录按钮
$('.record').click(function () {
$('.record').hide();
bodyScroolFun(false);
})
// 关闭去充值弹窗
$('.goToPay').click(function () {
$('.goToPay').hide();
bodyScroolFun(false);
})
// 关闭购买成功按钮
$('.buySuccess .buySuccess_in .buySuccessBut').click(function () {
$('.buySuccess').hide();
bodyScroolFun(false);
})
// 去充值按钮
$('.goToPay .goToPay_in .but').click(function () {
if (browser.app) {
if (browser.android) {
let channel = pubInfo.deviceInfo.channel;
console.log(pubInfo.deviceInfo);
if (channel == "google") {
window.androidJsObj.openChargePage(6);
} else {
window.androidJsObj.openChargePage(6);
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
}
} else if (browser.ios) {
let channel = pubInfo.deviceInfo.channel;
if (channel == "appstore") {
window.webkit.messageHandlers.openChargePage.postMessage(null);
} else {
window.webkit.messageHandlers.chargePayClickPage.postMessage(6);
window.location.href = urlPrefix + '/peko/modules/pay/index.html?channelType=4';
}
}
} else {
toastMsg('請在app內打開')
}
$('.goToPay').hide();
bodyScroolFun(false);
return false;
})
var magicStickNum = 1;
function magicStick (type, num) {
magicStickNum = Number($('.magicStick .magicStick_in input').val());
if (type == 1) {
// 加
magicStickNum++;
} else if (type == 2) {
// 减
magicStickNum--;
} else if (type == 3) {
// 快捷购买
magicStickNum += num;
} else {
}
magicStickNum <= 1 ? magicStickNum = 1 : magicStickNum = magicStickNum;
magicStickNum >= 99999999 ? magicStickNum = 99999999 : magicStickNum = magicStickNum;
$('.magicStick .magicStick_in .magicSticks b').text(magicStickNum * 100);
$('.magicStick .magicStick_in input').val(magicStickNum);
}
// 打开购买魔法棒弹窗
$('.page1 .top .but').click(function () {
$('.magicStick .magicStick_in h3').text('購買數量');
$('.magicStick').show();
bodyScroolFun(true);
})
// 魔法棒加弹窗
$('.magicStick .magicStick_in .add').click(function () {
magicStick(1)
return false;
})
// 魔法棒减弹窗
$('.magicStick .magicStick_in .decrease').click(function () {
magicStick(2)
return false;
})
// 魔法棒快捷购买弹窗
$('.magicStick .magicStick_in .quickAddition div').click(function () {
var num = Number($(this).attr('num'));
magicStick(3, num)
return false;
})
// 监听输入框的变化
$('.magicStick .magicStick_in input').on('input', function () {
magicStick();
})
// 魔法棒输入框弹窗
$('.magicStick .magicStick_in input').click(function () {
return false;
})
// 关闭购买魔法棒弹窗
$('.magicStick').click(function () {
$('.magicStick').hide();
bodyScroolFun(false);
})
// 确认购买魔法棒按钮
$('.magicStick .magicStick_in .but').click(function () {
buyStick(magicStickNum)
bodyScroolFun(false);
})
// 购买魔法棒
function buyStick (num) {
showLoading()
networkRequest({
type: 'get',
url: urlPrefix + '/promiseStar/buyStick',
data: { num },
success (res) {
if (res.code === 200) {
getConfig();
$('.buySuccess p').tetx(`魔法棒${num}`);
$('.buySuccess').show();
bodyScroolFun(true);
magicStickNum = 1;
$('.magicStick .magicStick_in .magicSticks b').text(0);
} else if (res.code === 31005) {
$('.goToPay').show();
bodyScroolFun(true);
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網路錯誤,請退出重進')
}
})
}
var wishingNum = 1;
function wishing (type, num) {
wishingNum = Number($('.wishingPop .wishingPop_in input').val());
if (type == 1) {
// 加
wishingNum++;
} else if (type == 2) {
// 减
wishingNum--;
} else if (type == 3) {
// 快捷购买
wishingNum += num;
} else {
}
wishingNum <= 1 ? wishingNum = 1 : wishingNum = wishingNum;
wishingNum >= 99999999 ? wishingNum = 99999999 : wishingNum = wishingNum;
$('.wishingPop .wishingPop_in input').val(wishingNum);
}
// 许愿加弹窗
$('.wishingPop .wishingPop_in .add').click(function () {
wishing(1)
return false;
})
// 许愿减弹窗
$('.wishingPop .wishingPop_in .decrease').click(function () {
wishing(2)
return false;
})
// 许愿快捷购买弹窗
$('.wishingPop .wishingPop_in .quickAddition div').click(function () {
var num = Number($(this).attr('num'));
wishing(3, num)
return false;
})
// 监听输入框的变化
$('.wishingPop .wishingPop_in input').on('input', function () {
wishing();
})
// 许愿输入框弹窗
$('.wishingPop .wishingPop_in input').click(function () {
return false;
})
// 关闭许愿弹窗
$('.wishingPop').click(function () {
$('.wishingPop').hide();
bodyScroolFun(false);
})
// 许愿按钮
var roundId;
$('.page1 ul li').on('click', '.wishIngBut', function () {
var stockNum = $(this).attr('stockNum');
roundId = $(this).attr('roundId');
if (stockNum == 0) {
toastMsg('该礼物库存不足,无法进行许愿');
return;
}
$('.wishingPop').show();
})
// 确认许愿按钮
$('.wishingPop .wishingPop_in .but').click(function () {
console.log(wishingNum < mymagicStickNum);
if (wishingNum > mymagicStickNum) {
$('.magicStick .magicStick_in h3').text('可用魔法棒不足,请购买');
$('.magicStick').show();
bodyScroolFun(true);
} else {
promise(wishingNum, roundId);
bodyScroolFun(false);
}
})
// 许愿接口
function promise (num, roundId) {
showLoading()
networkRequest({
type: 'post',
url: urlPrefix + '/promiseStar/promise',
data: { num, roundId },
success (res) {
if (res.code === 200) {
toastMsg('参与许愿成功')
} else {
toastMsg(res.message)
}
hideLoading(layerIndex)
},
error (err) {
hideLoading(layerIndex)
toastMsg('網路錯誤,請退出重進')
}
})
}

View File

@@ -0,0 +1,46 @@
var baba = document.querySelector('body');
baba.addEventListener('click', function (e) {
// $('body,html').css({ "width": "100%", "position": "relative", "overflow": "hidden" });
tianJia(e);
})
var erZi = [];
function tianJia (e) {
var sunZi = document.createElement('div');
sunZi.className = 'rabbit';
// sunZi.innerHTML = '<i class="iconfont icon-tuzi"></i>';
sunZi.innerHTML = '<img src="./images/star.png" alt="">';
baba.appendChild(sunZi);
erZi.push({
el: sunZi,
top: e.pageY - 30,
left: e.pageX - 20,
opacity: 1,
scale: 1,
color: `rgb(${255 * Math.random()},${255 * Math.random()},${255 * Math.random()})`
});
move();
};
function move () {
for (var i = 0; i < erZi.length; i++) {
if (erZi[i].opacity <= 0) {
baba.removeChild(erZi[i].el);
erZi.splice(i, 1);
return;
}
erZi[i].top--;
erZi[i].opacity = erZi[i].opacity - 0.02;
// erZi[i].scale = erZi[i].scale + 0.0001;
erZi[i].el.style.cssText = `
top: ${erZi[i].top}px;
left: ${erZi[i].left}px;
color: ${erZi[i].color};
opacity: ${erZi[i].opacity};
transform: scale(${erZi[i].scale});
position: absolute;
`
}
window.requestAnimationFrame(move);
// $('body,html').css({ "width": "100%", "position": "relative", "overflow": "auto" });
}