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) { //需要多給一個輪盤停止角度(stop-angle 0~360) let animateCircle = 500 //轉一圈500ms let res = {"url":"#", "path":"./images/gift/gift_01.png","stopAngle": 277} let stopTime = 2000 + (res.stopAngle / 360) * 500 $('body').on('click', '.roulette-btn, .roulette-disc', function(){ $.ajax({ url: _Project_Country + '/game/roulette/data/ajax_get_gift-p.php', dataType: 'json', async: false, method: 'POST', data: { Act_Game_ID: $("#Act_Game_ID").val() } }).done(function(res) { switch(res.status){ case "OK": $('.roulette-disc').addClass('spin'); setTimeout(function(){ $('.roulette-disc').removeClass('spin').css({ "transform":"rotate("+res.stopAngle+"deg)" }) },stopTime); setTimeout(function(){ $('body').append( `
` ); },stopTime + 1000); 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; }; }); }); $('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)