base = function () { //private menbers let isActivityOver = false; let userProfile = null; let userData = null; //private methods function init() { console.log('base init') // 判斷是否活動已結束 // entranceTimer(); // 用戶登入 GameService.getInstanse().init().then((profile) => { $(".wapper-loading .loading__text").text("LINE登入中"); // console.log(profile) userProfile = profile; getProfile(); // 正式用 記得開 GameService.getInstanse().userLogin() .then(_res => { console.log("_res: ",_res); $(".wapper-loading").remove(); gsap.to(".wrapper", { duration: 0.5, autoAlpha: 1 }); userData = GameService.getInstanse().getUserData(); console.log("userData: ",userData) if(userData === null) { register.LinePicHandler(profile.pictureUrl) goToRegister(); }else { passport.buildPassportHandler(userData) register.insertFromData(userData); goToPassport(); GameService.getInstanse().sendCompleteMessage(); } // 測試用 // goToPassport(); // passport.buildPassportHandler(userData) // register.insertFromData(userData); // ------------------------------------------ // goToRegister(); // register.LinePicHandler(profile.pictureUrl) }).catch(error => { alert("[BasePage Error - userLogin]: ", error); }) }).catch(error => { alert("[BasePage Error - init]: ", error); }) // 返回表單頁 $(".backform").on("click", function(){ // console.log("backform click"); goToRegister(); }); // 前往活動辦法頁 $(".goToActivity").on("click", function(){ // console.log("goToActivity click"); goToMethods(); }); } // 活動期間判斷 function entranceTimer() { var _nowDate = new Date(); var _endDate = new Date("2023/09/08 23:29"); if (_nowDate.getTime() >= _endDate.getTime()) { isActivityOver = true; // 活動結束後提供查詢 // myAlert(``); console.log("活動已結束") } else { isActivityOver = false; console.log("活動進行中") } } function getProfile() { return userProfile } // 提醒popup function myAlert(_msg) { $('#agreeAccModal').modal('hide'); $('#exampleModal').find('.alert-message').html(_msg); $('#exampleModal').modal('show'); $(".modal-backdrop.show").css("backdrop-filter", "blur(2px)"); $(".modal-backdrop.show").css("-webkit-backdrop-filter", "blur(2px)") } function goToRegister() { sectionFadeIn(".register"); sectionFadeOut(".passport"); sectionFadeOut(".methods"); } function goToPassport() { sectionFadeIn(".passport"); sectionFadeOut(".methods"); sectionFadeOut(".register"); } function goToMethods() { sectionFadeIn(".methods"); sectionFadeOut(".passport"); sectionFadeOut(".register"); } // page進入動態 function sectionFadeIn(el) { $(el).show(); gsap.to(el, { duration: 0.3, autoAlpha: 1 }) } // page離開動態 function sectionFadeOut(el) { gsap.to(el, { duration: 0.3, autoAlpha: 0, onComplete: function() { $(el).hide(); } }) } { $(document).ready(function () { init(); }); } //public return { sectionFadeIn: function(el) { sectionFadeIn(el) }, sectionFadeOut: function(el) { sectionFadeOut(el) }, myAlert: function (_msg) { myAlert(_msg); }, getProfile, goToRegister, goToPassport, goToMethods, }; }; var base = new base();