落日与鲸
2025-02-25 6744a15b9ecedc44b68f047152dfe2032dbccbdc
全部已读
2个文件已修改
91 ■■■■■ 已修改文件
H5/pages/index/index.vue 88 ●●●●● 补丁 | 查看 | 原始文档 | 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: {
@@ -117,9 +118,22 @@
                bannerlist: [],
                msgList: [],
                msgListTotal: [],
                member:1,
                userInfo:{},
                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,19 +141,25 @@
            this.getappletcinfo()
        },
        methods: {
            Allread() {
                getread().then(resp => {
                    console.log(resp, '=====');
                    this.getMessagelist()
                })
            },
            getBanner() {
                getBanner().then(resp => {
                    console.log(resp, '获取banner');
                    this.bannerlist = resp.data
                })
            },
            getappletcinfo(){
                getappletcinfo().then(resp=>{
                    console.log(resp,'-----判断角色');
                    this.userInfo =resp.data
                    this.member =resp.data?2:1
                    uni.setStorageSync('userInfo',resp.data)
                    uni.setStorageSync('member',this.member)
            getappletcinfo() {
                getappletcinfo().then(resp => {
                    console.log(resp, '-----判断角色');
                    this.userInfo = resp.data
                    this.member = resp.data ? 2 : 1
                    uni.setStorageSync('userInfo', resp.data)
                    uni.setStorageSync('member', this.member)
                })
            },
            getMessagelist() {
@@ -149,26 +169,38 @@
                }
                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 来处理时间差
                          // 计算总秒数
                            const totalSeconds = Math.floor(timeDifference / 1000);
                            // 计算天数
                            const days = Math.floor(totalSeconds / (3600 * 24));
                            // 计算剩余的秒数
                            const remainingSecondsAfterDays = totalSeconds % (3600 * 24);
                            // 计算小时数
                            const hours = Math.floor(remainingSecondsAfterDays / 3600);
                            // 计算剩余的秒数
                            const remainingSecondsAfterHours = remainingSecondsAfterDays % 3600;
                            // 计算分钟数
                            const minutes = Math.floor(remainingSecondsAfterHours / 60);
                        item.time = days&&hours?`${days} 天 ${hours}小时 ${minutes} `:!days&&hours?`${hours}小时 ${minutes}`:`${minutes}`
                        // 计算总秒数
                        const totalSeconds = Math.floor(timeDifference / 1000);
                        // 计算天数
                        const days = Math.floor(totalSeconds / (3600 * 24));
                        // 计算剩余的秒数
                        const remainingSecondsAfterDays = totalSeconds % (3600 * 24);
                        // 计算小时数
                        const hours = Math.floor(remainingSecondsAfterDays / 3600);
                        // 计算剩余的秒数
                        const remainingSecondsAfterHours = remainingSecondsAfterDays % 3600;
                        // 计算分钟数
                        const minutes = Math.floor(remainingSecondsAfterHours / 60);
                        item.time = days && hours ? `${days} 天 ${hours}小时 ${minutes} ` : !days && hours ?
                            `${hours}小时 ${minutes}` : `${minutes}`
                        return item
                    })
                    this.msgList = JSON.parse(JSON.stringify(this.msgListTotal)).filter(item => item.promptType ==
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)
}