fix: 修复大转盘停止转动问题
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Volo.Abp.Application.Services;
|
using Volo.Abp.Application.Services;
|
||||||
using Volo.Abp.EventBus.Local;
|
using Volo.Abp.EventBus.Local;
|
||||||
|
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
||||||
|
using Yi.Framework.Bbs.Domain.Managers;
|
||||||
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Application.Services.Integral
|
namespace Yi.Framework.Bbs.Application.Services.Integral
|
||||||
@@ -9,7 +11,8 @@ namespace Yi.Framework.Bbs.Application.Services.Integral
|
|||||||
public class LuckyService : ApplicationService
|
public class LuckyService : ApplicationService
|
||||||
{
|
{
|
||||||
private ILocalEventBus _localEventBus;
|
private ILocalEventBus _localEventBus;
|
||||||
public LuckyService(ILocalEventBus localEventBus) { _localEventBus = localEventBus; }
|
private BbsUserManager _bbsUserManager;
|
||||||
|
public LuckyService(ILocalEventBus localEventBus, BbsUserManager bbsUserManager) { _bbsUserManager = bbsUserManager; _localEventBus = localEventBus; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 大转盘
|
/// 大转盘
|
||||||
@@ -18,9 +21,22 @@ namespace Yi.Framework.Bbs.Application.Services.Integral
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<int> PostWheel()
|
public async Task<int> PostWheel()
|
||||||
{
|
{
|
||||||
int[] values=new int[10] { 0,10,30,50,60,80,90,100,200,666};
|
var userInfo = await _bbsUserManager.GetBbsUserInfoAsync(CurrentUser.Id.Value);
|
||||||
|
if (userInfo.Money < 50)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("钱钱不足!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int[] values = new int[10] { 0, 10, 30, 50, 60, 80, 90, 100, 200, 666 };
|
||||||
var index = GetWheelIndex();
|
var index = GetWheelIndex();
|
||||||
var value = values[index]-50;
|
var value = values[index] - 50;
|
||||||
|
|
||||||
|
//不存在负数钱钱
|
||||||
|
if (value < 0)
|
||||||
|
{
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//修改钱钱,如果钱钱不足,直接会丢出去,那本次抽奖将无效
|
//修改钱钱,如果钱钱不足,直接会丢出去,那本次抽奖将无效
|
||||||
await _localEventBus.PublishAsync(new MoneyChangeEventArgs { UserId = CurrentUser.Id!.Value, Number = value }, false);
|
await _localEventBus.PublishAsync(new MoneyChangeEventArgs { UserId = CurrentUser.Id!.Value, Number = value }, false);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ router.beforeEach((to, from, next) => {
|
|||||||
} else {
|
} else {
|
||||||
if (useUserStore().roles.length === 0) {
|
if (useUserStore().roles.length === 0) {
|
||||||
// 判断当前用户是否已拉取完user_info信息
|
// 判断当前用户是否已拉取完user_info信息
|
||||||
alert("获取用户信息")
|
|
||||||
useUserStore()
|
useUserStore()
|
||||||
.getInfo()
|
.getInfo()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
@@ -79,8 +79,22 @@ const startCallback = () => {
|
|||||||
// 假设后端返回的中奖索引是0
|
// 假设后端返回的中奖索引是0
|
||||||
// 调用stop停止旋转并传递中奖索引
|
// 调用stop停止旋转并传递中奖索引
|
||||||
}, 3000)
|
}, 3000)
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const ddd=(await luckyWheel()).data;
|
||||||
|
console.log(ddd,"dd");
|
||||||
index= (await luckyWheel()).data;
|
index= (await luckyWheel()).data;
|
||||||
myLucky.value.stop(index)
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
finally{
|
||||||
|
|
||||||
|
myLucky.value.stop(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user