var _Project_Country = ""; // ========================================================== // 購物後遊戲跳窗 // ========================================================== ;(function($) { $('body').on('click', '.game-model, .game-model-closer', function(e) { if(e.currentTarget === e.target) { $('.game-model').fadeOut(400) } }) })($) // ========================================================== // 扭蛋跳窗 // ========================================================== ;(function(jQuery, $, window, document) { //讓球隨機顏色 球尺寸166x166 let ballNum = Math.floor(Math.random() * 6 + 1) $(".machine-ball").css({"background-image":"url('"+$("#ball"+ballNum).val()+"')"}) let modelStep = 0 $('body').on('click', '.act_game_click_bt', function(e) { e.preventDefault() $.ajax({ url: _Project_Country + '/game/gacha/data/ajax_get_gift-p.php', dataType: 'json', async: false, method: 'POST', data: { Act_Game_ID: $("#Act_Game_ID").val() } }).done(function(res) { //console.log(res) switch(res.status){ case "OK": modelStep = 1 //modelCheck(modelStep) $('.hint-hand').hide() $('.gacha-machine-step2').css({"z-index":"2"}) setTimeout(function(){ $('.gacha-machine-step3').css({"z-index":"3"}) },200) setTimeout(function(){ $('.gacha-machine-step4').css({"z-index":"4"}) },700) setTimeout(function(){ $('.gacha-machine-step5').css({"z-index":"5"}) },1200) setTimeout(function(){ $('.machine-ball').addClass('roll') },1700) setTimeout(function(){ $('body').append( `
` ) },3700) break; case "TODAY_PLAYED": alert('今天已玩過遊戲了'); $(".game-model-closer").trigger("click"); break; case "ACT_PLAYED": alert('已參加過該活動'); $(".game-model-closer").trigger("click"); break; case "MEMBER_NOT_LOGIN": alert('須登入會員才可遊戲'); window.location = _Project_Country + '/member-login/'; break; case "ORDER_NOT_FULL": alert('訂單金額不符合遊戲條件'); $(".game-model-closer").trigger("click"); break; case "GAME_OVER": case "ERROR": alert('遊戲已結束'); $(".game-model-closer").trigger("click"); break; } }).fail(function(x, y, z) { //console.log(x) //console.log(y) //console.log(z) }) }) $('body').on('click', '.game-model-closer', function(e) { modelStep = 0 //modelCheck(modelStep) $(this).parents('.gmodel-wrapper').remove() }) /*function modelCheck(step) { if(step) { $('body, #game-wrapper').addClass('theme-stock') } else { $('body, #game-wrapper').removeClass('theme-stock') } }*/ })(jQuery, $, window, document)