开开发消息页

This commit is contained in:
田岩
2025-08-19 20:23:12 +08:00
parent 76bcb91480
commit 5a874ae9b3
19 changed files with 893 additions and 333 deletions
@@ -0,0 +1,355 @@
<template>
<view class="main_div max_page">
<scroll-view
ref="scrollRef"
:scroll-y="true"
class="scroll-Y"
:refresher-enabled="false"
:show-scrollbar="false"
@scrolltolower="scrolltolower"
@refresherrefresh="onRefresh"
@refresherrestore="triggered = 'restore'"
:refresher-triggered="triggered"
refresher-default-style="none"
>
<view class="content">
<view
style="
position: absolute;
top: -90rpx;
width: 100%;
height: 90rpx;
display: flex;
align-items: center;
justify-content: center;
"
></view>
<view class="item" v-for="(item, index) in data_list" @click="read">
<view class="icon">
<image
v-if="item.noticeTyp == '01'"
class="img_100"
src="@/static/images/messageNotification/type_01.png"
mode="widthFix"
></image>
<image
v-if="item.noticeTyp == '02'"
class="img_100"
src="@/static/images/messageNotification/type_02.png"
mode="widthFix"
></image>
<image
v-if="item.noticeTyp == '03'"
class="img_100"
src="@/static/images/messageNotification/type_03.png"
mode="widthFix"
></image>
</view>
<view class="right">
<view class="top">
<view class="title">
{{ item.noticeTitle }}
</view>
<view class="time">
{{ item.ctTime?.substr(0, 16) }}
</view>
</view>
<view class="bottom">
<view class="note ellipsis-text">
{{ item.noticeContent }}
</view>
<!-- <view class="num_div"></view> -->
<view class="read_div" v-if="item.isRead"></view>
</view>
</view>
</view>
<uv-load-more v-if="total != 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, reactive, nextTick, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { queryTraPersonalMessageNoticePaging } from '@/api/messageNotification.js';
const customStyle = {
backgroundColor: '#ffffff',
paddingLeft: '40rpx',
height: '78rpx',
paddingTop: '5px',
paddingBottom: '5px',
border: 'none'
};
const suffixIconStyle = {
color: '#2c8ef2',
fontSize: '50rpx'
};
const options = [
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
];
const status = ref('loadmore'); // loadmore - 加载前,loading - 加载中,nomore - 没有数据
const limit = 15;
const total = ref(-1);
const page = ref(0);
const data_list = reactive([]);
const triggered = ref(false);
const _freshing = ref(false);
const offset = ref(0);
const scrollRef = ref(null);
// 下拉过程中触发
const onPulling = (e) => {
page.value = 1;
total.value = -1;
page.data_list.length = 0;
getData();
};
// 刷新处理函数
const onRefresh = () => {
if (_freshing.value) return;
_freshing.value = true;
setTimeout(() => {
triggered.value = false;
_freshing.value = false;
}, 1000);
};
const getData = (from = '') => {
if (from == 'first') {
if (total.value !== -1) {
return;
}
status.value = 'loading';
total.value = -1;
page.value = 1;
data_list.length = 0;
} else {
if (status.value !== 'loadmore' && status.value !== '') return;
status.value = 'loading';
page.value++;
}
console.log(status.value, '阿斯顿撒');
setTimeout(() => {
queryTraPersonalMessageNoticePaging({
page: page.value,
limit: limit
})
.then((res) => {
total.value = res.total;
data_list.push(...res.body);
})
.finally(() => {
if (data_list.length >= total.value) {
status.value = 'nomore';
} else {
status.value = 'loadmore';
}
});
}, 200);
};
const scrolltolower = (item) => {
getData();
};
onMounted(() => {
// triggered.value = true;
getData();
// setTimeout(() => {
// triggered.value = true
// message_list.value.push(...[1, 2, 3, 4, 5])
// }, 1000)
console.log(scrollRef.value);
});
</script>
<style scoped lang="scss">
.pulldown-loading-box {
position: fixed;
left: 0;
right: 0;
z-index: 3;
transform: translateY(-100%);
transition: transform 0.3s;
z-index: 1;
}
.scroll-Y {
height: calc(100vh - 70rpx - var(--status-bar-height) - 78rpx - 40rpx);
position: relative;
overflow: hidden;
border-radius: 20rpx 20rpx 0 0;
.content {
width: 100%;
background-color: #fff;
box-shadow: 0 0 6rpx #b3d6ff;
position: relative;
.item {
height: 154rpx;
padding: 38rpx 0 38rpx 0;
margin: 0 38rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-top: 2rpx solid #efefef;
.icon {
width: 78rpx;
height: 78rpx;
}
.right {
margin-left: 16rpx;
flex: 1;
.top {
display: flex;
justify-content: space-between;
.title {
font-family: PingFangSC;
font-weight: 600;
font-size: 30rpx;
color: #000000;
line-height: 46rpx;
text-align: left;
font-style: normal;
}
.time {
font-size: 23rpx;
color: #999999;
line-height: 30rpx;
text-align: right;
font-style: normal;
}
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
overflow: hidden;
width: 100%;
.note {
font-family: PingFangSC;
font-weight: 400;
font-size: 26rpx;
color: #666666;
line-height: 35rpx;
text-align: left;
font-style: normal;
flex: 1;
}
.num_div {
padding: 0 8rpx;
height: 31rpx;
background: #ff6c75;
border-radius: 15rpx;
display: flex;
align-items: center;
justify-content: center;
font-family: ArialMT;
font-size: 22rpx;
color: #ffffff;
line-height: 26px;
min-width: 40rpx;
}
.read_div {
width: 16rpx;
height: 16rpx;
background-color: #d70c18;
border-radius: 100%;
}
}
}
}
}
}
.main_div {
display: flex;
flex-direction: column;
align-items: center;
background: linear-gradient(0deg, rgba(234, 246, 255, 0) 0%, #c3e6ff 100%);
// background-size: 100% 300px;
// background-repeat: no-repeat; /* 防止渐变重复平铺 */
padding-top: var(--status-bar-height);
overflow: hidden;
}
.body-title {
width: 100%;
height: 70rpx;
font-size: 33rpx;
padding-top: 10rpx;
font-weight: 500;
color: #000;
position: relative;
text-align: center;
.delete_div {
position: absolute;
right: 20rpx;
top: 17rpx;
width: 50rpx;
height: 50rpx;
.img {
width: 34rpx;
height: 34rpx;
}
}
.back_div {
position: absolute;
left: 26rpx;
height: 34rpx;
top: 17rpx;
.back-icon {
position: relative;
width: 50rpx;
height: 50rpx;
cursor: pointer;
display: flex;
align-items: center;
}
.back-icon::before,
.back-icon::after {
content: '';
position: absolute;
transition: all 0.3s ease;
}
.back-icon::after {
top: 25%;
left: 25%;
width: 40%;
height: 40%;
border-top: 4rpx solid #2b2c2e;
border-left: 4rpx solid #2b2c2e;
transform: rotate(-45deg);
}
}
}
.input-view {
width: 90%;
margin: 20rpx auto;
height: 78rpx;
}
</style>
+291 -198
View File
@@ -1,256 +1,349 @@
<template>
<view class="main_div max_page">
<view class="body-title">
<view class="back_div" @click="common.navigateBack()">
<view class="back_div">
<view class="back-icon"></view>
</view>
<view>消息</view>
<view class="delete_div" @click="common.navigateBack()">
<image class="img" src="@/static/images/messageNotification/delete_icon.png" mode="aspectFit">
</image>
<view class="delete_div">
<image class="img" src="@/static/images/messageNotification/delete_icon.png" mode="aspectFit"></image>
</view>
</view>
<view class="input-view">
<uv-input shape="circle" placeholderStyle='color:#999999;font-size:28rpx' placeholder="请输入关键词"
suffixIcon="search" :customStyle="customStyle" :suffixIconStyle="suffixIconStyle">
</uv-input>
<uv-input
shape="circle"
placeholderStyle="color:#999999;font-size:28rpx"
placeholder="请输入关键词"
suffixIcon="search"
:customStyle="customStyle"
:suffixIconStyle="suffixIconStyle"
></uv-input>
</view>
<scroll-view ref="scrollRef" scroll-y="true" class="scroll-Y" :refresher-enabled="true"
@refresherrefresh="onRefresh" @refresherrestore="triggered = 'restore'" :refresher-triggered="triggered"
refresher-default-style="none">
<!-- 主体 -->
<view class="content">
<view style="position: absolute;top: -90rpx;width: 100%;height: 90rpx;"> </view>
<uv-swipe-action>
<uv-swipe-action-item :options="options" :threshold="40" :index="index"
v-for="(item, index) in data_list">
<view class="item">
<view class="icon">
<image class="img_100" :src="`@/static/images/messageNotification/type_${item.noticeTyp}.png`" mode="widthFix"></image>
</view>
<view class="right">
<view class="top">
<view class="title">
{{item.noticeTitle}}
</view>
<view class="time">
{{item.ctTime.substr(0, 16)}}
</view>
</view>
<view class="bottom">
<view class="note ellipsis-text">
{{item.noticeContent}}
</view>
<view class="num_div">
</view>
</view>
</view>
<scroll-view
ref="scrollRef"
:scroll-y="true"
class="scroll-Y"
:refresher-enabled="false"
:show-scrollbar="false"
@scrolltolower="scrolltolower"
@refresherrefresh="onRefresh"
@refresherrestore="triggered = 'restore'"
:refresher-triggered="triggered"
refresher-default-style="none"
>
<view class="item" v-for="(item, index) in data_list" @click="readMessage(item)">
<view class="icon">
<image
v-if="item.noticeTyp == '01'"
class="img_100"
src="@/static/images/messageNotification/type_01.png"
mode="widthFix"
></image>
<image
v-if="item.noticeTyp == '02'"
class="img_100"
src="@/static/images/messageNotification/type_02.png"
mode="widthFix"
></image>
<image
v-if="item.noticeTyp == '03'"
class="img_100"
src="@/static/images/messageNotification/type_03.png"
mode="widthFix"
></image>
</view>
<view class="right">
<view class="top">
<view class="title">
{{ item.noticeTitle }}
</view>
</uv-swipe-action-item>
</uv-swipe-action>
<uv-load-more v-if="total != 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
<view class="time">
{{ item.ctTime?.substr(0, 16) }}
</view>
</view>
<view class="bottom">
<view class="note ellipsis-text">
{{ item.noticeContent }}
</view>
<!-- <view class="num_div"></view> -->
<view class="read_div" v-if="item.isRead"></view>
</view>
</view>
</view>
<list-no-data v-if="total == 0 && status == 'nomore'"></list-no-data>
<uv-load-more v-if="total != 0" :status="status" loadmore-text="轻轻上拉加载" :height="30"></uv-load-more>
</scroll-view>
<uni-popup ref="popup" type="bottom">
<view class="popup" @click.stop="getCode">
<view class="message_popup_div">
<view class="title">
{{ popup_info.title }}
</view>
<view class="text">消正息内容正文消息内容正文</view>
<view class="button_div" @click.stop="getCode">
<uv-button class="button">我知道了</uv-button>
</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script setup>
import {
ref,
reactive,
nextTick,
onMounted
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
import {
queryTraPersonalMessageNoticePaging
} from '@/api/messageNotification.js';
import { ref, reactive, nextTick, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { queryTraPersonalMessageNoticePaging } from '@/api/messageNotification.js';
const customStyle = {
backgroundColor: "#ffffff",
paddingLeft: "40rpx",
backgroundColor: '#ffffff',
paddingLeft: '40rpx',
height: '78rpx',
paddingTop: "5px",
paddingBottom: "5px",
border: "none"
}
paddingTop: '5px',
paddingBottom: '5px',
border: 'none'
};
const suffixIconStyle = {
color: "#2c8ef2",
fontSize: "50rpx"
}
const options = [{
text: '删除',
style: {
backgroundColor: '#f56c6c'
color: '#2c8ef2',
fontSize: '50rpx'
};
const options = [
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
}]
const status = ref('loadmore') // loadmore - 加载前,loading - 加载中,nomore - 没有数据
const limit = 15
const total = ref(-1)
const page = ref(0)
const data_list = reactive([])
const triggered = ref(false)
const _freshing = ref(false)
const offset = ref(0)
const scrollRef = ref(null)
];
const status = ref('loadmore'); // loadmore - 加载前,loading - 加载中,nomore - 没有数据
const limit = 15;
const total = ref(-1);
const page = ref(0);
const data_list = reactive([]);
const triggered = ref(false);
const _freshing = ref(false);
const offset = ref(0);
const scrollRef = ref(null);
const popup_info = reactive({
id: '',
title: '',
text: ''
});
const popup = ref(null);
// 下拉过程中触发
const onPulling = (e) => {
console.log("onpulling", e)
}
page.value = 1;
total.value = -1;
page.data_list.length = 0;
getData();
};
// 刷新处理函数
const onRefresh = () => {
if (_freshing.value) return
_freshing.value = true
if (_freshing.value) return;
_freshing.value = true;
setTimeout(() => {
triggered.value = false
_freshing.value = false
}, 1000)
}
triggered.value = false;
_freshing.value = false;
}, 1000);
};
const getData = (from = '') => {
if (from == 'first') {
if (total.value !== -1) {
return
return;
}
status.value = 'loading'
total.value = -1
page.value = 1
data_list.length = 0
status.value = 'loading';
total.value = -1;
page.value = 1;
data_list.length = 0;
} else {
if (status.value !== 'loadmore' && status.value !== '') return
status.value = 'loading'
page.value++
if (status.value !== 'loadmore' && status.value !== '') return;
status.value = 'loading';
page.value++;
}
console.log(status.value, '阿斯顿撒');
setTimeout(() => {
queryTraPersonalMessageNoticePaging({
page: page.value,
limit: limit
}).then(res => {
total.value = res.total
data_list.push(...res.body)
}).finally(() => {
if (data_list.length >= total.value) {
status.value = 'nomore'
} else {
status.value = 'loadmore'
}
queryTraPersonalMessageNoticePaging({
page: page.value,
limit: limit
})
.then((res) => {
total.value = res.total;
data_list.push(...res.body);
})
}, 200)
}
.finally(() => {
if (data_list.length >= total.value) {
status.value = 'nomore';
} else {
status.value = 'loadmore';
}
});
};
// 读取消息
const readMessage = (item) => {
console.log('readMessage', item);
popup_info.id = item.noticeId;
popup_info.title = item.noticeTitle;
popup_info.text = item.noticeContent;
// popup_info.id = '';
// popup_info.title = '课程提醒';
// popup_info.text = '这里是水水哈斯滴撒的撒嗲是对赛道';
popup.value.open();
};
const scrolltolower = (item) => {
getData();
};
onMounted(() => {
triggered.value = true
getData()
// triggered.value = true;
getData();
// setTimeout(() => {
// triggered.value = true
// message_list.value.push(...[1, 2, 3, 4, 5])
// }, 1000)
console.log(scrollRef.value);
})
});
</script>
<style scoped lang="scss">
.pulldown-loading-box {
position: fixed;
left: 0;
right: 0;
z-index: 3;
transform: translateY(-100%);
transition: transform .3s;
z-index: 1;
.popup{
width: 100vw;
height: 100vh;
position: relative;
}
.message_popup_div {
width: 580rpx;
border-radius: 38px;
background: #ffffff url('@/static/images/messageNotification/popup_bg.png') no-repeat center -4rpx;
background-size: auto 50%;
background-color: #ffffff;
margin: 0 auto;
overflow: hidden;
top: 30%;
position: absolute;
left: calc(50% - 290rpx);
.title {
padding: 0 40rpx;
width: 100%;
height: 90rpx;
line-height: 90rpx;
font-weight: 700;
text-align: center;
}
.text {
padding: 16rpx 40rpx;
font-family: PingFangSC;
font-size: 30rpx;
color: #333333;
line-height: 48rpx;
text-align: left;
font-style: normal;
min-height: 240rpx;
max-height: 650rpx;
overflow: auto;
}
.button_div {
overflow: hidden;
.button {
width: 100%;
height: 100%;
:deep(.uv-button) {
height: 100rpx;
font-family: PingFangSC;
font-weight: 500;
font-size: 36rpx;
color: #0066ff;
}
}
}
}
.scroll-Y {
height: calc(100vh - 70rpx - var(--status-bar-height) - 78rpx - 40rpx);
position: relative;
overflow: hidden;
border-radius: 20rpx 20rpx 0 0;
position: relative;
background-color: #fff;
box-shadow: 0 0 6rpx #b3d6ff;
.content {
width: 100%;
height: 100%;
border-radius: 20rpx 20rpx 0 0;
background-color: #fff;
box-shadow: 0 0 6rpx #B3D6FF;
position: relative;
.item {
width: 100%;
height: 154rpx;
padding: 38rpx 38rpx 38rpx 38rpx;
display: flex;
justify-content: space-between;
align-items: center;
.item {
height: 154rpx;
padding: 38rpx 0 38rpx 0;
margin: 0 38rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-top: 2rpx solid #efefef;
.icon {
width: 78rpx;
height: 78rpx;
}
.icon {
width: 78rpx;
height: 78rpx;
}
.right {
margin-left: 16rpx;
flex: 1;
.right {
margin-left: 16rpx;
flex: 1;
.top {
display: flex;
justify-content: space-between;
.top {
display: flex;
justify-content: space-between;
.title {
font-family: PingFangSC;
font-weight: 600;
font-size: 30rpx;
color: #000000;
line-height: 46rpx;
text-align: left;
font-style: normal;
}
.time {
font-size: 23rpx;
color: #999999;
line-height: 30rpx;
text-align: right;
font-style: normal;
}
.title {
font-family: PingFangSC;
font-weight: 600;
font-size: 30rpx;
color: #000000;
line-height: 46rpx;
text-align: left;
font-style: normal;
}
.bottom {
.time {
font-size: 23rpx;
color: #999999;
line-height: 30rpx;
text-align: right;
font-style: normal;
}
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
overflow: hidden;
width: 100%;
.note {
font-family: PingFangSC;
font-weight: 400;
font-size: 26rpx;
color: #666666;
line-height: 35rpx;
text-align: left;
font-style: normal;
flex: 1;
}
.num_div {
padding: 0 8rpx;
height: 31rpx;
background: #ff6c75;
border-radius: 15rpx;
display: flex;
justify-content: space-between;
.note {
font-family: PingFangSC;
font-weight: 400;
font-size: 26rpx;
color: #999999;
line-height: 34rpx;
text-align: left;
font-style: normal;
}
.num_div {
padding: 0 8rpx;
height: 31rpx;
background: #FF6C75;
border-radius: 15rpx;
display: flex;
align-items: center;
justify-content: center;
font-family: ArialMT;
font-size: 22rpx;
color: #FFFFFF;
line-height: 26px;
min-width: 40rpx;
}
align-items: center;
justify-content: center;
font-family: ArialMT;
font-size: 22rpx;
color: #ffffff;
line-height: 26px;
min-width: 40rpx;
}
.read_div {
width: 16rpx;
height: 16rpx;
background-color: #d70c18;
border-radius: 100%;
}
}
}
@@ -261,10 +354,11 @@
display: flex;
flex-direction: column;
align-items: center;
background: linear-gradient(0deg, rgba(234, 246, 255, 0) 0%, #C3E6FF 100%);
// background-size: 100% 300px;
// background-repeat: no-repeat; /* 防止渐变重复平铺 */
background: linear-gradient(0deg, rgba(195, 219, 255, 0) 0%, #c3dbff 100%);
background-size: 100% 300px;
background-repeat: no-repeat; /* 防止渐变重复平铺 */
padding-top: var(--status-bar-height);
overflow: hidden;
}
.body-title {
@@ -328,6 +422,5 @@
width: 90%;
margin: 20rpx auto;
height: 78rpx;
}
</style>