文件
yjyf/yjyf-master-app/pages/master/cert-upload.vue
MiAn 14533eadb7 feat: 用户端与师傅端双小程序架构解耦,新增师傅独立认证及超时自动关单机制
1. 账号体系与数据库解耦:
   - 师傅表 fa_master 解除对 fa_user.id 的外键依赖,升级为独立认证账号主表;
   - 新增师傅端独立支撑表:fa_master_security、fa_master_token、fa_master_wechat、fa_master_agreement_read;
   - 新增工单超时未接单自动关闭与原路退款配置(order_unaccepted_close_days)。

2. 服务端(Server):
   - 新增师傅端独立 API 控制器与认证库(MasterAuth, MasterBase, MasterMessage, MasterSecurity, MasterToken);
   - WxLogin 支持双小程序端(user/master)独立换取 session_key、openid 与 access_token;
   - 新增控制台调度命令 php think order:autoclose,支持订单超时自动关闭与售后退款闭环;
   - 修复 PHP 8.5 兼容性问题(Request.php 的 (bool) 强制转换);
   - 系统业务配置全面收敛至数据库 fa_config 及 site.php。

3. 小程序端:
   - yjyf-app(用户端):彻底剥离师傅端路由、组件及静态资源,增加隐私授权弹窗与评价模块;
   - yjyf-master-app(师傅端):全新独立微信小程序工程(wx140d90ceda786107),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
2026-11-23 15:10:30 +08:00

884 行
20 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="cert-upload-page">
<YjyfNavBar theme="white" :title="navTitle" :border="true" />
<!-- 加载中骨架 -->
<view class="loading-wrap" v-if="loading">
<view class="sk-line sk-h"></view>
<view class="sk-line sk-s"></view>
<view class="sk-box"></view>
<view class="sk-line sk-f"></view>
</view>
<!-- 错误重试 -->
<view class="error-wrap" v-else-if="loadError">
<image class="err-ico" src="/static/icons/master/workbench-error.svg" mode="aspectFit" />
<text class="err-title">证书信息加载失败</text>
<text class="err-sub">{{ loadError }}</text>
<view class="err-btn clickable-hover" @tap="loadDetail">
<text class="err-btn-txt">重新加载</text>
</view>
</view>
<!-- 表单主体 -->
<view class="form-body" v-else>
<!-- 已有记录的审核状态栏 -->
<view class="audit-banner" v-if="record" :class="'st-' + record.status">
<view class="audit-head">
<text class="audit-badge">{{ record.status_text }}</text>
<text class="audit-desc" v-if="record.status === 'pending'">已提交至平台审核,如需更新照片可重新上传提交</text>
<text class="audit-desc" v-else-if="record.status === 'pass'">证书已认证通过,若证件续期可更新上传</text>
<text class="audit-desc" v-else>请根据原因修改并重新提交清晰证件照片</text>
</view>
<text class="audit-reason" v-if="record.status === 'reject' && record.audit_msg">驳回原因:{{ record.audit_msg }}</text>
</view>
<!-- 其他证书名称输入框 -->
<view class="custom-name-row" v-if="isOther">
<text class="row-label">证书名称:</text>
<input
class="custom-name-input"
v-model="customName"
placeholder="请输入证书全称(如:消防设施操作员证)"
placeholder-class="ph-text"
maxlength="40"
/>
</view>
<!-- 标题与示例说明 -->
<view class="intro-block">
<text class="intro-title">上传“{{ displayCertTitle }}”照片</text>
<view class="intro-desc-wrap">
<text class="intro-star">*</text>
<text class="intro-desc">请上传本人的“{{ displayCertTitle }}”照片,并保持照片完整和清晰。</text>
<text class="sample-link clickable-hover" @tap="showSampleModal = true">查看示例{{ '>' }}</text>
</view>
</view>
<!-- 证件上传方框区域(含底纹框) -->
<view class="upload-area-wrap">
<view class="upload-box clickable-hover" @tap="handleChooseImage">
<!-- 未上传前展示古典证件底纹 -->
<image
v-if="!certImage"
class="frame-bg"
src="/static/icons/master/cert-frame-bg.svg"
mode="scaleToFill"
/>
<!-- 上传中状态 -->
<view class="uploading-mask" v-if="uploading">
<view class="spinner"></view>
<text class="uploading-txt">正在上传证书照片...</text>
</view>
<!-- 已上传证件预览 -->
<template v-else-if="certImage">
<image
class="preview-img"
:src="previewImageUrl"
mode="aspectFit"
@tap.stop="previewFullImage"
/>
<view class="preview-actions">
<view class="pa-btn clickable-hover" @tap.stop="previewFullImage">
<text class="pa-txt">查看大图</text>
</view>
<view class="pa-btn pa-primary clickable-hover" @tap.stop="handleChooseImage">
<text class="pa-txt">重新上传</text>
</view>
</view>
</template>
<!-- 默认未上传占位 -->
<view class="upload-placeholder" v-else>
<image class="cam-ico" src="/static/icons/master/cert-camera.svg" mode="aspectFit" />
<text class="upload-tip">点击上传证书照片</text>
</view>
</view>
</view>
<!-- 证件有效期 -->
<view class="expire-section">
<view class="expire-row">
<text class="expire-label">证件有效期至:</text>
<view class="expire-picker-wrap">
<text class="longterm-val" v-if="isLongTerm">长期有效</text>
<picker
v-else
mode="date"
:value="expireDate || todayDate"
:start="todayDate"
end="2099-12-31"
@change="onDateChange"
class="date-picker"
>
<view class="picker-inner">
<text class="picker-txt" :class="{ placeholder: !expireDate }">
{{ expireDate || '请选择截止日期' }}
</text>
<image class="picker-arrow" src="/static/icons/master/cert-date-down.svg" mode="aspectFit" />
</view>
</picker>
</view>
</view>
<!-- 长期有效切换行 -->
<view class="longterm-toggle-row clickable-hover" @tap="toggleLongTerm">
<image
class="check-ico"
:src="isLongTerm ? '/static/icons/invoice-check-on.svg' : '/static/icons/invoice-check-off.svg'"
mode="aspectFit"
/>
<text class="longterm-tip">证件无固定截止日期(长期有效)</text>
</view>
</view>
<!-- 已有证书删除按钮(主要供自定义或已传错撤回) -->
<view class="delete-wrap" v-if="record && record.id > 0">
<text class="delete-link clickable-hover" @tap="handleDelete">删除该证书记录</text>
</view>
</view>
<!-- 底部固定主提交按钮 -->
<view class="bottom-placeholder"></view>
<view class="bottom-bar" v-if="!loading && !loadError">
<view
class="submit-btn clickable-hover"
:class="{ disabled: !canSubmit || submitting }"
@tap="handleSubmit"
>
<text class="submit-txt">{{ submitting ? '正在提交...' : '确定提交' }}</text>
</view>
</view>
<!-- 示例图底部半屏弹窗 -->
<view class="modal-mask" v-if="showSampleModal" @tap="showSampleModal = false">
<view class="sample-sheet" @tap.stop>
<view class="sheet-title">示例图</view>
<text class="sheet-desc">{{ sampleTip }}</text>
<scroll-view scroll-y class="sample-scroll">
<view class="sample-list">
<view class="sample-item" v-for="(sp, idx) in sampleImages" :key="idx">
<image class="sample-img" :src="sp.url" mode="widthFix" />
</view>
</view>
</scroll-view>
<view class="sheet-footer">
<view class="know-btn clickable-hover" @tap="showSampleModal = false">
<text class="know-txt">好的,知道了</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { BASE_URL, isLogin, toLogin } from '@/utils/request.js';
const certCode = ref('');
const certId = ref(0);
const loading = ref(true);
const loadError = ref('');
const dict = ref({});
const record = ref(null);
const sampleTip = ref('下图仅用于示例展示,证件有效期、签发机关(审核机构)以您的真实证件为准。');
const sampleImages = ref([]);
const customName = ref('');
const certImage = ref('');
const certImageFull = ref('');
const expireDate = ref('');
const isLongTerm = ref(false);
const uploading = ref(false);
const submitting = ref(false);
const showSampleModal = ref(false);
const todayDate = computed(() => {
const d = new Date();
const y = d.getFullYear();
const m = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
return `${y}-${m}-${day}`;
});
const isOther = computed(() => certCode.value === 'other' || Number(dict.value.is_other || 0) === 1);
const navTitle = computed(() => {
if (dict.value && dict.value.cert_name) return dict.value.cert_name;
return '技能证书';
});
const displayCertTitle = computed(() => {
if (isOther.value) {
return customName.value.trim() || '其他证书';
}
return dict.value.cert_name || '技能证书';
});
const previewImageUrl = computed(() => {
if (certImageFull.value) return certImageFull.value;
const url = certImage.value;
if (!url) return '';
if (/^https?:\/\//i.test(url)) return url;
const origin = BASE_URL.replace(/\/api\/?$/, '');
return origin + (url.startsWith('/') ? url : '/' + url);
});
const canSubmit = computed(() => {
if (uploading.value) return false;
if (isOther.value && customName.value.trim().length < 2) return false;
if (!certImage.value) return false;
if (!isLongTerm.value && !expireDate.value) return false;
return true;
});
function onDateChange(e) {
expireDate.value = e.detail.value || '';
}
function toggleLongTerm() {
isLongTerm.value = !isLongTerm.value;
}
function previewFullImage() {
if (!previewImageUrl.value) return;
uni.previewImage({
urls: [previewImageUrl.value],
current: previewImageUrl.value
});
}
function handleChooseImage() {
if (uploading.value || submitting.value) return;
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: async (res) => {
const tempPath = res.tempFilePaths && res.tempFilePaths[0];
if (!tempPath) return;
uploading.value = true;
try {
const up = await api.upload(tempPath, 'cert');
certImage.value = up.url || up.fullurl || '';
certImageFull.value = up.fullurl || up.url || '';
if (!certImage.value) {
uni.showToast({ title: '上传失败,未获取到图片地址', icon: 'none' });
}
} catch (err) {
uni.showToast({ title: (err && (err.msg || err.message)) || '图片上传失败', icon: 'none' });
} finally {
uploading.value = false;
}
}
});
}
async function loadDetail() {
if (!isLogin()) {
toLogin();
return;
}
loading.value = true;
loadError.value = '';
try {
const params = { cert_code: certCode.value };
if (certId.value > 0) params.cert_id = certId.value;
const res = await api.masterCertDetail(params);
dict.value = res.dict || {};
record.value = res.record || null;
sampleTip.value = res.sample_tip || sampleTip.value;
sampleImages.value = Array.isArray(res.sample_images) ? res.sample_images : [];
if (record.value) {
certId.value = Number(record.value.id || 0);
if (isOther.value) {
customName.value = record.value.cert_name || '';
}
certImage.value = record.value.cert_image || '';
certImageFull.value = record.value.cert_image_full || record.value.cert_image || '';
isLongTerm.value = Number(record.value.is_long_term || 0) === 1;
expireDate.value = record.value.expire_date || '';
}
} catch (e) {
loadError.value = e.msg || e.message || '加载失败,请重试';
} finally {
loading.value = false;
}
}
async function handleSubmit() {
if (submitting.value) return;
if (isOther.value && customName.value.trim().length < 2) {
uni.showToast({ title: '请输入至少2个字的证书名称', icon: 'none' });
return;
}
if (!certImage.value) {
uni.showToast({ title: '请先上传证书照片', icon: 'none' });
return;
}
if (!isLongTerm.value && !expireDate.value) {
uni.showToast({ title: '请选择证件有效期截止日期', icon: 'none' });
return;
}
submitting.value = true;
try {
await api.masterSaveCert({
cert_code: certCode.value,
cert_id: certId.value,
custom_name: isOther.value ? customName.value.trim() : '',
cert_image: certImage.value,
expire_date: isLongTerm.value ? '' : expireDate.value,
is_long_term: isLongTerm.value ? 1 : 0
});
uni.showToast({ title: '提交成功,待平台审核', icon: 'success' });
setTimeout(() => {
submitting.value = false;
uni.navigateBack();
}, 750);
} catch (e) {
submitting.value = false;
uni.showToast({ title: e.msg || e.message || '提交失败,请重试', icon: 'none' });
}
}
function handleDelete() {
if (!record.value || !record.value.id) return;
uni.showModal({
title: '确认删除',
content: `确定要删除“${displayCertTitle.value}”的上传记录吗?`,
confirmColor: '#E8331B',
success: async (res) => {
if (!res.confirm) return;
try {
await api.masterDeleteCert({ cert_id: record.value.id });
uni.showToast({ title: '已删除', icon: 'success' });
setTimeout(() => {
uni.navigateBack();
}, 650);
} catch (e) {
uni.showToast({ title: e.msg || e.message || '删除失败', icon: 'none' });
}
}
});
}
onLoad((options) => {
certCode.value = (options && options.cert_code) ? decodeURIComponent(options.cert_code) : 'other';
certId.value = (options && options.cert_id) ? Number(options.cert_id) : 0;
loadDetail();
});
</script>
<style lang="scss" scoped>
.cert-upload-page {
min-height: 100vh;
background-color: $yjyf-bg-card;
box-sizing: border-box;
}
.loading-wrap {
padding: 40rpx 32rpx;
}
.sk-line,
.sk-box {
border-radius: 12rpx;
background: linear-gradient(90deg, $yjyf-border-color 25%, $yjyf-bg-page 50%, $yjyf-border-color 75%);
background-size: 200% 100%;
animation: shimmer 1.4s infinite linear;
margin-bottom: 24rpx;
}
.sk-h { width: 260rpx; height: 36rpx; }
.sk-s { width: 92%; height: 28rpx; }
.sk-box { width: 560rpx; height: 356rpx; margin: 40rpx auto; }
.sk-f { width: 100%; height: 88rpx; margin-top: 32rpx; }
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.error-wrap {
padding: 100rpx 40rpx;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}
.err-ico {
width: 120rpx;
height: 120rpx;
margin-bottom: 20rpx;
}
.err-title {
font-size: 30rpx;
font-weight: 600;
color: $yjyf-text-main;
margin-bottom: 10rpx;
}
.err-sub {
font-size: 25rpx;
color: $yjyf-text-secondary;
margin-bottom: 32rpx;
}
.err-btn {
padding: 18rpx 44rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-gradient-primary;
box-shadow: $yjyf-shadow-button;
}
.err-btn-txt {
font-size: 26rpx;
font-weight: 600;
color: #FFFFFF;
}
.form-body {
padding: 28rpx 32rpx 40rpx;
}
.audit-banner {
padding: 20rpx 24rpx;
border-radius: $yjyf-radius-md;
margin-bottom: 28rpx;
&.st-pending {
background-color: $yjyf-primary-bg;
border: 1rpx solid rgba(249, 141, 37, 0.28);
.audit-badge { background-color: $yjyf-warning; }
}
&.st-pass {
background-color: rgba($yjyf-success, 0.08);
border: 1rpx solid rgba($yjyf-success, 0.25);
.audit-badge { background-color: $yjyf-success; }
}
&.st-reject {
background-color: rgba($yjyf-danger, 0.08);
border: 1rpx solid rgba($yjyf-danger, 0.25);
.audit-badge { background-color: $yjyf-danger; }
}
}
.audit-head {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
}
.audit-badge {
font-size: 22rpx;
color: #FFFFFF;
font-weight: 600;
padding: 4rpx 14rpx;
border-radius: 6rpx;
}
.audit-desc {
font-size: 24rpx;
color: $yjyf-text-regular;
flex: 1;
}
.audit-reason {
display: block;
margin-top: 10rpx;
font-size: 24rpx;
color: $yjyf-danger;
line-height: 1.45;
}
.custom-name-row {
display: flex;
align-items: center;
padding: 18rpx 0 22rpx;
margin-bottom: 24rpx;
border-bottom: 1rpx solid $yjyf-border-color;
}
.row-label {
font-size: 30rpx;
font-weight: 500;
color: $yjyf-text-main;
flex-shrink: 0;
}
.custom-name-input {
flex: 1;
font-size: 28rpx;
color: $yjyf-text-main;
height: 52rpx;
}
.ph-text {
color: $yjyf-text-disabled;
font-size: 28rpx;
}
.intro-block {
margin-bottom: 36rpx;
}
.intro-title {
display: block;
font-size: 32rpx;
font-weight: 600;
color: $yjyf-text-main;
margin-bottom: 14rpx;
}
.intro-desc-wrap {
font-size: 26rpx;
line-height: 1.6;
color: $yjyf-text-secondary;
}
.intro-star {
color: $yjyf-danger;
margin-right: 4rpx;
}
.intro-desc {
color: $yjyf-text-secondary;
}
.sample-link {
color: $yjyf-primary;
margin-left: 12rpx;
font-weight: 500;
}
.upload-area-wrap {
display: flex;
justify-content: center;
margin-bottom: 44rpx;
}
.upload-box {
position: relative;
width: 560rpx;
height: 356rpx;
border-radius: 16rpx;
overflow: hidden;
background-color: $yjyf-bg-page;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: $yjyf-shadow-card;
}
.frame-bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.upload-placeholder {
position: relative;
z-index: 2;
display: flex;
flex-direction: column;
align-items: center;
padding: 0 36rpx;
text-align: center;
}
.cam-ico {
width: 100rpx;
height: 100rpx;
margin-bottom: 18rpx;
}
.upload-tip {
font-size: 28rpx;
color: $yjyf-text-main;
font-weight: 500;
line-height: 1.4;
}
.uploading-mask {
position: absolute;
inset: 0;
z-index: 4;
background: rgba(255, 255, 255, 0.88);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16rpx;
}
.spinner {
width: 48rpx;
height: 48rpx;
border-radius: 50%;
border: 4rpx solid $yjyf-primary-bg;
border-top-color: $yjyf-primary;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.uploading-txt {
font-size: 25rpx;
color: $yjyf-text-regular;
}
.preview-img {
width: 100%;
height: 100%;
background-color: $yjyf-bg-page;
}
.preview-actions {
position: absolute;
right: 16rpx;
bottom: 16rpx;
z-index: 3;
display: flex;
align-items: center;
gap: 12rpx;
}
.pa-btn {
padding: 10rpx 22rpx;
border-radius: $yjyf-radius-pill;
background-color: rgba(15, 23, 42, 0.65);
&.pa-primary {
background: $yjyf-gradient-primary;
}
}
.pa-txt {
font-size: 22rpx;
color: #FFFFFF;
}
.expire-section {
border-top: 1rpx solid $yjyf-border-color;
}
.expire-row {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 104rpx;
border-bottom: 1rpx solid $yjyf-border-color;
}
.expire-label {
font-size: 30rpx;
color: $yjyf-text-main;
flex-shrink: 0;
}
.expire-picker-wrap {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
padding-left: 16rpx;
}
.date-picker {
flex: 1;
}
.picker-inner {
display: flex;
align-items: center;
justify-content: space-between;
height: 80rpx;
}
.picker-txt {
font-size: 29rpx;
color: $yjyf-text-main;
&.placeholder {
color: $yjyf-text-disabled;
}
}
.longterm-val {
font-size: 29rpx;
color: $yjyf-success;
font-weight: 500;
}
.picker-arrow {
width: 28rpx;
height: 28rpx;
}
.longterm-toggle-row {
display: flex;
align-items: center;
gap: 12rpx;
padding: 24rpx 0;
}
.check-ico {
width: 32rpx;
height: 32rpx;
}
.longterm-tip {
font-size: 25rpx;
color: $yjyf-text-secondary;
}
.delete-wrap {
margin-top: 32rpx;
text-align: center;
}
.delete-link {
font-size: 26rpx;
color: $yjyf-danger;
}
.bottom-placeholder {
height: calc(env(safe-area-inset-bottom) + 148rpx);
}
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 32rpx calc(env(safe-area-inset-bottom) + 24rpx);
background-color: $yjyf-bg-card;
z-index: 20;
}
.submit-btn {
height: 90rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-gradient-primary;
display: flex;
align-items: center;
justify-content: center;
box-shadow: $yjyf-shadow-button;
&.disabled {
background: $yjyf-gradient-primary;
opacity: 0.42;
box-shadow: none;
}
}
.submit-txt {
font-size: 30rpx;
font-weight: 600;
color: #FFFFFF;
}
/* 示例图半屏弹窗 */
.modal-mask {
position: fixed;
inset: 0;
z-index: 999;
background-color: rgba(0, 0, 0, 0.55);
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.sample-sheet {
background-color: $yjyf-bg-card;
border-radius: 32rpx 32rpx 0 0;
padding: 36rpx 32rpx calc(env(safe-area-inset-bottom) + 28rpx);
max-height: 85vh;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.sheet-title {
font-size: 34rpx;
font-weight: 600;
color: $yjyf-text-main;
text-align: center;
margin-bottom: 24rpx;
}
.sheet-desc {
display: block;
font-size: 27rpx;
line-height: 1.55;
color: $yjyf-text-main;
margin-bottom: 24rpx;
}
.sample-scroll {
max-height: 52vh;
margin-bottom: 28rpx;
}
.sample-list {
display: flex;
flex-direction: column;
gap: 24rpx;
}
.sample-item {
border-radius: 16rpx;
overflow: hidden;
border: 1rpx solid $yjyf-border-color;
background-color: $yjyf-bg-page;
}
.sample-img {
width: 100%;
display: block;
}
.sheet-footer {
padding-top: 8rpx;
}
.know-btn {
height: 88rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-gradient-primary;
display: flex;
align-items: center;
justify-content: center;
box-shadow: $yjyf-shadow-button;
}
.know-txt {
font-size: 30rpx;
font-weight: 600;
color: #FFFFFF;
}
.clickable-hover:active {
opacity: 0.78;
}
</style>