kana-bbs/pages/account/index.vue

78 lines
1.7 KiB
Vue
Raw Normal View History

2022-01-30 17:37:25 +08:00
<template lang="pug">
.account
2022-01-30 18:12:48 +08:00
.header
label.img_add(for="img_add")
img.avatar(:src="account.avatar")
2022-01-30 18:40:28 +08:00
span.fa.fa-edit.avatar-edit
2022-01-30 18:12:48 +08:00
.name {{ account.name }}
2022-01-30 18:40:28 +08:00
input#img_add(type="file", accept="image/*", @change="upload($event)")
// multiple="multiple",
2022-01-30 18:12:48 +08:00
.content.main-width
p account
NuxtLink.button(to="/account/setting") 账户设置
2022-01-30 17:37:25 +08:00
</template>
<script>
export default {
computed: {
account() {
return this.$store.state.account;
},
},
methods: {
upload(event) {
let data = new FormData();
2022-01-30 18:12:48 +08:00
let option = { headers: { "Content-Type": "multipart/form-data" } };
2022-01-30 17:37:25 +08:00
data.append("img", event.target.files[0]);
2022-01-30 18:12:48 +08:00
this.$axios.post("/api/account", data, option).then((res) => {
console.log(res.data);
});
2022-01-30 17:37:25 +08:00
},
},
};
</script>
<style lang="sass">
.account
2022-01-30 18:12:48 +08:00
>.header
background-color: rgba(0, 0, 0, .5)
text-align: center
height: 200px
padding: 4rem
.avatar
height: 64px
width: 64px
border: none
border-radius: 50%
overflow: hidden
.img_add
cursor: pointer
2022-01-30 18:40:28 +08:00
position: relative
display: block
margin: auto
.avatar-edit
display: none
color: #ffffff
position: absolute
top: calc( 50% - .5rem )
left: calc( 50% - .5rem )
.img_add:hover
.avatar
filter: brightness(40%)
.avatar-edit
display: block
2022-01-30 18:12:48 +08:00
#img_add
display: none
.name
font-size: 1.2rem
font-weight: 600
color: #ffffff
>.content
background: #ffffff
padding: 2rem
border-radius: .5rem
box-sizing: border-box
position: relative
top: -4rem
2022-01-30 17:37:25 +08:00
</style>