bug
This commit is contained in:
@@ -4,26 +4,28 @@
|
||||
<div class="form">
|
||||
<div class="form-item avatar">
|
||||
<h2>头像</h2>
|
||||
<div class="form-item__right" @click="uploadImg">
|
||||
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
||||
<image class="avatar" :src="userInfo.avatar"></image>
|
||||
<div class="form-item__right">
|
||||
<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
||||
<image class="avatar" :src="userInfo.avatarUrl || 'https://cdn.cunwuyun.cn/wxmp/tianfuxing/avatar.png'"></image>
|
||||
</button>
|
||||
<image class="right" src="/static/images/next.png" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<h2>昵称</h2>
|
||||
<div class="form-item__right">
|
||||
<input placeholder="请输入昵称" type="nickname" v-model="userInfo.nickname" />
|
||||
<input placeholder="请输入昵称" type="nickname" v-model="userInfo.nickName" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn" @click="save">保存</div>
|
||||
<div class="btn-wrapper">
|
||||
<div class="btn" hover-class="text-hover">保存</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
export default {
|
||||
appName: '设置',
|
||||
name: 'UserInfo',
|
||||
@@ -33,15 +35,14 @@
|
||||
}
|
||||
},
|
||||
|
||||
onLoad () {
|
||||
if (uni.getStorageSync('token')) {
|
||||
this.userInfo = uni.getStorageSync('userInfo')
|
||||
console.log(this.userInfo)
|
||||
}
|
||||
computed: {
|
||||
...mapState(['user'])
|
||||
},
|
||||
|
||||
uni.$on('updateUserInfo', () => {
|
||||
this.getUserInfo()
|
||||
})
|
||||
onLoad () {
|
||||
this.userInfo = {
|
||||
...this.user
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -56,6 +57,32 @@
|
||||
})
|
||||
},
|
||||
|
||||
onChooseAvatar (e) {
|
||||
this.$loading()
|
||||
uni.uploadFile({
|
||||
url: this.$instance.defaults.baseURL + '/api/file/add',
|
||||
filePath: e.detail.avatarUrl,
|
||||
name: 'file',
|
||||
header: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
Authorization: uni.getStorageSync('token'),
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data)
|
||||
|
||||
if (data.code === 0) {
|
||||
this.$set(this.userInfo, 'avatarUrl', data.data[0].split(';')[0])
|
||||
} else {
|
||||
this.$toast(data.msg)
|
||||
}
|
||||
},
|
||||
complete: () => {
|
||||
this.$nextTick(() => {
|
||||
this.$hideLoading()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
uploadImg () {
|
||||
uni.chooseImage({
|
||||
@@ -118,6 +145,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-wrapper {
|
||||
padding: 0;
|
||||
width: 120px!important;
|
||||
height: 120px!important;
|
||||
border-radius: 50%;
|
||||
margin: 0;
|
||||
|
||||
image {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
}
|
||||
|
||||
.form {
|
||||
.form-item {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user