You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
4.9 KiB

3 years ago
<template>
3 years ago
<view>
<cpn-navbar title="设置" :isBack="true"></cpn-navbar>
<view>
<!-- 个人信息 -->
<view class="user-info">
<view class="user-info-title">个人信息</view>
<view class="user-info-content">
<view class="head-img">
<view class="text">头像</view>
<view style="display: flex">
<view class="avatar">
3 years ago
<u-avatar :src="vuex_user.upload.url || '/static/logo.png'" :size="104" mode="circle">
3 years ago
</u-avatar>
3 years ago
</view>
<view class="arrow" @click="chooseAvatar">
<u-icon name="arrow-right" size="24"></u-icon>
</view>
</view>
</view>
<view class="line"></view>
<view class="name">
<view class="name-text">账户名</view>
<view class="name-user">{{ vuex_user.name || "" }}</view>
</view>
</view>
</view>
<!-- 版本信息 -->
<view class="sys-info">
<view class="sys-info-title">版本信息</view>
<view class="sys-info-content">
<view>当前版本</view>
<view>V{{ vuex_version }}</view>
</view>
</view>
<view class="logout">
<u-button :hair-line="false" :custom-style="btnStyle" @click="logout">退</u-button>
</view>
</view>
</view>
3 years ago
</template>
<script>
3 years ago
import {
ROOTPATH
} from '@/common/config.js'
3 years ago
export default {
data() {
return {
btnStyle: {
width: "670rpx",
height: "76rpx",
color: "#1479FF",
border: "2rpx solid #1479FF",
},
};
},
methods: {
logout() {
this.$u.api.logout().then((res) => {
uni.showToast({
title: res.msg,
icon: 'none'
})
setTimeout(() => {
uni.navigateTo({
url: "/pages/login/login",
fail: (err) => {
console.log(err);
},
});
uni.clearStorageSync();
}, 1500)
});
},
chooseAvatar() {
// 此为uView的跳转方法详见"文档-JS"部分也可以用uni的uni.navigateTo
this.$u.route({
// 关于此路径,请见下方"注意事项"
url: '/uview-ui/components/u-avatar-cropper/u-avatar-cropper',
// 内部已设置以下默认参数值,可不传这些参数
params: {
// 输出图片宽度高等于宽单位px
destWidth: 300,
// 裁剪框宽度高等于宽单位px
rectWidth: 200,
// 输出的图片类型,如果'png'类型发现裁剪的图片太大,改成"jpg"即可
fileType: 'jpg',
}
3 years ago
})
3 years ago
},
},
computed: {
},
created() {
// 监听从裁剪页发布的事件,获得裁剪结果
uni.$on('uAvatarCropper', path => {
this.avatar = path;
// 可以在此上传到服务端
uni.uploadFile({
3 years ago
url: `${ROOTPATH}/api/nurse/upload-file`,
3 years ago
header: {
Authorization: `Bearer ${this.vuex_token}`
},
filePath: path,
name: 'file',
complete: (res) => {
this.$u.api.save({
avatar: JSON.parse(res.data).id
}).then(() => {
uni.showToast({
icon: "none",
title: '更换头像成功'
})
this.$store.dispatch('me')
})
}
});
})
},
};
3 years ago
</script>
<style scoped lang="scss">
3 years ago
.user-info {
margin-top: 28rpx;
&-title {
height: 40rpx;
font-size: 28rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #abaebe;
line-height: 40rpx;
padding-left: 40rpx;
}
&-content {
width: 750rpx;
background: #ffffff;
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(219, 218, 218, 0.5);
margin: 26rpx auto 0 auto;
.head-img {
display: flex;
justify-content: space-between;
align-items: center;
&>view>view {
align-self: center;
}
.text {
font-size: 32rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #333333;
padding-left: 40rpx;
}
.avatar {
padding: 18rpx 0rpx;
}
.arrow {
padding: 0 50rpx 0 40rpx;
}
}
.line {
width: 670rpx;
height: 2rpx;
border: 2rpx solid #eeeff5;
margin: 0 auto;
}
.name {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 40rpx;
&-text {
font-size: 32rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #333333;
}
&-user {
font-size: 32rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #333333;
}
}
}
}
.sys-info {
margin-top: 34rpx;
&-title {
font-size: 28rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #abaebe;
padding: 0 0 26rpx 36rpx;
}
&-content {
background: #ffffff;
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(219, 218, 218, 0.5);
display: flex;
justify-content: space-between;
align-items: center;
padding: 22rpx 40rpx;
&>view {
font-size: 32rpx;
font-family: PingFang-SC-Medium, PingFang-SC;
font-weight: 500;
color: #333333;
}
}
}
.logout {
margin-top: 40rpx;
}
3 years ago
</style>