|
|
@@ -1,36 +1,71 @@
|
|
1
|
1
|
<template>
|
|
2
|
|
- <view class="welfare-page">
|
|
|
2
|
+ <scroll-view scroll-y class="welfare-page">
|
|
|
3
|
+ <!-- 用户信息栏 -->
|
|
|
4
|
+ <view class="user-header">
|
|
|
5
|
+ <image :src="userAvatar" class="avatar" />
|
|
|
6
|
+ <view class="info">
|
|
|
7
|
+ <text class="name">{{ userName }}</text>
|
|
|
8
|
+ <text class="coins">金币: {{ coins }}</text>
|
|
|
9
|
+ </view>
|
|
|
10
|
+ <view class="vip-tag" v-if="isVIP">
|
|
|
11
|
+ <uni-icons type="crown" size="16" color="#ffc53d"></uni-icons>
|
|
|
12
|
+ <text>VIP会员</text>
|
|
|
13
|
+ </view>
|
|
|
14
|
+ </view>
|
|
3
|
15
|
<!-- 签到区域 -->
|
|
4
|
16
|
<view class="signin-section">
|
|
5
|
|
- <text class="title">每日签到</text>
|
|
6
|
|
- <view class="signin-grid">
|
|
|
17
|
+ <view class="sign-header">
|
|
|
18
|
+ <text class="title">每日签到</text>
|
|
|
19
|
+ <text class="subtitle">已连续签到 {{ signedDays }} 天</text>
|
|
|
20
|
+ </view>
|
|
|
21
|
+
|
|
|
22
|
+ <view class="sign-calendar">
|
|
7
|
23
|
<view
|
|
8
|
|
- v-for="(day, index) in 7"
|
|
9
|
|
- :key="day"
|
|
10
|
|
- :class="['day', { signed: index < signedDays, today: index === currentDay }]"
|
|
11
|
|
- @click="signIn(index)"
|
|
|
24
|
+ v-for="day in 7"
|
|
|
25
|
+ :key="day"
|
|
|
26
|
+ :class="[
|
|
|
27
|
+ 'sign-day',
|
|
|
28
|
+ {
|
|
|
29
|
+ 'signed': day <= signedDays,
|
|
|
30
|
+ 'today': day === currentDay && !todaySigned,
|
|
|
31
|
+ 'active': day === currentDay && todaySigned
|
|
|
32
|
+ }
|
|
|
33
|
+ ]"
|
|
|
34
|
+ @click="handleSign(day)"
|
|
12
|
35
|
>
|
|
13
|
|
- <text>第{{ day }}天</text>
|
|
14
|
|
- <text class="reward">+{{ calculateReward(index) }}金币</text>
|
|
|
36
|
+ <text class="day-label">第{{ day }}天</text>
|
|
|
37
|
+ <text class="reward">+{{ getReward(day) }}金币</text>
|
|
15
|
38
|
</view>
|
|
16
|
39
|
</view>
|
|
17
|
40
|
<text class="tip">已连续签到 {{ signedDays }} 天</text>
|
|
18
|
41
|
</view>
|
|
19
|
42
|
|
|
|
43
|
+ <!-- 合作任务 -->
|
|
|
44
|
+ <PartnerTask />
|
|
|
45
|
+
|
|
20
|
46
|
<!-- 任务中心 -->
|
|
21
|
|
- <view class="tasks-section">
|
|
22
|
|
- <text class="title">每日任务</text>
|
|
|
47
|
+ <view class="task-center">
|
|
|
48
|
+ <view class="section-header">
|
|
|
49
|
+ <text class="title">每日任务</text>
|
|
|
50
|
+ <text class="more">查看更多</text>
|
|
|
51
|
+ </view>
|
|
|
52
|
+
|
|
23
|
53
|
<view class="task-list">
|
|
24
|
|
- <view v-for="task in dailyTasks" :key="task.id" class="task-item">
|
|
|
54
|
+ <view
|
|
|
55
|
+ v-for="task in dailyTasks"
|
|
|
56
|
+ :key="task.id"
|
|
|
57
|
+ class="task-item"
|
|
|
58
|
+ >
|
|
25
|
59
|
<view class="task-info">
|
|
26
|
|
- <text class="task-name">{{ task.name }}</text>
|
|
27
|
|
- <text class="task-reward">+{{ task.reward }}金币</text>
|
|
|
60
|
+ <uni-icons :type="task.icon" size="20" :color="task.completed ? '#52c41a' : '#666'"></uni-icons>
|
|
|
61
|
+ <text class="name">{{ task.name }}</text>
|
|
28
|
62
|
</view>
|
|
29
|
63
|
<button
|
|
30
|
|
- :class="['task-btn', { disabled: task.completed }]"
|
|
|
64
|
+ class="action-btn"
|
|
|
65
|
+ :class="{ completed: task.completed }"
|
|
31
|
66
|
@click="completeTask(task)"
|
|
32
|
67
|
>
|
|
33
|
|
- {{ task.completed ? '已完成' : '去完成' }}
|
|
|
68
|
+ {{ task.completed ? '已完成' : '+'+task.reward+'金币' }}
|
|
34
|
69
|
</button>
|
|
35
|
70
|
</view>
|
|
36
|
71
|
</view>
|
|
|
@@ -51,23 +86,39 @@
|
|
51
|
86
|
</view>
|
|
52
|
87
|
</view>
|
|
53
|
88
|
</view>
|
|
54
|
|
- </view>
|
|
|
89
|
+ </scroll-view>
|
|
55
|
90
|
</template>
|
|
56
|
91
|
|
|
57
|
92
|
<script setup>
|
|
58
|
|
-import { ref } from 'vue'
|
|
|
93
|
+import { ref, onMounted } from 'vue'
|
|
|
94
|
+import { useSignSystem } from '@/utils/signUtils'
|
|
|
95
|
+import PartnerTask from '@/components/PartnerTask.vue'
|
|
|
96
|
+import { useUserStore } from '@/stores/user'
|
|
|
97
|
+
|
|
|
98
|
+const userStore = useUserStore()
|
|
|
99
|
+const { signedDays, todaySigned, signRewards, loadSignStatus, doSign } = useSignSystem()
|
|
59
|
100
|
|
|
60
|
|
-const signedDays = ref(3)
|
|
61
|
|
-const currentDay = ref(3) // 0-6 表示周一到周日
|
|
|
101
|
+// 用户数据
|
|
|
102
|
+const userName = ref('哎呀用户')
|
|
|
103
|
+const userAvatar = ref('/static/avatar/default.png')
|
|
|
104
|
+const coins = ref(350)
|
|
|
105
|
+const isVIP = ref(true)
|
|
62
|
106
|
|
|
63
|
107
|
// 每日任务
|
|
64
|
108
|
const dailyTasks = ref([
|
|
65
|
|
- { id: 1, name: '阅读30分钟', reward: 50, completed: false },
|
|
66
|
|
- { id: 2, name: '分享给好友', reward: 30, completed: true },
|
|
67
|
|
- { id: 3, name: '评论本章节', reward: 20, completed: false },
|
|
68
|
|
- { id: 4, name: '完善个人资料', reward: 10, completed: false }
|
|
|
109
|
+ { id: 1, name: '阅读30分钟', icon: 'eye', reward: 50, completed: false },
|
|
|
110
|
+ { id: 2, name: '分享给好友', icon: 'redo', reward: 30, completed: true },
|
|
|
111
|
+ { id: 3, name: '评论本章节', icon: 'chat', reward: 20, completed: false },
|
|
|
112
|
+ { id: 4, name: '完善个人资料', icon: 'person', reward: 10, completed: false }
|
|
69
|
113
|
])
|
|
|
114
|
+// 当前星期几(0-6)
|
|
|
115
|
+const currentDay = ref(new Date().getDay() + 1)
|
|
70
|
116
|
|
|
|
117
|
+// 获取每日奖励
|
|
|
118
|
+const getReward = (day) => {
|
|
|
119
|
+ const reward = signRewards.value.find(r => r.day === day)
|
|
|
120
|
+ return reward ? reward.reward : 10 + day * 5
|
|
|
121
|
+}
|
|
71
|
122
|
// 合作平台
|
|
72
|
123
|
const partners = ref([
|
|
73
|
124
|
{ id: 1, name: '百度地图', icon: '/static/partners/baidu.png', url: 'https://map.baidu.com' },
|
|
|
@@ -76,29 +127,43 @@ const partners = ref([
|
|
76
|
127
|
{ id: 4, name: '饿了么', icon: '/static/partners/eleme.png', url: 'https://www.ele.me' }
|
|
77
|
128
|
])
|
|
78
|
129
|
|
|
79
|
|
-// 签到逻辑
|
|
80
|
|
-const signIn = (dayIndex) => {
|
|
81
|
|
- if (dayIndex !== currentDay.value) return
|
|
82
|
|
- if (signedDays.value > currentDay.value) return
|
|
|
130
|
+// 处理签到
|
|
|
131
|
+const handleSign = async (day) => {
|
|
|
132
|
+ if (day !== currentDay.value) {
|
|
|
133
|
+ uni.showToast({ title: '请先完成今日签到', icon: 'none' })
|
|
|
134
|
+ return
|
|
|
135
|
+ }
|
|
83
|
136
|
|
|
84
|
|
- signedDays.value++
|
|
85
|
|
- uni.showToast({ title: `签到成功!获得${calculateReward(dayIndex)}金币` })
|
|
86
|
|
-}
|
|
87
|
|
-
|
|
88
|
|
-// 计算签到奖励
|
|
89
|
|
-const calculateReward = (day) => {
|
|
90
|
|
- const baseReward = 10
|
|
91
|
|
- return baseReward * (day + 1)
|
|
|
137
|
+ if (todaySigned.value) {
|
|
|
138
|
+ uni.showToast({ title: '今日已签到', icon: 'none' })
|
|
|
139
|
+ return
|
|
|
140
|
+ }
|
|
|
141
|
+
|
|
|
142
|
+ const reward = await doSign()
|
|
|
143
|
+ if (reward) {
|
|
|
144
|
+ coins.value += reward
|
|
|
145
|
+ }
|
|
92
|
146
|
}
|
|
93
|
147
|
|
|
94
|
148
|
// 完成任务
|
|
95
|
149
|
const completeTask = (task) => {
|
|
96
|
150
|
if (task.completed) return
|
|
97
|
|
-
|
|
98
|
151
|
task.completed = true
|
|
99
|
|
- uni.showToast({ title: `任务完成!获得${task.reward}金币` })
|
|
|
152
|
+ coins.value += task.reward
|
|
|
153
|
+ uni.showToast({ title: `任务完成!获得${task.reward}金币`, icon: 'success' })
|
|
100
|
154
|
}
|
|
101
|
|
-
|
|
|
155
|
+// 初始化
|
|
|
156
|
+onMounted(async () => {
|
|
|
157
|
+ await loadSignStatus()
|
|
|
158
|
+
|
|
|
159
|
+ // 加载用户信息
|
|
|
160
|
+ if (userStore.userInfo) {
|
|
|
161
|
+ userName.value = userStore.userInfo.nickname || '哎呀用户'
|
|
|
162
|
+ userAvatar.value = userStore.userInfo.avatar || '/static/avatar/default.png'
|
|
|
163
|
+ coins.value = userStore.userInfo.coins || 0
|
|
|
164
|
+ isVIP.value = userStore.isVIP
|
|
|
165
|
+ }
|
|
|
166
|
+})
|
|
102
|
167
|
// 跳转合作平台
|
|
103
|
168
|
const goPartnerTask = (partner) => {
|
|
104
|
169
|
uni.navigateTo({
|
|
|
@@ -109,117 +174,170 @@ const goPartnerTask = (partner) => {
|
|
109
|
174
|
|
|
110
|
175
|
<style scoped>
|
|
111
|
176
|
.welfare-page {
|
|
|
177
|
+ height: 100vh;
|
|
|
178
|
+ background-color: var(--bg-color);
|
|
112
|
179
|
padding: 20px;
|
|
|
180
|
+ box-sizing: border-box;
|
|
113
|
181
|
}
|
|
114
|
182
|
|
|
115
|
|
-.title {
|
|
|
183
|
+.user-header {
|
|
|
184
|
+ display: flex;
|
|
|
185
|
+ align-items: center;
|
|
|
186
|
+ margin-bottom: 25px;
|
|
|
187
|
+}
|
|
|
188
|
+
|
|
|
189
|
+.avatar {
|
|
|
190
|
+ width: 60px;
|
|
|
191
|
+ height: 60px;
|
|
|
192
|
+ border-radius: 50%;
|
|
|
193
|
+ margin-right: 15px;
|
|
|
194
|
+}
|
|
|
195
|
+
|
|
|
196
|
+.info {
|
|
|
197
|
+ flex: 1;
|
|
|
198
|
+}
|
|
|
199
|
+
|
|
|
200
|
+.name {
|
|
116
|
201
|
font-size: 18px;
|
|
117
|
202
|
font-weight: bold;
|
|
118
|
|
- margin-bottom: 15px;
|
|
119
|
203
|
display: block;
|
|
120
|
204
|
}
|
|
121
|
205
|
|
|
122
|
|
-.signin-section {
|
|
123
|
|
- margin-bottom: 25px;
|
|
|
206
|
+.coins {
|
|
|
207
|
+ font-size: 14px;
|
|
|
208
|
+ color: #faad14;
|
|
|
209
|
+ display: block;
|
|
|
210
|
+ margin-top: 5px;
|
|
|
211
|
+}
|
|
|
212
|
+
|
|
|
213
|
+.vip-tag {
|
|
|
214
|
+ background: linear-gradient(135deg, #ffd666 0%, #ffc53d 100%);
|
|
|
215
|
+ color: #1a3353;
|
|
|
216
|
+ padding: 4px 10px;
|
|
|
217
|
+ border-radius: 15px;
|
|
|
218
|
+ font-size: 12px;
|
|
|
219
|
+ display: flex;
|
|
|
220
|
+ align-items: center;
|
|
|
221
|
+}
|
|
|
222
|
+
|
|
|
223
|
+.sign-card {
|
|
|
224
|
+ background-color: var(--card-bg);
|
|
|
225
|
+ border-radius: 16px;
|
|
|
226
|
+ padding: 20px;
|
|
|
227
|
+ margin-bottom: 20px;
|
|
|
228
|
+}
|
|
|
229
|
+
|
|
|
230
|
+.sign-header {
|
|
|
231
|
+ display: flex;
|
|
|
232
|
+ justify-content: space-between;
|
|
|
233
|
+ align-items: center;
|
|
|
234
|
+ margin-bottom: 15px;
|
|
|
235
|
+}
|
|
|
236
|
+
|
|
|
237
|
+.title {
|
|
|
238
|
+ font-size: 18px;
|
|
|
239
|
+ font-weight: bold;
|
|
124
|
240
|
}
|
|
125
|
241
|
|
|
126
|
|
-.signin-grid {
|
|
|
242
|
+.subtitle {
|
|
|
243
|
+ font-size: 14px;
|
|
|
244
|
+ color: #666;
|
|
|
245
|
+}
|
|
|
246
|
+
|
|
|
247
|
+.sign-calendar {
|
|
127
|
248
|
display: grid;
|
|
128
|
249
|
grid-template-columns: repeat(7, 1fr);
|
|
129
|
|
- gap: 5px;
|
|
|
250
|
+ gap: 8px;
|
|
130
|
251
|
}
|
|
131
|
252
|
|
|
132
|
|
-.day {
|
|
|
253
|
+.sign-day {
|
|
133
|
254
|
border: 1px solid #eee;
|
|
134
|
255
|
border-radius: 8px;
|
|
135
|
|
- padding: 8px 5px;
|
|
|
256
|
+ padding: 10px 5px;
|
|
136
|
257
|
text-align: center;
|
|
137
|
|
- font-size: 12px;
|
|
138
|
|
-
|
|
139
|
|
- &.signed {
|
|
140
|
|
- background-color: #e6fffb;
|
|
141
|
|
- border-color: #36cfc9;
|
|
142
|
|
- }
|
|
143
|
|
-
|
|
144
|
|
- &.today {
|
|
145
|
|
- background-color: #fff7e6;
|
|
146
|
|
- border-color: #ffc53d;
|
|
147
|
|
- }
|
|
|
258
|
+ background-color: #fafafa;
|
|
148
|
259
|
}
|
|
149
|
260
|
|
|
150
|
|
-.reward {
|
|
151
|
|
- display: block;
|
|
152
|
|
- color: #faad14;
|
|
153
|
|
- font-weight: bold;
|
|
|
261
|
+.sign-day.signed {
|
|
|
262
|
+ background-color: #e6fffb;
|
|
|
263
|
+ border-color: #36cfc9;
|
|
|
264
|
+}
|
|
|
265
|
+
|
|
|
266
|
+.sign-day.today {
|
|
|
267
|
+ background-color: #fff7e6;
|
|
|
268
|
+ border-color: #ffc53d;
|
|
154
|
269
|
}
|
|
155
|
270
|
|
|
156
|
|
-.tip {
|
|
|
271
|
+.sign-day.active {
|
|
|
272
|
+ background-color: #fff1b8;
|
|
|
273
|
+ border-color: #ffc53d;
|
|
|
274
|
+}
|
|
|
275
|
+
|
|
|
276
|
+.day-label {
|
|
|
277
|
+ font-size: 13px;
|
|
157
|
278
|
display: block;
|
|
158
|
|
- margin-top: 10px;
|
|
159
|
|
- color: #8c8c8c;
|
|
|
279
|
+}
|
|
|
280
|
+
|
|
|
281
|
+.reward {
|
|
160
|
282
|
font-size: 12px;
|
|
|
283
|
+ color: #faad14;
|
|
|
284
|
+ font-weight: bold;
|
|
|
285
|
+ display: block;
|
|
|
286
|
+ margin-top: 3px;
|
|
161
|
287
|
}
|
|
162
|
288
|
|
|
163
|
|
-.task-list {
|
|
164
|
|
- border-top: 1px solid #f0f0f0;
|
|
|
289
|
+.task-center {
|
|
|
290
|
+ background-color: var(--card-bg);
|
|
|
291
|
+ border-radius: 16px;
|
|
|
292
|
+ padding: 20px;
|
|
165
|
293
|
}
|
|
166
|
294
|
|
|
167
|
|
-.task-item {
|
|
|
295
|
+.section-header {
|
|
168
|
296
|
display: flex;
|
|
169
|
297
|
justify-content: space-between;
|
|
170
|
298
|
align-items: center;
|
|
171
|
|
- padding: 12px 0;
|
|
172
|
|
- border-bottom: 1px solid #f0f0f0;
|
|
173
|
|
-}
|
|
174
|
|
-
|
|
175
|
|
-.task-info {
|
|
176
|
|
- flex: 1;
|
|
|
299
|
+ margin-bottom: 15px;
|
|
177
|
300
|
}
|
|
178
|
301
|
|
|
179
|
|
-.task-name {
|
|
180
|
|
- display: block;
|
|
|
302
|
+.more {
|
|
181
|
303
|
font-size: 14px;
|
|
|
304
|
+ color: var(--primary-color);
|
|
182
|
305
|
}
|
|
183
|
306
|
|
|
184
|
|
-.task-reward {
|
|
185
|
|
- font-size: 12px;
|
|
186
|
|
- color: #faad14;
|
|
187
|
|
-}
|
|
188
|
|
-
|
|
189
|
|
-.task-btn {
|
|
190
|
|
- margin: 0;
|
|
191
|
|
- padding: 0 10px;
|
|
192
|
|
- height: 28px;
|
|
193
|
|
- line-height: 28px;
|
|
194
|
|
- font-size: 12px;
|
|
195
|
|
- background-color: #1890ff;
|
|
196
|
|
- color: white;
|
|
197
|
|
-
|
|
198
|
|
- &.disabled {
|
|
199
|
|
- background-color: #bfbfbf;
|
|
200
|
|
- }
|
|
|
307
|
+.task-list {
|
|
|
308
|
+ border-top: 1px solid #f0f0f0;
|
|
201
|
309
|
}
|
|
202
|
310
|
|
|
203
|
|
-.partner-grid {
|
|
204
|
|
- display: grid;
|
|
205
|
|
- grid-template-columns: repeat(4, 1fr);
|
|
206
|
|
- gap: 15px;
|
|
|
311
|
+.task-item {
|
|
|
312
|
+ display: flex;
|
|
|
313
|
+ justify-content: space-between;
|
|
|
314
|
+ align-items: center;
|
|
|
315
|
+ padding: 15px 0;
|
|
|
316
|
+ border-bottom: 1px solid #f0f0f0;
|
|
207
|
317
|
}
|
|
208
|
318
|
|
|
209
|
|
-.partner-item {
|
|
|
319
|
+.task-info {
|
|
210
|
320
|
display: flex;
|
|
211
|
|
- flex-direction: column;
|
|
212
|
321
|
align-items: center;
|
|
213
|
322
|
}
|
|
214
|
323
|
|
|
215
|
|
-.partner-icon {
|
|
216
|
|
- width: 50px;
|
|
217
|
|
- height: 50px;
|
|
218
|
|
- border-radius: 10px;
|
|
219
|
|
- margin-bottom: 5px;
|
|
|
324
|
+.name {
|
|
|
325
|
+ font-size: 15px;
|
|
|
326
|
+ margin-left: 10px;
|
|
220
|
327
|
}
|
|
221
|
328
|
|
|
222
|
|
-.partner-name {
|
|
223
|
|
- font-size: 12px;
|
|
|
329
|
+.action-btn {
|
|
|
330
|
+ background-color: var(--primary-color);
|
|
|
331
|
+ color: white;
|
|
|
332
|
+ border: none;
|
|
|
333
|
+ border-radius: 16px;
|
|
|
334
|
+ height: 30px;
|
|
|
335
|
+ line-height: 30px;
|
|
|
336
|
+ padding: 0 12px;
|
|
|
337
|
+ font-size: 13px;
|
|
|
338
|
+}
|
|
|
339
|
+
|
|
|
340
|
+.action-btn.completed {
|
|
|
341
|
+ background-color: #bfbfbf;
|
|
224
|
342
|
}
|
|
225
|
343
|
</style>
|