hookehuyr

feat(活动海报): 优化按钮逻辑并改进样式

重构活动按钮文本显示逻辑,根据用户状态显示不同文本
改进页面样式包括背景渐变、按钮阴影和交互效果
移除未使用的头像变量并优化定位授权检查流程
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
11 top: 0; 11 top: 0;
12 left: 0; 12 left: 0;
13 width: 100%; 13 width: 100%;
14 - height: 100%; 14 + height: calc(100vh - 300rpx); // 减去底部区域的高度,确保背景图不被遮挡
15 object-fit: contain; 15 object-fit: contain;
16 object-position: top center; 16 object-position: top center;
17 z-index: 1; 17 z-index: 1;
...@@ -45,9 +45,19 @@ ...@@ -45,9 +45,19 @@
45 right: 0; 45 right: 0;
46 padding: 40rpx; 46 padding: 40rpx;
47 padding-bottom: 180rpx; // 为底部导航留出空间 47 padding-bottom: 180rpx; // 为底部导航留出空间
48 - background: linear-gradient(transparent, rgba(0, 0, 0, 0.7)); 48 + background: linear-gradient(
49 - backdrop-filter: blur(20rpx); 49 + transparent 0%,
50 + rgba(0, 0, 0, 0.1) 20%,
51 + rgba(0, 0, 0, 0.3) 50%,
52 + rgba(0, 0, 0, 0.6) 80%,
53 + rgba(0, 0, 0, 0.8) 100%
54 + );
55 + backdrop-filter: blur(30rpx);
56 + -webkit-backdrop-filter: blur(30rpx);
50 z-index: 5; 57 z-index: 5;
58 +
59 + // 增加渐变高度,让过渡更自然
60 + min-height: 300rpx;
51 } 61 }
52 62
53 .location-tip { 63 .location-tip {
...@@ -56,19 +66,22 @@ ...@@ -56,19 +66,22 @@
56 align-items: center; 66 align-items: center;
57 justify-content: center; 67 justify-content: center;
58 padding: 24rpx; 68 padding: 24rpx;
59 - background-color: rgba(255, 247, 230, 0.9); 69 + background-color: rgba(255, 247, 230, 0.95);
60 - border: 1rpx solid rgba(255, 213, 145, 0.8); 70 + border: 1rpx solid rgba(255, 213, 145, 0.9);
61 - border-radius: 12rpx; 71 + border-radius: 16rpx;
62 margin-bottom: 32rpx; 72 margin-bottom: 32rpx;
63 - backdrop-filter: blur(10rpx); 73 + backdrop-filter: blur(20rpx);
74 + -webkit-backdrop-filter: blur(20rpx);
64 cursor: pointer; 75 cursor: pointer;
65 transition: all 0.3s ease; 76 transition: all 0.3s ease;
66 - 77 + box-shadow: 0 4rpx 16rpx rgba(255, 213, 145, 0.3), 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
78 +
67 &:active { 79 &:active {
68 - background-color: rgba(255, 247, 230, 0.7); 80 + background-color: rgba(255, 247, 230, 0.8);
69 transform: scale(0.98); 81 transform: scale(0.98);
82 + box-shadow: 0 2rpx 8rpx rgba(255, 213, 145, 0.2), 0 1rpx 4rpx rgba(0, 0, 0, 0.1);
70 } 83 }
71 - 84 +
72 .tip-content { 85 .tip-content {
73 display: flex; 86 display: flex;
74 align-items: center; 87 align-items: center;
...@@ -95,9 +108,15 @@ ...@@ -95,9 +108,15 @@
95 } 108 }
96 109
97 .location-error { 110 .location-error {
98 - background-color: rgba(255, 241, 240, 0.9); 111 + background-color: rgba(255, 241, 240, 0.95);
99 - border: 1rpx solid rgba(255, 163, 158, 0.8); 112 + border: 1rpx solid rgba(255, 163, 158, 0.9);
100 - 113 + box-shadow: 0 4rpx 16rpx rgba(255, 163, 158, 0.3), 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
114 +
115 + &:active {
116 + background-color: rgba(255, 241, 240, 0.8);
117 + box-shadow: 0 2rpx 8rpx rgba(255, 163, 158, 0.2), 0 1rpx 4rpx rgba(0, 0, 0, 0.1);
118 + }
119 +
101 .tip-text { 120 .tip-text {
102 color: #cf1322; 121 color: #cf1322;
103 } 122 }
...@@ -109,22 +128,26 @@ ...@@ -109,22 +128,26 @@
109 border-radius: 44rpx; 128 border-radius: 44rpx;
110 font-size: 32rpx; 129 font-size: 32rpx;
111 font-weight: 600; 130 font-weight: 600;
112 - box-shadow: 0 8rpx 24rpx rgba(59, 130, 246, 0.4); 131 + box-shadow: 0 8rpx 32rpx rgba(59, 130, 246, 0.5), 0 4rpx 16rpx rgba(0, 0, 0, 0.2);
113 - backdrop-filter: blur(10rpx); 132 + backdrop-filter: blur(15rpx);
114 - 133 + -webkit-backdrop-filter: blur(15rpx);
134 + border: 1rpx solid rgba(255, 255, 255, 0.2);
135 +
115 &:active { 136 &:active {
116 transform: translateY(2rpx); 137 transform: translateY(2rpx);
117 - box-shadow: 0 4rpx 12rpx rgba(59, 130, 246, 0.3); 138 + box-shadow: 0 4rpx 16rpx rgba(59, 130, 246, 0.4), 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
118 } 139 }
119 140
120 &.nut-button--primary { 141 &.nut-button--primary {
121 - background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%); 142 + background: linear-gradient(135deg, rgba(24, 144, 255, 0.95) 0%, rgba(9, 109, 217, 0.95) 100%);
122 - border: none; 143 + border: 1rpx solid rgba(255, 255, 255, 0.3);
123 - box-shadow: 0 8rpx 24rpx rgba(24, 144, 255, 0.3); 144 + box-shadow: 0 8rpx 32rpx rgba(24, 144, 255, 0.4), 0 4rpx 16rpx rgba(0, 0, 0, 0.2);
145 + color: white;
146 + text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.2);
124 147
125 &:active { 148 &:active {
126 transform: translateY(2rpx); 149 transform: translateY(2rpx);
127 - box-shadow: 0 4rpx 12rpx rgba(24, 144, 255, 0.3); 150 + box-shadow: 0 4rpx 16rpx rgba(24, 144, 255, 0.3), 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
128 } 151 }
129 } 152 }
130 } 153 }
...@@ -157,7 +180,7 @@ ...@@ -157,7 +180,7 @@
157 align-items: center; 180 align-items: center;
158 padding: 20rpx; 181 padding: 20rpx;
159 border-radius: 12rpx; 182 border-radius: 12rpx;
160 - 183 +
161 &:active { 184 &:active {
162 background-color: #f5f5f5; 185 background-color: #f5f5f5;
163 } 186 }
...@@ -218,13 +241,13 @@ ...@@ -218,13 +241,13 @@
218 height: 80rpx; 241 height: 80rpx;
219 border-radius: 40rpx; 242 border-radius: 40rpx;
220 font-size: 28rpx; 243 font-size: 28rpx;
221 - 244 +
222 &.primary { 245 &.primary {
223 background-color: #1890ff; 246 background-color: #1890ff;
224 color: white; 247 color: white;
225 border: none; 248 border: none;
226 } 249 }
227 - 250 +
228 &.secondary { 251 &.secondary {
229 background-color: #f5f5f5; 252 background-color: #f5f5f5;
230 color: #666; 253 color: #666;
......
1 <!-- 1 <!--
2 * @Date: 2022-09-19 14:11:06 2 * @Date: 2022-09-19 14:11:06
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-09-06 13:27:43 4 + * @LastEditTime: 2025-09-06 18:09:54
5 * @FilePath: /lls_program/src/pages/ActivitiesCover/index.vue 5 * @FilePath: /lls_program/src/pages/ActivitiesCover/index.vue
6 * @Description: 活动海报页面 - 展示活动信息并处理定位授权 6 * @Description: 活动海报页面 - 展示活动信息并处理定位授权
7 --> 7 -->
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
50 :loading="isJoining" 50 :loading="isJoining"
51 @click="checkFamilyStatusAndJoinActivity" 51 @click="checkFamilyStatusAndJoinActivity"
52 > 52 >
53 - {{ hasLocationAuth && !locationError ? '进入活动' : '参加活动' }} 53 + {{ getButtonText() }}
54 </nut-button> 54 </nut-button>
55 </view> 55 </view>
56 56
...@@ -168,7 +168,7 @@ const show_save = ref(false) // 显示保存弹窗 ...@@ -168,7 +168,7 @@ const show_save = ref(false) // 显示保存弹窗
168 const startDraw = ref(false) // 开始绘制海报 168 const startDraw = ref(false) // 开始绘制海报
169 const posterPath = ref('') // 海报路径 169 const posterPath = ref('') // 海报路径
170 const nickname = ref('老来赛用户') // 用户昵称 170 const nickname = ref('老来赛用户') // 用户昵称
171 -const avatar = ref('https://cdn.ipadbiz.cn/icon/tou@2x.png') // 用户头像 171 +// const avatar = ref('https://cdn.ipadbiz.cn/icon/tou@2x.png') // 用户头像
172 172
173 // 保存选项 173 // 保存选项
174 const actions_save = ref([{ 174 const actions_save = ref([{
...@@ -301,10 +301,38 @@ const getUserLocation = async (skipAuthCheck = false) => { ...@@ -301,10 +301,38 @@ const getUserLocation = async (skipAuthCheck = false) => {
301 } 301 }
302 302
303 /** 303 /**
304 + * 获取按钮显示文本
305 + */
306 +const getButtonText = () => {
307 + // 如果没有加入家庭,显示"加入家庭"
308 + if (!hasJoinedFamily.value) {
309 + return '参加活动'
310 + }
311 +
312 + // 如果位置获取失败,显示"重新定位"
313 + if (locationError.value) {
314 + return '重新定位'
315 + }
316 +
317 + // 如果需要显示位置提示,说明需要授权
318 + if (showLocationPrompt.value) {
319 + return '授权定位'
320 + }
321 +
322 + // 如果已有定位授权且有位置信息,显示"进入活动"
323 + if (hasLocationAuth.value && userLocation.value.lng && userLocation.value.lat) {
324 + return '进入活动'
325 + }
326 +
327 + // 默认显示"参加活动"
328 + return '参加活动'
329 +}
330 +
331 +/**
304 * 检查用户是否加入家庭并处理参加活动按钮点击 332 * 检查用户是否加入家庭并处理参加活动按钮点击
305 */ 333 */
306 const checkFamilyStatusAndJoinActivity = async () => { 334 const checkFamilyStatusAndJoinActivity = async () => {
307 - // Mock data: hasJoinedFamily is set to false 335 + // 如果没有加入家庭,引导用户加入家庭
308 if (!hasJoinedFamily.value) { 336 if (!hasJoinedFamily.value) {
309 Taro.showModal({ 337 Taro.showModal({
310 title: '提示', 338 title: '提示',
...@@ -319,9 +347,24 @@ const checkFamilyStatusAndJoinActivity = async () => { ...@@ -319,9 +347,24 @@ const checkFamilyStatusAndJoinActivity = async () => {
319 } 347 }
320 }, 348 },
321 }); 349 });
322 - } else { 350 + return
323 - handleJoinActivity();
324 } 351 }
352 +
353 + // 如果位置获取失败,重新获取位置
354 + if (locationError.value) {
355 + await retryGetLocation()
356 + return
357 + }
358 +
359 + // 如果需要显示位置提示,说明需要授权
360 + if (showLocationPrompt.value) {
361 + showLocationPrompt.value = false // 隐藏提示,直接尝试获取位置
362 + await handleJoinActivity()
363 + return
364 + }
365 +
366 + // 正常参加活动流程
367 + await handleJoinActivity()
325 }; 368 };
326 369
327 370
...@@ -402,25 +445,6 @@ const handleJoinActivity = async () => { ...@@ -402,25 +445,6 @@ const handleJoinActivity = async () => {
402 isJoining.value = true 445 isJoining.value = true
403 446
404 try { 447 try {
405 - // 首先检查用户是否已加入家庭
406 - if (!hasJoinedFamily.value) {
407 - Taro.showModal({
408 - title: '提示',
409 - content: '没有加入家庭是无法参加活动的',
410 - cancelText: '关闭',
411 - confirmText: '前往加入',
412 - success: (res) => {
413 - if (res.confirm) {
414 - Taro.navigateTo({
415 - url: '/pages/Welcome/index',
416 - });
417 - }
418 - },
419 - });
420 - isJoining.value = false
421 - return
422 - }
423 -
424 // 检查定位授权状态 448 // 检查定位授权状态
425 const authSetting = await Taro.getSetting() 449 const authSetting = await Taro.getSetting()
426 const hasLocationPermission = authSetting.authSetting['scope.userLocation'] 450 const hasLocationPermission = authSetting.authSetting['scope.userLocation']
...@@ -818,7 +842,9 @@ const initPageData = async () => { ...@@ -818,7 +842,9 @@ const initPageData = async () => {
818 hasJoinedFamily.value = true 842 hasJoinedFamily.value = true
819 } 843 }
820 } 844 }
821 - // 移除页面初始化时的定位权限检查,改为在用户点击参加活动时检查 845 +
846 + // 检查定位授权状态(不获取位置,只检查权限)
847 + await checkLocationAuth()
822 } 848 }
823 849
824 // 处理页面加载时的授权检查 850 // 处理页面加载时的授权检查
......