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) { //測試 let res = {"url":"#", "path":"./images/gift/gift_01.png"} $('body').on('click', '.dice-start', function(){ $('.dice-start, .dice-static').removeClass('show') $('.dice-end, .dice-dynamic').addClass('show') $.ajax({ url: _Project_Country + '/game/dice/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) $('.dice-start, .dice-static').removeClass('show') $('.dice-end, .dice-dynamic').addClass('show') setTimeout(function(){ $('body').append( `
` ) },3000); 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)