systemNotify.vue
4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<template>
<view class="notify-page">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view style="width: 750rpx;height:53rpx;background-color: #f8f9fa;position:fixed;top:0;z-index: 99999;">
<view @click="openTypeClick" style="background-color: #f8f9fa;width: 700rpx;position: relative;top: 35rpx;">
<u--input suffixIcon="arrow-down" shape="circle" disabled v-model="model1.userInfo.type"
placeholder="请选择类型" border="surround"></u--input>
<u-action-sheet :show="showType" :actions="actions" title="请选择类型" @close="showType = false"
@select="typeSelect"></u-action-sheet>
</view>
</view>
<view style="height: 110rpx;"></view>
<view class="notify-main">
<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback"
@up="upCallback">
<view class="u-flex main">
<view @click="clickNotifyDetail(item, index)" class="u-flex main-item" v-for="(item, index) in list"
:key="index">
<view class="u-flex item">
<view class="item-avatar">
<u-avatar class="avatar" shape="circle" size="40" :src="item.sysNotice.avatar">
</u-avatar>
</view>
<view class="u-flex item-content">
<text class="text-top text-clip">{{ item.sysNotice.title }}</text>
<text class="text-bottom text-clip">{{ item.sysNotice.createTime }}</text>
</view>
</view>
<view class="item-right u-flex" style="justify-content: space-between;">
<text class="text">{{ formatType(item.sysNotice) }}</text>
<u-badge style="margin-right: 10rpx;" v-if="item.readStatus == '0'" numberType="overflow"
isDot />
</view>
</view>
</view>
</mescroll-body>
</view>
</view>
</template>
<script>
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import api from '@/api/index.js'
export default {
mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
data() {
return {
model1: {
userInfo: {
type: ''
}
},
showType: false,
actions: [{
name: '全部',
value: ''
},
{
name: '会议',
value: 'MEETING'
},
{
name: '公告',
value: 'NOTICE'
},
{
name: '其他',
value: 'OTHER'
}
],
page: {
num: 0,
size: 10
},
downOption: {
auto: false //是否在初始化后,自动执行downCallback; 默认true
},
list: [],
pre: false,
isJudgeNextPage: '',
distance: 0,
scrollDistance: 0
};
},
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
this.pre = false;
uni.removeStorageSync('storagePre');
},
onShow() {
this.pre = uni.getStorageSync('storagePre');
if (this.pre) {}
},
onHide() {
uni.removeStorageSync('storagePre');
},
methods: {
formatType(e) {
return e?.type == 'OTHER' ? '其他' : e?.type == 'MEETING' ? '会议' : '公告';
},
openTypeClick() {
this.showType = true;
uni.hideKeyboard();
},
typeSelect(e) {
this.isJudgeNextPage = e.value;
this.page.num = 1;
this.model1.userInfo.type = e.name;
this.loadData(1, this.isJudgeNextPage == '' ? null : this.isJudgeNextPage);
uni.pageScrollTo({
scrollTop: this.scrollDistance + 20,
duration: 50
});
uni.pageScrollTo({
scrollTop: this.scrollDistance - 20,
duration: 50
});
},
onPageScroll(e) {
this.scrollDistance = e.scrollTop;
},
/*下拉刷新的回调 */
downCallback() {
//联网加载数据
this.list.length = 0;
this.page.num = 1;
this.loadData(1);
this.isJudgeNextPage = '';
this.model1.userInfo.type = '';
},
/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
upCallback() {
if (this.isJudgeNextPage != '') {
//联网加载数据
this.page.num += 1;
this.loadData(this.page.num, this.isJudgeNextPage);
} else {
//联网加载数据
this.page.num += 1;
this.loadData(this.page.num);
}
},
async loadData(pageNo, t) {
let httpData = {
page: pageNo,
pageSize: 10,
type: t
};
const res = await api.notifyApi.getNotifyApi({
params: httpData,
custom: {
load: false
}
})
uni.stopPullDownRefresh();
this.mescroll.endByPage(res.items.length, res.total);
if (pageNo == 1) {
this.list = res.items;
} else {
this.list = this.list.concat(res.items);
}
},
async clickNotifyDetail(e, i) {
this.list[i].readStatus = 1;
await api.notifyApi.byNotifyIdGetDetailApi(e.sysNotice.id)
uni.navigateTo({
url: './notifyDetail?data=' + encodeURIComponent(JSON.stringify(e.sysNotice))
});
}
}
};
</script>
<style lang="scss" scoped>
@import './static/systemNotify.scss';
/deep/ .u-badge--error {
position: relative;
right: 11rpx;
}
</style>