diff --git a/honey_box/package/index/sign.vue b/honey_box/package/index/sign.vue index 8fad2b11..66116a65 100644 --- a/honey_box/package/index/sign.vue +++ b/honey_box/package/index/sign.vue @@ -257,23 +257,24 @@ .sign-btn { margin: 40rpx auto 0; width: 400rpx; - height: 122rpx; - border-radius: 40rpx; + height: 96rpx; + border-radius: 48rpx; display: flex; justify-content: center; align-items: center; font-size: 32rpx; font-family: Source Han Sans CN; - font-weight: 400; - background: url($imgurl+'common/jixuchou.png') no-repeat 0 0 / 100% 100%; + font-weight: 500; + background: #03D8F4; + color: #404040; } .signYes { - color: #FFFFFF; + color: #404040; } .signNo { - color: #FFFFFF; + color: #404040; filter: grayscale(100%); } diff --git a/honey_box/pages/infinite/daily_check_in.vue b/honey_box/pages/infinite/daily_check_in.vue index af6dabe6..2775e9fd 100644 --- a/honey_box/pages/infinite/daily_check_in.vue +++ b/honey_box/pages/infinite/daily_check_in.vue @@ -69,9 +69,8 @@ - {{ !is_sign ? "今日已签到" : "每日签到" - }} + style="width: 340rpx; height: 84rpx; background-color: #03D8F4; border-radius: 42rpx; margin-top: 32rpx;"> + {{ signBtnText }} {{ checkinData.Requirement }} @@ -120,9 +119,18 @@ export default { ], }, is_sign: false, + isLoggedIn: false, // 是否已登录 isSignCooldown: false, // 添加防抖状态变量 } }, + computed: { + signBtnText() { + if (!this.isLoggedIn) { + return '每日签到'; + } + return this.is_sign ? '每日签到' : '今日已签到'; + } + }, onLoad() { this.load(); }, @@ -147,6 +155,10 @@ export default { } }, async load() { + // 检查登录状态 + const token = uni.getStorageSync('token'); + this.isLoggedIn = !!token; + let sign_in_spend_limit = this.$config.getAppSetting("sign_in_spend_limit"); if (sign_in_spend_limit && sign_in_spend_limit > 0) { this.checkinData.Requirement = "签到条件:当日消费满" + sign_in_spend_limit + "钻石" @@ -190,6 +202,22 @@ export default { }, async sign() { + // 检查是否登录 + const token = uni.getStorageSync('token'); + if (!token) { + uni.showModal({ + title: '提示', + content: '请先登录后再签到', + confirmText: '去登录', + success: (res) => { + if (res.confirm) { + this.$c.to({ url: '/pages/user/login' }); + } + } + }); + return false; + } + if (!this.is_sign) { this.$c.msg("已签到") return false; @@ -338,7 +366,7 @@ export default { &:active { transform: scale(0.95); - background-color: darken(#D8FD24, 5%); + background-color: darken(#03D8F4, 5%); &::after { content: ''; diff --git a/server/HoneyBox/src/HoneyBox.Api/Controllers/SignController.cs b/server/HoneyBox/src/HoneyBox.Api/Controllers/SignController.cs index cf46a7a5..aadf6fed 100644 --- a/server/HoneyBox/src/HoneyBox.Api/Controllers/SignController.cs +++ b/server/HoneyBox/src/HoneyBox.Api/Controllers/SignController.cs @@ -34,22 +34,29 @@ public class SignController : ControllerBase /// GET /api/sign_info /// /// 返回用户签到状态、连续签到天数、签到配置等信息 + /// 未登录用户也可以查看签到配置,但不显示个人签到状态 /// Requirements: 3.1 /// [HttpGet("sign_info")] - [Authorize] + [AllowAnonymous] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] public async Task> GetSignInfo() { var userId = GetCurrentUserId(); - if (userId == null) - { - return ApiResponse.Unauthorized(); - } - + try { - var signInfo = await _signService.GetSignInfoAsync(userId.Value); + SignInfoResponse signInfo; + if (userId.HasValue) + { + // 已登录用户,返回完整签到信息 + signInfo = await _signService.GetSignInfoAsync(userId.Value); + } + else + { + // 未登录用户,只返回签到配置 + signInfo = await _signService.GetSignConfigAsync(); + } return ApiResponse.Success(signInfo, "获取成功"); } catch (Exception ex) diff --git a/server/HoneyBox/src/HoneyBox.Core/Interfaces/ISignService.cs b/server/HoneyBox/src/HoneyBox.Core/Interfaces/ISignService.cs index 4995b896..7ccf97e8 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Interfaces/ISignService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Interfaces/ISignService.cs @@ -8,12 +8,18 @@ namespace HoneyBox.Core.Interfaces; public interface ISignService { /// - /// 获取签到信息 + /// 获取签到信息(需要登录) /// /// 用户ID /// 签到信息 Task GetSignInfoAsync(int userId); + /// + /// 获取签到配置(无需登录) + /// + /// 签到配置信息 + Task GetSignConfigAsync(); + /// /// 执行签到 /// diff --git a/server/HoneyBox/src/HoneyBox.Core/Services/SignService.cs b/server/HoneyBox/src/HoneyBox.Core/Services/SignService.cs index 3d7c9bdd..2b8343d8 100644 --- a/server/HoneyBox/src/HoneyBox.Core/Services/SignService.cs +++ b/server/HoneyBox/src/HoneyBox.Core/Services/SignService.cs @@ -91,6 +91,46 @@ public class SignService : ISignService }; } + /// + public async Task GetSignConfigAsync() + { + var now = DateTime.Now; + var currentMonth = now.Month; + var currentYear = now.Year; + var totalDays = DateTime.DaysInMonth(currentYear, currentMonth); + var nowDay = now.Day; + var restDays = totalDays - nowDay; + + // 获取每日签到配置 (type=1) + var dailyConfigs = await _dbContext.SignConfigs + .Where(c => c.Type == 1 && c.Status == 1 && c.Day <= totalDays) + .OrderBy(c => c.Sort) + .ToListAsync(); + + // 获取累计签到配置 (type=2) + var continuousConfigs = await _dbContext.SignConfigs + .Where(c => c.Type == 2 && c.Status == 1) + .OrderBy(c => c.Sort) + .ToListAsync(); + + // 处理每日签到配置(未登录状态,所有都显示未签到) + var dailyConfigDtos = await ProcessDailyConfigsAsync(dailyConfigs, 0, 1); + + // 处理累计签到配置(未登录状态,所有都显示未达到) + var continuousConfigDtos = await ProcessContinuousConfigsAsync(continuousConfigs, 0, new List()); + + return new SignInfoResponse + { + Days = 0, + IsSign = 0, + SignDays = 0, + TotalDays = totalDays, + RestDays = restDays, + DailyConfigs = dailyConfigDtos, + ContinuousConfigs = continuousConfigDtos + }; + } + /// public async Task DoSignAsync(int userId)