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 modelStep = 0 $('body').on('click', '.act_game_click_bt', function(e) { e.preventDefault() $.ajax({ url: _Project_Country + '/game/red-envelope/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) $('body').append(`
`); 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)