| | |
| | | </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> |
| | | |
| | |
| | | import { |
| | | getBanner, |
| | | getMessagelist, |
| | | getappletcinfo |
| | | getappletcinfo, |
| | | getread |
| | | } from './service.js' |
| | | export default { |
| | | components: { |
| | |
| | | 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() |
| | |
| | | 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() { |
| | |
| | | } |
| | | 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 == |