InspectionCleaning/pages/user/index.vue

231 lines
5.0 KiB
Vue
Raw Normal View History

2025-04-07 16:58:53 +08:00
<template>
<view class="content">
<!-- 设置 -->
<view class="head">
<view class="personInfo">
2025-04-08 15:56:13 +08:00
<view>张三</view>
<view class="account">勤工岗</view>
2025-04-07 16:58:53 +08:00
</view>
<u-avatar
2025-04-08 15:56:13 +08:00
src="/static/images/avatar.png"
2025-04-07 16:58:53 +08:00
size="140"
mode="circle"
class="avatar"
></u-avatar>
</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">
2025-04-08 15:56:13 +08:00
<text v-if="item.content">{{ item.content }}</text>
<u-icon
v-else
name="arrow-right"
color="#a5a7ab"
size="32"
></u-icon>
2025-04-07 16:58:53 +08:00
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
toast,
clearStorageSync,
setStorageSync,
getStorageSync,
useRouter,
} from "@/utils/utils.js";
export default {
data() {
return {
baseInfo: {
name: "",
phone: "",
avatar: "",
company_name: "",
registerDate: "",
login_code: "",
auth: 0,
},
version: "",
cellList: [
{
2025-04-08 15:56:13 +08:00
title: "任职周期",
2025-04-08 13:33:16 +08:00
icon: "/static/images/icon-unit.png",
2025-04-08 15:56:13 +08:00
path: "",
content: "2025-01-01~2025-12-31",
2025-04-07 16:58:53 +08:00
},
{
title: "版本信息",
2025-04-08 13:33:16 +08:00
icon: "/static/images/icon-info.png",
2025-04-07 16:58:53 +08:00
path: "/pages/user/versionInfo/index",
},
{
title: "注销",
2025-04-08 13:33:16 +08:00
icon: "/static/images/icon-logout.png",
2025-04-07 16:58:53 +08:00
path: "",
},
],
};
},
onLoad() {
this.getUserInfo();
const that = this;
uni.getSystemInfo({
success: function (res) {
console.log("res", res);
that.version = res.appVersion;
},
});
},
onShow() {
uni.$on("refresh", (e) => {
this.getUserInfo();
uni.$off("refresh");
});
},
// 下拉刷新
onPullDownRefresh() {
//console.log('refresh');
this.getUserInfo();
uni.stopPullDownRefresh(); //停止刷新
},
methods: {
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);
}
});
},
});
},
});
},
getUserInfo() {
this.$api.baseInfo().then((res) => {
//console.log(res)
this.baseInfo = res.data;
this.avatar_src = res.data.avatar;
});
},
service_center() {
toast("未设置跳转,请自行定义");
},
setting() {
useRouter("/pages/my/account/setting", {}, "navigateTo");
},
toPage(path) {
if (!path) return;
console.log("path", path);
useRouter(path, {}, "navigateTo");
},
},
};
</script>
<style lang="scss" scoped>
.content {
2025-04-08 13:58:11 +08:00
height: calc(100vh - 100rpx - 88rpx);
background: #f6f8fc;
2025-04-07 16:58:53 +08:00
.head {
display: flex;
justify-content: space-between;
min-height: 300rpx;
padding: 70rpx 40rpx 0;
2025-04-08 13:58:11 +08:00
background: linear-gradient(to bottom, #e5ebfd, #f6f8fc);
2025-04-07 16:58:53 +08:00
.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 {
margin-left: 50rpx;
}
}
.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>