- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
534 行
12 KiB
Vue
534 行
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="!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 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] || '通知';
|
||
}
|
||
|
||
async function load() {
|
||
if (!isLogin()) { toLogin(); 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;
|
||
const targetUrl = props.roleType === 'master'
|
||
? `/pages/master/detail?id=${orderId}`
|
||
: `/pages/order/detail?id=${orderId}`;
|
||
uni.navigateTo({ url: targetUrl });
|
||
}
|
||
|
||
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 (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: -webkit-box;
|
||
-webkit-box-orient: vertical;
|
||
-webkit-line-clamp: 2;
|
||
overflow: hidden;
|
||
margin-top: 14rpx;
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-regular;
|
||
line-height: 1.5;
|
||
}
|
||
.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;
|
||
}
|
||
|
||
/* 消息详情抽屉 */
|
||
.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>
|