You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/public/login.html

134 lines
5.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.14/theme-chalk/index.min.css">
<title>支付系统</title>
</head>
<body>
<div id="app">
<el-container>
<el-main>
<el-row>
<el-col :span="24">
<el-tabs v-model="activeName">
<el-tab-pane label="登录" name="login">
<el-form ref="loginForm" :model="loginForm" label-width="80px">
<el-form-item label="账号">
<el-input v-model="loginForm.username"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input show-password v-model="loginForm.password"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="login">登录</el-button>
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="注册" name="register">
<el-form ref="registerForm" :model="registerForm" label-width="80px">
<el-form-item label="账号">
<el-input v-model="registerForm.username"></el-input>
</el-form-item>
<el-form-item label="密码">
<el-input show-password v-model="registerForm.password"></el-input>
</el-form-item>
<el-form-item label="确认密码">
<el-input show-password v-model="registerForm.confirm_password"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="register">注册</el-button>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</el-main>
</el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.9/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.14/index.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.min.js"></script>
<script>
new Vue({
el: '#app',
data() {
return {
activeName: 'login',
loginForm: {
username: '',
password: ''
},
registerForm: {
username: '',
password: '',
confirm_password: ''
}
}
},
created() {
if (window.sessionStorage.getItem('token')) {
window.location.href = '/account.html'
return;
}
},
methods: {
register() {
if (this.registerForm.confirm_password != this.registerForm.password) {
this.$message.error('密码和确认密码不一致');
return;
}
axios.post('/account/register', this.registerForm)
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
this.activeName = 'login';
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
login() {
axios.post('/account/login', this.loginForm)
.then( (response) => {
console.log(response);
let result = response.data
if (result.code != 1000) {
return this.$message.error(response.data.message);
}
window.sessionStorage.setItem('token', result.data.token)
window.location.href = '/account.html';
})
.catch((error) => {
this.$message.error('请求错误');
console.log(error);
});
console.log('submit!');
},
getQueryParam(name) {
var query = window.location.search.substring(1);
console.log(query)
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
console.log(pair[0], name)
if(pair[0] == name) {
return pair[1];
}
}
return undefined;
}
}
})
</script>
</html>