InspectionCleaning/pages/user/index.vue

276 lines
6.4 KiB
Vue

<template>
<view class="content">
<!-- 设置 -->
<view class="head">
<view class="personInfo">
<view @click="handleClick">{{ baseInfo.name }}</view>
<view class="account">{{ baseInfo.personType }}</view>
</view>
<view class="avatar-box">
<u-avatar
:src="baseInfo.avatar || '/static/images/avatar.png'"
size="140"
mode="circle"
class="avatar"
></u-avatar>
<view
class="sex-icon"
:class="{
'sex-icon-man': baseInfo.sex === 0,
'sex-icon-woman': baseInfo.sex === 1,
}"
>
<u-icon
v-if="baseInfo.sex === 0"
name="man"
color="#fff"
size="26"
></u-icon>
<u-icon v-else name="woman" color="#fff" size="26"></u-icon>
</view>
</view>
</view>
<view class="cell-list-box">
<view class="cell-list-group">
<view
class="cell-list-item"
v-for="item in cellList"
@click="toPage(item.path)"
>
<view class="cell-list-item-left">
<image
style="width: 60rpx; height: 60rpx"
mode="aspectFit"
:src="item.icon"
></image>
<text>{{ item.title }}</text>
</view>
<view class="cell-list-item-right">
<text v-if="item.content">{{ item.content }}</text>
<u-icon
v-else
name="arrow-right"
color="#a5a7ab"
size="32"
></u-icon>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { GetCompanyInformation } from "@/api/apiList.js";
import {
toast,
clearStorageSync,
setStorageSync,
getStorageSync,
useRouter,
} from "@/utils/utils.js";
export default {
data() {
return {
baseInfo: {
avatar: "",
companyName: "南昌理工",
name: "保洁",
sex: 0, // 0 男 1 女
time: "2025/4/2-2026/4/2",
personType: "保洁员",
},
clickCount: 0, // 用于记录点击次数
version: "",
cellList: [
{
title: "任职周期",
icon: "/static/images/icon-unit.png",
path: "",
content: "2025-01-01~2025-12-31",
},
{
title: "版本信息",
icon: "/static/images/icon-info.png",
path: "/pages/user/versionInfo/index",
},
{
title: "注销",
icon: "/static/images/icon-logout.png",
path: "",
},
],
};
},
onLoad() {
// this.getUserInfo();
// const that = this;
// uni.getSystemInfo({
// success: function (res) {
// console.log("res", res);
// that.version = res.appVersion;
// },
// });
},
onShow() {
this.getCompanyInformation();
// uni.$on("refresh", (e) => {
// this.getUserInfo();
// uni.$off("refresh");
// });
},
// 下拉刷新
onPullDownRefresh() {
//console.log('refresh');
// this.getUserInfo();
// uni.stopPullDownRefresh(); //停止刷新
},
methods: {
handleClick() {
this.clickCount++; // 每次点击增加点击次数
if (this.clickCount === 6) {
this.clickCount = 0; // 执行完函数后重置点击次数
uni.navigateTo({
url: "/pages/login/login"
});
}
},
upload_avatar() {
const _this = this;
uni.chooseImage({
count: 1,
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
sourceType: ["album", "camera"], //从相册选择
success: function (res) {
uni.uploadFile({
url: _this.$api_url + "/api/index/upload_cos",
filePath: res.tempFilePaths[0],
name: "file",
formData: {
floder: "avatar",
},
success: (uploadFileRes) => {
//let retData = JSON.parse(uploadFileRes)
let retData = JSON.parse(uploadFileRes.data);
console.log("up:", retData);
const _data = {
avatar: retData.data.file,
};
_this.$api.baseInfoSave(_data).then((ret) => {
if (ret.code == 1) {
_this.baseInfo.avatar = retData.data.file;
} else {
toast(res.msg);
}
});
},
});
},
});
},
// 获取单位信息
async getCompanyInformation() {
const res = await GetCompanyInformation();
if (res.succeed) {
this.baseInfo = res.data;
this.cellList[0].content = this.baseInfo.time;
}
},
toPage(path) {
if (!path) return;
useRouter(path, {}, "navigateTo");
},
},
};
</script>
<style lang="scss" scoped>
.content {
height: calc(100vh - 100rpx - 88rpx);
background: #f6f8fc;
.head {
display: flex;
justify-content: space-between;
min-height: 300rpx;
padding: 70rpx 40rpx 0;
background: linear-gradient(to bottom, #e5ebfd, #f6f8fc);
.personInfo {
color: #333;
margin-top: 25rpx;
font-size: 40rpx;
font-weight: 600;
margin-left: 30rpx;
line-height: 50rpx;
.account {
color: #999;
font-size: 28rpx;
font-weight: normal;
margin-top: 10rpx;
}
}
.avatar-box {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
position: relative;
.avatar {
width: 100%;
}
.sex-icon {
width: 32rpx;
height: 32rpx;
line-height: 32rpx;
text-align: center;
border-radius: 50%;
position: absolute;
top: 20rpx;
right: 0;
}
.sex-icon-man {
background-color: #007aff;
}
.sex-icon-woman {
background-color: #ff4d4f;
}
}
}
.cell-list-box {
padding: 0 32rpx;
.cell-list-group {
.cell-list-item {
border-bottom: 1px solid #e9eaee;
padding: 0 10rpx;
height: 120rpx;
display: flex;
justify-content: space-between;
align-items: center;
&-left {
display: flex;
text {
margin-left: 24rpx;
align-self: center;
}
}
}
}
}
}
</style>