usuario okay

This commit is contained in:
arturo guerrero
2019-07-19 22:40:38 -05:00
parent 01ce28caf7
commit 6113b7bb40
18 changed files with 131 additions and 100 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+5 -6
View File
@@ -3740,12 +3740,6 @@
"is-obj": "^1.0.0"
}
},
"dotenv": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-7.0.0.tgz",
"integrity": "sha512-M3NhsLbV1i6HuGzBUH8vXrtxOk+tWmzWKDMbAVSUp3Zsjm7ywFeuwrUXhmhQyRK1q5B5GGy7hcXPbj3bnfZg2g==",
"dev": true
},
"duplexer": {
"version": "0.1.1",
"resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
@@ -14803,6 +14797,11 @@
"resolved": "https://registry.npmjs.org/vuejs-datepicker/-/vuejs-datepicker-1.5.4.tgz",
"integrity": "sha512-AVzgu3pb/fF/Sj3qu8YPnp7KhtsXkm8TSnBEcyYsWb1bMJr5FdPCxuIzISgw5kq0It7HkVJUGXQ4CiCwq9hhww=="
},
"vuex": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.1.tgz",
"integrity": "sha512-ER5moSbLZuNSMBFnEBVGhQ1uCBNJslH9W/Dw2W7GZN23UQA69uapP5GTT9Vm8Trc0PzBSVt6LzF3hGjmv41xcg=="
},
"watchpack": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz",
+2 -1
View File
@@ -23,7 +23,8 @@
"vue": "^2.5.17",
"vue-router": "^3.0.1",
"vue2-animate": "^2.1.0",
"vuejs-datepicker": "^1.5.4"
"vuejs-datepicker": "^1.5.4",
"vuex": "^3.1.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.1.1",
+2 -1
View File
@@ -16,5 +16,6 @@ export default {
</script>
<style lang="scss">
@import './scss/main.scss'
@import './scss/main.scss';
</style>
+3 -3
View File
@@ -10,14 +10,14 @@ if (process.env.NODE_ENV === 'development') {
api.url = config.PROD
}
api.isAuth = function () {
if (window.localStorage.pcpumaT && window.localStorage.pcpumaU) {
if (window.sessionStorage.pcpumaT && window.sessionStorage.pcpumaU) {
return true
}
return false
}
api.exit = function () {
window.localStorage.token = null
window.localStorage.usuario = null
window.sessionStorage.token = null
window.sessionStorage.usuario = null
}
export default api
+5 -5
View File
@@ -92,7 +92,7 @@ export default {
url: api.url + '/multar',
data: this.multar,
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -140,14 +140,14 @@ export default {
id: pre
},
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(res => {
swal('Exito', 'Peticion exitosa ', 'success')
axios.get(api.url + '/prestamo', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -166,7 +166,7 @@ export default {
mounted () {
axios.get(api.url + '/prestamo', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -179,7 +179,7 @@ export default {
})
axios.get(api.url + '/multa', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
+2 -2
View File
@@ -48,7 +48,7 @@ export default {
mounted () {
axios.get(api.url + '/prestamo/' + this.usuario, {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -76,7 +76,7 @@ export default {
dateBan: this.dateBan
},
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(res => {
+3 -3
View File
@@ -58,10 +58,10 @@ export default {
data: {
equipo: this.tipo,
idUsuario: this.usuario,
idKiosko: window.localStorage.pcpumaK
idKiosko: window.sessionStorage.pcpumaK
},
headers: {
token: window.localStorage.pcpumaT
token: window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -82,7 +82,7 @@ export default {
idUsuario: this.usuario
},
headers: {
token: window.localStorage.pcpumaT
token: window.sessionStorage.pcpumaT
}
})
.then(response => {
+5 -5
View File
@@ -76,9 +76,9 @@ export default {
}
},
mounted () {
axios.get(api.url + '/carritos/' + window.localStorage.pcpumaK, {
axios.get(api.url + '/carritos/' + window.sessionStorage.pcpumaK, {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -97,14 +97,14 @@ export default {
url: api.url + '/carrito',
data: this.carrito,
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
swal('Exito', 'Se actualizo', 'success')
axios.get(api.url + '/carritos/' + window.localStorage.pcpumaK, {
axios.get(api.url + '/carritos/' + window.sessionStorage.pcpumaK, {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
+8 -8
View File
@@ -154,9 +154,9 @@ export default {
}
},
mounted () {
axios.get(api.url + '/equipo/?kiosko=' + window.localStorage.pcpumaK, {
axios.get(api.url + '/equipo/?kiosko=' + window.sessionStorage.pcpumaK, {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -175,14 +175,14 @@ export default {
url: api.url + '/equipo',
data: this.equipo,
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
swal('Exito', 'Se actualizo', 'success')
axios.get(api.url + '/equipo/?kiosko=' + window.localStorage.pcpumaK, {
axios.get(api.url + '/equipo/?kiosko=' + window.sessionStorage.pcpumaK, {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -253,16 +253,16 @@ export default {
headers: {
admin: '123',
'Content-Type': 'multipart/form-data',
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
console.log(response.data)
axios.interceptors.request.eject(fue)
axios.interceptors.request.eject(regreso)
axios.get(api.url + '/equipo/?kiosko=' + window.localStorage.pcpumaK, {
axios.get(api.url + '/equipo/?kiosko=' + window.sessionStorage.pcpumaK, {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
+7 -5
View File
@@ -26,15 +26,13 @@ export default {
},
methods: {
salir: function () {
window.localStorage.removeItem('pcpumaT')
window.localStorage.removeItem('pcpumaU')
window.localStorage.removeItem('pcpumaK')
this.$store.commit('close')
this.$router.push('login')
}
},
computed: {
login: function () {
if (window.localStorage.pcpumaT) {
if (window.sessionStorage.pcpumaT) {
return true
}
return false
@@ -44,7 +42,11 @@ export default {
</script>
<style lang="scss" scoped>
.navbar{
width: 100%;
border-bottom: #B08100 solid 5px;
// box-shadow: 0px 13px 21px 2px rgba(0,0,0,0.21);
box-shadow: 0px 13px 21px 2px rgba(0,0,0,0.21);
position:fixed;
top:0;
}
</style>
+19 -11
View File
@@ -2,7 +2,8 @@
main
nav.navbar.is-u-blue
div.navbar-brand
a.navbar-item PC PUMA
a.navbar-item
b PC PUMA
.container
.columns
.column.is-4.is-offset-4.has-text-centered
@@ -25,7 +26,7 @@
i
font-awesome-icon(icon="lock")
.field.has-text-centered
input.button.is-u-blue(type="submit" v-on:click="Login()" value="Iniciar sesión")
input.button.is-u-blue(type="submit" v-on:click="Login($event)" value="Iniciar sesión")
</template>
<script>
@@ -45,16 +46,19 @@ export default {
}
},
methods: {
Login: function () {
axios.post(api.url + '/login', {
nombre: this.user,
pass: this.pass
Login: function (event) {
if (event) event.preventDefault()
axios({
method: 'post',
url: api.url + '/login',
data: {
usuario: this.user,
pass: this.pass
}
})
.then(response => {
console.log(response.data.data)
window.localStorage.pcpumaT = response.data.data.token
window.localStorage.pcpumaU = response.data.data.usuario
window.localStorage.pcpumaK = response.data.data.id
console.log(response.data)
this.$store.commit('login', response.data)
this.$router.push('/')
})
.catch(error => {
@@ -66,5 +70,9 @@ export default {
}
</script>
<style lang="css">
<style lang="css" scoped>
.navbar{
border-bottom: #B08100 solid 5px;
box-shadow: 0px 13px 21px 2px rgba(0,0,0,0.21);
}
</style>
+7 -9
View File
@@ -43,14 +43,12 @@
.column.is-12
table.table.is-fullwidth
thead
th Id
th Descripcion
th Semanas
th Editar
th Borrar
tbody
tr(v-for="dt in data")
td {{dt.id}}
td {{dt.nombre}}
td {{dt.semanas}}
td
@@ -82,7 +80,7 @@ export default {
mounted () {
axios.get(api.url + '/multa', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -116,7 +114,7 @@ export default {
semanas: this.sem
},
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -124,7 +122,7 @@ export default {
swal('Exito', 'Peticion exitosa ', 'success')
axios.get(api.url + '/multa', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -148,14 +146,14 @@ export default {
id
},
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
swal('Exito', 'Se elimino el Registro ', 'success')
axios.get(api.url + '/multa', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
@@ -181,14 +179,14 @@ export default {
semanas: this.multa.semanas
},
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
swal('Exito', 'Se actualizo el Registro ', 'success')
axios.get(api.url + '/multa', {
headers: {
'token': window.localStorage.pcpumaT
'token': window.sessionStorage.pcpumaT
}
})
.then(response => {
+23 -24
View File
@@ -18,11 +18,11 @@
font-awesome-icon(icon="user")
.field
.control.has-text-centered
input.button.is-link(v-on:click="usuario()" type="submit" value="Buscar")
input.button.is-link(v-on:click="usuario($event)" type="submit" value="Buscar")
br
.columns(v-if="data.id")
.columns(v-if="data.idUsuario")
.column.is-3.is-offset-1
p.is-size-3 Usuario : {{data.id}}
p.is-size-3 Usuario : {{data.idUsuario}}
p.is-size-4 Multa : {{multa(data.multa)}}
br
.field
@@ -54,24 +54,25 @@ export default {
}
},
methods: {
usuario: function () {
usuario: function (event) {
if (event) event.preventDefault()
axios.get(api.url + '/usuario/?id=' + this.buscar, {
headers: {
'token': window.localStorage.pcpumaT
'token': this.$store.getters.token
}
})
.then(response => {
console.log(response)
axios.get(api.url + '/prestamo/' + this.buscar, {
.then(res1 => {
// console.log(response)
this.data = res1.data
return axios.get(api.url + '/prestamo/' + this.buscar, {
headers: {
'token': window.localStorage.pcpumaT
'token': this.$store.getters.token
}
})
.then(data => {
this.prest = data.data.data
console.log(this.prest)
})
this.data = response.data.data
})
.then(res2 => {
// console.log(this.prest)
this.prest = res2.data
})
.catch(error => {
swal('Error', error.response.data.err, 'error')
@@ -87,23 +88,21 @@ export default {
ban: function () {
axios({
method: 'put',
url: api.url + '/ban',
url: api.url + '/usuario/' + this.data.idUsuario,
data: {
id: this.data.id
ban: !this.data.ban
},
headers: {
'token': window.localStorage.pcpumaT,
'admin': '123'
'token': this.$store.getters.token
}
})
.then(response => {
// console.log(response)
this.data = response.data.data
swal('Exito', 'Se cambio de estado con Exito', 'success')
.then(res => {
console.log(res)
this.data = res.data
swal('Exito', !this.data.ban ? 'Usuario Desbloqueado' : 'Usuario Bloqueado' , 'success')
})
.catch(error => {
// console.log(error)
swal('Error', error.response.data.err, 'error')
console.log(error)
})
}
}
+3 -4
View File
@@ -5,6 +5,7 @@ import { faLaptop, faFlag, faUpload, faTrash, faTabletAlt, faUser, faLock, faSea
import { faChrome } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import router from './routes.js'
import store from './store'
library.add(faChrome, faSearch, faShoppingCart, faCheckCircle, faPen, faEye)
library.add(faUndo)
@@ -17,12 +18,10 @@ library.add(faTabletAlt)
library.add(faTrash)
Vue.component('font-awesome-icon', FontAwesomeIcon)
console.log(process.env)
// import Child from './components/Child.vue'
Vue.config.productionTip = false
// Vue.component('child', Child)
new Vue({
render: h => h(App),
router
router,
store
}).$mount('#app')
+11 -11
View File
@@ -1,4 +1,5 @@
import Vue from 'vue'
import store from './store.js'
import VueRouter from 'vue-router'
import Carrito from './layout/Carrito.vue'
import Inicio from './layout/Inicio.vue'
@@ -9,31 +10,30 @@ import Multa from './layout/Multa.vue'
const routes = [
{ path: '/', component: Inicio, name: 'inicio' },
{ path: '/login', component: Login, name: 'login', meta: { isPublic: true } },
{ path: '/carrito', component: Carrito, name: 'carrito' },
{ path: '/login', component: Login, name: 'login' },
{ path: '/usuario', component: Usuario, name: 'usuario' },
{ path: '/equipo/', component: Equipo, name: 'equipo' },
{ path: '/multa', component: Multa, name: 'multa' }
]
Vue.use(VueRouter)
const router = new VueRouter({ routes })
const router = new VueRouter({ mode: 'history', routes })
const isAuthenticated = function () {
if (window.localStorage.pcpumaT) {
return true
}
return false
return store.getters.isLoggedIn
}
router.beforeEach((to, from, next) => {
if (!isAuthenticated() && to.path !== '/login') {
return next('/login')
if (!to.meta.isPublic && !isAuthenticated()) {
return next({ name: 'login' })
}
if (isAuthenticated() && to.path === '/login') {
return next('/')
if (to.name === 'login' && isAuthenticated()) {
return next({ name: 'home' })
}
next()
return next()
})
export default router
+24
View File
@@ -0,0 +1,24 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
session: {}
},
getters: {
isLoggedIn: state => !!state.session.token,
token: state => state.session.token
},
mutations: {
login (state, payload = {}) {
state.session = payload
},
close (state) {
state.session = {}
}
}
})
export default store