文件
yjyf/yjyf-master-app/pages/master/certs.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

457 行
10 KiB
Vue

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

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

<template>
<view class="certs-page">
<YjyfNavBar theme="white" title="技能证书" :border="true" />
<!-- 顶部合规提示条(数据来自接口下发) -->
<view class="notice-bar" v-if="noticeText">
<image class="notice-ico" src="/static/icons/master/cert-notice.svg" mode="aspectFit" />
<text class="notice-txt">{{ noticeText }}</text>
</view>
<!-- 搜索框 -->
<view class="search-section">
<view class="search-box">
<image class="search-ico" src="/static/icons/master/cert-search.svg" mode="aspectFit" />
<input
class="search-input"
v-model="keyword"
placeholder="搜索技能证书"
placeholder-class="search-ph"
confirm-type="search"
/>
<view class="clear-btn clickable-hover" v-if="keyword" @tap="keyword = ''">
<image class="clear-ico" src="/static/icons/master/cert-clear.svg" mode="aspectFit" />
</view>
</view>
</view>
<!-- 加载骨架态 -->
<view class="content-wrap" v-if="loading">
<view class="cert-card skeleton-card">
<view class="sk-row" v-for="i in 8" :key="i">
<view class="sk-bar sk-title"></view>
<view class="sk-bar sk-status"></view>
</view>
</view>
</view>
<!-- 加载失败态 -->
<view class="content-wrap" v-else-if="loadError">
<view class="state-card">
<image class="state-ico" src="/static/icons/master/workbench-error.svg" mode="aspectFit" />
<text class="state-title">证书列表加载失败</text>
<text class="state-sub">{{ loadError }}</text>
<view class="retry-btn clickable-hover" @tap="loadCerts">
<text class="retry-txt">重新加载</text>
</view>
</view>
</view>
<!-- 证书列表主卡 -->
<view class="content-wrap" v-else>
<view class="cert-card" v-if="filteredItems.length > 0 || filteredCustomItems.length > 0 || showOtherEntry">
<!-- 27项标准技能证书 -->
<view
class="cert-row clickable-hover"
v-for="item in filteredItems"
:key="item.cert_code"
@tap="goUpload(item.cert_code)"
>
<text class="cert-name">{{ item.cert_name }}</text>
<view class="cert-right">
<text class="cert-status" :class="statusCls(item.status)">{{ item.status_text }}</text>
<image class="cert-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
<!-- 师傅已上传的自定义证书 -->
<view
class="cert-row clickable-hover"
v-for="cItem in filteredCustomItems"
:key="'custom-' + cItem.id"
@tap="goUpload('other', cItem.id)"
>
<view class="cert-name-wrap">
<text class="cert-name">{{ cItem.cert_name }}</text>
<text class="custom-badge">自定义</text>
</view>
<view class="cert-right">
<text class="cert-status" :class="statusCls(cItem.status)">{{ cItem.status_text }}</text>
<image class="cert-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
<!-- 底部固定入口:其他证书 -->
<view
class="cert-row clickable-hover"
v-if="showOtherEntry"
@tap="goUpload(otherEntry.cert_code || 'other')"
>
<text class="cert-name">{{ otherEntry.cert_name || '其他证书' }}</text>
<view class="cert-right">
<image class="cert-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
</view>
<!-- 搜索无结果空态 -->
<view class="state-card" v-else>
<text class="state-title">未找到“{{ trimmedKeyword }}”相关证书</text>
<text class="state-sub">您可以清空关键词查看全部,或直接上传其他证书</text>
<view class="empty-actions">
<view class="ghost-btn clickable-hover" @tap="keyword = ''">
<text class="ghost-txt">清空搜索</text>
</view>
<view class="retry-btn clickable-hover" @tap="goUpload('other')">
<text class="retry-txt">上传其他证书</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import api from '@/utils/api.js';
import { isLogin, toLogin } from '@/utils/request.js';
const loading = ref(true);
const loadError = ref('');
const noticeText = ref('');
const keyword = ref('');
const items = ref([]);
const customItems = ref([]);
const otherEntry = ref({ cert_code: 'other', cert_name: '其他证书' });
const trimmedKeyword = computed(() => String(keyword.value || '').trim());
const filteredItems = computed(() => {
const kw = trimmedKeyword.value.toLowerCase();
if (!kw) return items.value;
return items.value.filter(it => String(it.cert_name || '').toLowerCase().includes(kw));
});
const filteredCustomItems = computed(() => {
const kw = trimmedKeyword.value.toLowerCase();
if (!kw) return customItems.value;
return customItems.value.filter(it => String(it.cert_name || '').toLowerCase().includes(kw));
});
const showOtherEntry = computed(() => {
const kw = trimmedKeyword.value.toLowerCase();
if (!kw) return true;
return String(otherEntry.value.cert_name || '其他证书').toLowerCase().includes(kw);
});
function statusCls(status) {
if (status === 'pass') return 'st-pass';
if (status === 'pending') return 'st-pending';
if (status === 'reject') return 'st-reject';
return 'st-none';
}
function goUpload(certCode, certId = 0) {
let url = `/pages/master/cert-upload?cert_code=${encodeURIComponent(certCode || 'other')}`;
if (certId > 0) {
url += `&cert_id=${certId}`;
}
uni.navigateTo({ url });
}
async function loadCerts() {
if (!isLogin()) {
toLogin();
return;
}
loading.value = true;
loadError.value = '';
try {
const res = await api.masterCerts();
noticeText.value = res.notice || '';
items.value = Array.isArray(res.items) ? res.items : [];
customItems.value = Array.isArray(res.custom_items) ? res.custom_items : [];
if (res.other_entry) {
otherEntry.value = res.other_entry;
}
} catch (e) {
loadError.value = e.msg || e.message || '网络异常,请稍后重试';
} finally {
loading.value = false;
}
}
onShow(() => {
loadCerts();
});
</script>
<style lang="scss" scoped>
.certs-page {
min-height: 100vh;
background-color: $yjyf-bg-page;
padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
box-sizing: border-box;
}
.notice-bar {
display: flex;
align-items: flex-start;
gap: 12rpx;
padding: 18rpx 28rpx;
background-color: $yjyf-primary-bg;
}
.notice-ico {
width: 30rpx;
height: 30rpx;
flex-shrink: 0;
margin-top: 4rpx;
}
.notice-txt {
flex: 1;
font-size: 24rpx;
line-height: 1.5;
color: $yjyf-text-main;
}
.search-section {
background-color: $yjyf-bg-card;
padding: 16rpx 24rpx 20rpx;
border-bottom: 1rpx solid $yjyf-border-color;
}
.search-box {
display: flex;
align-items: center;
gap: 12rpx;
height: 72rpx;
padding: 0 24rpx;
background-color: $yjyf-bg-page;
border-radius: 36rpx;
}
.search-ico {
width: 30rpx;
height: 30rpx;
flex-shrink: 0;
}
.search-input {
flex: 1;
height: 72rpx;
font-size: 28rpx;
color: $yjyf-text-main;
}
.search-ph {
color: $yjyf-text-muted;
font-size: 26rpx;
}
.clear-btn {
padding: 8rpx;
display: flex;
align-items: center;
justify-content: center;
}
.clear-ico {
width: 30rpx;
height: 30rpx;
}
.content-wrap {
padding: 20rpx 20rpx 0;
}
.cert-card {
background-color: $yjyf-bg-card;
border-radius: $yjyf-radius-lg;
overflow: hidden;
box-shadow: $yjyf-shadow-card;
}
.cert-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
min-height: 100rpx;
padding: 24rpx 28rpx;
border-bottom: 1rpx solid $yjyf-border-color;
box-sizing: border-box;
&:last-child {
border-bottom: none;
}
}
.cert-name-wrap {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
gap: 12rpx;
}
.cert-name {
font-size: 29rpx;
font-weight: 500;
color: $yjyf-text-main;
line-height: 1.4;
word-break: break-all;
}
.custom-badge {
flex-shrink: 0;
font-size: 20rpx;
padding: 2rpx 10rpx;
border-radius: 6rpx;
color: $yjyf-primary;
background-color: $yjyf-primary-bg;
border: 1rpx solid rgba(240, 113, 13, 0.25);
}
.cert-right {
display: flex;
align-items: center;
gap: 10rpx;
flex-shrink: 0;
}
.cert-status {
font-size: 26rpx;
&.st-none {
color: $yjyf-text-muted;
}
&.st-pending {
color: $yjyf-warning;
font-weight: 500;
}
&.st-pass {
color: $yjyf-success;
font-weight: 500;
}
&.st-reject {
color: $yjyf-danger;
font-weight: 500;
}
}
.cert-arrow {
width: 24rpx;
height: 24rpx;
opacity: 0.45;
}
.skeleton-card {
padding: 8rpx 28rpx;
}
.sk-row {
display: flex;
align-items: center;
justify-content: space-between;
height: 96rpx;
border-bottom: 1rpx solid $yjyf-border-color;
&:last-child {
border-bottom: none;
}
}
.sk-bar {
height: 28rpx;
border-radius: 8rpx;
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;
}
.sk-title {
width: 240rpx;
}
.sk-status {
width: 110rpx;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.state-card {
background-color: $yjyf-bg-card;
border-radius: $yjyf-radius-lg;
padding: 72rpx 36rpx;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
box-shadow: $yjyf-shadow-card;
}
.state-ico {
width: 120rpx;
height: 120rpx;
margin-bottom: 20rpx;
}
.state-title {
font-size: 30rpx;
font-weight: 600;
color: $yjyf-text-main;
margin-bottom: 10rpx;
}
.state-sub {
font-size: 25rpx;
color: $yjyf-text-secondary;
line-height: 1.5;
margin-bottom: 32rpx;
}
.empty-actions {
display: flex;
align-items: center;
gap: 20rpx;
}
.retry-btn {
padding: 18rpx 40rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-gradient-primary;
box-shadow: $yjyf-shadow-button;
}
.retry-txt {
font-size: 26rpx;
font-weight: 600;
color: #FFFFFF;
}
.ghost-btn {
padding: 16rpx 36rpx;
border-radius: $yjyf-radius-pill;
border: 1rpx solid $yjyf-border-color;
background-color: $yjyf-bg-page;
}
.ghost-txt {
font-size: 26rpx;
color: $yjyf-text-regular;
}
.clickable-hover:active {
opacity: 0.72;
}
</style>