Houjie
2025-04-11 1bf977929dd324f3ac64b70debd8a79443c54392
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<template>
    <view class="bg-white" >
        <cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="index">
            <block slot="backText">返回</block>
            <block slot="content">公告消息</block>
        </cu-custom>
        <view class="container">
            <view class="solid-bottom">
                <scroll-view scroll-x class="bg-white nav text-center ">
                    <view class="flex text-center justify-around">
                        <view class="cu-item" :class="item.value==TabCur?'text-blue cur':''" v-for="(item,index) in tabs" :key="index" @tap="tabSelect" :data-id="item.value">
                            {{item.title}}
                        </view>
                    </view>
                </scroll-view>
            </view>
            
             <mescroll-uni ref="mescrollRef" @init="mescrollInit" :top="top"  @down="downCallback"  @up="upCallback">
                <!-- 数据列表 -->
                <view class="al-list cu-list">
                    <view class="message_text bg-white cu-item flex justify-around align-center solid-bottom margin-bottom-sm margin-top-sm" style="width: 100vw;" v-for="(item,index) in msgList" :key="index" @tap="goAnnotationDetail(item)" :class="modalName=='move-box-'+ index?'move-cur':''"
                      @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
                        <view v-if="isEmail(item)" class="padding-left">
                            <view class="cu-avatar radius cuIcon-mail bg-orange" ></view>
                        </view>
                        <view v-if="item.msgCategory == '1'&&!isEmail(item)" class="padding-left">
                            <view class="cu-avatar radius cuIcon-notification bg-orange" ></view>
                        </view>
                        <view v-if="item.msgCategory == '2'&&!isEmail(item)" class="padding-left">
                            <view class="cu-avatar radius cuIcon-notice bg-orange" ></view>
                        </view>
                        <view class="titlePad content" style="height: 4em;">
                            <view class="flex justify-start text-cut text-lg" style="width:26em;color: #333;font-family: '黑体';">
                                <!-- <view v-if="item.readFlag == '0'"  class="cu-tag light bg-blue">未读</view> -->
                                <view v-if="item.readFlag == '0'">
                                    <text class="cuIcon-title text-red padding-left-sm" style="margin-right: -0.8em;"></text>
                                </view>
                                <view class="padding-left">
                                    <text class="text-black" v-if="isEmail(item)&&item.emailTitle">{{titleFilter(item.emailTitle,12)}} </text>
                                    <text class="text-black" v-else>{{titleFilter(item.titile,12)}} </text>
                                </view>
                            </view>
                            <view class="flex justify-between margin-top-xs" style="font-family: '黑体';color: #999;">
                                <view v-if="isEmail(item)" class="text-content text-cut" style="padding-left: .8rem;width:18em;"
                                 v-html="item.msgContent" @click="goEmailDetailPage(item);">
                                </view>
                                <view v-else-if="!isEmail(item)" style="padding-left: .8rem;">
                                    <view class="text-content text-cut" v-if="item.msgAbstract && item.msgAbstract.length > 0" style="width:18em;"
                                     v-html="item.msgAbstract">
                                    </view>
                                    <view v-else>
                                        无摘要
                                    </view>
                                </view>
                            </view>
            
                        </view>
                        <view class="action text-sm" style="color: #aaa;margin-top: -2em;margin-left: -13em;width: 10em;">
                            <text >{{formatDate(item.sendTime,10)}}</text>
                        </view>
                        <view class="move">
                            <view class="bg-red" style="margin-right: 3em;margin-left: 2px;" @tap.stop="deleteAnnotation(item)">删除</view>
                        </view>
                    </view>
                </view>
            </mescroll-uni>
        </view>
 
    </view>
</template>
 
<script>
    const tabs = [{title:'通知公告',value:0}, {title:'系统消息',value:1}];
    import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
    
    
    export default {
        mixins: [MescrollMixin], // 使用mixin
        name: 'annotationList',
        
        watch: {
            cur: {
                immediate: true,
                handler() {
                    console.log('watch', this.cur)
                },
            },
        },
        data() {
            return {
                tabs,
                TabCur: 0,
                scrollLeft: 0,
                NavBarColor:this.NavBarColor,
                upOption:{
                    page: {
                        num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
                        size: 10 // 每页数据的数量
                    },
                    noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
                    empty:{
                        tip: '~ 暂无数据 ~', // 提示
                        
                    },
                    loading:'',
                    text:'全部',
                    isShowNoMore:false,
                    textNoMore:'我是有底线的 >_<'
                },
                msgList: [], //列表数据
                read: "all",
                announcement1:[],
                msg1Count:"",
                msg1Title:"",
                announcement2:[],
                msg2Count:"",
                msg2Title:"",
                url:"/sys/sysAnnouncementSend/getMyAnnouncementSend",
                delUrl:'/sys/sysAnnouncementSend/delete',
                listTouchStart: 0,
                modalName: null,
                listTouchDirection: null,
            }
        },
        onShow() {
            if(this.mescroll){
                this.mescroll.resetUpScroll()
            }
        },
        computed:{
            top() {
                return this.CustomBar * 2 + 95
            },
            style() {
                var StatusBar= this.StatusBar;
                var CustomBar= this.CustomBar;
                var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
                return style
            },
        },
        methods: {
            // unique(arr) {
            //     var obj = {};
            //     return arr.filter(function(item, index, arr){
            //         return obj.hasOwnProperty(typeof item + item) ? false : (obj[typeof item + item] = true)
            //     })
            // },
            upCallback(page) {
                //联网加载数据
                console.log("tabindex",this.TabCur )
                let keyword = this.TabCur
                if(keyword == 0){
                    this.$http.get(this.url,{params:{pageNo: page.num, pageSize:page.size,msgCategory: '1'}}).then(res=>{
                        //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
                        
                        this.announcement1 = res.data.result.records
                        this.mescroll.endSuccess(this.announcement1.length);
                        //console.log("url", res)
                        //设置列表数据
                          if (res.data.success) {
                             console.log("res",res.data)
                             this.msg1Count = res.data.result.total
                             this.msg1Title = "通知(" + res.data.result.total + ")";
                             for(let annItem of this.announcement1){
                                     this.msgList.push(annItem)                            
                                }
                         }
                        if(page.num == 1){
                            this.msgList = []; //如果是第一页需手动制空列表
                            this.msgList = this.msgList.concat(this.announcement1); //追加新数据
                        }
                        
                    }).catch(()=>{
                        //联网失败, 结束加载
                        this.mescroll.endErr();
                    })
                }
                if(keyword == 1){
                    this.$http.get(this.url,{params:{pageNo: page.num,pageSize: page.size,msgCategory: '2'}}).then(res=>{
                        //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
                        this.announcement2 = res.data.result.records
                        this.mescroll.endSuccess(this.announcement2.length,this.msgCount);
                        
                        //设置列表数据
                          if (res.data.success) {
                              console.log("res sys",res.data)
                             this.msg2Count = res.data.result.total
                             this.msg2Title = "通知(" + res.data.result.total + ")";
                             // this.announcement2.filter((item,index) => {
                             // // console.log("item",item)
                             //  if(item.anntId == this.announcement2[index+1].anntId){
                                //   this.announcement2.splice(item,1)
                                  for(let item of this.announcement2){
                                      this.msgList.push(item)                            
                                  }
                            //   }
                            // })
                         }
                        if(page.num == 1){
                            this.msgList = []; //如果是第一页需手动制空列表
                            this.msgList = this.msgList.concat(this.announcement2); //追加新数据
                        }
                    }).catch(()=>{
                        //联网失败, 结束加载
                        this.mescroll.endErr();
                    })
                }
                
            },
        
            tabSelect(e) {
                this.TabCur = e.currentTarget.dataset.id;
                this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
                this.msgList = []// 先置空列表,显示加载进度
                this.mescroll.resetUpScroll() // 再刷新列表数据
            },
            goAnnotationDetail(item){
                //item.readFlag = '1'
                this.mescroll.resetUpScroll() 
                if(item.openType=="component" && item.openPage.indexOf('email')>= 0){
                    this.goEmailDetailPage(item)
                }else{
                    // console.log("detail",encodeURIComponent(JSON.stringify(item)))
                    uni.navigateTo({
                        url: '/pages/annotation/annotationDetail?item='+ encodeURIComponent(JSON.stringify(item))
                    });
                }
            },
            isEmail(item){
                if(item.openType=="component" &&item.openPage.indexOf('email')>=0){
                  return true;
                }else{
                  return false;
                }
            },
            goEmailDetailPage(item){
                console.log("go",item.anntId)
                console.log("item",item)
                 if(item.readFlag == '0'){
                    //item.readFlag = '1'
                    this.mescroll.resetUpScroll() 
                    let readUrl = '/sys/sysAnnouncementSend/editByAnntIdAndUserId';
                    this.$http.put(readUrl,{anntId:item.anntId})                    
                }
                // console.log("goe",item.busId)
                
                uni.navigateTo({
                    url: '/pages/mail/mailDetail?id='+item.busId
                });
                
            },
            ListTouchStart(e) {
                this.listTouchStart = e.touches[0].pageX
            },
            
            // ListTouch计算方向
            ListTouchMove(e) {
                this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
            },
            
            // ListTouch计算滚动
            ListTouchEnd(e) {
                if (this.listTouchDirection == 'left') {
                    this.modalName = e.currentTarget.dataset.target
                } else {
                    this.modalName = null
                }
                this.listTouchDirection = null
            },
            deleteAnnotation(item) {
                this.$http.delete(this.delUrl+'?id='+item.id).then(res => {
                    console.log("结果数据9", res)
                    if (res.data.success) {
                        this.mescroll.resetUpScroll() 
                    }
                }).catch(e => {
                    console.log("al delUrl请求错误2", e)
                    this.mescroll.endErr();
                })
            },
            formatDate(text,len){
                if(!text || text.length==0){
                    return ''
                }
                if(text.length<len){
                    return text;
                }
                return text.substr(0,len)
            },
            titleFilter(text,len){
                if(!text || text.length==0){
                    return ''
                }
                if(text.length<len){
                    return text;
                }
                return text.substr(0,len)+"..."
            }
            
        }
    }
</script>
 
<style scoped>
    .e-btn{margin-bottom: 1rem;}
 
    .titlePad{margin-top:0.6rem;}
    .cu-list>.move-cur{
        transform: translateX(-150rpx);
        
    }
    .nav .cu-item.cur {
        position: flex;
        z-index: 9;
        border-bottom: 4upx solid;
    }
 
</style>