mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-01 01:21:04 +08:00
feat: coffe redeem
This commit is contained in:
@@ -1,28 +1,7 @@
|
||||
<template>
|
||||
<div class="activity-list-page">
|
||||
<div class="activity-list-page-card" v-for="a in activities" :key="a.id">
|
||||
<router-link v-if="a.type === 'MILK_TEA'" class="activity-link" to="/activities/milk-tea">
|
||||
<div class="activity-list-page-card-normal">
|
||||
<div v-if="a.icon" class="activity-card-normal-left">
|
||||
<img :src="a.icon" alt="avatar" class="activity-card-left-avatar-img" />
|
||||
</div>
|
||||
<div class="activity-card-normal-right">
|
||||
<div class="activity-card-normal-right-header">
|
||||
<div class="activity-list-page-card-title">{{ a.title }}</div>
|
||||
<div v-if="a.ended" class="activity-list-page-card-state-end">已结束</div>
|
||||
<div v-else class="activity-list-page-card-state-ongoing">进行中</div>
|
||||
</div>
|
||||
<div class="activity-list-page-card-content">{{ a.content }}</div>
|
||||
<div class="activity-list-page-card-footer">
|
||||
<div class="activity-list-page-card-footer-start-time">
|
||||
<i class="fas fa-clock"></i>
|
||||
<span>开始于 {{ TimeManager.format(a.startTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</router-link>
|
||||
<div v-else class="activity-list-page-card-normal">
|
||||
<div class="activity-list-page-card-normal">
|
||||
<div v-if="a.icon" class="activity-card-normal-left">
|
||||
<img :src="a.icon" alt="avatar" class="activity-card-left-avatar-img" />
|
||||
</div>
|
||||
@@ -41,6 +20,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<MilkTeaActivityComponent v-if="a.type === 'MILK_TEA'" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -48,9 +28,11 @@
|
||||
<script>
|
||||
import { API_BASE_URL } from '../main'
|
||||
import TimeManager from '../utils/time'
|
||||
import MilkTeaActivityComponent from '../components/MilkTeaActivityComponent.vue'
|
||||
|
||||
export default {
|
||||
name: 'ActivityListPageView',
|
||||
components: { MilkTeaActivityComponent },
|
||||
data() {
|
||||
return { activities: [], TimeManager }
|
||||
},
|
||||
@@ -68,6 +50,7 @@ export default {
|
||||
background-color: var(--background-color);
|
||||
padding: 20px;
|
||||
height: calc(100vh - var(--header-height) - 40px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.activity-list-page-card {
|
||||
|
||||
@@ -62,6 +62,11 @@
|
||||
</span>
|
||||
</NotificationContainer>
|
||||
</template>
|
||||
<template v-else-if="item.type === 'ACTIVITY_REDEEM' && !item.parentComment">
|
||||
<NotificationContainer :item="item" :markRead="markRead">
|
||||
<span class="notif-user">{{ item.fromUser.username }} </span> 申请进行奶茶兑换,联系方式是:{{ item.content }}
|
||||
</NotificationContainer>
|
||||
</template>
|
||||
<template v-else-if="item.type === 'REACTION' && item.post && !item.comment">
|
||||
<NotificationContainer :item="item" :markRead="markRead">
|
||||
<span class="notif-user">{{ item.fromUser.username }} </span> 对我的文章
|
||||
@@ -287,7 +292,8 @@ export default {
|
||||
USER_UNFOLLOWED: 'fas fa-user-minus',
|
||||
POST_SUBSCRIBED: 'fas fa-bookmark',
|
||||
POST_UNSUBSCRIBED: 'fas fa-bookmark',
|
||||
REGISTER_REQUEST: 'fas fa-user-clock'
|
||||
REGISTER_REQUEST: 'fas fa-user-clock',
|
||||
ACTIVITY_REDEEM: 'fas fa-coffee'
|
||||
}
|
||||
|
||||
const reactionEmojiMap = {
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
<template>
|
||||
<div class="milk-tea-page">
|
||||
<div class="milk-tea-status">
|
||||
<div class="status-title">已兑换奶茶人数</div>
|
||||
<ProgressBar :value="info.level1Count" :max="50" />
|
||||
<div class="status-text">{{ info.level1Count }} / 50</div>
|
||||
</div>
|
||||
<div v-if="user" class="user-level">
|
||||
<LevelProgress :exp="user.experience" :current-level="user.currentLevel" :next-exp="user.nextLevelExp" />
|
||||
</div>
|
||||
<LoginOverlay v-else />
|
||||
<div v-if="user && user.currentLevel >= 1 && !info.ended" class="redeem-button" @click="openDialog">
|
||||
兑换
|
||||
</div>
|
||||
<div v-if="dialogVisible" class="redeem-dialog">
|
||||
<div class="redeem-dialog-overlay" @click="closeDialog"></div>
|
||||
<div class="redeem-dialog-content">
|
||||
<input v-model="contact" class="redeem-input" placeholder="联系方式" />
|
||||
<div class="redeem-actions">
|
||||
<button @click="submitRedeem" :disabled="loading">提交</button>
|
||||
<button @click="closeDialog">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ProgressBar from '../components/ProgressBar.vue'
|
||||
import LevelProgress from '../components/LevelProgress.vue'
|
||||
import LoginOverlay from '../components/LoginOverlay.vue'
|
||||
import { API_BASE_URL, toast } from '../main'
|
||||
import { getToken, fetchCurrentUser } from '../utils/auth'
|
||||
|
||||
export default {
|
||||
name: 'MilkTeaActivityPageView',
|
||||
components: { ProgressBar, LevelProgress, LoginOverlay },
|
||||
data () {
|
||||
return {
|
||||
info: { level1Count: 0, ended: false },
|
||||
user: null,
|
||||
dialogVisible: false,
|
||||
contact: '',
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
async mounted () {
|
||||
await this.loadInfo()
|
||||
this.user = await fetchCurrentUser()
|
||||
},
|
||||
methods: {
|
||||
async loadInfo () {
|
||||
const res = await fetch(`${API_BASE_URL}/api/activities/milk-tea`)
|
||||
if (res.ok) {
|
||||
this.info = await res.json()
|
||||
}
|
||||
},
|
||||
openDialog () {
|
||||
this.dialogVisible = true
|
||||
},
|
||||
closeDialog () {
|
||||
this.dialogVisible = false
|
||||
},
|
||||
async submitRedeem () {
|
||||
if (!this.contact) return
|
||||
this.loading = true
|
||||
const token = getToken()
|
||||
const res = await fetch(`${API_BASE_URL}/api/activities/milk-tea/redeem`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ contact: this.contact })
|
||||
})
|
||||
if (res.ok) {
|
||||
toast.success('兑换成功!')
|
||||
this.dialogVisible = false
|
||||
await this.loadInfo()
|
||||
} else {
|
||||
toast.error('兑换失败')
|
||||
}
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.milk-tea-page {
|
||||
padding: 20px;
|
||||
background-color: var(--background-color);
|
||||
height: calc(100vh - var(--header-height) - 40px);
|
||||
}
|
||||
|
||||
.milk-tea-status {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.status-title {
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 14px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.redeem-button {
|
||||
margin-top: 20px;
|
||||
padding: 6px 12px;
|
||||
border-radius: 4px;
|
||||
background-color: var(--primary-color);
|
||||
color: white;
|
||||
width: fit-content;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.redeem-button:hover {
|
||||
background-color: var(--primary-color-hover);
|
||||
}
|
||||
|
||||
.redeem-dialog {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.redeem-dialog-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
backdrop-filter: blur(3px);
|
||||
-webkit-backdrop-filter: blur(3px);
|
||||
}
|
||||
|
||||
.redeem-dialog-content {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
background-color: var(--background-color);
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
.redeem-actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.redeem-input {
|
||||
padding: 6px;
|
||||
border: 1px solid var(--normal-border-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user