1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <template>
- <div>
- <router-view></router-view>
- </div>
- </template>
- <script>
- export default {
- replace: false,
- data() {
- return {
- register: {
- email: "",
- username: "",
- password: ""
- },
- login: {
- email: "",
- password: ""
- },
- likes: [],
- dislikes: [],
- loggedIn: false,
- stations: []
- }
- },
- methods: {
- logout() {
- this.socket.emit('users.logout');
- location.reload();
- }
- },
- ready: function () {
- lofig.folder = 'config/default.json';
- lofig.get('socket.url', res => {
- let socket = this.socket = io(window.location.protocol + '//' + res);
- socket.on("ready", status => this.loggedIn = status);
- socket.emit("stations.index", data => this.stations = data);
- });
- },
- events: {
- 'register': function () {
- let { register: { email, username, password } } = this;
- this.socket.emit('users.register', email, username, password, grecaptcha.getResponse(), (result) => {
- console.log(result);
- location.reload();
- });
- },
- 'login': function () {
- let { login: { email, password } } = this;
- this.socket.emit('users.login', email, password, (result) => {
- console.log(result);
- location.reload();
- });
- },
- 'joinStation': function (id) {
- this.socket.emit('stations.join', id, (result) => {
- this.stations.find(station => station.id === id).users = result.userCount;
- });
- },
- 'leaveStation': function () {
- this.socket.emit('stations.leave', (result) => {
- //this.stations.find(station => station.id === id).users = result.userCount;
- });
- }
- }
- }
- </script>
|