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

381 行
8.7 KiB
Vue

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

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

<template>
<view class="skills-page">
<YjyfNavBar theme="orange" title="服务技能" />
<view class="header-section">
<view class="tip-banner">
<image class="tip-icon" src="/static/icons/info-orange.svg" mode="aspectFit" />
<view class="tip-content">
<text class="tip-title">选择认证服务技能</text>
<text class="tip-sub">勾选真实可承接的项目,抢单大厅将按技能精准匹配工单</text>
</view>
</view>
</view>
<!-- 加载骨架 -->
<view class="loading-state" v-if="loading">
<text class="loading-text">正在加载服务技能字典...</text>
</view>
<!-- 技能大类手风琴列表 -->
<view class="accordion-container" v-else>
<view class="cat-card" v-for="group in tree" :key="group.category">
<view class="cat-header clickable-hover" @tap="toggleExpand(group.category)">
<view class="cat-title-wrap">
<text class="cat-title">{{ group.category }}</text>
<text class="cat-count" v-if="groupSelectedCount(group) > 0">已选 {{ groupSelectedCount(group) }}</text>
</view>
<image
class="cat-arrow"
:class="{ collapsed: isCollapsed(group.category) }"
src="/static/icons/chevron-up-gray.svg"
mode="aspectFit"
/>
</view>
<view class="cat-body" v-if="!isCollapsed(group.category)">
<view class="skills-grid">
<view
class="skill-chip clickable-hover"
v-for="item in group.items"
:key="item.id"
:class="{ active: isSelected(item.name) }"
@tap="toggleSkill(item.name)"
>
<text class="chip-text">{{ item.name }}</text>
</view>
</view>
</view>
</view>
<!-- 其他技能自定义输入区 -->
<view class="cat-card custom-card">
<view class="custom-head">
<text class="cat-title">其他补充技能</text>
<text class="custom-sub">多项技能用空格或逗号分隔</text>
</view>
<view class="custom-body">
<textarea
class="custom-textarea"
v-model="customText"
placeholder="例如:电动窗帘调试、商用净水器安装"
maxlength="200"
/>
</view>
</view>
</view>
<!-- 底部固定保存栏(content-box 防全面屏安全区挤压) -->
<view class="bottom-bar-placeholder"></view>
<view class="bottom-bar">
<view class="confirm-btn clickable-hover" :class="{ disabled: submitting }" @tap="handleConfirm">
<text class="confirm-txt">
{{ submitting ? '保存中...' : (selectedTotal > 0 ? `保存技能(已选 ${selectedTotal} 项)` : '保存技能') }}
</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref, reactive, 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 submitting = ref(false);
const tree = ref([]);
const selectedMap = reactive({});
const customText = ref('');
const collapsedMap = reactive({});
const selectedTotal = computed(() => Object.keys(selectedMap).length);
function isSelected(name) {
return !!selectedMap[name];
}
function groupSelectedCount(group) {
if (!group || !group.items) return 0;
return group.items.reduce((acc, it) => acc + (selectedMap[it.name] ? 1 : 0), 0);
}
function toggleSkill(name) {
if (selectedMap[name]) {
delete selectedMap[name];
} else {
selectedMap[name] = true;
}
}
function isCollapsed(category) {
return !!collapsedMap[category];
}
function toggleExpand(category) {
collapsedMap[category] = !collapsedMap[category];
}
async function loadSkillDict() {
if (!isLogin()) {
toLogin();
return;
}
loading.value = true;
try {
const res = await api.masterSkillDict();
tree.value = res.tree || [];
customText.value = res.custom_text || '';
for (const k in selectedMap) {
delete selectedMap[k];
}
const validSet = new Set();
(tree.value || []).forEach(g => {
(g.items || []).forEach(it => {
if (it && it.name) validSet.add(it.name);
});
});
const selectedArr = res.selected_skills || [];
selectedArr.forEach(name => {
if (validSet.has(name)) {
selectedMap[name] = true;
}
});
} catch (e) {
uni.showToast({ title: e.msg || '加载技能字典失败', icon: 'none' });
} finally {
loading.value = false;
}
}
async function handleConfirm() {
if (submitting.value) return;
const selectedList = Object.keys(selectedMap);
const cText = customText.value.trim();
if (selectedList.length === 0 && !cText) {
uni.showToast({ title: '请至少选择或输入一项技能', icon: 'none' });
return;
}
submitting.value = true;
try {
await api.masterSaveSkills({
selected_skills: selectedList,
custom_text: cText
});
uni.showToast({ title: '服务技能保存成功', icon: 'success' });
setTimeout(() => {
submitting.value = false;
uni.navigateBack();
}, 700);
} catch (e) {
submitting.value = false;
uni.showToast({ title: e.msg || '保存失败,请稍后重试', icon: 'none' });
}
}
onShow(() => {
loadSkillDict();
});
</script>
<style lang="scss" scoped>
.skills-page {
min-height: 100vh;
background-color: $yjyf-bg-page;
box-sizing: border-box;
}
.header-section {
margin: 20rpx $yjyf-space-md 0;
}
.tip-banner {
display: flex;
align-items: flex-start;
background: $yjyf-primary-bg;
padding: 22rpx 24rpx;
border-radius: $yjyf-radius-md;
}
.tip-icon {
width: 36rpx;
height: 36rpx;
margin-right: 16rpx;
margin-top: 2rpx;
flex-shrink: 0;
}
.tip-content {
display: flex;
flex-direction: column;
}
.tip-title {
font-size: $yjyf-font-body;
font-weight: 700;
color: $yjyf-text-main;
}
.tip-sub {
margin-top: 6rpx;
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
}
.loading-state {
padding: 120rpx 0;
text-align: center;
}
.loading-text {
font-size: $yjyf-font-sub;
color: $yjyf-text-secondary;
}
.accordion-container {
display: flex;
flex-direction: column;
gap: 20rpx;
padding: 20rpx $yjyf-space-md 0;
}
.cat-card {
background: $yjyf-bg-card;
border-radius: $yjyf-radius-md;
overflow: hidden;
box-shadow: $yjyf-shadow-card;
}
.cat-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 26rpx 24rpx;
}
.cat-title-wrap {
display: flex;
align-items: center;
gap: 12rpx;
}
.cat-title {
font-size: $yjyf-font-body;
font-weight: 700;
color: $yjyf-text-main;
}
.cat-count {
height: 36rpx;
padding: 0 14rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-primary-bg;
color: $yjyf-primary;
font-size: $yjyf-font-micro;
font-weight: 600;
display: inline-flex;
align-items: center;
}
.cat-arrow {
width: 28rpx;
height: 28rpx;
transition: transform 0.22s ease;
}
.cat-arrow.collapsed {
transform: rotate(180deg);
}
.cat-body {
padding: 0 24rpx 24rpx;
}
.skills-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16rpx;
}
.skill-chip {
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
background: $yjyf-bg-page;
border: 2rpx solid transparent;
border-radius: $yjyf-radius-sm;
padding: 0 12rpx;
text-align: center;
}
.chip-text {
font-size: $yjyf-font-sub;
color: $yjyf-text-regular;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.skill-chip.active {
background: $yjyf-primary-bg;
border-color: $yjyf-primary;
}
.skill-chip.active .chip-text {
color: $yjyf-primary;
font-weight: 600;
}
.custom-card {
padding: 24rpx;
}
.custom-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.custom-sub {
font-size: $yjyf-font-micro;
color: $yjyf-text-muted;
}
.custom-body {
margin-top: 16rpx;
}
.custom-textarea {
width: 100%;
height: 168rpx;
background: $yjyf-bg-page;
border: 1rpx solid $yjyf-border-color;
border-radius: $yjyf-radius-sm;
padding: 18rpx 20rpx;
font-size: $yjyf-font-body;
color: $yjyf-text-main;
box-sizing: border-box;
line-height: 1.5;
}
.bottom-bar-placeholder {
height: calc(144rpx + env(safe-area-inset-bottom));
}
.bottom-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 88rpx;
padding: 20rpx $yjyf-space-lg calc(20rpx + env(safe-area-inset-bottom));
box-sizing: content-box;
background: $yjyf-bg-card;
box-shadow: $yjyf-shadow-bar;
z-index: 99;
display: flex;
align-items: center;
}
.confirm-btn {
width: 100%;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
background: $yjyf-gradient-primary;
border-radius: $yjyf-radius-pill;
box-shadow: $yjyf-shadow-card;
}
.confirm-txt {
color: $yjyf-bg-card;
font-size: $yjyf-font-body;
font-weight: 700;
}
.confirm-btn.disabled {
opacity: 0.6;
}
</style>