Files
FE_CPONE/apps/login/index.php
2026-04-27 10:08:27 +07:00

113 lines
3.1 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Login</title>
<link rel="stylesheet" href="../../libs/vendor/css/google-fonts.css">
<link rel="stylesheet" href="../../libs/vendor/css/vuetify.min.css">
</head>
<body>
<div v-cloak id="app">
<v-app id="inspire">
<v-content>
<v-container fluid fill-height>
<v-layout align-center justify-center>
<v-flex xs12 sm8 md4>
<v-card class="elevation-12">
<v-toolbar dark color="primary">
<v-toolbar-title>One UI</v-toolbar-title>
<v-spacer></v-spacer>
</v-toolbar>
<v-alert
:value="isError"
type="warning"
>
{{errorMessage}}
</v-alert>
<v-progress-circular
indeterminate
v-show="isLoading"
>
</v-progress-circular>
<v-card-text>
<v-form>
<v-text-field v-model="userName" prepend-icon="person" label="Login" type="text"></v-text-field>
<v-text-field @keydown.enter="doLogin" v-model="userPassword" prepend-icon="lock" label="Password" type="password"></v-text-field>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="doLogin" color="primary">Login</v-btn>
</v-card-actions>
{{afterLogin}}
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-content>
</v-app>
</div>
<!-- Vendor -->
<script src="../../libs/vendor/axios.min.js"></script>
<script src="../../libs/vendor/vue.js"></script>
<script src="../../libs/vendor/vuex.js"></script>
<script src="../../libs/vendor/vuetify.js"></script>
<!-- App Script -->
<?php
$ts = "?ts=" . Date("ymdhis");
?>
<script type="module">
import { store } from './store.js<?php echo $ts ?>';
//window.store = store;
new Vue({
store,
el: '#app',
data: {
userName: "",
userPassword: ""
},
methods : {
doLogin() {
this.$store.dispatch("login",{
"userName": this.userName,
"userPassword": this.userPassword
});
}
},
computed: {
...Vuex.mapState({
errorMessage: state => state.errorMessage,
isLoading: state => state.isLoading,
isLogin: state => state.isLogin,
nextPage: state => state.nextPage
}),
isError: function() {
return this.errorMessage != "";
},
afterLogin: function() {
if (this.isLogin) {
document.location.href = this.nextPage;
};
}
},
created: function(){
this.$store.dispatch("loadToken");
}
});
</script>
<style>
[v-cloak] {
display: none
}
</style>
</body>
</html>