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),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
564 行
12 KiB
Vue
564 行
12 KiB
Vue
<template>
|
||
<view class="user-message-view">
|
||
<YjyfNavBar theme="orange" title="消息中心" />
|
||
|
||
<view class="head">
|
||
<scroll-view scroll-x class="cats-scroll" :show-scrollbar="false">
|
||
<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)"
|
||
>
|
||
<text class="cat-txt">{{ c.name }}</text>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
<view class="read-all clickable-hover" @tap="readAll">
|
||
<text class="read-all-txt">全部已读</text>
|
||
</view>
|
||
</view>
|
||
|
||
<YjyfRefreshScroll
|
||
class="msg-scroll"
|
||
theme="light"
|
||
:refresh-task="load"
|
||
@scrolltolower="loadMore"
|
||
>
|
||
<view class="list" v-if="list.length">
|
||
<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="title-wrap">
|
||
<view class="dot" v-if="!m.is_read"></view>
|
||
<text class="type-tag">{{ typeLabel(m.type) }}</text>
|
||
<text class="title">{{ m.title }}</text>
|
||
</view>
|
||
<text class="time">{{ m.time_text }}</text>
|
||
</view>
|
||
|
||
<text class="content">{{ m.content }}</text>
|
||
|
||
<view class="msg-foot">
|
||
<text class="detail-hint">{{ Number(m.order_id) > 0 ? '点击前往关联工单' : '点击查看完整通知' }}</text>
|
||
<view class="go-link">
|
||
<text class="go-txt">{{ Number(m.order_id) > 0 ? '查看工单' : '查看详情' }}</text>
|
||
<image class="go-arrow" src="/static/icons/arrow-right-orange.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="foot-more" v-if="list.length >= 20">
|
||
<text class="foot-more-txt">{{ loadingMore ? '加载中...' : (hasMore ? '上滑加载更多消息' : '已加载全部消息') }}</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="empty-box" v-else-if="!loggedIn">
|
||
<image class="empty-img" src="/static/icons/empty-message.svg" mode="aspectFit" />
|
||
<text class="empty-title">登录后查看消息通知</text>
|
||
<text class="empty-sub">订单动态、审核结果与服务提醒将在此展示</text>
|
||
<view class="empty-login-btn clickable-hover" @tap="goLogin">立即登录</view>
|
||
</view>
|
||
|
||
<view class="empty-box" v-else-if="!loading">
|
||
<image class="empty-img" src="/static/icons/empty-message.svg" mode="aspectFit" />
|
||
<text class="empty-title">暂无相关消息通知</text>
|
||
<text class="empty-sub">订单动态、审核结果与服务提醒将在此展示</text>
|
||
</view>
|
||
</YjyfRefreshScroll>
|
||
|
||
<!-- 消息详情半屏抽屉 -->
|
||
<view class="drawer-mask" v-if="activeMsg" @tap="activeMsg = null">
|
||
<view class="drawer-panel" @tap.stop>
|
||
<view class="drawer-head">
|
||
<view class="dh-left">
|
||
<text class="type-tag">{{ typeLabel(activeMsg.type) }}</text>
|
||
<text class="drawer-title">{{ activeMsg.title }}</text>
|
||
</view>
|
||
<view class="close-hit" @tap="activeMsg = null">
|
||
<image class="close-ico" src="/static/icons/close.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
<text class="drawer-time">通知时间:{{ activeMsg.time_text }}</text>
|
||
<scroll-view scroll-y class="drawer-body">
|
||
<text class="drawer-content">{{ activeMsg.content }}</text>
|
||
</scroll-view>
|
||
<view
|
||
v-if="Number(activeMsg.order_id) > 0"
|
||
class="drawer-btn clickable-hover"
|
||
@tap="jumpToOrder(activeMsg.order_id)"
|
||
>
|
||
前往查看关联工单
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, watch, 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 props = defineProps({
|
||
roleType: {
|
||
type: String,
|
||
default: 'user'
|
||
}
|
||
});
|
||
|
||
const list = ref([]);
|
||
const loading = ref(false);
|
||
const loggedIn = ref(isLogin());
|
||
const loadingMore = ref(false);
|
||
const page = ref(1);
|
||
const hasMore = ref(false);
|
||
const category = ref('all');
|
||
const activeMsg = ref(null);
|
||
|
||
const cats = [
|
||
{ key: 'all', name: '全部' },
|
||
{ key: 'order', name: '订单' },
|
||
{ key: 'audit', name: '审核' },
|
||
{ key: 'remind', name: '提醒' },
|
||
{ key: 'system', name: '系统' }
|
||
];
|
||
|
||
function typeLabel(t) {
|
||
return { order: '订单', audit: '审核', remind: '提醒', system: '系统' }[t] || '通知';
|
||
}
|
||
|
||
function goLogin() {
|
||
toLogin('/pages/index/index?tab=2');
|
||
}
|
||
|
||
async function load() {
|
||
loggedIn.value = isLogin();
|
||
if (!loggedIn.value) {
|
||
list.value = [];
|
||
hasMore.value = false;
|
||
loading.value = false;
|
||
return;
|
||
}
|
||
loading.value = true;
|
||
page.value = 1;
|
||
try {
|
||
const res = await api.messageList({
|
||
type: props.roleType,
|
||
category: category.value,
|
||
page: 1,
|
||
limit: 20
|
||
});
|
||
const rows = res?.list || [];
|
||
list.value = rows;
|
||
const total = Number(res?.total || 0);
|
||
hasMore.value = rows.length < total;
|
||
uni.$emit('yjyf:refreshUnread');
|
||
} catch (e) {
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
async function loadMore() {
|
||
if (loading.value || loadingMore.value || !hasMore.value) return;
|
||
loadingMore.value = true;
|
||
const next = page.value + 1;
|
||
try {
|
||
const res = await api.messageList({
|
||
type: props.roleType,
|
||
category: category.value,
|
||
page: next,
|
||
limit: 20
|
||
});
|
||
const rows = res?.list || [];
|
||
list.value = list.value.concat(rows);
|
||
page.value = next;
|
||
const total = Number(res?.total || 0);
|
||
hasMore.value = list.value.length < total;
|
||
} catch (e) {
|
||
} finally {
|
||
loadingMore.value = false;
|
||
}
|
||
}
|
||
|
||
function switchCat(k) {
|
||
if (category.value === k) return;
|
||
category.value = k;
|
||
load();
|
||
}
|
||
|
||
function jumpToOrder(orderId) {
|
||
activeMsg.value = null;
|
||
uni.navigateTo({ url: `/pages/order/detail?id=${orderId}` });
|
||
}
|
||
|
||
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: props.roleType });
|
||
m.is_read = 1;
|
||
uni.$emit('yjyf:refreshUnread');
|
||
} catch (e) {
|
||
} finally {
|
||
m._reading = false;
|
||
}
|
||
}
|
||
if (Number(m.order_id) > 0) {
|
||
jumpToOrder(m.order_id);
|
||
} else {
|
||
activeMsg.value = m;
|
||
}
|
||
}
|
||
|
||
async function readAll() {
|
||
if (!isLogin()) {
|
||
goLogin();
|
||
return;
|
||
}
|
||
if (readingAll.value) return;
|
||
readingAll.value = true;
|
||
try {
|
||
const res = await api.messageReadAll({ type: props.roleType });
|
||
uni.showToast({ title: `已标记已读(${res?.count || 0} 条)`, icon: 'none' });
|
||
uni.$emit('yjyf:refreshUnread');
|
||
await load();
|
||
} catch (e) {
|
||
} finally {
|
||
readingAll.value = false;
|
||
}
|
||
}
|
||
|
||
watch(() => props.roleType, () => {
|
||
load();
|
||
});
|
||
|
||
onMounted(() => {
|
||
load();
|
||
});
|
||
|
||
defineExpose({
|
||
load
|
||
});
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
@import '@/uni.scss';
|
||
/* #ifdef MP-WEIXIN */
|
||
:host {
|
||
flex: 1;
|
||
height: 100%;
|
||
min-height: 0;
|
||
width: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
}
|
||
/* #endif */
|
||
|
||
.user-message-view {
|
||
flex: 1;
|
||
height: 100%;
|
||
min-height: 0;
|
||
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;
|
||
justify-content: space-between;
|
||
background: $yjyf-bg-card;
|
||
padding: 16rpx $yjyf-space-md 20rpx;
|
||
border-bottom: 1rpx solid $yjyf-border-color;
|
||
}
|
||
.cats-scroll {
|
||
flex: 1;
|
||
min-width: 0;
|
||
white-space: nowrap;
|
||
margin-right: 16rpx;
|
||
}
|
||
.cats {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 14rpx;
|
||
}
|
||
.cat {
|
||
height: 56rpx;
|
||
padding: 0 26rpx;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-bg-page;
|
||
}
|
||
.cat-txt {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-regular;
|
||
}
|
||
.cat.on {
|
||
background: $yjyf-primary-bg;
|
||
}
|
||
.cat.on .cat-txt {
|
||
color: $yjyf-primary;
|
||
font-weight: 700;
|
||
}
|
||
.read-all {
|
||
flex-shrink: 0;
|
||
height: 56rpx;
|
||
padding: 0 8rpx;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
.read-all-txt {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-primary;
|
||
font-weight: 600;
|
||
}
|
||
|
||
.msg-scroll {
|
||
flex: 1;
|
||
height: 0;
|
||
width: 100%;
|
||
}
|
||
.list {
|
||
padding: 20rpx $yjyf-space-md 64rpx;
|
||
}
|
||
.msg {
|
||
background: $yjyf-bg-card;
|
||
border-radius: $yjyf-radius-md;
|
||
padding: 24rpx;
|
||
margin-bottom: 20rpx;
|
||
box-shadow: $yjyf-shadow-card;
|
||
border-left: 6rpx solid transparent;
|
||
}
|
||
.msg.unread {
|
||
border-left-color: $yjyf-primary;
|
||
}
|
||
.msg-top {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.title-wrap {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
.dot {
|
||
width: 14rpx;
|
||
height: 14rpx;
|
||
border-radius: 50%;
|
||
background: $yjyf-danger;
|
||
margin-right: 10rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
.type-tag {
|
||
height: 36rpx;
|
||
padding: 0 12rpx;
|
||
border-radius: 8rpx;
|
||
background: $yjyf-primary-bg;
|
||
color: $yjyf-primary;
|
||
font-size: $yjyf-font-micro;
|
||
font-weight: 600;
|
||
margin-right: 12rpx;
|
||
flex-shrink: 0;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
.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: 16rpx;
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-muted;
|
||
}
|
||
.content {
|
||
display: block;
|
||
margin-top: 14rpx;
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-regular;
|
||
line-height: 1.5;
|
||
word-break: break-all;
|
||
}
|
||
.msg-foot {
|
||
margin-top: 18rpx;
|
||
padding-top: 14rpx;
|
||
border-top: 1rpx solid $yjyf-border-color;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.detail-hint {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-muted;
|
||
}
|
||
.go-link {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
}
|
||
.go-txt {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-primary;
|
||
font-weight: 600;
|
||
}
|
||
.go-arrow {
|
||
width: 22rpx;
|
||
height: 22rpx;
|
||
margin-left: 4rpx;
|
||
}
|
||
|
||
.foot-more {
|
||
padding: 16rpx 0;
|
||
text-align: center;
|
||
}
|
||
.foot-more-txt {
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-muted;
|
||
}
|
||
|
||
.empty-box {
|
||
padding: 120rpx 32rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
}
|
||
.empty-img {
|
||
width: 184rpx;
|
||
height: 184rpx;
|
||
margin-bottom: 20rpx;
|
||
}
|
||
.empty-title {
|
||
font-size: $yjyf-font-body;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
}
|
||
.empty-sub {
|
||
margin-top: 10rpx;
|
||
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;
|
||
}
|
||
|
||
/* 消息详情抽屉 */
|
||
.drawer-mask {
|
||
position: fixed;
|
||
inset: 0;
|
||
z-index: 950;
|
||
background: rgba(0, 0, 0, 0.48);
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: flex-end;
|
||
}
|
||
.drawer-panel {
|
||
background: $yjyf-bg-card;
|
||
border-radius: 28rpx 28rpx 0 0;
|
||
padding: 28rpx $yjyf-space-lg calc(32rpx + env(safe-area-inset-bottom));
|
||
box-sizing: border-box;
|
||
}
|
||
.drawer-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
.dh-left {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
.drawer-title {
|
||
flex: 1;
|
||
min-width: 0;
|
||
font-size: $yjyf-font-title;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.close-hit {
|
||
width: 56rpx;
|
||
height: 56rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.close-ico {
|
||
width: 30rpx;
|
||
height: 30rpx;
|
||
}
|
||
.drawer-time {
|
||
display: block;
|
||
margin-top: 10rpx;
|
||
font-size: $yjyf-font-micro;
|
||
color: $yjyf-text-muted;
|
||
}
|
||
.drawer-body {
|
||
max-height: 48vh;
|
||
margin-top: 24rpx;
|
||
padding: 22rpx;
|
||
border-radius: $yjyf-radius-sm;
|
||
background: $yjyf-bg-page;
|
||
box-sizing: border-box;
|
||
}
|
||
.drawer-content {
|
||
font-size: $yjyf-font-body;
|
||
color: $yjyf-text-main;
|
||
line-height: 1.65;
|
||
white-space: pre-wrap;
|
||
}
|
||
.drawer-btn {
|
||
margin-top: 28rpx;
|
||
height: 88rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-gradient-primary;
|
||
color: $yjyf-bg-card;
|
||
font-size: $yjyf-font-body;
|
||
font-weight: 600;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: $yjyf-shadow-card;
|
||
}
|
||
</style>
|