Files
ks-app-employment-service/pages/mine/company-mine.vue

286 lines
7.8 KiB
Vue
Raw Normal View History

2025-10-24 11:34:11 +08:00
<template>
2025-10-24 16:54:52 +08:00
<AppLayout back-gorund-color="#F4F4F4">
2025-10-24 11:34:11 +08:00
<!-- 自定义tabbar -->
<CustomTabBar :currentPage="4" />
<!-- 企业信息卡片 -->
<view class="company-info-card btn-feel" @click="goToCompanyInfo">
<view class="company-avatar">
2025-10-24 16:54:52 +08:00
<image class="company-avatar-img" :src="companyInfo.avatar || '/static/imgs/avatar.jpg'"></image>
2025-10-24 11:34:11 +08:00
</view>
<view class="company-details">
2025-10-24 16:54:52 +08:00
<view class="company-name">{{ companyInfo.name || '暂无公司名称' }}</view>
<view class="company-completeness">
信息完整度 {{ companyInfo.completeness || '100%' }}
<text class="verification-status" :class="{ 'verified': companyInfo.isVerified, 'unverified': !companyInfo.isVerified }">
{{ companyInfo.isVerified ? '已实名' : '未实名' }}
</text>
</view>
2025-10-24 11:34:11 +08:00
</view>
<view class="company-arrow">
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<!-- 服务专区 -->
<view class="service-zone-card">
<view class="service-title">服务专区</view>
<view class="service-item btn-feel">
<view class="service-left">
2025-10-24 16:54:52 +08:00
<uni-icons type="contact" size="20" color="#256BFA"></uni-icons>
2025-10-24 11:34:11 +08:00
<text class="service-text">实名认证</text>
</view>
2025-10-24 16:54:52 +08:00
<view class="service-status" :class="{ 'verified': companyInfo.isVerified, 'unverified': !companyInfo.isVerified }">
{{ companyInfo.isVerified ? '已通过' : '未认证' }}
</view>
2025-10-24 11:34:11 +08:00
</view>
<view class="service-item btn-feel">
<view class="service-left">
2025-10-24 16:54:52 +08:00
<uni-icons type="notification" size="20" color="#256BFA"></uni-icons>
2025-10-24 11:34:11 +08:00
<text class="service-text">通知与提醒</text>
</view>
<view class="service-status">已开启</view>
</view>
</view>
<!-- 退出登录按钮 -->
<view class="logout-btn btn-feel" @click="logOut">
退出登录
</view>
<!-- 退出确认弹窗 -->
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog
mode="base"
title="确定退出登录吗?"
type="info"
:duration="2000"
:before-close="true"
@confirm="confirm"
@close="close"
></uni-popup-dialog>
</uni-popup>
</AppLayout>
</template>
<script setup>
2025-10-24 16:54:52 +08:00
import { reactive, inject, ref, onMounted, onUnmounted } from 'vue';
2025-10-24 11:34:11 +08:00
import { onLoad, onShow } from '@dcloudio/uni-app';
2025-10-24 16:54:52 +08:00
import useUserStore from '@/stores/useUserStore';
2025-10-24 11:34:11 +08:00
const { $api, navTo } = inject('globalFunction');
const popup = ref(null);
// 企业信息数据
const companyInfo = reactive({
2025-10-24 16:54:52 +08:00
name: '',
avatar: '/static/imgs/avatar.jpg',
completeness: '100%',
isVerified: false // 实名状态
2025-10-24 11:34:11 +08:00
});
function goToCompanyInfo() {
navTo('/pages/mine/company-info');
}
function logOut() {
popup.value.open();
}
function close() {
popup.value.close();
}
function confirm() {
2025-10-24 16:54:52 +08:00
// 调用退出登录
useUserStore().logOut();
// 关闭弹窗
popup.value.close();
// 跳转到首页
2025-10-24 11:34:11 +08:00
uni.reLaunch({
url: '/pages/index/index'
});
}
onShow(() => {
// 获取企业信息
getCompanyInfo();
});
2025-10-24 16:54:52 +08:00
// 监听退出登录事件,显示微信登录弹窗
onMounted(() => {
uni.$on('showLoginModal', () => {
// 这里可以显示微信登录弹窗
// 由于这个页面没有 WxAuthLogin 组件,我们跳转到首页让首页处理
uni.reLaunch({
url: '/pages/index/index'
});
});
});
onUnmounted(() => {
uni.$off('showLoginModal');
});
// 从缓存获取公司信息
2025-10-24 11:34:11 +08:00
function getCompanyInfo() {
2025-10-24 16:54:52 +08:00
try {
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
console.log('缓存中的userInfo:', cachedUserInfo);
// 检查是否有company字段
if (cachedUserInfo.company) {
companyInfo.name = cachedUserInfo.company.name || '';
// 判断是否实名legalIdCard字段有值则表示已实名
companyInfo.isVerified = !!(cachedUserInfo.company.legalIdCard && cachedUserInfo.company.legalIdCard.trim());
console.log('公司名称:', companyInfo.name);
console.log('实名状态:', companyInfo.isVerified);
console.log('legalIdCard值:', cachedUserInfo.company.legalIdCard);
} else {
console.log('缓存中没有company字段');
companyInfo.name = '';
companyInfo.isVerified = false;
}
} catch (error) {
console.error('获取公司信息失败:', error);
companyInfo.name = '';
companyInfo.isVerified = false;
}
2025-10-24 11:34:11 +08:00
}
</script>
<style lang="stylus" scoped>
.company-info-card {
display: flex;
align-items: center;
padding: 30rpx;
background: #FFFFFF;
margin: 20rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.company-avatar {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
overflow: hidden;
margin-right: 24rpx;
.company-avatar-img {
width: 100%;
height: 100%;
}
}
.company-details {
flex: 1;
.company-name {
font-size: 36rpx;
font-weight: 600;
color: #333333;
margin-bottom: 8rpx;
}
.company-completeness {
font-size: 28rpx;
color: #6C7282;
2025-10-24 16:54:52 +08:00
display: flex;
align-items: center;
gap: 16rpx;
.verification-status {
font-size: 24rpx;
padding: 4rpx 12rpx;
border-radius: 12rpx;
&.verified {
background-color: #E8F5E8;
color: #52C41A;
}
&.unverified {
background-color: #FFF2E8;
color: #FA8C16;
}
}
2025-10-24 11:34:11 +08:00
}
}
.company-arrow {
margin-left: 20rpx;
}
}
.service-zone-card {
background: #FFFFFF;
margin: 0 20rpx 20rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
padding: 32rpx;
.service-title {
font-size: 32rpx;
font-weight: 600;
color: #000000;
margin-bottom: 32rpx;
}
.service-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 0;
border-bottom: 1rpx solid #F5F5F5;
&:last-child {
border-bottom: none;
}
.service-left {
display: flex;
align-items: center;
.service-text {
font-size: 28rpx;
color: #333333;
2025-10-24 16:54:52 +08:00
margin-left: 16rpx;
2025-10-24 11:34:11 +08:00
}
}
.service-status {
font-size: 28rpx;
color: #6E6E6E;
2025-10-24 16:54:52 +08:00
&.verified {
color: #52C41A;
}
&.unverified {
color: #FA8C16;
}
2025-10-24 11:34:11 +08:00
}
}
}
.logout-btn {
height: 96rpx;
background: #FFFFFF;
margin: 0 20rpx 40rpx;
border-radius: 20rpx;
text-align: center;
line-height: 96rpx;
font-size: 28rpx;
color: #256BFA;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
}
.btn-feel {
transition: transform 0.2s ease;
&:active {
transform: scale(0.98);
}
}
</style>