This commit is contained in:
zpc 2026-02-05 11:32:15 +08:00
parent 5a3ce933ea
commit 799fb29e0e
2 changed files with 53 additions and 29 deletions

View File

@ -49,7 +49,7 @@
普通奖励
</view>
<view class="center" style="color: #333333; font-size: 24rpx;">
<view v-if="hasAnyGaoJiang" class="center" style="color: #333333; font-size: 24rpx;">
高级奖励
</view>
<view class="get-btn">
@ -65,7 +65,7 @@
<image :src="$img1('my/quan.png')" mode="aspectFit"></image>
</view>
<view class="prize center" @click="preview(item)" style="background: #FFFFFF;">
<view v-if="hasAnyGaoJiang" class="prize center" @click="preview(item)" style="background: #FFFFFF;">
<image :src="$img1('my/liwu.png')" mode="aspectFit"></image>
</view>
<view v-if="item.is_ling == 1 && item.pu_jiang.length>0" class="get-btn center"
@ -223,6 +223,14 @@
}
},
computed: {
//
hasAnyGaoJiang() {
if (!this.pageData || !this.pageData.level_list) return false;
return this.pageData.level_list.some(item => item.gao_jiang && item.gao_jiang.length > 0);
}
},
onLoad(options) {
this.getData()
this.tabChange(this.tabCur)

View File

@ -32,10 +32,16 @@ public class QuanYiService : IQuanYiService
throw new InvalidOperationException("用户不存在");
}
// 从数据库获取等级配置
var vipLevelConfigs = await _dbContext.VipLevels
.Where(v => v.DeletedAt == null)
.OrderBy(v => v.Level)
.ToListAsync();
var response = new QuanYiResponse
{
UserImg = GetImageUrl(user.HeadImg),
QuanYiLevel = GetQuanYiLevelInfo(user.OuQiLevel ?? 0, user.OuQi ?? 0)
QuanYiLevel = GetQuanYiLevelInfo(user.OuQiLevel ?? 0, user.OuQi ?? 0, vipLevelConfigs)
};
// Get all VIP levels with level > 0
@ -374,43 +380,53 @@ public class QuanYiService : IQuanYiService
/// <summary>
/// Get QuanYi level info based on ou_qi_level and ou_qi
/// </summary>
private QuanYiLevelInfo GetQuanYiLevelInfo(int ouQiLevel, int ouQi)
private QuanYiLevelInfo GetQuanYiLevelInfo(int ouQiLevel, int ouQi, List<VipLevel> vipLevelConfigs)
{
// This mimics the PHP User::ou_qi_level method
// Level titles based on ou_qi_level
var levelTitles = new Dictionary<int, string>
{
{ 0, "普通" },
{ 1, "青铜" },
{ 2, "白银" },
{ 3, "黄金" },
{ 4, "铂金" },
{ 5, "钻石" },
{ 6, "星耀" },
{ 7, "王者" }
};
// 从数据库配置构建等级阈值
var levelThresholds = vipLevelConfigs
.ToDictionary(v => v.Level, v => v.Number);
// 构建等级标题
var levelTitles = vipLevelConfigs
.ToDictionary(v => v.Level, v => v.Title ?? $"等级{v.Level}");
var levelThresholds = new Dictionary<int, int>
// 如果没有配置,使用默认值
if (!levelThresholds.Any())
{
{ 0, 0 },
{ 1, 100 },
{ 2, 500 },
{ 3, 1000 },
{ 4, 3000 },
{ 5, 6000 },
{ 6, 10000 },
{ 7, 20000 }
};
levelThresholds = new Dictionary<int, int>
{
{ 0, 0 },
{ 1, 100 },
{ 2, 500 },
{ 3, 1000 },
{ 4, 3000 },
{ 5, 6000 },
{ 6, 10000 },
{ 7, 20000 }
};
levelTitles = new Dictionary<int, string>
{
{ 0, "普通" },
{ 1, "青铜" },
{ 2, "白银" },
{ 3, "黄金" },
{ 4, "铂金" },
{ 5, "钻石" },
{ 6, "星耀" },
{ 7, "王者" }
};
}
var title = levelTitles.GetValueOrDefault(ouQiLevel, "普通");
var nextLevel = ouQiLevel + 1;
var nextOuQi = levelThresholds.GetValueOrDefault(nextLevel, 99999);
var nextOuQi = levelThresholds.GetValueOrDefault(nextLevel, 0);
var currentLevelOuQi = levelThresholds.GetValueOrDefault(ouQiLevel, 0);
var maxLevel = levelThresholds.Keys.DefaultIfEmpty(0).Max();
// 计算差值和进度
int cha;
int jindu;
if (nextLevel > 7)
if (nextLevel > maxLevel || nextOuQi == 0)
{
// 已满级
cha = -1;