driverSchool/pages/index/selfInfo.vue
2024-08-28 11:53:54 +08:00

224 lines
4.1 KiB
Vue

<template>
<view class="content">
<view class="container">
<!-- #ifdef MP-WEIXIN -->
<headers :titles="titles"><uni-icons @click="goback()" type="arrow-left" color="#000000"
size="22px"></uni-icons></headers>
<!-- #endif -->
<u-loadmore :status="status" v-if="show == true" />
</view>
<view class="self">
<view class="self-list">
<view class="self-left">头像</view>
<view class="touxiang">
<button class="avatar-wrapper" type="balanced" open-type="chooseAvatar"
@chooseavatar="onChooseavatar">
<image src="http://www.nuoyunr.com/lananRsc/detection/touxiang.png" mode=""
v-if="!selfInfo.userIcon"></image>
<image :src=" baseUrl+selfInfo.userIcon " mode="" v-if="selfInfo.userIcon"></image>
</button>
</view>
</view>
<view class="self-list">
<view class="self-left">昵称</view>
<input style="text-align: right;" type="text" placeholder="请输入" v-model="selfInfo.name" />
</view>
</view>
<view class="anniu" @click="updateProfile()">
确认修改
</view>
</view>
</template>
<script>
import headers from '../../components/header/headers.vue'
import tabbar from '../../components/tabbar/tabbar.vue'
import request from '../../utils/request'
import {
getToken
} from '@/utils/auth'
export default {
data() {
return {
titles: "设置",
fileList1: [],
baseUrl: this.$baseUrl,
avatar: '',
selfInfo: ''
}
},
// 发送好友
onShareAppMessage(res) {
return {
title: this.titles,
path: '/pages/index/index',
}
},
// 分享朋友圈
onShareTimeline(res) {
return {
title: this.titles,
path: '/pages/index/index',
}
},
onShow() {
this.findSelfInfo()
},
onPullDownRefresh() {
console.log("刷新");
uni.stopPullDownRefresh()
},
onReachBottom() {
// this.show = true
setTimeout(() => {
console.log("加载执行");
}, 2000)
},
components: {
headers,
tabbar
},
methods: {
async updateProfile() {
const res = await request({
method: 'PUT',
url: '/system/user/profile/updateNickName',
data: {
realName: this.selfInfo.name
}
})
if (res.code == 200) {
uni.showToast({
title: '昵称修改成功'
})
// this.closenickNameInputPop()
this.findSelfInfo()
}
},
async findSelfInfo() {
let res = await request({
url: `/driving/findSelfInfo`,
method: 'get',
})
this.selfInfo = res
},
onChooseavatar(e) {
uni.uploadFile({
url: this.baseUrl + '/system/user/profile/avatar',
filePath: e.detail.avatarUrl,
name: 'avatarfile',
header: {
Authorization: 'Bearer ' + getToken()
},
success: (uploadFileRes) => {
console.log(uploadFileRes);
if (uploadFileRes.statusCode == 200) {
this.findSelfInfo()
}
}
});
},
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
button {
margin: 0;
padding: 0;
outline: none;
border-radius: 0;
background-color: transparent;
line-height: inherit;
width: max-content;
width: 45px;
height: 45px;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
button:after {
border: none;
}
/*取消button点击的默认样式*/
button:focus {
border: 0 none;
outline: none !important;
}
.self {
.self-list {
display: flex;
justify-content: space-between;
height: 130rpx;
background-color: #fff;
border-bottom: 1px solid #eee;
padding: 0 28rpx;
align-items: center;
.self-right-img {
height: 110rpx;
width: 110rpx;
}
.self-right-nick {
color: #666;
}
.self-left {}
}
}
.content {
background: #f4f5f6;
height: 100vh;
}
.container {
width: 100%;
background: #f4f5f6;
box-sizing: border-box;
padding-top: 88px;
}
.touxiang {
width: 45px;
height: 45px;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.anniu {
width: 80%;
height: 35px;
border-radius: 50px;
background: #a4e9bf;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
margin: 40px auto;
}
</style>