base.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. base = function () {
  2. //private menbers
  3. let isActivityOver = false;
  4. let userProfile = null;
  5. let userData = null;
  6. //private methods
  7. function init() {
  8. console.log('base init')
  9. // 判斷是否活動已結束
  10. // entranceTimer();
  11. // 用戶登入
  12. GameService.getInstanse().init().then((profile) => {
  13. $(".wapper-loading .loading__text").text("LINE登入中");
  14. // console.log(profile)
  15. userProfile = profile;
  16. getProfile();
  17. // 正式用 記得開
  18. GameService.getInstanse().userLogin()
  19. .then(_res => {
  20. console.log("_res: ",_res);
  21. $(".wapper-loading").remove();
  22. gsap.to(".wrapper", {
  23. duration: 0.5,
  24. autoAlpha: 1
  25. });
  26. userData = GameService.getInstanse().getUserData();
  27. console.log("userData: ",userData)
  28. if(userData === null) {
  29. register.LinePicHandler(profile.pictureUrl)
  30. sectionFadeIn(".register");
  31. }else {
  32. sectionFadeIn(".passport");
  33. passport.buildPassportHandler(userData)
  34. }
  35. })
  36. })
  37. // 返回表單頁
  38. $(".backform").on("click", function(){
  39. console.log("backform click")
  40. sectionFadeOut(".methods");
  41. sectionFadeIn(".register");
  42. });
  43. // 前往活動辦法頁
  44. $(".goToActivity").on("click", function(){
  45. console.log("backform click")
  46. sectionFadeOut(".register");
  47. sectionFadeIn(".methods");
  48. });
  49. }
  50. // 活動期間判斷
  51. function entranceTimer() {
  52. var _nowDate = new Date();
  53. var _endDate = new Date("2023/09/08 23:29");
  54. if (_nowDate.getTime() >= _endDate.getTime()) {
  55. isActivityOver = true;
  56. // 活動結束後提供查詢
  57. // myAlert(``);
  58. console.log("活動已結束")
  59. } else {
  60. isActivityOver = false;
  61. console.log("活動進行中")
  62. }
  63. }
  64. function getProfile() {
  65. return userProfile
  66. }
  67. // 提醒popup
  68. function myAlert(_msg) {
  69. $('#agreeAccModal').modal('hide');
  70. $('#exampleModal').find('.alert-message').html(_msg);
  71. $('#exampleModal').modal('show');
  72. $(".modal-backdrop.show").css("backdrop-filter", "blur(2px)");
  73. $(".modal-backdrop.show").css("-webkit-backdrop-filter", "blur(2px)")
  74. }
  75. // page進入動態
  76. function sectionFadeIn(el) {
  77. // $(el).fadeIn();
  78. gsap.to(el, {
  79. duration: 0.3,
  80. autoAlpha: 1
  81. })
  82. }
  83. // page離開動態
  84. function sectionFadeOut(el) {
  85. // $(el).fadeOut();
  86. gsap.to(el, {
  87. duration: 0.3,
  88. autoAlpha: 0
  89. })
  90. }
  91. {
  92. $(document).ready(function () {
  93. init();
  94. });
  95. }
  96. //public
  97. return {
  98. sectionFadeIn: function(el) {
  99. sectionFadeIn(el)
  100. },
  101. sectionFadeOut: function(el) {
  102. sectionFadeOut(el)
  103. },
  104. myAlert: function (_msg) {
  105. myAlert(_msg);
  106. },
  107. getProfile,
  108. };
  109. };
  110. var base = new base();