首页卡片开发

This commit is contained in:
冯辉
2025-10-24 16:54:52 +08:00
parent 92ee5c5311
commit 2d6370b796
22 changed files with 896 additions and 205 deletions

View File

@@ -1,5 +1,5 @@
<template>
<AppLayout title="企业信息">
<AppLayout>
<view class="company-info-container">
<!-- 头部信息 -->
<view class="header-info">
@@ -131,6 +131,15 @@
</view>
</view>
<!-- 企业规模 -->
<view class="form-item clickable" @click="selectScale">
<view class="label">企业规模</view>
<view class="input-content">
<input class="input-con" v-model="formData.scaleText" disabled placeholder="请选择企业规模" />
<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
</view>
</view>
<!-- 联系人信息列表 -->
<view class="contact-section">
<view class="section-title">联系人信息</view>
@@ -225,9 +234,11 @@ import { onLoad } from '@dcloudio/uni-app'
import AreaCascadePicker from '@/components/area-cascade-picker/area-cascade-picker.vue'
import SelectPopup from '@/components/selectPopup/selectPopup.vue'
import useDictStore from '@/stores/useDictStore'
import useUserStore from '@/stores/useUserStore'
const { $api } = inject('globalFunction')
const dictStore = useDictStore()
const userStore = useUserStore()
// 表单数据
const formData = reactive({
@@ -246,6 +257,8 @@ const formData = reactive({
legalPhone: '', // 法人联系方式
industryType: '', // 是否是本地重点发展产业
isLocalCompany: null, // 是否是本地企业 (true/false/null)
scale: '', // 企业规模
scaleText: '', // 企业规模显示文本
companyContactList: [
{ contactPerson: '', contactPersonPhone: '' }
]
@@ -311,7 +324,8 @@ const completionPercentage = computed(() => {
formData.legalIdCard,
formData.legalPhone,
formData.industryType,
formData.isLocalCompany !== null ? 'filled' : ''
formData.isLocalCompany !== null ? 'filled' : '',
formData.scale
]
// 检查联系人信息
@@ -464,6 +478,73 @@ const selectLocalCompany = () => {
})
}
// 企业规模选项数据从字典中获取
const scaleOptions = computed(() => {
const scaleData = dictStore.state?.scale || []
console.log('企业规模选项数据:', scaleData)
return scaleData
})
// 选择企业规模
const selectScale = () => {
console.log('点击企业规模,当前数据:', scaleOptions.value)
console.log('字典store状态:', dictStore.state.scale)
// 获取企业规模选项,优先使用字典数据,失败时使用备用数据
let options = scaleOptions.value
if (!options || !options.length) {
console.log('企业规模数据为空,尝试重新加载')
// 尝试重新加载字典数据
dictStore.getDictData().then(() => {
if (dictStore.state.scale && dictStore.state.scale.length > 0) {
selectScale() // 递归调用
} else {
// 使用备用数据
console.log('使用备用企业规模数据')
options = fallbackScaleOptions
showScaleSelector(options)
}
}).catch(() => {
// 使用备用数据
console.log('字典加载失败,使用备用企业规模数据')
options = fallbackScaleOptions
showScaleSelector(options)
})
return
}
showScaleSelector(options)
}
// 备用企业规模选项(当字典数据加载失败时使用)
const fallbackScaleOptions = [
{ label: '1-10人', value: '1' },
{ label: '11-50人', value: '2' },
{ label: '51-100人', value: '3' },
{ label: '101-500人', value: '4' },
{ label: '501-1000人', value: '5' },
{ label: '1000人以上', value: '6' }
]
// 显示企业规模选择器
const showScaleSelector = (options) => {
console.log('企业规模选项列表:', options)
openSelectPopup({
title: '企业规模',
maskClick: true,
data: [options],
success: (_, [value]) => {
console.log('选择的企业规模:', value)
formData.scale = value.value
formData.scaleText = value.label
updateCompletion()
$api.msg('企业规模选择成功')
}
})
}
// 添加联系人
const addContact = () => {
@@ -573,6 +654,11 @@ const confirm = () => {
return
}
if (!formData.scale.trim()) {
$api.msg('请选择企业规模')
return
}
// 验证身份证号格式
const idCardRegex = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
if (!idCardRegex.test(formData.legalIdCard)) {
@@ -623,6 +709,7 @@ const confirm = () => {
legalPhone: formData.legalPhone,
industryType: formData.industryType,
isLocalCompany: formData.isLocalCompany,
scale: formData.scaleText,
companyContactList: formData.companyContactList.filter(contact => contact.contactPerson.trim() && contact.contactPersonPhone.trim())
}
@@ -632,10 +719,19 @@ const confirm = () => {
}
$api.createRequest('/app/user/registerUser', submitData, 'post')
.then((resData) => {
.then(async (resData) => {
uni.hideLoading()
$api.msg('企业信息保存成功')
// 保存成功后,重新获取用户信息并更新缓存
try {
await userStore.getUserResume()
console.log('用户信息已更新到缓存')
} catch (error) {
console.error('获取用户信息失败:', error)
// 即使获取用户信息失败,也不影响页面跳转
}
// 跳转到首页或企业相关页面
uni.reLaunch({
url: '/pages/index/index'