文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit c1cd5cc6 by Wang Yuhang

修改Login.vue

parent c00a69a5
...@@ -66,6 +66,18 @@ export default { ...@@ -66,6 +66,18 @@ export default {
type: this.password ? 1 : 0 type: this.password ? 1 : 0
} }
this.$store.commit('setUserInfo', userInfo) this.$store.commit('setUserInfo', userInfo)
// 登录接口
this.axios.post('/signin', {
userName: this.userName,
password: this.password
}).then(res => {
if (res.code === 1) {
// 存储用户ID和身份
// 跳转页面
this.$router.push({path: '/taskHall'})
} else if (res.code === 0) { alert('用户名或密码错误') }
})
this.$router.push('/index').catch(data => {}) this.$router.push('/index').catch(data => {})
}, },
register () { register () {
...@@ -74,6 +86,20 @@ export default { ...@@ -74,6 +86,20 @@ export default {
type: this.password ? 1 : 0 type: this.password ? 1 : 0
} }
this.$store.commit('setUserInfo', userInfo) this.$store.commit('setUserInfo', userInfo)
this.axios.post('/signup', {
userName: this.userName,
password: this.password,
email: this.email
}).then(res => {
if (res.code === 1) {
// 存储用户ID和身份
// 跳转至用户大厅
this.$router.push({path: '/taskHall'})
} else if (res.code === 0) { alert('注册失败') }
window.reload()
})
this.$router.push('/index').catch(data => {}) this.$router.push('/index').catch(data => {})
} }
} }
...@@ -153,38 +179,3 @@ export default { ...@@ -153,38 +179,3 @@ export default {
} }
} }
</style> </style>
<!--axios函数功能-->
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
<script>
const mock = true
if (mock) require('@/mock/api.js')
//登录
axios.post("/signin",{
userName : this.userName,
password : this.password
}).then(res=>{
if(res.code == 1){
//存储用户ID和身份
// 跳转页面
this.$router.push({path:"/taskHall"});
}
else if(res.code == 0)
alert("用户名或密码错误");
}),
axios.post("/signup",{
userName : this.userName,
password : this.password,
email : this.email,
}).then(res=>{
if(res.code == 1){
//存储用户ID和身份
//跳转至用户大厅
this.$router.push({path:"/taskHall"});
}
else if(res.code == 0)
alert("注册失败");
window.reload();
})
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment