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

293 lines
9.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
<!-- 编辑头像 -->
<view class="avatar-section btn-feel" @click="editAvatar">
<view class="avatar-label">编辑头像</view>
<view class="avatar-container">
2025-10-24 16:54:52 +08:00
<image class="company-avatar" :src="companyInfo.avatar || '/static/imgs/avatar.jpg'"></image>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<!-- 企业详细信息 -->
<view class="info-section">
<view class="info-item btn-feel" @click="editInfo('name')">
<view class="info-label">企业名称</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.name || '暂无公司名称' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('code')">
<view class="info-label">统一社会代码</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.socialCode || '暂无统一社会代码' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('location')">
<view class="info-label">企业注册地点</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.location || '暂无注册地点' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('description')">
<view class="info-label">企业信息介绍</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.description || '暂无企业介绍' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('legalPerson')">
<view class="info-label">企业法人姓名</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.legalPerson || '暂无法人信息' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('contact1')">
<view class="info-label">企业联系人名称</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.contact1Name || '暂无联系人' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('contact1Phone')">
<view class="info-label">企业联系人电话</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.contact1Phone || '暂无联系电话' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('contact2')">
<view class="info-label">企业联系人名称</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.contact2Name || '暂无联系人' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
<view class="info-item btn-feel" @click="editInfo('contact2Phone')">
<view class="info-label">企业联系人电话</view>
<view class="info-content">
2025-10-24 16:54:52 +08:00
<text class="info-value">{{ companyInfo.contact2Phone || '暂无联系电话' }}</text>
2025-10-24 11:34:11 +08:00
<uni-icons color="#A2A2A2" type="right" size="16"></uni-icons>
</view>
</view>
</view>
</AppLayout>
</template>
<script setup>
import { reactive, inject, onMounted } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
2025-10-24 16:54:52 +08:00
import AppLayout from '@/components/AppLayout/AppLayout.vue';
2025-10-24 11:34:11 +08:00
const { $api, navTo } = inject('globalFunction');
// 企业信息数据
const companyInfo = reactive({
2025-10-24 16:54:52 +08:00
name: '',
avatar: '/static/imgs/avatar.jpg',
2025-10-24 11:34:11 +08:00
completeness: '100%',
2025-10-24 16:54:52 +08:00
socialCode: '',
location: '',
description: '',
legalPerson: '',
contact1Name: '',
contact1Phone: '',
contact2Name: '',
contact2Phone: '',
isVerified: false // 实名状态
2025-10-24 11:34:11 +08:00
});
function editAvatar() {
// 编辑头像逻辑
uni.chooseImage({
count: 1,
success: (res) => {
// 上传头像
uploadAvatar(res.tempFilePaths[0]);
}
});
}
function uploadAvatar(filePath) {
// 上传头像到服务器
uni.uploadFile({
url: '/api/upload/avatar',
filePath: filePath,
name: 'avatar',
success: (res) => {
const data = JSON.parse(res.data);
if (data.success) {
companyInfo.avatar = data.data.url;
uni.showToast({
title: '头像更新成功',
icon: 'success'
});
}
}
});
}
function editInfo(type) {
// 根据类型跳转到不同的编辑页面
const editPages = {
name: '/pages/mine/edit-company-name',
code: '/pages/mine/edit-company-code',
location: '/pages/mine/edit-company-location',
description: '/pages/mine/edit-company-description',
legalPerson: '/pages/mine/edit-legal-person',
contact1: '/pages/mine/edit-contact1',
contact1Phone: '/pages/mine/edit-contact1-phone',
contact2: '/pages/mine/edit-contact2',
contact2Phone: '/pages/mine/edit-contact2-phone'
};
if (editPages[type]) {
navTo(editPages[type]);
}
}
onShow(() => {
// 获取企业信息
getCompanyInfo();
});
2025-10-24 16:54:52 +08:00
// 从缓存获取公司信息
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) {
const company = cachedUserInfo.company;
// 基本信息
companyInfo.name = company.name || '';
companyInfo.socialCode = company.code || '';
companyInfo.location = company.registeredAddress || '';
companyInfo.description = company.description || '';
companyInfo.legalPerson = company.legalPerson || '';
// 联系人信息
if (company.companyContactList && company.companyContactList.length > 0) {
const contacts = company.companyContactList;
companyInfo.contact1Name = contacts[0]?.contactPerson || '';
companyInfo.contact1Phone = contacts[0]?.contactPersonPhone || '';
if (contacts.length > 1) {
companyInfo.contact2Name = contacts[1]?.contactPerson || '';
companyInfo.contact2Phone = contacts[1]?.contactPersonPhone || '';
}
}
// 判断是否实名legalIdCard字段有值则表示已实名
companyInfo.isVerified = !!(company.legalIdCard && company.legalIdCard.trim());
console.log('公司名称:', companyInfo.name);
console.log('实名状态:', companyInfo.isVerified);
console.log('legalIdCard值:', company.legalIdCard);
} else {
console.log('缓存中没有company字段');
// 保持默认值
}
} catch (error) {
console.error('获取公司信息失败:', error);
// 保持默认值
}
}
function goBack() {
uni.navigateBack();
2025-10-24 11:34:11 +08:00
}
</script>
<style lang="stylus" scoped>
.avatar-section {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
background: #FFFFFF;
margin: 20rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.avatar-label {
font-size: 28rpx;
color: #333333;
}
.avatar-container {
display: flex;
align-items: center;
.company-avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 16rpx;
}
}
}
.info-section {
background: #FFFFFF;
margin: 0 20rpx 40rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
.info-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
border-bottom: 1rpx solid #F5F5F5;
&:last-child {
border-bottom: none;
}
.info-label {
font-size: 28rpx;
color: #6C7282;
min-width: 200rpx;
}
.info-content {
display: flex;
align-items: center;
flex: 1;
.info-value {
font-size: 28rpx;
color: #333333;
flex: 1;
text-align: right;
margin-right: 16rpx;
word-break: break-all;
}
}
}
}
.btn-feel {
transition: transform 0.2s ease;
&:active {
transform: scale(0.98);
}
}
</style>