123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- 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();
|