App.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div>
  3. <router-view></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. replace: false,
  9. data() {
  10. return {
  11. home: {
  12. visible: true
  13. },
  14. station: {
  15. visible: false
  16. },
  17. register: {
  18. email: "",
  19. username: "",
  20. password: ""
  21. },
  22. login: {
  23. email: "",
  24. password: ""
  25. },
  26. likes: [],
  27. dislikes: [],
  28. loggedIn: true,
  29. groups: [
  30. {
  31. id: "lu08gw56571r4497wrk9",
  32. name: "Official Rooms",
  33. rooms: [
  34. { id: "73qvw65746acvo8yqfr", thumbnail: "https://lh6.googleusercontent.com/-ghASz3s6yL4/AAAAAAAAAAI/AAAAAAAAALc/tFblPp2myu0/s0-c-k-no-ns/photo.jpg", name: "Country", description: "Johnny Cash - I Walk The Line", users: 10 },
  35. { id: "enxcysmhn1k7ld56ogvi", thumbnail: "http://66.media.tumblr.com/1734069af425e491fae7deae0a19869f/tumblr_o0i0xmIYrF1v421f2o1_1280.jpg", name: "Pop", description: "Sia - Cheap Thrills", users: 14 },
  36. { id: "kqa99gbva7lij05dn29", thumbnail: "http://www.youredm.com/wp-content/uploads/2014/09/taking-you-higher.jpg", name: "Chill", description: "MrSuicideSheep - Taking you higher", users: 13 },
  37. { id: "w19hu791iiub6wmjf9a4i", thumbnail: "http://edmsauce.wpengine.netdna-cdn.com/wp-content/uploads/2012/12/Deadmau5-album-title-goes-here.jpg", name: "EDM", description: "Deadmau5 - There Might Be Coffee", users: 13 }
  38. ]
  39. },
  40. {
  41. id: "g2b8v03xaedj8ht1emi",
  42. name: "Trending Rooms",
  43. rooms: [
  44. { id: "73qvw65746acvo8yqfr", thumbnail: "https://lh6.googleusercontent.com/-ghASz3s6yL4/AAAAAAAAAAI/AAAAAAAAALc/tFblPp2myu0/s0-c-k-no-ns/photo.jpg", name: "Country", description: "Johnny Cash - I Walk The Line", users: 10 },
  45. { id: "enxcysmhn1k7ld56ogvi", thumbnail: "http://66.media.tumblr.com/1734069af425e491fae7deae0a19869f/tumblr_o0i0xmIYrF1v421f2o1_1280.jpg", name: "Pop", description: "Sia - Cheap Thrills", users: 14 },
  46. { id: "kqa99gbva7lij05dn29", thumbnail: "http://www.youredm.com/wp-content/uploads/2014/09/taking-you-higher.jpg", name: "Chill", description: "MrSuicideSheep - Taking you higher", users: 13 },
  47. { id: "w19hu791iiub6wmjf9a4i", thumbnail: "http://edmsauce.wpengine.netdna-cdn.com/wp-content/uploads/2012/12/Deadmau5-album-title-goes-here.jpg", name: "EDM", description: "Deadmau5 - There Might Be Coffee", users: 13 }
  48. ]
  49. }
  50. ]
  51. }
  52. },
  53. methods: {
  54. logout() {
  55. $.ajax({
  56. method: "GET",
  57. url: "/users/logout",
  58. dataType: "json",
  59. complete: function (msg) {
  60. alert("Logged in!");
  61. location.reload();
  62. }
  63. });
  64. }
  65. },
  66. ready: function () {
  67. let local = this;
  68. local.socket = io();
  69. local.socket.on("ready", status => {
  70. local.loggedIn = status;
  71. local.socket.emit("/user/ratings", result => {
  72. if (!result.err) {
  73. local.likes = result.likes;
  74. local.dislikes = result.dislikes;
  75. }
  76. });
  77. });
  78. },
  79. events: {
  80. 'register': function() {
  81. console.log('registered');
  82. $.ajax({
  83. method: "POST",
  84. url: "/users/register",
  85. data: JSON.stringify({
  86. email: this.register.email,
  87. username: this.register.username,
  88. password: this.register.password,
  89. recaptcha: grecaptcha.getResponse()
  90. }),
  91. contentType: "application/json; charset=utf-8",
  92. dataType: "json",
  93. success: function (msg) {
  94. if (msg) console.log(msg);
  95. alert("Registered!");
  96. //do something
  97. },
  98. error: function (err) {
  99. if (err) console.log(err);
  100. alert("Not registered!");
  101. //do something else
  102. }
  103. });
  104. },
  105. 'login': function() {
  106. console.log('login');
  107. $.ajax({
  108. method: "POST",
  109. url: "/users/login",
  110. data: JSON.stringify({
  111. email: this.login.email,
  112. password: this.login.password
  113. }),
  114. contentType: "application/json; charset=utf-8",
  115. dataType: "json",
  116. success: function (msg) {
  117. if (msg) console.log(msg);
  118. alert("Logged in!");
  119. //do something
  120. },
  121. error: function (err) {
  122. if (err) console.log(err);
  123. alert("Not logged in!");
  124. //do something else
  125. }
  126. });
  127. }
  128. }
  129. }
  130. </script>