@ -36,16 +36,29 @@
< / view >
<!-- 营业执照 -- >
< view class = "info-card mx-30rpx mt-30rpx rounded-24rpx bg-white p -30rpx" >
< view class = "rounded-24rpx bg-white mx -30rpx relative " >
<!-- 审核状态标签 -- >
< view class = "absolute top-20rpx right-34rpx" >
< view v-if = "auditStatus == 0"
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "160rpx" height = "160rpx" :src = "`${OSS}images/chayishi/applying.png`" / >
< / view >
< view v -else -if = " auditStatus = = 1 "
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "160rpx" height = "160rpx" :src = "`${OSS}images/chayishi/success.png`" / >
< / view >
< view v -else -if = " auditStatus = = 2 "
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "160rpx" height = "160rpx" :src = "`${OSS}images/chayishi/fail.png`" / >
< / view >
< / view >
<!-- 营业执照 -- >
< view class = "info-card mt-30rpx px-30rpx pt-20rpx" >
< text class = "mb-24rpx block text-32rpx text-[#303133] font-bold leading-44rpx" > 营业执照 < / text >
< view v-if = "documents.businessLicense" class="relative w-[200rpx]" >
< wd -img width = "200rpx" height = "200rpx" :src = "documents.businessLicense" mode = "aspectFill"
class = "rounded-12rpx" / >
<!-- 审核状态标签 -- >
< view v-if = "auditStatus.businessLicense === 'approved'"
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/success.png`" / >
< / view >
< / view >
< view v -else class = "empty-state flex flex-col items-center justify-center py-60rpx" >
< wd-img width = "120rpx" height = "120rpx" :src = "`${OSS}images/chayishi/text.png`" / >
@ -54,24 +67,11 @@
< / view >
<!-- 资质证书 -- >
< view class = "info-card mx-30rpx mt-30rpx rounded-24rpx bg-white p-30rpx" >
< view class = "info-card px -30rpx" >
< text class = "mb-24rpx block text-32rpx text-[#303133] font-bold leading-44rpx" > 资质证书 < / text >
< view v-if = "documents.qualification" class="relative w-[200rpx]" >
< wd -img width = "200rpx" height = "200rpx" :src = "documents.qualification" mode = "aspectFill"
class = "rounded-12rpx" / >
<!-- 审核状态标签 -- >
< view v-if = "auditStatus.qualification === 'rejected'"
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/fail.png`" / >
< / view >
< view v -else -if = " auditStatus.qualification = = = ' pending ' "
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/applying.png`" / >
< / view >
< view v -else -if = " auditStatus.qualification = = = ' approved ' "
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/success.png`" / >
< / view >
< / view >
< view v -else class = "empty-state flex flex-col items-center justify-center py-60rpx" >
< wd-img width = "120rpx" height = "120rpx" :src = "`${OSS}images/chayishi/text.png`" / >
@ -80,33 +80,21 @@
< / view >
<!-- 健康证 -- >
< view class = "info-card mx-30rpx mt-30rpx rounded-24rpx bg-white p-30rpx" >
< view class = "info-card rounded-24rpx px -30rpx" >
< text class = "mb-24rpx block text-32rpx text-[#303133] font-bold leading-44rpx" > 健康证 < / text >
< view v-if = "documents.healthCert" class="relative w-[200rpx]" >
< wd -img width = "200rpx" height = "200rpx" :src = "documents.healthCert" mode = "aspectFill"
class = "rounded-12rpx" / >
<!-- 审核状态标签 -- >
< view v-if = "auditStatus.healthCert === 'approved'"
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/success.png`" / >
< / view >
< view v -else -if = " auditStatus.healthCert = = = ' pending ' "
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/applying.png`" / >
< / view >
< view v -else -if = " auditStatus.healthCert = = = ' rejected ' "
class = "status-badge absolute right-8rpx top-8rpx" >
< wd-img width = "80rpx" height = "80rpx" :src = "`${OSS}images/chayishi/fail.png`" / >
< / view >
< / view >
< view v -else class = "empty-state flex flex-col items-center justify-center py-60rpx" >
< wd-img width = "120rpx" height = "120rpx" :src = "`${OSS}images/chayishi/text.png`" / >
< text class = "mt-24rpx text-28rpx text-[#909399] leading-40rpx" > 暂未提交信息 < / text >
< / view >
< / view >
< / view >
<!-- 修改信息按钮 -- >
< view class = "mx-30rpx mb-40rpx mt-40rpx" >
<!-- 修改信息按钮 - 待审核和审核失败可修改信息 -- >
< view class = "mx-30rpx mb-40rpx mt-40rpx" v-if = "auditStatus == 0 || auditStatus == 2" >
< view class = "edit-btn h-88rpx rounded-16rpx bg-[#4C9F44] text-center leading-88rpx"
@click ="UploadData.handleEdit" >
< text class = "text-32rpx text-[#fff] font-bold" > 修改信息 < / text >
@ -200,7 +188,7 @@
<!-- 提交按钮 ( 仅在新增 / 编辑状态显示 ) -- >
< view v-if = "pageStatus === 'add' || pageStatus === 'edit'"
class = "fixed bottom-0 left-0 right-0 px-30rpx pb-40rpx pt-24rpx z-100" >
< view class = "save-btn h-88rpx rounded-16 rpx bg-[#4C9F44] text-center leading-88rpx"
< view class = "save-btn h-88rpx rounded-8 rpx bg-[#4C9F44] text-center leading-88rpx"
@click ="UploadData.handleSubmit" >
< text class = "text-32rpx text-[#fff] font-bold" > 提交 < / text >
< / view >
@ -211,7 +199,7 @@
< script lang = "ts" setup >
import { router } from '@/utils/tools'
import { useToast } from 'wot-design-uni'
import { addTeaSpecialistQualification , getTeaSpecialistQualification } from '@/api/tes-specialist'
import { addTeaSpecialistQualification , getTeaSpecialistQualification , editTeaSpecialistQualification } from '@/api/tes-specialist'
const OSS = inject ( 'OSS' )
const navbarHeight = inject ( 'navbarHeight' )
@ -230,12 +218,8 @@
healthCert : '' , // 健康证
} )
// 审核状态: 'approved' | 'pending' | 'rejected' | 'none'
const auditStatus = ref ( {
businessLicense : 'approved' , // 'approved' | 'pending' | 'rejected' | 'none'
qualification : 'none' ,
healthCert : 'pending' ,
} )
// 审核状态
const auditStatus = ref < number > ( 0 ) // 0 待审核 1 通过 2 未通过
// 上传文件
const fileList1 = ref < any [ ] > ( [ ] ) // 营业执照
@ -243,19 +227,27 @@
const fileList3 = ref < any [ ] > ( [ ] ) // 健康证
const action = import . meta . env . VITE _UPLOAD _BASEURL
// certId
const certId = ref < number > ( 0 )
// 初始化:根据实际情况判断页面状态
onLoad ( ( option s: any ) => {
onLoad ( async ( arg s: any ) => {
token . value = uni . getStorageSync ( 'token' )
certId . value = args . certId || 0
// 如果有状态参数,使用参数
if ( option s. status ) {
pageStatus . value = option s. status as 'add' | 'edit' | 'pending' | 'view'
if ( arg s. status ) {
pageStatus . value = arg s. status as 'add' | 'edit' | 'pending' | 'view'
}
// TODO: 否则根据API数据判断状态
// 如果已提交且在审核中, 显示pending
// 如果已审核通过, 显示view
// 如果有数据但需要编辑, 显示edit
UploadData . handleGetInfo ( )
if ( certId . value > 0 ) {
await UploadData . handleGetInfo ( )
}
// 如果无数据, 显示add
} )
@ -264,30 +256,24 @@
* 初始化数据
*/
handleGetInfo : async ( ) => {
const res = await getTeaSpecialistQualification ( )
console . log ( "🚀 ~ res:" , res )
const res = await getTeaSpecialistQualification ( certId . value )
} ,
// 回显图片-编辑状态
fileList1 . value = res . license _img ? [ { url : res . license _img } ] : [ ] // 营业执照
fileList2 . value = res . cert _img ? [ { url : res . cert _img } ] : [ ] // 资质证书
fileList3 . value = res . fitness _img ? [ { url : res . fitness _img } ] : [ ] // 健康证
// 上传图片
handleUploadImage : ( type : 'businessLicense' | 'qualification' | 'healthCert' ) => {
uni . chooseImage ( {
count : 1 ,
sourceType : [ 'camera' , 'album' ] ,
success : ( res ) => {
// TODO: 上传图片到服务器
console . log ( '选择图片:' , res )
documents . value [ type ] = res . tempFilePaths [ 0 ]
} ,
} )
} ,
// 回显图片-预览状态
documents . value = {
businessLicense : res . license _img || '' ,
qualification : res . cert _img || '' ,
healthCert : res . fitness _img || '' ,
}
// 删除图片
handleDeleteImage : ( type : 'businessLicense' | 'qualification' | 'healthCert' ) => {
documents . value [ type ] = ''
// 设置审核状态
auditStatus . value = res . status // 0 待审核 1 通过 2 未通过
} ,
// 修改信息
handleEdit : ( ) => {
pageStatus . value = 'edit'
@ -348,13 +334,29 @@
* 提交数据
*/
handleSubmit : async ( ) => {
// // TODO: 实现提交逻辑
const licenseImg = documents . value . businessLicense ? documents . value . businessLicense . replace ( import . meta . env . VITE _OSS _BASEURL , '' ) : ''
const certImg = documents . value . qualification ? documents . value . qualification . replace ( import . meta . env . VITE _OSS _BASEURL , '' ) : ''
const fitnessImg = documents . value . healthCert ? documents . value . healthCert . replace ( import . meta . env . VITE _OSS _BASEURL , '' ) : ''
if ( certId . value > 0 ) {
// 编辑资料
await editTeaSpecialistQualification ( {
id : certId . value ,
license _img : licenseImg ,
cert _img : certImg ,
fitness _img : fitnessImg ,
} )
toast . show ( '资料修改成功' )
} else {
// 添加资料
await addTeaSpecialistQualification ( {
license _img : documents . value . businessL icense,
cert _img : documents . value . qualification ,
fitness _img : documents . value . healthCert ,
license _img : l icenseImg ,
cert _img : certImg ,
fitness _img : fitnessImg ,
} )
toast . show ( '资料提交成功' )
}
// 提交后设置为申请中状态
pageStatus . value = 'pending'
} ,