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>
<view class="center" style="color: #333333; font-size: 24rpx;"> <view v-if="hasAnyGaoJiang" class="center" style="color: #333333; font-size: 24rpx;">
高级奖励 高级奖励
</view> </view>
<view class="get-btn"> <view class="get-btn">
@ -65,7 +65,7 @@
<image :src="$img1('my/quan.png')" mode="aspectFit"></image> <image :src="$img1('my/quan.png')" mode="aspectFit"></image>
</view> </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> <image :src="$img1('my/liwu.png')" mode="aspectFit"></image>
</view> </view>
<view v-if="item.is_ling == 1 && item.pu_jiang.length>0" class="get-btn center" <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) { onLoad(options) {
this.getData() this.getData()
this.tabChange(this.tabCur) this.tabChange(this.tabCur)

View File

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