feat: add lottery follow action
This commit is contained in:
@@ -66,7 +66,16 @@
|
||||
<text v-else>{{ (draw.game_name || '').substring(0, 1) }}</text>
|
||||
</view>
|
||||
<view class="latest-card__meta">
|
||||
<text class="latest-card__name">{{ draw.game_name || draw.code }}</text>
|
||||
<view class="latest-card__name-row">
|
||||
<text class="latest-card__name">{{ draw.game_name || draw.code }}</text>
|
||||
<view class="latest-card__follow"
|
||||
:class="{ 'latest-card__follow--active': isFollowing(draw.code) }"
|
||||
@tap.stop="toggleFollow(draw)">
|
||||
<u-icon :name="isFollowing(draw.code) ? 'star-fill' : 'star'" size="24"
|
||||
:color="isFollowing(draw.code) ? '#e6a23c' : '#1468e8'" />
|
||||
<text>{{ isFollowing(draw.code) ? '已关注' : '关注' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="latest-card__issue-row">
|
||||
<text>第{{ draw.issue }}期</text>
|
||||
<text class="latest-card__status">已开奖</text>
|
||||
@@ -235,6 +244,22 @@ const latestUpdatedAt = ref('--:--')
|
||||
const gameSelections = ref<Record<number, { code: string; name: string }>>(uni.getStorageSync('lottery_selections') || {})
|
||||
const selectedGameCode = ref('')
|
||||
const selectedGameName = ref('')
|
||||
const followedGameCodes = ref<string[]>(uni.getStorageSync('lottery_followed_games') || [])
|
||||
|
||||
const isFollowing = (code: string) => followedGameCodes.value.includes(code)
|
||||
|
||||
const toggleFollow = (draw: any) => {
|
||||
const code = draw?.code
|
||||
if (!code) return
|
||||
if (isFollowing(code)) {
|
||||
followedGameCodes.value = followedGameCodes.value.filter((item) => item !== code)
|
||||
uni.showToast({ title: '已取消关注', icon: 'none' })
|
||||
} else {
|
||||
followedGameCodes.value = [...followedGameCodes.value, code]
|
||||
uni.showToast({ title: '已关注', icon: 'none' })
|
||||
}
|
||||
uni.setStorageSync('lottery_followed_games', followedGameCodes.value)
|
||||
}
|
||||
|
||||
const saveSelections = () => {
|
||||
uni.setStorageSync('lottery_selections', gameSelections.value)
|
||||
@@ -2286,4 +2311,30 @@ onReachBottom(() => {
|
||||
.latest-card__action {
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.latest-card__name-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.latest-card__name-row .latest-card__name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.latest-card__follow {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
flex-shrink: 0;
|
||||
color: #1468e8;
|
||||
font-size: 18rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.latest-card__follow--active {
|
||||
color: #e6a23c;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user