You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
6.0 KiB

3 weeks ago
<template>
<view class="fate-page">
<view class="top-safe" :style="{ height: menuButtonInfo.top + 'px' }"></view>
<view class="nav">
<view class="back" @tap="back"></view>
<view class="title">今日缘分</view>
<view class="ghost"></view>
</view>
<view class="hero">
3 weeks ago
<view class="hero-title">今天的 {{ todayCount }} 次轻连接</view>
3 weeks ago
<view class="hero-sub">它们不会变成关系压力只留下一点情绪轨迹</view>
</view>
<view class="timeline">
<view class="line"></view>
2 weeks ago
<view class="fate-card" v-for="item in fates" :key="item.id" @tap="openChat(item)">
3 weeks ago
<view class="node" :class="item.type">{{ item.type }}</view>
<view class="card-main">
<view class="card-top">
<text class="name">{{ item.name }}</text>
<text class="time">{{ item.time }}</text>
</view>
<view class="feeling">{{ item.feeling }}</view>
2 weeks ago
<view class="remeet" v-if="item.remeet">10分钟后可再遇见一次</view>
3 weeks ago
</view>
</view>
</view>
3 weeks ago
<view class="empty">{{ loading ? '正在加载...' : (hasMore ? '上滑加载更多缘分' : (fates.length ? '今天先到这里' : '今天还没有轻连接')) }}</view>
3 weeks ago
</view>
</template>
<script>
2 weeks ago
import { pageIeMatches } from '@/common/ieApi.js'
3 weeks ago
3 weeks ago
export default {
data() {
return {
menuButtonInfo: { top: 44 },
3 weeks ago
fates: [],
pageNumber: 1,
pageSize: 10,
hasMore: true,
loading: false
}
},
computed: {
todayCount() {
const today = new Date().toDateString()
return this.fates.filter(item => item.rawDate && item.rawDate.toDateString() === today).length
3 weeks ago
}
},
onLoad() {
if (uni.getMenuButtonBoundingClientRect) this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
3 weeks ago
this.loadFates()
},
onReachBottom() {
this.loadFates()
3 weeks ago
},
methods: {
3 weeks ago
formatTime(value) {
if (!value) return ''
const date = new Date(value)
if (Number.isNaN(date.getTime())) return ''
const now = new Date()
if (date.toDateString() === now.toDateString()) {
return `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
}
return `${date.getMonth() + 1}/${date.getDate()}`
},
normalizeRecord(item) {
const date = new Date(item.createTime)
return {
id: item.id,
2 weeks ago
matchId: item.matchId,
roomId: item.roomId,
2 weeks ago
targetUserId: item.targetUserId,
2 weeks ago
type: item.mode || 'i',
3 weeks ago
name: item.anonymousName || '半匿名漂流者',
2 weeks ago
avatar: item.avatarText || (item.mode === 'e' ? '光' : '月'),
avatarUrl: item.avatarUrl || '',
3 weeks ago
time: this.formatTime(item.createTime),
rawDate: Number.isNaN(date.getTime()) ? null : date,
2 weeks ago
feeling: item.quoteText || item.stateText || item.failReason || '这次连接只留下了一点情绪轨迹。',
remeet: item.status === 3
3 weeks ago
}
},
2 weeks ago
openChat(item) {
if (!item || !item.roomId) {
uni.showToast({ title: '这条缘分还没有聊天入口', icon: 'none' })
return
}
uni.navigateTo({
url: '/package1/ieBrowser/chat?mode=' + item.type +
'&roomId=' + item.roomId +
'&targetUserId=' + (item.targetUserId || '') +
'&name=' + encodeURIComponent(item.name || '半匿名漂流者') +
'&avatar=' + encodeURIComponent(item.avatar || item.type || '◌') +
'&avatarUrl=' + encodeURIComponent(item.avatarUrl || '') +
'&quote=' + encodeURIComponent(item.feeling || '')
})
},
3 weeks ago
async loadFates() {
if (this.loading || !this.hasMore) return
this.loading = true
try {
2 weeks ago
const page = await pageIeMatches(this.pageNumber, this.pageSize)
3 weeks ago
const list = page && page.records ? page.records.map(this.normalizeRecord) : []
2 weeks ago
const exists = new Set(this.fates.map(item => item.matchId || item.id))
this.fates = this.fates.concat(list.filter(item => !exists.has(item.matchId || item.id)))
3 weeks ago
this.hasMore = page ? (page.current || this.pageNumber) < (page.pages || this.pageNumber) : false
this.pageNumber += 1
} finally {
this.loading = false
}
},
3 weeks ago
back() { uni.redirectTo({ url: '/package1/ieBrowser/index' }) }
}
}
</script>
<style lang="scss" scoped>
page { background: #f7f9ff; }
.fate-page { min-height: 100vh; padding: 0 30rpx 60rpx; box-sizing: border-box; color: #151a2d; background: radial-gradient(circle at 84% 12%, rgba(139,124,255,.22), transparent 300rpx), linear-gradient(180deg, #fbfdff, #eef4ff); }
.nav { height: 90rpx; display: flex; align-items: center; }
.back, .ghost { width: 70rpx; font-size: 56rpx; color: rgba(21,26,45,.64); }
.title { flex: 1; text-align: center; font-size: 31rpx; font-weight: 800; }
.hero { margin-top: 22rpx; padding: 36rpx; border-radius: 44rpx; background: rgba(255,255,255,.58); border: 1rpx solid rgba(255,255,255,.86); backdrop-filter: blur(24rpx); }
.hero-title { font-size: 44rpx; font-weight: 800; }
.hero-sub { margin-top: 14rpx; color: rgba(21,26,45,.52); font-size: 25rpx; line-height: 40rpx; }
.timeline { position: relative; margin-top: 36rpx; }
.line { position: absolute; left: 37rpx; top: 30rpx; bottom: 30rpx; width: 2rpx; background: rgba(139,124,255,.2); }
.fate-card { position: relative; display: flex; margin-bottom: 24rpx; }
.node { z-index: 1; width: 76rpx; height: 76rpx; border-radius: 50%; text-align: center; line-height: 76rpx; font-size: 30rpx; font-weight: 800; }
.node.i { color: #fff; background: #7771d8; }
.node.e { color: #11162a; background: #a9ffe7; }
.card-main { flex: 1; margin-left: 20rpx; padding: 28rpx; border-radius: 34rpx; background: rgba(255,255,255,.64); box-shadow: 0 22rpx 54rpx rgba(96,112,160,.12); }
.card-top { display: flex; }
.name { flex: 1; font-size: 28rpx; font-weight: 800; }
.time { color: rgba(21,26,45,.4); font-size: 22rpx; }
.feeling { margin-top: 14rpx; color: rgba(21,26,45,.62); font-size: 25rpx; line-height: 40rpx; }
.remeet { display: inline-block; margin-top: 18rpx; padding: 8rpx 18rpx; border-radius: 999rpx; color: #11162a; background: #dffef4; font-size: 21rpx; }
3 weeks ago
.empty { margin-top: 32rpx; text-align: center; color: rgba(21,26,45,.36); font-size: 23rpx; }
3 weeks ago
</style>