d56bd957
“wangming”
修复问题,组建AI
|
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
|
<template>
<view class="main">
<view class="toptitle">
<view class="toptitle_left" @click="ht">
<u-icon name="arrow-left" color="#fff" size="20"></u-icon>
</view>
<view class="toptitle_title">
信息推送
</view>
</view>
<view class="" style="margin-bottom: 10px;">
<u-notice-bar :text="text1"></u-notice-bar>
</view>
<view class="box" v-for="(item, index) in xxtsList" :key="index" @click="openDetail(item)">
<view class="l1">
<!-- '../../../static/img/head.jpg' -->
<image style="width: 80%;border-radius: 1000px" src="/static/head.png" mode="widthFix"></image>
</view>
<view class="center">
<view class="f1">
{{ item.bt }}
</view>
<view class="f2">
{{ item.fl }} · {{ formatTime(item.tssj) }}
</view>
</view>
<view class="r1">
<view v-if="item.sfyd !== '是'" style="border: 1px solid red;border-radius: 10000px;width: 12px;height: 12px;background-color: red;"></view>
</view>
</view>
<u-empty
v-if="!loading && xxtsList.length === 0"
mode="message"
icon="http://cdn.uviewui.com/uview/empty/message.png"
>
</u-empty>
</view>
</template>
<script>
export default {
data() {
return {
text1: '请大家多多关心消息内容',
xxtsList: [],
loading: false,
form:{
currentPage: 1,
pageSize: 20,
sort: 'desc',
sidx: '',
jsr:""
},
nv_length: 0,
}
},
onShow(){
this.form.currentPage = 1
this.nv_length = 0
this.xxtsList = []
this.fetchXxtsList();
},
onReachBottom() {
var page = Math.ceil(this.nv_length / this.form.pageSize);
if (page > parseInt(this.form.currentPage)) {
this.form.currentPage = parseInt(this.form.currentPage) + 1
this.fetchXxtsList(true);
} else {
uni.showToast({
icon: "error",
title: "没有更多内容"
})
}
},
methods:{
ht(){
uni.navigateBack({
delta: 1
});
},
formatTime(ts){
if(!ts) return '';
const d = new Date(ts);
const Y = d.getFullYear();
const M = String(d.getMonth()+1).padStart(2,'0');
const D = String(d.getDate()).padStart(2,'0');
const h = String(d.getHours()).padStart(2,'0');
const m = String(d.getMinutes()).padStart(2,'0');
return `${Y}-${M}-${D} ${h}:${m}`;
},
fetchXxtsList(append = false){
if (this.loading) return;
this.loading = true;
const userInfo = uni.getStorageSync('userinfo') || {};
this.form.jsr = userInfo.userId || userInfo.id;
// 确保不传递 sfyd 参数,返回所有消息(包括已读和未读)
// 显式构建 params 对象,只包含需要的字段,避免意外包含 sfyd
const params = {
currentPage: this.form.currentPage,
pageSize: this.form.pageSize,
sort: this.form.sort,
sidx: this.form.sidx || '',
jsr: this.form.jsr
// 明确不包含 sfyd 字段
};
// 双重保险:确保 params 对象中没有 sfyd 字段
if ('sfyd' in params) {
delete params.sfyd;
}
// 检查 form 对象是否被意外修改
if (this.form.hasOwnProperty('sfyd')) {
console.warn('警告: form 对象包含 sfyd 字段:', this.form.sfyd);
}
console.log('获取消息列表参数:', JSON.stringify(params));
console.log('form 对象:', JSON.stringify(this.form));
this.API.xxtsjl(params).then(res=>{
console.log('消息列表响应:', res);
if (res && res.code === 200 && res.data) {
this.nv_length = res.data.pagination ? res.data.pagination.total : 0;
const rows = Array.isArray(res.data.list) ? res.data.list : [];
console.log(`获取到 ${rows.length} 条消息,总数: ${this.nv_length}`);
if (!append) {
this.xxtsList = [];
}
for(let i=0;i<rows.length;i++){
this.xxtsList.push(rows[i]);
}
console.log(`当前列表共有 ${this.xxtsList.length} 条消息`);
if (this.xxtsList.length === 0 && !append) {
uni.showToast({
icon: 'none',
title: '暂无消息'
});
}
} else {
console.warn('消息列表响应异常:', res);
if (!append) {
this.xxtsList = [];
}
uni.showToast({
icon: 'none',
title: res?.msg || '加载失败'
});
}
}).catch(err => {
console.error('获取消息列表失败:', err);
if (!append) {
this.xxtsList = [];
}
uni.showToast({
icon: 'none',
title: '加载失败,请稍后重试'
});
}).finally(()=>{
this.loading = false;
});
},
confirm(e){
console.log("11",e);
this.title = e.value[0]
this.show = false
this.keyword = ''
},
openDetail(item){
console.log(item);
try{
uni.setStorageSync('xxts_item', JSON.stringify(item));
}catch(e){}
const id = item.ff || item.ff || item.ff;
if(id){
uni.navigateTo({
url: `/pages/new/xxts/detail?id=${id}`
})
}else{
uni.navigateTo({
url: `/pages/new/xxts/detail`
})
}
},
}
}
</script>
<style scoped lang="scss">
@import 'index.scss';
</style>
|