Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.axios = require('axios');
- Vue.use(Framework7Vue);
- Vue.component('page-about', require('./components/mobile/AboutComponent.vue'));
- new Vue({
- el: '#app',
- framework7: {
- root: '#app',
- animateNavBackIcon: true,
- swipePanel: 'right',
- routes: [
- {
- path: '/about/',
- component: 'page-about'
- }
- ],
- },
- data: function () {
- return {
- loginMessage: null,
- isLogin: false,
- profile: null,
- loginUsername: null,
- loginPassword: null
- }
- },
- methods: {
- login: function () {
- var v = this;
- axios.post(process.env.MIX_APP_URL + '/api/auth/login', {
- username: this.loginUsername,
- password: this.loginPassword
- })
- .then(function (response) {
- if(response.data.token) {
- v.loginMessage = "ورود با موفقیت انجام شد. کمی صبر کنید...";
- localStorage.setItem('token', response.data.token);
- axios.post(process.env.MIX_APP_URL + '/api/user',{token:response.data.token}).then(function(response){v.profile = response.data.user;}).catch(function (error){});
- v.isLogin = true;
- v.$f7.closeModal();
- } else {
- v.loginMessage = "اطلاعات وارد شده اشتباه است.";
- }
- })
- .catch(function (error) {
- v.loginMessage = "خطا در ارتباط با شبکه";
- });
- },
- logout: function() {
- var v = this;
- v.isLogin = false;
- localStorage.removeItem("token");
- }
- },
- //computed: {
- mounted:function () {
- var v = this;
- if(localStorage.getItem("token")) {
- axios.post(process.env.MIX_APP_URL + '/api/user',{token:localStorage.getItem("token")}).then(function(response){v.profile = response.data.user;}).catch(function (error){});
- v.isLogin = true;
- return v.profile;
- } else {
- v.isLogin = false;
- }
- }
- //}
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement