配合前后端
This commit is contained in:
39
Yi.Vue/src/api/accountApi.js
Normal file
39
Yi.Vue/src/api/accountApi.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import myaxios from '@/util/myaxios'
|
||||
export default {
|
||||
login(username, password) {
|
||||
return myaxios({
|
||||
url: '/Account/login',
|
||||
method: 'post',
|
||||
data: {
|
||||
username,
|
||||
password
|
||||
}
|
||||
})
|
||||
},
|
||||
logout() {
|
||||
return myaxios({
|
||||
url: '/Account/logout',
|
||||
method: 'post',
|
||||
})
|
||||
},
|
||||
logged() {
|
||||
return myaxios({
|
||||
url: '/Account/logged',
|
||||
method: 'post',
|
||||
})
|
||||
},
|
||||
register(username, password, email, code) {
|
||||
return myaxios({
|
||||
url: `/Account/register?code=${code}`,
|
||||
method: 'post',
|
||||
data: { username, password, email }
|
||||
})
|
||||
},
|
||||
email(emailAddress) {
|
||||
return myaxios({
|
||||
url: `/Account/email?emailAddress=${emailAddress}`,
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
30
Yi.Vue/src/api/actionApi.js
Normal file
30
Yi.Vue/src/api/actionApi.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import myaxios from '@/util/myaxios'
|
||||
export default {
|
||||
getActions() {
|
||||
return myaxios({
|
||||
url: '/Action/getActions',
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
addAction(action) {
|
||||
return myaxios({
|
||||
url: '/action/addAction',
|
||||
method: 'post',
|
||||
data: action
|
||||
})
|
||||
},
|
||||
updateAction(action) {
|
||||
return myaxios({
|
||||
url: '/action/UpdateAction',
|
||||
method: 'post',
|
||||
data: action
|
||||
})
|
||||
},
|
||||
delActionList(Ids) {
|
||||
return myaxios({
|
||||
url: '/action/DelAllAction',
|
||||
method: 'post',
|
||||
data: Ids
|
||||
})
|
||||
},
|
||||
}
|
||||
16
Yi.Vue/src/api/fileApi.js
Normal file
16
Yi.Vue/src/api/fileApi.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import myaxios from '@/util/myaxios'
|
||||
export default {
|
||||
OnPostUploadImage(file) {
|
||||
return myaxios({
|
||||
url: '/File/OnPostUploadImage',
|
||||
method: 'post',
|
||||
data: file
|
||||
})
|
||||
},
|
||||
getLogs() {
|
||||
return myaxios({
|
||||
url: '/File/GetLogs',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
}
|
||||
50
Yi.Vue/src/api/roleApi.js
Normal file
50
Yi.Vue/src/api/roleApi.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import myaxios from '@/util/myaxios'
|
||||
export default {
|
||||
getRoles() {
|
||||
return myaxios({
|
||||
url: '/Role/getRoles',
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
AddRole(role) {
|
||||
return myaxios({
|
||||
url: '/Role/AddRole',
|
||||
method: 'post',
|
||||
data: role
|
||||
})
|
||||
},
|
||||
delRole(roleId) {
|
||||
return myaxios({
|
||||
url: `/Role/DelRole?roleId=${roleId}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
updateRole(role) {
|
||||
return myaxios({
|
||||
url: '/role/updateRole',
|
||||
method: 'post',
|
||||
data: role
|
||||
})
|
||||
},
|
||||
delRoleList(Ids) {
|
||||
return myaxios({
|
||||
url: '/role/delAllRole',
|
||||
method: 'post',
|
||||
data: Ids
|
||||
})
|
||||
},
|
||||
setAction(Id, Ids) {
|
||||
return myaxios({
|
||||
url: '/role/setAction',
|
||||
method: 'post',
|
||||
data: { "Id": Id, "Ids": Ids }
|
||||
})
|
||||
},
|
||||
GetActionByRoleId(roleId) {
|
||||
return myaxios({
|
||||
url: `/role/GetActionByRoleId?roleId=${roleId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
101
Yi.Vue/src/api/userApi.js
Normal file
101
Yi.Vue/src/api/userApi.js
Normal file
@@ -0,0 +1,101 @@
|
||||
import myaxios from '@/util/myaxios'
|
||||
export default {
|
||||
getAllUser() {
|
||||
return myaxios({
|
||||
url: '/User/getAllUser',
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
getUserByUserId(userId) {
|
||||
if (userId == undefined) {
|
||||
userId = 0;
|
||||
}
|
||||
return myaxios({
|
||||
url: `/User/getUserByUserId?userId=${userId}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
|
||||
addUser(user) {
|
||||
return myaxios({
|
||||
url: '/User/addUser',
|
||||
method: 'post',
|
||||
data: user
|
||||
})
|
||||
},
|
||||
delUser(userId) {
|
||||
return myaxios({
|
||||
url: `/User/delUser?userId=${userId}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
updateUser(user) {
|
||||
return myaxios({
|
||||
url: '/User/updateUser',
|
||||
method: 'post',
|
||||
data: user
|
||||
})
|
||||
},
|
||||
tryUpdateUser(form) {
|
||||
return myaxios({
|
||||
url: '/User/tryUpdateUser',
|
||||
method: 'post',
|
||||
data: form
|
||||
})
|
||||
},
|
||||
|
||||
delUserList(Ids) {
|
||||
return myaxios({
|
||||
url: '/User/delAllUser',
|
||||
method: 'post',
|
||||
data: Ids
|
||||
})
|
||||
},
|
||||
setRole(Id, Ids) {
|
||||
return myaxios({
|
||||
url: '/User/setRole',
|
||||
method: 'post',
|
||||
data: { "Id": Id, "Ids": Ids }
|
||||
})
|
||||
},
|
||||
|
||||
setRoleList(userIds, roleIds) {
|
||||
return myaxios({
|
||||
url: '/User/setRoleList',
|
||||
method: 'post',
|
||||
data: { "userIds": userIds, "roleIds": roleIds }
|
||||
})
|
||||
},
|
||||
getRoleByuserId(userId) {
|
||||
if (userId == undefined) {
|
||||
userId = 0;
|
||||
}
|
||||
return myaxios({
|
||||
url: `/User/getRoleByuserId?userId=${userId}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
getSpecialAction(userId) {
|
||||
return myaxios({
|
||||
url: `/User/getSpecialAction?userId=${userId}`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
setSpecialAction(Id, Ids) {
|
||||
return myaxios({
|
||||
url: '/User/setSpecialAction',
|
||||
method: 'post',
|
||||
data: { "Id": Id, "Ids": Ids }
|
||||
})
|
||||
},
|
||||
getActionByUserId(userId) {
|
||||
if (userId == undefined) {
|
||||
userId = 0;
|
||||
}
|
||||
return myaxios({
|
||||
url: `/User/getActionByUserId?userId=${userId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
1
Yi.Vue/src/assets/login.svg
Normal file
1
Yi.Vue/src/assets/login.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 14 KiB |
65
Yi.Vue/src/layouts/login/LayoutLogin.vue
Normal file
65
Yi.Vue/src/layouts/login/LayoutLogin.vue
Normal file
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<v-app>
|
||||
<v-container fluid class="grey lighten-5" v-bind:style="{ height: allDiv }">
|
||||
<v-row v-bind:style="{ height: allDiv }">
|
||||
<!-- -------------------------------公告----------------------------------- -->
|
||||
<v-col
|
||||
cols="0"
|
||||
sm="4"
|
||||
md="3"
|
||||
class="white d-none d-sm-flex text-center"
|
||||
>
|
||||
<div style="width: 100%">
|
||||
<h1 class="light-blue--text mt-8">{{title}} <br />维基 百科</h1>
|
||||
<p class="my-4 title">Angstrong</p>
|
||||
<p class="my-4 title">欢迎!在这里,我们无所不谈!</p>
|
||||
|
||||
<a href="https://beian.miit.gov.cn">工信部备案号:赣ICP备20008025号-2</a>
|
||||
<v-img
|
||||
src="../../assets/login.svg"
|
||||
contain
|
||||
v-bind:style="{ marginTop: imgDiv }"
|
||||
style="width: 100%"
|
||||
></v-img>
|
||||
</div>
|
||||
</v-col>
|
||||
<!-- -------------------------------------------------------------------------- -->
|
||||
|
||||
<!-- ------------------------------表单-------------------------------- -->
|
||||
<v-col cols="12" sm="8" md="9">
|
||||
<v-container class="text-center align-center" fluid>
|
||||
<div class="mt-15">
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
</v-container>
|
||||
</v-col>
|
||||
<!-- --------------------------------------------------------------- -->
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-app>
|
||||
</template>
|
||||
<script>
|
||||
// import settingApi from "@/api/settingApi";
|
||||
export default {
|
||||
created() {
|
||||
this.initialize();
|
||||
},
|
||||
methods: {
|
||||
initialize() {
|
||||
// settingApi.getTitle().then((resp) => {
|
||||
// this.title = resp.data;
|
||||
// });
|
||||
},
|
||||
},
|
||||
data: () => ({
|
||||
title:"",
|
||||
allDiv: document.documentElement.clientHeight + "px",
|
||||
imgDiv: document.documentElement.clientHeight - 540 + "px",
|
||||
// email: '',
|
||||
// emailRules: [
|
||||
// v => !!v || 'E-mail is required',
|
||||
// v => /.+@.+\..+/.test(v) || 'E-mail must be valid',
|
||||
// ],
|
||||
}),
|
||||
};
|
||||
</script>
|
||||
@@ -3,6 +3,8 @@ import App from './App.vue'
|
||||
import router from './router'
|
||||
import vuetify from './plugins/vuetify'
|
||||
import './plugins'
|
||||
import './store/index'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
|
||||
import LayoutLogin from '../layouts/login/LayoutLogin.vue'
|
||||
import login from '../views/login.vue'
|
||||
import register from '../views/register.vue'
|
||||
import { trailingSlash } from '@/util/helpers'
|
||||
import {
|
||||
layout,
|
||||
@@ -18,11 +22,29 @@ const router = new VueRouter({
|
||||
|
||||
return { x: 0, y: 0 }
|
||||
},
|
||||
routes: [layout('Default', [
|
||||
route('Index'),
|
||||
route('AdmUser', null, 'AdmUser'),
|
||||
route('AdmRole', null, 'AdmRole'),
|
||||
])]
|
||||
routes: [{
|
||||
path: '/layoutLogin',
|
||||
name: 'layoutLogin',
|
||||
component: LayoutLogin,
|
||||
redirect: "/login",
|
||||
children: [{
|
||||
path: "/login",
|
||||
name: "login",
|
||||
component: login
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'register',
|
||||
component: register
|
||||
}
|
||||
]
|
||||
},
|
||||
layout('Default', [
|
||||
route('Index'),
|
||||
route('AdmUser', null, 'AdmUser'),
|
||||
route('AdmRole', null, 'AdmRole'),
|
||||
])
|
||||
]
|
||||
})
|
||||
router.beforeEach((to, from, next) => {
|
||||
return to.path.endsWith('/') ? next() : next(trailingSlash(to.path))
|
||||
|
||||
18
Yi.Vue/src/store/index.js
Normal file
18
Yi.Vue/src/store/index.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import home from './modules/home'
|
||||
import user from './modules/user'
|
||||
import theme from './modules/theme'
|
||||
import loader from './modules/loader'
|
||||
Vue.use(Vuex);
|
||||
|
||||
//实例化
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
home,
|
||||
user,
|
||||
theme,
|
||||
loader
|
||||
}
|
||||
})
|
||||
export default store
|
||||
42
Yi.Vue/src/store/modules/home.js
Normal file
42
Yi.Vue/src/store/modules/home.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const state = { //状态
|
||||
plateId: 0,
|
||||
discussId: 0,
|
||||
plateString: "",
|
||||
}
|
||||
|
||||
const mutations = { //变化//载荷
|
||||
SET_PLATEID(state, n) {
|
||||
state.plateId = n
|
||||
},
|
||||
SET_DOSCUSSIDSTRING(state, n) {
|
||||
state.plateString = n
|
||||
},
|
||||
SET_DOSCUSSID(state, n) {
|
||||
state.discussId = n
|
||||
},
|
||||
}
|
||||
|
||||
//在action中可以配合axios进行权限判断
|
||||
const actions = { //动作
|
||||
set_plateId(context, n) {
|
||||
context.commit('SET_PLATEID', n)
|
||||
},
|
||||
set_plateString(context, n) {
|
||||
context.commit('SET_DOSCUSSIDSTRING', n)
|
||||
},
|
||||
set_discussId(context, n) {
|
||||
context.commit('SET_DOSCUSSID', n)
|
||||
}
|
||||
}
|
||||
|
||||
// const getters = { //类似与计算属性 派生属性
|
||||
// msg(state) {
|
||||
// if (state.count > 80) {
|
||||
// return "成绩优异"
|
||||
// } else {
|
||||
// return "成绩不合格"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
export default { state, mutations, actions }
|
||||
34
Yi.Vue/src/store/modules/loader.js
Normal file
34
Yi.Vue/src/store/modules/loader.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const state = { //状态
|
||||
load: false
|
||||
}
|
||||
|
||||
const mutations = { //变化//载荷
|
||||
OPEN(state) {
|
||||
state.load = true;
|
||||
},
|
||||
CLOSE(state) {
|
||||
state.load = false;
|
||||
},
|
||||
}
|
||||
|
||||
//在action中可以配合axios进行权限判断
|
||||
const actions = { //动作
|
||||
openLoad(context) {
|
||||
context.commit('OPEN')
|
||||
},
|
||||
closeLoad(context) {
|
||||
context.commit('CLOSE')
|
||||
}
|
||||
}
|
||||
|
||||
// const getters = { //类似与计算属性 派生属性
|
||||
// msg(state) {
|
||||
// if (state.count > 80) {
|
||||
// return "成绩优异"
|
||||
// } else {
|
||||
// return "成绩不合格"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
export default { state, mutations, actions }
|
||||
33
Yi.Vue/src/store/modules/theme.js
Normal file
33
Yi.Vue/src/store/modules/theme.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import vuetify from '../../plugins/vuetify';
|
||||
const state = { //状态
|
||||
light: {
|
||||
primary: '#1976D2',
|
||||
secondary: '#424242',
|
||||
accent: '#82B1FF',
|
||||
error: '#FF5252',
|
||||
info: '#2196F3',
|
||||
success: '#4CAF50',
|
||||
warning: '#FFC107',
|
||||
cyan: "#FAB2B1",
|
||||
blue: "#2196F3"
|
||||
},
|
||||
dark: {}
|
||||
}
|
||||
|
||||
const mutations = { //变化//载荷
|
||||
SET_Light(state, n) {
|
||||
state.light = n
|
||||
vuetify.framework.theme.themes.light = n
|
||||
},
|
||||
}
|
||||
|
||||
//在action中可以配合axios进行权限判断
|
||||
const actions = { //动作
|
||||
set_light(context, n) {
|
||||
context.commit('SET_Light', n)
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default { state, mutations, actions }
|
||||
122
Yi.Vue/src/store/modules/user.js
Normal file
122
Yi.Vue/src/store/modules/user.js
Normal file
@@ -0,0 +1,122 @@
|
||||
import { getToken, setToken, getUser, setUser, removeToken } from '../../util/usertoken'
|
||||
import accountApi from "@/api/accountApi"
|
||||
|
||||
//再导入axion请求
|
||||
const state = { //状态
|
||||
token: getToken(),
|
||||
user: getUser()
|
||||
}
|
||||
|
||||
const mutations = { //变化//载荷
|
||||
SET_TOKEN(state, token) {
|
||||
state.token = token
|
||||
setToken(token)
|
||||
},
|
||||
SET_USER(state, user) {
|
||||
state.user = user
|
||||
setUser(user)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//在action中可以配合axios进行权限判断
|
||||
const actions = { //动作
|
||||
setIcon({ commit, state }, icon) {
|
||||
state.user.icon = icon
|
||||
commit('SET_USER', state.user)
|
||||
},
|
||||
|
||||
|
||||
setLevel({ commit, state }, level) {
|
||||
|
||||
commit('SET_USER', state.user)
|
||||
},
|
||||
|
||||
// qqUpdate({ state }, openid) {
|
||||
// return new Promise((resolv, reject) => {
|
||||
// qqApi.qqupdate(openid, state.user.id).then(resp => {
|
||||
// resolv(resp)
|
||||
// }).catch(error => {
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
|
||||
// qqLogin({ commit }, openid) {
|
||||
// return new Promise((resolv, reject) => {
|
||||
// qqApi.qqlogin(openid).then(resp => {
|
||||
// if (resp.status) {
|
||||
// commit('SET_TOKEN', resp.data.token)
|
||||
// commit('SET_USER', resp.data.user)
|
||||
// }
|
||||
// resolv(resp)
|
||||
// }).catch(error => {
|
||||
// reject(error)
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
|
||||
Login({ commit }, form) {
|
||||
return new Promise((resolv, reject) => {
|
||||
accountApi.login(form.username.trim(), form.password.trim()).then(resp => {
|
||||
if (resp.status) {
|
||||
commit('SET_TOKEN', resp.data.token)
|
||||
commit('SET_USER', resp.data.user)
|
||||
}
|
||||
|
||||
resolv(resp)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
Register({ commit }, form) {
|
||||
return new Promise((resolv, reject) => {
|
||||
accountApi.register(form.username.trim(), form.password.trim(), form.email.trim(), form.code.trim()).then(resp => {
|
||||
resolv(resp)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
Logged({ commit }) {
|
||||
return new Promise((resolv, reject) => {
|
||||
accountApi.logged().then(resp => {
|
||||
resolv(resp)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// GetUserInfo({ commit, state }) {
|
||||
// return new Promise((resolv, reject) => {
|
||||
// // getUserInfo(state.token).then(response => {
|
||||
// // commit('SET_USER', response.data)
|
||||
// // resolve(response)
|
||||
// // }).catch(error=>{
|
||||
// // reject(error)
|
||||
// // })
|
||||
// })
|
||||
// },
|
||||
Logout({ commit, state }) {
|
||||
return new Promise((resolv, reject) => {
|
||||
accountApi.logout().then(response => {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_USER', null)
|
||||
removeToken()
|
||||
resolv(response)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default { state, mutations, actions }
|
||||
163
Yi.Vue/src/views/login.vue
Normal file
163
Yi.Vue/src/views/login.vue
Normal file
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<v-card
|
||||
class="px-6 py-4 mx-auto elevation-4 rounded-md"
|
||||
style="height: 600px; width: 500px"
|
||||
>
|
||||
<div>
|
||||
<h1 class="title my-2">Angstrong</h1>
|
||||
<v-subheader>登入你的用户</v-subheader>
|
||||
</div>
|
||||
|
||||
<v-form ref="form" v-model="valid" lazy-validation>
|
||||
<v-text-field
|
||||
v-model="user_name"
|
||||
:rules="user_nameRules"
|
||||
label="用户名"
|
||||
outlined
|
||||
clearable
|
||||
required
|
||||
:counter="20"
|
||||
></v-text-field>
|
||||
|
||||
<v-text-field
|
||||
v-model="password"
|
||||
:rules="passwordRules"
|
||||
label="密码"
|
||||
outlined
|
||||
clearable
|
||||
required
|
||||
type="password"
|
||||
></v-text-field>
|
||||
<v-row>
|
||||
<v-col cols="6">
|
||||
<v-checkbox
|
||||
v-model="checkbox"
|
||||
:rules="[(v) => !!v || '同意后才可进入']"
|
||||
label="你同意协议吗?"
|
||||
required
|
||||
></v-checkbox
|
||||
></v-col>
|
||||
<v-col cols="6" class="text-right pt-8"
|
||||
><router-link to="/register">前往注册</router-link></v-col
|
||||
>
|
||||
</v-row>
|
||||
</v-form>
|
||||
|
||||
<v-btn
|
||||
class="my-2 light-blue white--text"
|
||||
@click="login"
|
||||
large
|
||||
style="width: 100%"
|
||||
@keyup.enter="enterSearch"
|
||||
:loading="loader"
|
||||
:disabled="btn_dis"
|
||||
>
|
||||
登入
|
||||
</v-btn>
|
||||
<p class="my-2">或使用登录</p>
|
||||
<v-btn class="my-2 cyan white--text" @click="qqlogin" large style="width: 100%" :loading="loader" :disabled="btn_dis">
|
||||
<v-icon class="mx-2" > mdi-qqchat </v-icon>
|
||||
QQ
|
||||
</v-btn>
|
||||
|
||||
<v-btn class="cyan white--text" @click="yklogin" large style="width: 100%" :loading="loader" :disabled="btn_dis">
|
||||
<v-icon class="mx-2"> mdi-message-text </v-icon>
|
||||
临时游客
|
||||
</v-btn>
|
||||
</v-card>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
btn_dis:false,
|
||||
loader: null,
|
||||
valid: true,
|
||||
user_name: "",
|
||||
user_nameRules: [
|
||||
(v) => !!v || "用户名不能为空",
|
||||
(v) => (v && v.length <= 20) || "用户名必须小于20个字符",
|
||||
],
|
||||
password: "",
|
||||
passwordRules: [
|
||||
(v) => !!v || "密码不能为空",
|
||||
(v) => (v && v.length <= 120) || "密码必须小于20个字符",
|
||||
],
|
||||
select: null,
|
||||
checkbox: true,
|
||||
}),
|
||||
created() {
|
||||
this.enterSearch();
|
||||
},
|
||||
methods: {
|
||||
enterSearch() {
|
||||
document.onkeydown = (e) => {
|
||||
//13表示回车键,baseURI是当前页面的地址,为了更严谨,也可以加别的,可以打印e看一下
|
||||
if (e.keyCode === 13 && e.target.baseURI.match("/")) {
|
||||
//回车后执行搜索方法
|
||||
this.login();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
qqlogin() {
|
||||
// QC.Login.showPopup(myqq.myqqLogin);
|
||||
// window.close();
|
||||
},
|
||||
yklogin() {
|
||||
this.loader = "true";
|
||||
this.btn_dis=true;
|
||||
this.$store
|
||||
.dispatch("Login", {
|
||||
username: "游客",
|
||||
password: "",
|
||||
})
|
||||
.then((resp) => {
|
||||
if (resp.status) {
|
||||
this.$router.push("/");
|
||||
} else {
|
||||
this.loader=null;
|
||||
this.btn_dis=false;
|
||||
this.$dialog.notify.error(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
login() {
|
||||
if (this.$refs.form.validate()) {
|
||||
this.loader = "true";
|
||||
this.btn_dis=true;
|
||||
this.$store
|
||||
.dispatch("Login", {
|
||||
username: this.user_name,
|
||||
password: this.password,
|
||||
})
|
||||
.then((resp) => {
|
||||
if (resp.status) {
|
||||
this.$router.push("/");
|
||||
} else {
|
||||
this.loader = null;
|
||||
this.btn_dis=false;
|
||||
this.$dialog.notify.error(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$dialog.notify.error("请合理输入数据", {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.$refs.form.reset();
|
||||
},
|
||||
resetValidation() {
|
||||
this.$refs.form.resetValidation();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
238
Yi.Vue/src/views/register.vue
Normal file
238
Yi.Vue/src/views/register.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<v-card
|
||||
class="px-6 py-4 mx-auto elevation-4 rounded-md"
|
||||
style=" height: 600px; width: 500px"
|
||||
>
|
||||
<div>
|
||||
<h1 class="title my-2">Angstrong</h1>
|
||||
<v-subheader>注册加入我们</v-subheader>
|
||||
</div>
|
||||
|
||||
<v-form ref="form" v-model="valid" lazy-validation>
|
||||
<v-text-field
|
||||
v-model="user_name"
|
||||
:rules="user_nameRules"
|
||||
label="用户名"
|
||||
outlined
|
||||
clearable
|
||||
required
|
||||
:counter="20"
|
||||
></v-text-field>
|
||||
|
||||
<v-text-field
|
||||
ref="myemail"
|
||||
v-model="email"
|
||||
:rules="emailRules"
|
||||
label="邮箱"
|
||||
outlined
|
||||
clearable
|
||||
required
|
||||
></v-text-field>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="6" md="8">
|
||||
<v-text-field
|
||||
v-model="code"
|
||||
label="验证码"
|
||||
outlined
|
||||
clearable
|
||||
required
|
||||
:counter="20"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="2" md="1">
|
||||
<v-progress-circular
|
||||
class="mt-2"
|
||||
size="40"
|
||||
:rotate="360"
|
||||
:value="value"
|
||||
color="cyan"
|
||||
>
|
||||
{{ value }}
|
||||
</v-progress-circular>
|
||||
</v-col>
|
||||
<v-col cols="4" md="3">
|
||||
<v-btn class="mt-1" large :dark="!dis_mail" color="cyan" @click="sendMail"
|
||||
:disabled="dis_mail"
|
||||
>发送</v-btn
|
||||
>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-text-field
|
||||
v-model="password"
|
||||
:rules="passwordRules"
|
||||
label="密码"
|
||||
outlined
|
||||
clearable
|
||||
required
|
||||
type="password"
|
||||
></v-text-field>
|
||||
<v-row>
|
||||
<v-col cols="6">
|
||||
<v-checkbox
|
||||
v-model="checkbox"
|
||||
:rules="[(v) => !!v || '同意后才可进入']"
|
||||
label="你同意协议吗?"
|
||||
required
|
||||
></v-checkbox
|
||||
></v-col>
|
||||
<v-col cols="6" class="text-right pt-8"
|
||||
><router-link to="/login">返回</router-link></v-col
|
||||
>
|
||||
</v-row>
|
||||
</v-form>
|
||||
|
||||
<v-btn
|
||||
class="my-2 light-blue white--text"
|
||||
@click="register"
|
||||
large
|
||||
style="width: 100%"
|
||||
:loading="loader"
|
||||
:disabled="btn_dis"
|
||||
>
|
||||
注册
|
||||
</v-btn>
|
||||
<!-- <p>或使用登录</p>
|
||||
<v-btn dark class="my-2 cyan" @click="login" large style="width: 100%">
|
||||
<v-icon class="mx-2"> mdi-message-text </v-icon>
|
||||
QQ
|
||||
</v-btn>
|
||||
|
||||
<v-btn dark class="cyan" @click="login" large style="width: 100%">
|
||||
<v-icon class="mx-2"> mdi-message-text </v-icon>
|
||||
微信
|
||||
</v-btn> -->
|
||||
</v-card>
|
||||
</template>
|
||||
<script>
|
||||
import accountApi from "../api/accountApi.js";
|
||||
export default {
|
||||
data: () => ({
|
||||
btn_dis:false,
|
||||
loader: null,
|
||||
dis_mail:false,
|
||||
value:100,
|
||||
code: "",
|
||||
valid: true,
|
||||
user_name: "",
|
||||
user_nameRules: [
|
||||
(v) => !!v || "用户名不能为空",
|
||||
(v) => (v && v.length <= 20) || "用户名必须小于20个字符",
|
||||
],
|
||||
email: "",
|
||||
emailRules: [
|
||||
(v) => !!v || "邮箱不能为空",
|
||||
(v) => /.+@.+\..+/.test(v) || "无效的邮箱",
|
||||
],
|
||||
password: "",
|
||||
passwordRules: [
|
||||
(v) => !!v || "密码不能为空",
|
||||
(v) => (v && v.length <= 120) || "密码必须小于120个字符",
|
||||
(v) => (v && v.length >= 7) || "密码必须大于等于7个字符",
|
||||
],
|
||||
select: null,
|
||||
checkbox: true,
|
||||
}),
|
||||
created()
|
||||
{
|
||||
setInterval(this.addValue,1000)
|
||||
},
|
||||
// watch:{
|
||||
// value(val,old)
|
||||
// {
|
||||
|
||||
// val+=1
|
||||
// if (val==100)
|
||||
// {
|
||||
// this.dis_mail=false
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.dis_mail=true
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
methods: {
|
||||
addValue()
|
||||
{
|
||||
if(this.value<=99)
|
||||
{
|
||||
this.value+=1
|
||||
}
|
||||
if(this.value==100)
|
||||
{
|
||||
this.dis_mail=false
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dis_mail=true
|
||||
}
|
||||
},
|
||||
register() {
|
||||
if (this.$refs.form.validate()) {
|
||||
this.loader = "true";
|
||||
this.btn_dis=true;
|
||||
this.$store
|
||||
.dispatch("Register", {
|
||||
username: this.user_name,
|
||||
password: this.password,
|
||||
email: this.email,
|
||||
code: this.code,
|
||||
})
|
||||
.then((resp) => {
|
||||
if (resp.status) {
|
||||
this.$dialog.notify.success(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
this.$router.push("/login");
|
||||
} else {
|
||||
this.loader=null;
|
||||
this.btn_dis=false;
|
||||
this.$dialog.notify.error(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$dialog.notify.error("请合理输入数据", {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.$refs.form.reset();
|
||||
},
|
||||
resetValidation() {
|
||||
this.$refs.form.resetValidation();
|
||||
},
|
||||
sendMail() {
|
||||
if (this.$refs.myemail.validate()) {
|
||||
|
||||
this.value=0
|
||||
this.dis_mail=true
|
||||
accountApi.email(this.email).then((resp) => {
|
||||
if (resp.status) {
|
||||
this.$dialog.notify.success(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
} else {
|
||||
this.$dialog.notify.error(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$dialog.notify.error("请合理输入邮箱", {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user