文件
yjyf/yjyf-master-app/components/master/MasterMessageView.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

285 行
8.1 KiB
Vue

<template>
<view class="message-view">
<YjyfNavBar theme="orange" title="消息中心" />
<view class="head">
<view class="cats">
<view v-for="c in cats" :key="c.key" class="cat clickable-hover" :class="{ on: category === c.key }" @tap="switchCat(c.key)">{{ c.name }}</view>
</view>
<text class="read-all clickable-hover" @tap="readAll">全部已读</text>
</view>
<YjyfRefreshScroll
class="msg-scroll"
theme="light"
:refresh-task="load"
>
<view class="list">
<view class="msg clickable-hover" :class="{ unread: !m.is_read }" v-for="m in list" :key="m.id" @tap="open(m)">
<view class="msg-top">
<view class="dot" v-if="!m.is_read"></view>
<text class="title">{{ m.title }}</text>
<text class="time">{{ m.time_text }}</text>
</view>
<text class="content">{{ m.content }}</text>
<view class="go-row" v-if="m.order_id">
<text class="go">查看工单详情</text>
<image class="go-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
</view>
</view>
<view class="empty-box" v-if="!loggedIn">
<image class="empty-img" src="/static/icons/empty-message.svg" mode="aspectFit" />
<text class="empty-txt">登录后查看系统派单与消息通知</text>
<view class="empty-login-btn clickable-hover" @tap="goMasterLogin">立即登录</view>
</view>
<view class="empty-box" v-else-if="!loading && !list.length">
<image class="empty-img" src="/static/icons/empty-message.svg" mode="aspectFit" />
<text class="empty-txt">暂无消息通知</text>
</view>
</view>
</YjyfRefreshScroll>
<!-- 系统通知详情抽屉 -->
<view class="detail-mask" v-if="activeMsg" @tap="activeMsg = null">
<view class="detail-sheet" @tap.stop>
<view class="ds-head">
<text class="ds-title">{{ activeMsg.title }}</text>
<view class="ds-close clickable-hover" @tap="activeMsg = null">
<image class="ds-close-ico" src="/static/icons/close.svg" mode="aspectFit" />
</view>
</view>
<text class="ds-time">{{ activeMsg.time_text }}</text>
<text class="ds-content">{{ activeMsg.content }}</text>
<view class="ds-btn clickable-hover" @tap="activeMsg = null">我知道了</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import api from '@/utils/api.js';
import { isLogin, toLogin } from '@/utils/request.js';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
import YjyfRefreshScroll from '@/components/YjyfRefreshScroll.vue';
const emit = defineEmits(['switch-tab']);
const list = ref([]);
const loggedIn = ref(isLogin());
const loading = ref(false);
const category = ref('all');
const activeMsg = ref(null);
const cats = [
{ key: 'all', name: '全部' },
{ key: 'order', name: '工单' },
{ key: 'system', name: '系统' },
{ key: 'remind', name: '提醒' }
];
function goMasterLogin() {
toLogin('/pages/master/hall?tab=2');
}
async function load() {
loggedIn.value = isLogin();
if (!loggedIn.value) {
list.value = [];
loading.value = false;
return;
}
loading.value = true;
try {
const res = await api.messageList({ type: 'master', category: category.value, limit: 30 });
list.value = res.list || [];
} catch (e) {
} finally {
loading.value = false;
}
}
function switchCat(k) {
category.value = k;
load();
}
const readingAll = ref(false);
async function open(m) {
if (!m.is_read && !m._reading) {
m._reading = true;
try {
await api.messageRead({ id: m.id, type: 'master' });
m.is_read = 1;
uni.$emit('yjyf:unreadChanged');
uni.$emit('yjyf:refreshUnread');
} catch (e) {
} finally {
m._reading = false;
}
}
if (m.order_id) {
uni.navigateTo({ url: `/pages/master/detail?id=${m.order_id}` });
} else {
activeMsg.value = m;
}
}
async function readAll() {
if (!isLogin()) {
goMasterLogin();
return;
}
if (readingAll.value) return;
readingAll.value = true;
try {
const res = await api.messageReadAll({ type: 'master' });
uni.showToast({ title: '已全部标记已读(' + (res.count || 0) + ' 条)', icon: 'none' });
uni.$emit('yjyf:unreadChanged');
uni.$emit('yjyf:refreshUnread');
await load();
} catch (e) {
} finally {
readingAll.value = false;
}
}
onMounted(() => {
load();
});
defineExpose({
load
});
</script>
<style lang="scss" scoped>
.message-view {
height: calc(100vh - 112rpx - constant(safe-area-inset-bottom));
height: calc(100vh - 112rpx - env(safe-area-inset-bottom));
display: flex;
flex-direction: column;
overflow: hidden;
background: $yjyf-bg-page;
}
.head {
flex-shrink: 0;
position: relative;
z-index: 2;
display: flex;
align-items: center;
background: $yjyf-bg-card;
padding: 20rpx $yjyf-space-md;
border-bottom: 1rpx solid $yjyf-border-color;
}
.msg-scroll { flex: 1; height: 0; width: 100%; }
.cats { flex: 1; display: flex; gap: 14rpx; }
.cat {
padding: 0 24rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-bg-page;
font-size: $yjyf-font-sub;
color: $yjyf-text-regular;
}
.cat.on {
background: $yjyf-primary-bg;
color: $yjyf-primary;
font-weight: 600;
}
.read-all { font-size: $yjyf-font-sub; color: $yjyf-primary; font-weight: 500; }
.list { padding: $yjyf-space-md; }
.msg {
background: $yjyf-bg-card;
border-radius: $yjyf-radius-md;
padding: $yjyf-space-md;
margin-bottom: 20rpx;
box-shadow: $yjyf-shadow-card;
}
.msg.unread { border-left: 6rpx solid $yjyf-primary; }
.msg-top { display: flex; align-items: center; }
.dot { width: 14rpx; height: 14rpx; border-radius: 50%; background: $yjyf-primary; margin-right: 12rpx; flex-shrink: 0; }
.title { flex: 1; min-width: 0; font-size: $yjyf-font-body; font-weight: 700; color: $yjyf-text-main; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.time { flex-shrink: 0; margin-left: 12rpx; font-size: $yjyf-font-micro; color: $yjyf-text-muted; }
.content {
display: block;
margin-top: 12rpx;
font-size: $yjyf-font-sub;
color: $yjyf-text-regular;
line-height: 1.5;
word-break: break-all;
}
.go-row {
margin-top: 16rpx;
padding-top: 14rpx;
border-top: 1rpx solid $yjyf-border-color;
display: flex;
align-items: center;
justify-content: space-between;
}
.go { font-size: $yjyf-font-sub; color: $yjyf-primary; font-weight: 500; }
.go-arrow { width: 26rpx; height: 26rpx; opacity: 0.6; }
.empty-box {
padding: 140rpx 0;
display: flex;
flex-direction: column;
align-items: center;
}
.empty-img { width: 160rpx; height: 160rpx; margin-bottom: 20rpx; }
.empty-txt { font-size: $yjyf-font-sub; color: $yjyf-text-secondary; }
.empty-login-btn {
margin-top: 28rpx;
height: 76rpx;
padding: 0 56rpx;
border-radius: 38rpx;
background: linear-gradient(135deg, #FFA93F 0%, #F0710D 100%);
color: #FFFFFF;
font-size: 28rpx;
font-weight: 600;
display: inline-flex;
align-items: center;
justify-content: center;
}
.detail-mask {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
z-index: 1000;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.detail-sheet {
background: $yjyf-bg-card;
border-radius: $yjyf-radius-lg $yjyf-radius-lg 0 0;
padding: 36rpx $yjyf-space-lg calc(36rpx + env(safe-area-inset-bottom));
}
.ds-head { display: flex; align-items: center; justify-content: space-between; gap: 16rpx; }
.ds-title { flex: 1; font-size: $yjyf-font-title; font-weight: 700; color: $yjyf-text-main; }
.ds-close { width: 56rpx; height: 56rpx; display: flex; align-items: center; justify-content: flex-end; }
.ds-close-ico { width: 32rpx; height: 32rpx; opacity: 0.65; }
.ds-time { display: block; margin-top: 10rpx; font-size: $yjyf-font-micro; color: $yjyf-text-muted; }
.ds-content { display: block; margin: 28rpx 0 40rpx; font-size: $yjyf-font-body; color: $yjyf-text-regular; line-height: 1.65; white-space: pre-wrap; }
.ds-btn {
height: 88rpx;
border-radius: $yjyf-radius-pill;
background: $yjyf-gradient-primary;
color: #FFFFFF;
font-size: $yjyf-font-body;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
}
.clickable-hover:active { opacity: 0.85; }
</style>