Skip to content

Instantly share code, notes, and snippets.

@brownsugar
Created October 19, 2020 18:39
Show Gist options
  • Save brownsugar/7488b4d1e7d84f724ec012d6034bba83 to your computer and use it in GitHub Desktop.
Save brownsugar/7488b4d1e7d84f724ec012d6034bba83 to your computer and use it in GitHub Desktop.
// class default
// 基本樣式的class
var defaultObj = {
addClass: "default",
hasCloseBtn: true,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
$.gbox.close();
}
}]
}
var alterObj = {
addClass: "default",
hasCloseBtn: false,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
$.gbox.open(checkAccountRender(gameaccountlist), accountObj);
}
}]
}
// class listlb
// 清單樣式的class
var listObj = {
addClass: "listlb",
hasCloseBtn: true,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
$.gbox.close();
}
}]
}
var redirectObj = {
addClass: "default",
hasCloseBtn: true,
hasActionBtn: true,
afterClose: function () {
location.href = errorurl;
}
}
// 已完成參加 跳窗
var completeHTML = '<div class="lb-bold">已完成參加</div>';
// $.gbox.open(completeHTML,defaultObj);
// 今日已參與活動 跳窗
var todayHTML = '<div class="lb-bold">今日已參與活動,次數將於00點重置。</div>';
// $.gbox.open(todayHTML,defaultObj);
var checkObj = {
addClass: "default",
hasCloseBtn: false,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '我在想想',
id: 'success',
class: "lb-btn__cancel",
click: function () {
$.gbox.open(checkAccountRender(gameaccountlist), accountObj);
}
},
{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
joinGame();
}
}]
}
// 確定要使用 跳窗
function checkRender(account) {
var checkHTML =
'<div class="lb-bold">確定要使用</div>\
<div class="lb-text-box">\
<div class="lb-text">'+ account + '</div>\
</div>\
<div class="lb-bold">參加嗎?</div>\
<div class="lb-notice">\
<span>※注意事項:</span>\
<span>虛寶獎勵將會發送至選定的遊戲帳號內,</span>\
<span>選擇後將不可再修改。</span>\
</div>\
';
return checkHTML;
}
// $.gbox.open(checkRender("一二三四五六七八九十一二三四五六七八九十"),checkObj);
var accountObj = {
addClass: "listlb",
hasCloseBtn: false,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
ServiceAccount = $('input:radio:checked[name="account"]').val();
ServiceAccountId = $('input:radio:checked[name="account"]').attr('id');
if (ServiceAccount == undefined || ServiceAccount == '') {
PopUpAlert('請選擇遊戲帳號', alterObj);
return;
}
else {
getGameAccountData(ServiceAccount, ServiceAccountId);
}
}
}]
}
function checkAccountRender(data) {
var html = "";
for (var i = 0; i < data.length; i++) {
html +=
'<div class="lb-list__radio-group">\
<input id="'+ data[i].ServiceAccountDisplayName + '" class="lb-list__radio" type="radio" name="account" value="' + data[i].ServiceAccountID + '" />\
<label for="'+ data[i].ServiceAccountDisplayName + '" class="lb-list__radio-label">\
<span class="lb-list__radio-style"></span>\
<span class="lb-list__radio-text">'+ data[i].ServiceAccountDisplayName + '</span>\
</label>\
</div>\
';
}
var checkAccountHTML =
'<div class="lb-title">\
<span>請選擇</span>\
<spa>要參加抽鬼牌的遊戲帳號</spa>\
</div>\
<div class="lb-list lb-list--scroll">'+ html + '</div>\
<div class="lb-notice">\
<span>※注意事項:</span>\
<span>虛寶獎勵將會發送至選定的遊戲帳號內,</span>\
<span>選擇後將不可再修改。</span>\
</div>\
';
return checkAccountHTML
}
// $.gbox.open(checkAccountRender(accountList),accountObj);
// 活動獎勵清單
var eventListObj = {
addClass: "listlb",
hasCloseBtn: true,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
$.gbox.close();
}
}]
}
var eventList = [{
event: "遊俠X(永久)"
}, {
event: "阿緹密斯X(永久)"
}, {
event: "尖峰 SR-R (永久)"
}, {
event: "鈦金齒輪1個"
}, {
event: "GASH 100點"
}, {
event: "GASH 200點"
}, {
event: "GASH 500點"
}]
function eventListRender(data) {
var html = "";
for (var i = 0; i < data.length; i++) {
html +=
'<div class="lb-list__event-text">' + data[i].event + '</div>\
';
}
var eventListHTML =
'<div class="lb-title">\
<span>活動獎勵清單</span>\
</div>\
<div class="lb-list lb-list--scroll">'+ html + '</div>\
';
return eventListHTML
}
// $.gbox.open(eventListRender(eventList),eventListObj);
$(".main-btn__event-list").on("click", function () {
$.gbox.open(eventListRender(eventList), eventListObj);
})
// 我的中獎清單
var myGiftListObj = {
addClass: "listlb",
hasCloseBtn: true,
hasActionBtn: true,
afterClose: function () {
$.gbox.close();
},
actionBtns: [{
text: '確定',
id: 'success',
class: "lb-btn__success",
click: function () {
$.gbox.close();
}
}]
}
function myGiftRender(data) {
var html = "";
for (var i = 0; i < data.length; i++) {
html +=
'<div class="lb-list__mygift-group">\
<span class="lb-list__mygift-date">'+ data[i].LogTime + '</span>\
<span class="lb-list__mygift-gift">'+ data[i].ItemName + '</span>\
</div>\
';
}
var myGiftHTML =
'<div class="lb-title">\
<span>我的中獎清單</span>\
</div>\
<div class="lb-list lb-list--scroll">'+ html + '</div>\
';
return myGiftHTML
}
// $.gbox.open(myGiftRender(myGiftList),myGiftListObj);
$(".main-btn__my-list").on("click", function () {
GetWinLog(MainAccountID, StarAccount, ServiceAccount);
//$.gbox.open(myGiftRender(myGiftList), myGiftListObj);
})
function checkPoker(arr) {
return arr.every(function (v, i) {
return arr[0] == v;
})
}
// ========================== 抽牌 ==============================
var playNum = 0;
var cardArr = [];
var play = false;
$(".main-card.off").on("click", function () {
// 當抽牌次數大於兩次 或 再抽牌狀態下 當下不能抽牌
if (play) {
return
}
if (playNum >= 2) {
$.gbox.open(todayHTML, defaultObj);
return;
}
// 防止再次點擊同一張牌
if (!$(this).hasClass("off")) {
return
}
// 抽牌的狀態下防止再次點擊抽牌
play = true;
// 抽牌次數遞增
playNum++;
// 移除記號
$(this).removeClass("off")
// 重新排列牌組
if ($(".main-card.off").length > 1) {
gsap.to($(".main-card.off").eq(0), {
top: "6%",
left: "13%",
rotation: -10,
duration: .5
})
gsap.to($(".main-card.off").eq(1), {
top: "6%",
left: "45%",
rotation: 10,
duration: .5
})
}
// 沒有得獎文字
// $(".main-content__my-get-title").text("哎呀真可惜!沒中獎!")
// $(".main-content__my-get-info").text("明天再接再厲!")
// 得獎文字
// $(".main-content__my-get-title").text("恭喜獲得")
// $(".main-content__my-get-info").text("一二三四五六七八九十一二三")
// 中一般獎項的文字
// $(".main-content__my-notice").text("獎勵將於2個小時內發放至遊戲內禮物盒。")
// 中gash點數的文字
// $(".main-content__my-notice").text("GASH點數將於11/30前發放。")
var _this = $(this)
doPoker(playNum, _this);
})
function playPoker(currnt, data, callback) {
// 當前抽牌
var cardThis = currnt;
var cardGet = data.ItemInfo.card;
// 判斷兩張是否一樣
cardArr.push(cardGet);
// 獲取卡片內容後增加樣式
cardThis.find(".back").addClass(cardGet);
// 抽牌時 說明欄會變成空
$(".main-content-box").addClass("in");
// 提高當前抽牌的層級
gsap.set(currnt, {
zIndex: 2
})
// 進入抽牌動畫 第一步驟
// 大大的展示出玩家都到的牌
gsap.to(cardThis, {
left: "50%",
x: "-50%",
top: 10,
scale: 1.3,
rotation: 0,
durtation: .4,
onComplete: function () {
// 第二步驟
// 翻牌展示出玩家的牌
gsap.to(cardThis, {
force3D: true,
rotationY: -180,
durtation: 0.3,
onComplete: function () {
// 第三步驟
// 牌移到下方區塊
gsap.to(cardThis, {
scale: .6,
y: "150%",
opacity: 0,
display: "none",
duration: .4,
})
// 下方區塊放置玩家抽到的牌
$(".main-content__my-card").eq(playNum - 1).addClass(cardGet);
$(".main-content__my-card").eq(playNum - 1).addClass("show");
// 兩次抽牌結束
if (playNum == 2) {
setTimeout(function () {
// 顯示出獎勵名稱區塊
$(".main-content__my-box").addClass("done")
// 判斷抽取狀態有沒有中獎
if (data.IsWin == 1) {
$(".main-content__my-get-title").text("恭喜獲得")
$(".main-content__my-get-info").text(data.ItemInfo.ItemName)
// 判斷獎品是 道具 還是 gash
if (data.ItemInfo.ItemName.indexOf("GASH") >= 0) {
$(".main-content__my-notice").text("GASH點數將於11/30前發放。")
} else {
$(".main-content__my-notice").text("獎勵將於2個小時內發放至遊戲內禮物盒。")
}
} else {
$(".main-content__my-get-title").text("哎呀真可惜!沒中獎!")
$(".main-content__my-get-info").text("明天再接再厲!")
}
}, 800);
// 可以傳入 function
if (callback) {
callback()
}
}
// 抽牌狀態預設
play = false;
}
})
}
})
}
// 畫面載入執行他
// playPokerComplete(data)
function playPokerComplete(data) {
console.log(data);
$(".main-content-box").addClass("in");
data.ItemInfo.forEach(function (v, i) {
$(".main-card").eq(i).hide().removeClass("off")
$(".main-content__my-card").eq(i).addClass(v.card);
$(".main-content__my-card").eq(i).addClass("show");
})
// 顯示出獎勵名稱區塊
$(".main-content__my-box").addClass("done")
// 判斷抽取狀態有沒有中獎
if (data.IsWin == 1) {
$(".main-content__my-get-title").text("恭喜獲得")
$(".main-content__my-get-info").text(data.ItemInfo[1].ItemName)
// 判斷獎品是 道具 還是 gash
if (data.ItemInfo[1].ItemName.indexOf("GASH")>=0) {
$(".main-content__my-notice").text("GASH點數將於11/30前發放。")
} else {
$(".main-content__my-notice").text("獎勵將於2個小時內發放至遊戲內禮物盒。")
}
} else {
$(".main-content__my-get-title").text("哎呀真可惜!沒中獎!")
$(".main-content__my-get-info").text("明天再接再厲!")
}
//play = true;
playNum = 2;
}
var errorurl = "https://bfweb.beanfun.com/";
var gameaccountlist = [];
var gameaccountdata = [];
var stockid = '';
$(document).ready(function () {
if (ErrMsg != '') {
PopUpAlert(ErrMsg, redirectObj);
return;
}
//BGOSDK
BGO.check_app_exist(function (res) {
if (res.result !== null && res.result !== undefined && res.result === 'ok') {
}
else {
PopUpAlert('『系統異常<br/> 請嘗試關閉beanfun!並重新開啟<br/> 若仍無法排除請洽客服人員<br/> (錯誤碼: 1911) 』', redirectObj);
return;
}
});
if (IsJoin == 'False') {
getGameAccountList(MainAccountID);
}
else {
CheckIsPlay(MainAccountID, StarAccount, ServiceAccount);
}
});
//帳號列表
function getGameAccountList(mainAccount) {
loadding(true);
$.ajax({
type: "POST",
url: "index.aspx/GetGameAccountList",
data: JSON.stringify({ MainAccountID: mainAccount }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d.IsSuccess == false) {
loadding(false);
PopUpAlert(result.d.ResultMessage, redirectObj);
}
else {
loadding(false);
gameaccountlist = result.d.ResultData;
$.gbox.open(checkAccountRender(gameaccountlist), accountObj);
}
}
});
}
//帳號資訊
function getGameAccountData(serviceAccount, ServiceAccountId) {
loadding(true);
$.ajax({
type: "POST",
url: "index.aspx/GetGameAccountData",
data: JSON.stringify({ ServiceAccount: serviceAccount }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d.IsSuccess == false) {
loadding(false);
PopUpAlert(result.d.ResultMessage, alterObj);
}
else {
loadding(false);
gameaccountdata = result.d.ResultData;
$.gbox.open(checkRender(ServiceAccountId), checkObj);
}
}
});
}
//參加活動
function joinGame() {
loadding(true);
$.ajax({
type: "POST",
url: "index.aspx/InsertJoinLog",
data: JSON.stringify(
{
StarAccount: StarAccount,
MainAccountID: MainAccountID,
ServiceAccount: ServiceAccount,
AccountData: gameaccountdata
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d.IsSuccess == false) {
loadding(false);
PopUpAlert(result.d.ResultMessage, defaultObj);
}
else {
loadding(false);
$.gbox.open(completeHTML, defaultObj);
}
}
});
}
//取得獎項
function doPoker(playcount, curr) {
loadding(true);
$.ajax({
type: "POST",
url: "index.aspx/PlayPoker",
data: JSON.stringify(
{
PlayCount: playcount,
StockID: stockid,
StarAccount: StarAccount,
MainAccountID: MainAccountID,
ServiceAccount: ServiceAccount
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d.IsSuccess == false) {
loadding(false);
PopUpAlert(result.d.ResultMessage, defaultObj);
}
else {
loadding(false);
stockid = result.d.ResultData.ItemInfo.StockID;
if (result.d.ResultMessage == null) {
playPoker(curr, result.d.ResultData, null)
}
else {
playPoker(curr, result.d.ResultData, PopUpAlert(result.d.ResultMessage, defaultObj))
}
}
}
});
}
//查詢中獎記錄
function GetWinLog(MainAccountID, StarAccount, ServiceAccount) {
loadding(true);
$.ajax({
type: "POST",
url: "index.aspx/GetWinLog",
data: JSON.stringify(
{
MainAccountID: MainAccountID,
StarAccount: StarAccount,
ServiceAccount: ServiceAccount
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d.IsSuccess == false) {
loadding(false);
PopUpAlert(result.d.ResultMessage, defaultObj);
}
else {
loadding(false);
$.gbox.open(myGiftRender(result.d.ResultData), myGiftListObj);
}
}
});
}
//確認今日是否已完成抽牌
function CheckIsPlay(MainAccountID, StarAccount, ServiceAccount) {
loadding(true);
$.ajax({
type: "POST",
url: "index.aspx/CheckIsPlay",
data: JSON.stringify(
{
MainAccountID: MainAccountID,
StarAccount: StarAccount,
ServiceAccount: ServiceAccount
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
if (result.d.IsSuccess == false) {
loadding(false);
PopUpAlert(result.d.ResultMessage, defaultObj);
}
else {
loadding(false);
if (result.d.ResultData.ItemInfo.length != 0) {
playPokerComplete(result.d.ResultData);
}
}
}
});
}
// PopUp Alert
function PopUpAlert(msg, obj) {
$.gbox.open(msg, obj);
}
//Loading
function loadding(load) {
if (load) {
$('body').append('<div class="loadding-module"><div class="loadding"></div></div>');
var i = 0;
setInterval(function () {
i++;
$('.loadding').css('-ms-transform', "rotate(" + i + "deg)");
$('.loadding').css('-webkit-transform', "rotate(" + i + "deg)");
$('.loadding').css('transform', "rotate(" + i + "deg)");
}, 5)
} else {
$('.loadding-module').remove();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment