落日与鲸
2025-02-25 6744a15b9ecedc44b68f047152dfe2032dbccbdc
全部已读
2个文件已修改
43 ■■■■■ 已修改文件
H5/pages/index/index.vue 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/index/service.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/index/index.vue
@@ -85,7 +85,7 @@
                            </view>
                        </view>
                    </view>
                    <text class="flex j-center fs-27 color4 pb-48">全部已读</text>
                    <text class="flex j-center fs-27 color4 pb-48" @click="Allread">全部已读</text>
                </view>
@@ -101,7 +101,8 @@
    import {
        getBanner,
        getMessagelist,
        getappletcinfo
        getappletcinfo,
        getread
    } from './service.js'
    export default {
        components: {
@@ -119,7 +120,20 @@
                msgListTotal: [],
                member:1,
                userInfo:{},
                isLoading: false,
            }
        },
        onPullDownRefresh() {
            if (!this.isLoading) {
                this.pageNum = this.pageNum + 1
                this.getMessagelist()
            } else {
                return uni.showToast({
                    title: '没有更多了...',
                    icon: 'none'
                })
            }
        },
        onLoad() {
            this.getBanner()
@@ -127,6 +141,12 @@
            this.getappletcinfo()
        },
        methods: {
            Allread() {
                getread().then(resp => {
                    console.log(resp, '=====');
                    this.getMessagelist()
                })
            },
            getBanner() {
                getBanner().then(resp => {
                    console.log(resp, '获取banner');
@@ -149,7 +169,18 @@
                }
                getMessagelist(data).then(resp => {
                    console.log(resp, '获取消息列表');
                    this.msgListTotal = resp.data.records.map(item => {
                    if (resp.data.records.length < 5 && this.pageNum == 1) {
                        this.msgListTotal = resp.data.records
                        this.isLoading = true
                    } else if (resp.data.records.length < 5 && this.pageNum != 1) {
                        this.msgListTotal = [...this.msgListTotal, resp.data.records]
                        this.isLoading = true
                    } else {
                        this.msgListTotal = [...this.msgListTotal, resp.data.records]
                        this.isLoading = false
                    }
                    this.msgListTotal = this.msgListTotal.map(item => {
                        const timeDifference = new Date().getTime() - new Date(item.createTime).getTime()
                        // 使用 dayjs 的 duration 来处理时间差
@@ -167,7 +198,8 @@
                            // 计算分钟数
                            const minutes = Math.floor(remainingSecondsAfterHours / 60);
                            
                        item.time = days&&hours?`${days} 天 ${hours}小时 ${minutes} `:!days&&hours?`${hours}小时 ${minutes}`:`${minutes}`
                        item.time = days && hours ? `${days} 天 ${hours}小时 ${minutes} ` : !days && hours ?
                            `${hours}小时 ${minutes}` : `${minutes}`
                        
                        return item
                    })
H5/pages/index/service.js
@@ -9,3 +9,6 @@
export const getappletcinfo =(params)=>{
    return request.get(`/api/huacheng-sangeshenbian/applet/home/current-user-info`,params)
export const getread=(params)=>{
    return request.post(`/api/huacheng-sangeshenbian/applet/home/read`,params)
}