system-notify.vue
3.91 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
<template>
<view class="notify-page">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<view class="notify-page-top-select">
<view @click="handleTypeClick" class="top-select">
<u--input suffixIcon="arrow-down" shape="circle" disabled v-model="notifyType"
placeholder="请选择类型" border="surround"></u--input>
<u-action-sheet safe-area-inset-bottom :show="showType" :actions="actions" title="请选择类型" @close="showType = false"
@select="handleTypeSelect"></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="handleNotifyDetail(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.senderDate }}</text>
</view>
</view>
<view class="item-right u-flex" style="justify-content: space-between;">
<text class="text">{{ formatType(item.sysNotice.type) }}</text>
<!-- readStatus===0则阅读状态表示未阅读 -->
<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'
import { useNavigateTo } from '@/plugins/utils.js'
import { actions } from './config/data.js'
export default {
mixins: [MescrollMixin],
data() {
return {
notifyType:'',
showType: false,
actions,
page: {
page: 0,
pageSize: 10
},
downOption: {
auto: false //是否在初始化后,自动执行downCallback; 默认true
},
list: [],
selectType: '',
distance: 0,
};
},
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
},
methods: {
formatType(e) {
const findName = this.actions.find((item)=>item.value===e && item.value!=='')
if(!findName) return
return findName.name
},
handleTypeClick() {
this.showType = true;
uni.hideKeyboard();
},
handleTypeSelect(e) {
this.selectType = e.value;
this.page.page = 1;
this.notifyType = e.name;
this.loadData(1, !this.selectType ? null : this.selectType);
},
downCallback() {
this.list.length = 0;
this.page.page = 1;
this.loadData(1);
this.selectType = '';
this.notifyType = '';
},
upCallback() {
if (this.selectType) {
this.page.page += 1;
this.loadData(this.page.page, this.selectType);
} else {
this.page.page += 1;
this.loadData(this.page.page);
}
},
async loadData(page, type) {
let params = {
page,
pageSize: 10,
type
};
const res = await api.notifyApi.getNotifyApi({
params,
custom: {
load: false
}
})
uni.stopPullDownRefresh();
this.mescroll.endByPage(res.items.length, res.total);
if (page == 1) {
this.list = res.items;
} else {
this.list = this.list.concat(res.items);
}
},
async handleNotifyDetail(item, index) {
this.list[index].readStatus = 1;//点击了则说明阅读了
await api.notifyApi.byNotifyIdGetDetailApi(item.sysNotice.id)
useNavigateTo('./notify-detail?data=', item.sysNotice)
}
}
};
</script>
<style lang="scss" scoped>
@import './static/systemNotify.scss';
/deep/ .u-badge--error {
position: relative;
right: 11rpx;
}
</style>