321
This commit is contained in:
parent
c162a647bb
commit
b8f041d3ff
|
|
@ -257,23 +257,24 @@
|
||||||
.sign-btn {
|
.sign-btn {
|
||||||
margin: 40rpx auto 0;
|
margin: 40rpx auto 0;
|
||||||
width: 400rpx;
|
width: 400rpx;
|
||||||
height: 122rpx;
|
height: 96rpx;
|
||||||
border-radius: 40rpx;
|
border-radius: 48rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
font-family: Source Han Sans CN;
|
font-family: Source Han Sans CN;
|
||||||
font-weight: 400;
|
font-weight: 500;
|
||||||
background: url($imgurl+'common/jixuchou.png') no-repeat 0 0 / 100% 100%;
|
background: #03D8F4;
|
||||||
|
color: #404040;
|
||||||
}
|
}
|
||||||
|
|
||||||
.signYes {
|
.signYes {
|
||||||
color: #FFFFFF;
|
color: #404040;
|
||||||
}
|
}
|
||||||
|
|
||||||
.signNo {
|
.signNo {
|
||||||
color: #FFFFFF;
|
color: #404040;
|
||||||
filter: grayscale(100%);
|
filter: grayscale(100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,8 @@
|
||||||
<view class="justify-center" style="width: 100%; height: 198rpx; background-color: #fff; margin-top: -10rpx;">
|
<view class="justify-center" style="width: 100%; height: 198rpx; background-color: #fff; margin-top: -10rpx;">
|
||||||
<view class="align-center column">
|
<view class="align-center column">
|
||||||
<view class="sign-btn center" @click="sign"
|
<view class="sign-btn center" @click="sign"
|
||||||
style="width: 340rpx; height: 84rpx; background-color: #D8FD24; margin-top: 32rpx;">
|
style="width: 340rpx; height: 84rpx; background-color: #03D8F4; border-radius: 42rpx; margin-top: 32rpx;">
|
||||||
<text style="color: #333333; font-size: 32rpx; font-weight: 600;">{{ !is_sign ? "今日已签到" : "每日签到"
|
<text style="color: #404040; font-size: 32rpx; font-weight: 600;">{{ signBtnText }}</text>
|
||||||
}}</text>
|
|
||||||
</view>
|
</view>
|
||||||
<text style="color: #8A8A8A; font-size: 20rpx; margin-top: 12rpx;">{{ checkinData.Requirement
|
<text style="color: #8A8A8A; font-size: 20rpx; margin-top: 12rpx;">{{ checkinData.Requirement
|
||||||
}}</text>
|
}}</text>
|
||||||
|
|
@ -120,9 +119,18 @@ export default {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
is_sign: false,
|
is_sign: false,
|
||||||
|
isLoggedIn: false, // 是否已登录
|
||||||
isSignCooldown: false, // 添加防抖状态变量
|
isSignCooldown: false, // 添加防抖状态变量
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
signBtnText() {
|
||||||
|
if (!this.isLoggedIn) {
|
||||||
|
return '每日签到';
|
||||||
|
}
|
||||||
|
return this.is_sign ? '每日签到' : '今日已签到';
|
||||||
|
}
|
||||||
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.load();
|
this.load();
|
||||||
},
|
},
|
||||||
|
|
@ -147,6 +155,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async load() {
|
async load() {
|
||||||
|
// 检查登录状态
|
||||||
|
const token = uni.getStorageSync('token');
|
||||||
|
this.isLoggedIn = !!token;
|
||||||
|
|
||||||
let sign_in_spend_limit = this.$config.getAppSetting("sign_in_spend_limit");
|
let sign_in_spend_limit = this.$config.getAppSetting("sign_in_spend_limit");
|
||||||
if (sign_in_spend_limit && sign_in_spend_limit > 0) {
|
if (sign_in_spend_limit && sign_in_spend_limit > 0) {
|
||||||
this.checkinData.Requirement = "签到条件:当日消费满" + sign_in_spend_limit + "钻石"
|
this.checkinData.Requirement = "签到条件:当日消费满" + sign_in_spend_limit + "钻石"
|
||||||
|
|
@ -190,6 +202,22 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
async sign() {
|
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) {
|
if (!this.is_sign) {
|
||||||
this.$c.msg("已签到")
|
this.$c.msg("已签到")
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -338,7 +366,7 @@ export default {
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
background-color: darken(#D8FD24, 5%);
|
background-color: darken(#03D8F4, 5%);
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
|
|
|
||||||
|
|
@ -34,22 +34,29 @@ public class SignController : ControllerBase
|
||||||
/// GET /api/sign_info
|
/// GET /api/sign_info
|
||||||
///
|
///
|
||||||
/// 返回用户签到状态、连续签到天数、签到配置等信息
|
/// 返回用户签到状态、连续签到天数、签到配置等信息
|
||||||
|
/// 未登录用户也可以查看签到配置,但不显示个人签到状态
|
||||||
/// Requirements: 3.1
|
/// Requirements: 3.1
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[HttpGet("sign_info")]
|
[HttpGet("sign_info")]
|
||||||
[Authorize]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(ApiResponse<SignInfoResponse>), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(ApiResponse<SignInfoResponse>), StatusCodes.Status200OK)]
|
||||||
public async Task<ApiResponse<SignInfoResponse>> GetSignInfo()
|
public async Task<ApiResponse<SignInfoResponse>> GetSignInfo()
|
||||||
{
|
{
|
||||||
var userId = GetCurrentUserId();
|
var userId = GetCurrentUserId();
|
||||||
if (userId == null)
|
|
||||||
{
|
|
||||||
return ApiResponse<SignInfoResponse>.Unauthorized();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
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<SignInfoResponse>.Success(signInfo, "获取成功");
|
return ApiResponse<SignInfoResponse>.Success(signInfo, "获取成功");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,18 @@ namespace HoneyBox.Core.Interfaces;
|
||||||
public interface ISignService
|
public interface ISignService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取签到信息
|
/// 获取签到信息(需要登录)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">用户ID</param>
|
/// <param name="userId">用户ID</param>
|
||||||
/// <returns>签到信息</returns>
|
/// <returns>签到信息</returns>
|
||||||
Task<SignInfoResponse> GetSignInfoAsync(int userId);
|
Task<SignInfoResponse> GetSignInfoAsync(int userId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取签到配置(无需登录)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>签到配置信息</returns>
|
||||||
|
Task<SignInfoResponse> GetSignConfigAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行签到
|
/// 执行签到
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,46 @@ public class SignService : ISignService
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<SignInfoResponse> 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<int>());
|
||||||
|
|
||||||
|
return new SignInfoResponse
|
||||||
|
{
|
||||||
|
Days = 0,
|
||||||
|
IsSign = 0,
|
||||||
|
SignDays = 0,
|
||||||
|
TotalDays = totalDays,
|
||||||
|
RestDays = restDays,
|
||||||
|
DailyConfigs = dailyConfigDtos,
|
||||||
|
ContinuousConfigs = continuousConfigDtos
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public async Task<SignResultResponse> DoSignAsync(int userId)
|
public async Task<SignResultResponse> DoSignAsync(int userId)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user