Files
peko-h5/view/peko/modules/act-treasureSnatching/js/rule.js

135 lines
5.3 KiB
JavaScript
Raw Normal View History

2023-03-07 19:01:52 +08:00
// 封装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 urlPrefix = getUrlPrefix();
let browser = checkVersion()
let env = EnvCheck();
if (env == 'test') {
new VConsole();
}
// 初始化函数
$(function () {
getInfoFromClient()
setTimeout(function () {
// 返回事件
$('.back').click(() => {
if (browser.app) {
if (browser.android) {
window.androidJsObj.closeWebView();
} else {
window.webkit.messageHandlers.closeWebView.postMessage(null);
}
} else {
toastMsg('请在APP内打开')
}
})
2023-10-23 10:46:33 +08:00
if (browser.android) {
console.log(JSON.parse(pubInfo.deviceInfo));
if (JSON.parse(pubInfo.deviceInfo).appVersionCode >= 210) {
$('.tab2 img').attr('src', './images/rule_rule2.png')
}
} else if (browser.ios) {
console.log(pubInfo.deviceInfo);
// console.log(pubInfo.deviceInfo.appVersion.replace(".",""));
console.log(pubInfo.deviceInfo.appVersion.replace(".", "").replace(".", ""));
if (pubInfo.deviceInfo.appVersion.replace(".", "").replace(".", "") >= 20100) {
$('.tab2 img').attr('src', './images/rule_rule2.png')
}
}
2023-03-07 19:01:52 +08:00
getPoolList();
}, 100)
$('body,html').css('padding-top', `${(document.documentElement.clientWidth / 750 * 120) / 75}rem`);
})
// 奖池列表接口
function getPoolList () {
$('.tab1 li').remove();
showLoading()
networkRequest({
type: 'GET',
url: urlPrefix + '/act/seize-treasure/draw/pool/list',//item
data: { orderType: 2 },
success (res) {
if (res.code === 200) {
var str = '';
res.data.forEach((res, i) => {
str += `
<li style="display: ${res.rewardShowValue <= 0 ? 'none' : 'block'}">
<div class="txBox">
<img class='txBoxImg${i + 1}' src="${res.rewardPicUrl}" alt="">
</div>
<div class="giftName">${res.rewardName}</div>
<img src="./images/zs.png" alt="" class="icon">
<div class="score">${res.rewardShowValue}</div>
<div class="probability">${res.showRatio / 1000}%</div>
</li>
`
});
$('.tab1').append(str);
res.data.forEach((res, i) => {
if (res.rewardType == "activityProps") {
//活动道具
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.4666666667rem", "height": "1.4666666667rem", "top": "0.9066666667rem" });
} else if (res.rewardType == "gift") {
//礼物
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.4666666667rem", "height": "1.4666666667rem", "top": "0.9066666667rem" });
} else if (res.rewardType == "namePlate") {
//铭牌
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.6rem", "height": "0.5rem", "top": "1rem" });
} else if (res.rewardType == "car") {
//座驾
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.8rem", "height": "1.3rem", "top": "0.9066666667rem" });
} else if (res.rewardType == "headwear") {
//头饰
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.4666666667rem", "height": "1.4666666667rem", "top": "0.9066666667rem" });
} else if (res.rewardType == "chatBubble") {
//气泡
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.4666666667rem", "height": "1.4666666667rem", "top": "0.9066666667rem" });
} else if (res.rewardType == "infoCard") {
//资料卡
$(`.tab1 li .txBox .txBoxImg${i + 1}`).css({ "width": "1.4rem", "height": "1rem", "top": "1.1rem" });
}
})
hideLoading(layerIndex)
} else {
toastMsg(res.message)
hideLoading(layerIndex)
}
},
error (err) {
hideLoading(layerIndex)
toastMsg('网络错误,请退出重进')
}
})
}
// =======================规则页=======================
$('.tab div').click(function () {
var i = $(this).index() + 1;
$(this).addClass('active').siblings().removeClass('active');
if (i == 1) {
$('.tab1').show();
$('.tab2').hide();
} else {
$('.tab2').show();
$('.tab1').hide();
}
})