This commit is contained in:
Putoo
2026-05-23 18:36:37 +08:00
parent 05e340801f
commit dbace8a8b2
27 changed files with 729 additions and 52 deletions

View File

@@ -0,0 +1,45 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_ship
{
/// <summary>
/// usId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string usId { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// goodsId
/// </summary>
[SugarColumn(IsNullable = true)]
public int? goodsId { get; set; }
/// <summary>
/// name
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? name { get; set; }
/// <summary>
/// speed
/// </summary>
[SugarColumn(IsNullable = true)]
public int? speed { get; set; }
/// <summary>
/// weight
/// </summary>
[SugarColumn(IsNullable = true)]
public int? weight { get; set; }
}
}

View File

@@ -23,5 +23,11 @@ namespace Application.Domain.Entity
/// </summary> /// </summary>
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public int? maxWeight { get; set; } public int? maxWeight { get; set; }
/// <summary>
/// 船只当前负重
/// </summary>
[SugarColumn(IsNullable = true)]
public int? shipOnWeight { get; set; }
} }
} }

View File

@@ -0,0 +1,9 @@
namespace Application.Domain;
public static class GameConfig
{
public const int OnLineTime = 30;//在线延迟时间(分钟)
public const int SendChatGoodsBase = 10014;//小海螺
public const int SendChatGoodsArea = 10001;//大海螺
public const int SendChatGoodsService = 10002;//金海螺
}

View File

@@ -0,0 +1,11 @@
namespace Application.Domain;
public static class GoodsEnum
{
public enum Code
{
Drug,//药品
Prop,//物品
Cargo,//货物
}
}

View File

@@ -19,4 +19,13 @@ public interface IGameMapService
Task UpdateUserOnMap(string userId, string ip, string mapId); Task UpdateUserOnMap(string userId, string ip, string mapId);
#endregion #endregion
#region
Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int take);
Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int page,
int limit, RefAsync<int> total);
#endregion
} }

View File

@@ -24,5 +24,12 @@ public interface IUnitUserService
Task<bool> RegisterUserInfo(string userId, string nick, string sex); Task<bool> RegisterUserInfo(string userId, string nick, string sex);
#endregion
#region
Task<int> GetOnlineCount();
#endregion #endregion
} }

View File

@@ -0,0 +1,22 @@
namespace Application.Domain;
public interface IUnitUserWeight
{
Task<unit_user_weight> GetUserWeightInfo(string userId);
Task<bool> UpdateUserWeight(string userId, int op, int weight);
Task<bool> UpdateUserMaxWeight(string userId, int op, int weight);
Task<bool> AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count);
Task<bool> CheakUserWeight(string userId, int useWeight);
#region
Task<List<unit_user_ship>> GetUserShip(string userId);
Task<int> GetUserShipMaxWeight(string userId);
Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight);
Task<bool> CheakUserShipWeight(string userId, int useWeight);
Task<bool> DeleteUserShip(string usId, string userId);
Task<bool> AddUserShip(string userId, string name, int goodsId, int speed, int weight);
#endregion
}

View File

@@ -2,7 +2,7 @@
namespace Application.Domain; namespace Application.Domain;
public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGameEquService, ITransient public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGameGoodsService, ITransient
{ {
#region #region
@@ -120,10 +120,21 @@ public class GameGoodsService(ISqlSugarClient DbClient, IRedisCache redis) : IGa
if (isOk) if (isOk)
{ {
//更新负重 //更新负重
int weightCount = Convert.ToInt32(UserGoods.weight) * count;
if (weightCount > 0)
{
var weightService = App.GetService<IUnitUserWeight>();
if (UserGoods.code == nameof(GoodsEnum.Code.Cargo))//跑商物品处理
{
await weightService.UpdateUserShipOnWeight(userId, op, weightCount);
}
else
{
await weightService.UpdateUserWeight(userId, op, weightCount);
}
}
//添加日志 await AddGoodsLog(userId, goodsId, op, count, remark); //添加日志
await AddGoodsLog(userId, goodsId, op, count, remark);
} }
return isOk; return isOk;

View File

@@ -1,6 +1,6 @@
namespace Application.Domain; namespace Application.Domain;
public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGameMapService, ITransient public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMapService, ITransient
{ {
#region #region
@@ -31,6 +31,7 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
return data; return data;
} }
public async Task<List<game_city_map>> GetMapCity(int cityId) public async Task<List<game_city_map>> GetMapCity(int cityId)
{ {
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "CityShowMap"); string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "CityShowMap");
@@ -41,8 +42,10 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
data = await db.Queryable<game_city_map>().Where(it => it.cityId == cityId && it.show == 1).ToListAsync(); data = await db.Queryable<game_city_map>().Where(it => it.cityId == cityId && it.show == 1).ToListAsync();
await redis.AddHashAsync(key, cityId.ToString(), data); await redis.AddHashAsync(key, cityId.ToString(), data);
} }
return data; return data;
} }
public async Task<int> GetMapCityByMapId(string mapId) public async Task<int> GetMapCityByMapId(string mapId)
{ {
var data = await GetMapInfo(mapId); var data = await GetMapInfo(mapId);
@@ -69,6 +72,7 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
return data; return data;
} }
public async Task<game_city_npc> GetNpcInfo(int npcId) public async Task<game_city_npc> GetNpcInfo(int npcId)
{ {
string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "NpcInfo"); string key = string.Format(BaseCache.BaseCacheKeys, "MapCityData", "NpcInfo");
@@ -77,8 +81,9 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
{ {
var db = DbClient.AsTenant().GetConnectionWithAttr<game_city_npc>(); var db = DbClient.AsTenant().GetConnectionWithAttr<game_city_npc>();
data = await db.Queryable<game_city_npc>().Where(it => it.npcId == npcId).SingleAsync(); data = await db.Queryable<game_city_npc>().Where(it => it.npcId == npcId).SingleAsync();
await redis.AddHashAsync(key, npcId.ToString(),data); await redis.AddHashAsync(key, npcId.ToString(), data);
} }
return data; return data;
} }
@@ -126,5 +131,48 @@ public class GameMapService (ISqlSugarClient DbClient, IRedisCache redis): IGame
} }
} }
#endregion
#region
private async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
long time = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0 - GameConfig.OnLineTime));
var data = await db.Queryable<unit_user_online>().Where(it => it.upTime > time && it.mapId == mapId)
.WhereIF(noUser.Count > 0, it => !noUser.Contains(it.userId))
.OrderByDescending(it=>it.upTime)
.ToListAsync();
List<UserModel> result = new List<UserModel>();
data.ForEach(async it =>
{
var temp = await UserModelTool.GetUserView(it.userId);
bool isAdd = showArea == 1 && area != temp.area ? false : true;
if (isAdd)
{
result.Add(temp);
}
});
return result;
}
public async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int take)
{
var data = await GetMapUser(mapId, area, showArea, noUser);
return data.Take(take).ToList();
}
public async Task<List<UserModel>> GetMapUser(string mapId, int area, int showArea, List<string> noUser, int page,
int limit, RefAsync<int> total)
{
var data = await GetMapUser(mapId, area, showArea, noUser);
total = data.Count;
return data.Skip((page - 1) * limit) // 跳过前面的页
.Take(limit) // 取当前页
.ToList();
}
#endregion #endregion
} }

View File

@@ -90,7 +90,6 @@ public class UnitUserService : IUnitUserService, ITransient
await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo"), result.userNo); await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "UserNo"), result.userNo);
await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid"), result.token); await _redisClient.DelHashAsync(string.Format(UserCache.BaseCacheKeys, "UserInfo", "Sid"), result.token);
} }
#endregion #endregion
@@ -144,8 +143,8 @@ public class UnitUserService : IUnitUserService, ITransient
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0; .Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result) if (result)
{ {
await ClearUserInfo(0, userId);//清理个人信息表缓存 await ClearUserInfo(0, userId); //清理个人信息表缓存
//注册账户 //注册账户
unit_user_acc acc = new unit_user_acc(); unit_user_acc acc = new unit_user_acc();
acc.userId = userId; acc.userId = userId;
@@ -159,7 +158,7 @@ public class UnitUserService : IUnitUserService, ITransient
copper.userId = userId; copper.userId = userId;
copper.copper = 0; copper.copper = 0;
db.Insertable(copper).AddQueue(); db.Insertable(copper).AddQueue();
//注册个人基础属性 //注册个人基础属性
unit_user_attr userAttr = GameTool.GetAttrData(1); unit_user_attr userAttr = GameTool.GetAttrData(1);
userAttr.userId = userId; userAttr.userId = userId;
@@ -175,14 +174,14 @@ public class UnitUserService : IUnitUserService, ITransient
morale.userId = userId; morale.userId = userId;
morale.morale = userAttr.upMorale; morale.morale = userAttr.upMorale;
db.Insertable(morale).AddQueue(); db.Insertable(morale).AddQueue();
//注册等级经验 //注册等级经验
unit_user_exp exp = new unit_user_exp(); unit_user_exp exp = new unit_user_exp();
exp.userId = userId; exp.userId = userId;
exp.exp = 0; exp.exp = 0;
exp.upExp = GameTool.GetUserUpExp(1); exp.upExp = GameTool.GetUserUpExp(1);
db.Insertable(exp).AddQueue(); db.Insertable(exp).AddQueue();
//注册负重 //注册负重
unit_user_weight weight = new unit_user_weight(); unit_user_weight weight = new unit_user_weight();
weight.userId = userId; weight.userId = userId;
@@ -196,7 +195,7 @@ public class UnitUserService : IUnitUserService, ITransient
vitality.upVitality = 50; vitality.upVitality = 50;
vitality.upTime = TimeAssist.GetDateTimeYMDString(0); vitality.upTime = TimeAssist.GetDateTimeYMDString(0);
db.Insertable(vitality).AddQueue(); db.Insertable(vitality).AddQueue();
//注册在线 //注册在线
unit_user_online online = new unit_user_online(); unit_user_online online = new unit_user_online();
online.userId = userId; online.userId = userId;
@@ -204,9 +203,8 @@ public class UnitUserService : IUnitUserService, ITransient
online.mapId = "16_27"; online.mapId = "16_27";
online.upTime = TimeAssist.GetTimeStampNum; online.upTime = TimeAssist.GetTimeStampNum;
db.Insertable(online).AddQueue(); db.Insertable(online).AddQueue();
await db.SaveQueuesAsync(false); await db.SaveQueuesAsync(false);
} }
return result; return result;
@@ -245,4 +243,15 @@ public class UnitUserService : IUnitUserService, ITransient
} }
#endregion #endregion
#region
public async Task<int> GetOnlineCount()
{
long time = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddMinutes(0-GameConfig.OnLineTime));
var db = _dbClient.AsTenant().GetConnectionWithAttr<unit_user_online>();
return await db.Queryable<unit_user_online>().Where(it => it.upTime > time).CountAsync();
}
#endregion
} }

View File

@@ -0,0 +1,177 @@
namespace Application.Domain;
public class UnitUserWeight(ISqlSugarClient DbClient, IRedisCache redis) : IUnitUserWeight, ITransient
{
public async Task<unit_user_weight> GetUserWeightInfo(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Weight");
var data = await redis.GetHashAsync<unit_user_weight>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
data = await db.Queryable<unit_user_weight>().Where(it => it.userId == userId).SingleAsync();
await redis.AddHashAsync(key, userId, data);
}
data.maxWeight = await GetUserMaxWeight(data);
return data;
}
private async Task<int> GetUserMaxWeight(unit_user_weight data)
{
int result = (int)data.maxWeight;
//其他属性加层
return result;
}
private async Task ClearUserWeightInfo(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Weight");
await redis.DelHashAsync(key, userId);
}
public async Task<bool> UpdateUserWeight(string userId, int op, int weight)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
bool result = await db.Updateable<unit_user_weight>()
.SetColumnsIF(op == 0, it => it.onWeight == it.onWeight - weight)
.SetColumnsIF(op == 1, it => it.onWeight == it.onWeight + weight)
.SetColumnsIF(op == 2, it => it.onWeight == weight)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserWeightInfo(userId);
}
return result;
}
public async Task<bool> UpdateUserMaxWeight(string userId, int op, int weight)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
bool result = await db.Updateable<unit_user_weight>()
.SetColumnsIF(op == 0, it => it.maxWeight == it.maxWeight - weight)
.SetColumnsIF(op == 1, it => it.maxWeight == it.maxWeight + weight)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserWeightInfo(userId);
}
return result;
}
public async Task<bool> AddUserWeightLog(string userId, int goodsId, string goodsName, int weight, int count)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight_log>();
unit_user_weight_log log = new unit_user_weight_log();
log.logId = StringAssist.NewGuid;
log.userId = userId;
log.goodsId = goodsId;
log.goodsName = goodsName;
log.weight = weight;
log.count = count;
log.sum = weight * count;
log.addTime = DateTime.Now;
return await db.Insertable(log).ExecuteCommandAsync() > 0;
}
public async Task<bool> CheakUserWeight(string userId, int useWeight)
{
bool result = false;
var weightInfo = await GetUserWeightInfo(userId);
if (weightInfo != null)
{
result = (useWeight + weightInfo.onWeight) <= weightInfo.maxWeight;
}
return result;
}
#region
public async Task<List<unit_user_ship>> GetUserShip(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Ship");
var data = await redis.GetHashAsync<List<unit_user_ship>>(key, userId);
if (data == null)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
data = await db.Queryable<unit_user_ship>().Where(it => it.userId == userId).ToListAsync();
await redis.AddHashAsync(key, userId, data);
}
return data;
}
public async Task<int> GetUserShipMaxWeight(string userId)
{
var data = await GetUserShip(userId);
return data.Sum(it => (int)it.weight);
}
private async Task ClearUserShipData(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "WeightData", "Ship");
await redis.DelHashAsync(key, userId);
}
public async Task<bool> UpdateUserShipOnWeight(string userId, int op, int weight)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_weight>();
bool result = await db.Updateable<unit_user_weight>()
.SetColumnsIF(op == 0, it => it.shipOnWeight == it.shipOnWeight - weight)
.SetColumnsIF(op == 1, it => it.shipOnWeight == it.shipOnWeight + weight)
.Where(it => it.userId == userId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserWeightInfo(userId);
}
return result;
}
public async Task<bool> CheakUserShipWeight(string userId, int useWeight)
{
bool result = false;
var weightInfo = await GetUserWeightInfo(userId);
var maxShipWeight = await GetUserShipMaxWeight(userId);
if (weightInfo != null)
{
result = (useWeight + weightInfo.onWeight) <= maxShipWeight;
}
return result;
}
public async Task<bool> DeleteUserShip(string usId,string userId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
bool result = await db.Deleteable<unit_user_ship>().Where(it => it.usId == usId).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserShipData(userId);
}
return result;
}
public async Task<bool> AddUserShip(string userId,string name,int goodsId,int speed,int weight)
{
unit_user_ship ship = new unit_user_ship();
ship.usId = StringAssist.NewGuid;
ship.userId = userId;
ship.goodsId = goodsId;
ship.name = name;
ship.speed = speed;
ship.weight = weight;
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_ship>();
bool result = await db.Insertable(ship).ExecuteCommandAsync() > 0;
if (result)
{
await ClearUserShipData(userId);
}
return result;
}
#endregion
}

View File

@@ -11,10 +11,11 @@ namespace Application.Web.Controllers.Chat;
public class ChatController : ControllerBase public class ChatController : ControllerBase
{ {
private readonly IGameChatService _chatService; private readonly IGameChatService _chatService;
private readonly IGameGoodsService _goodsService;
public ChatController(IGameChatService chatService) public ChatController(IGameChatService chatService,IGameGoodsService goodsService)
{ {
_chatService = chatService; _chatService = chatService;
_goodsService = goodsService;
} }
/// <summary> /// <summary>
@@ -26,6 +27,7 @@ public class ChatController : ControllerBase
[HttpGet] [HttpGet]
public async Task<IPoAction> GetChatData(int type, int page) public async Task<IPoAction> GetChatData(int type, int page)
{ {
string userId = StateHelper.userId;
int areaId = StateHelper.areaId; int areaId = StateHelper.areaId;
string teamId = ""; string teamId = "";
string groupId = ""; string groupId = "";
@@ -37,15 +39,15 @@ public class ChatController : ControllerBase
switch (type) switch (type)
{ {
case 0: case 0:
sendGoodsCount = 199; sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsBase);
sendGoodsName = "小海螺"; sendGoodsName = "小海螺";
break; break;
case 3: case 3:
sendGoodsCount = 15; sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsArea);
sendGoodsName = "大海螺"; sendGoodsName = "大海螺";
break; break;
case 4: case 4:
sendGoodsCount = 9; sendGoodsCount = await _goodsService.GetUserGoodsCount(userId,GameConfig.SendChatGoodsService);
sendGoodsName = "金海螺"; sendGoodsName = "金海螺";
break; break;
} }
@@ -71,12 +73,14 @@ public class ChatController : ControllerBase
int areaId = StateHelper.areaId; int areaId = StateHelper.areaId;
string par = string.Empty; string par = string.Empty;
string code = GameChatEnum.Code.Public.ToString(); string code = GameChatEnum.Code.Public.ToString();
int goodsId = 0;
bool isSend = false; bool isSend = false;
switch (pars.type) switch (pars.type)
{ {
case 0: case 0:
isSend = true; isSend = true;
code =nameof(GameChatEnum.Code.Public); code =nameof(GameChatEnum.Code.Public);
goodsId = GameConfig.SendChatGoodsBase;
break; break;
case 1: case 1:
isSend = true; isSend = true;
@@ -90,23 +94,39 @@ public class ChatController : ControllerBase
break; break;
case 3: case 3:
isSend = true; isSend = true;
goodsId = GameConfig.SendChatGoodsArea;
code = nameof(GameChatEnum.Code.Region); code = nameof(GameChatEnum.Code.Region);
break; break;
case 4: case 4:
isSend = true; isSend = true;
goodsId = GameConfig.SendChatGoodsService;
code = nameof(GameChatEnum.Code.Dress); code = nameof(GameChatEnum.Code.Dress);
break; break;
} }
if (isSend == false) if (isSend == false)
{ {
return PoAction.Message("无法发言!"); return PoAction.Message("无法发言!");
} }
if (goodsId != 0)
{
var myCount = await _goodsService.GetUserGoodsCount(userId, goodsId);
if (myCount < 1)
{
return PoAction.Message("暂无发言道具,去商城购买海螺才可以发言哦!");
}
}
string sign = StringAssist.NoHTML(pars.sign); string sign = StringAssist.NoHTML(pars.sign);
bool result = await _chatService.SendChat(userId, areaId, code, sign, par); bool result = await _chatService.SendChat(userId, areaId, code, sign, par);
if (result) if (result)
{ {
if (goodsId != 0)//扣除道具
{
await _goodsService.UpdateUserGoods(userId, 0, goodsId, 1, "发言");
}
return PoAction.Ok(true); return PoAction.Ok(true);
} }
else else

View File

@@ -47,13 +47,17 @@ public class MapController : ControllerBase
string teamId = ""; string teamId = "";
string groupId = ""; string groupId = "";
var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId); var chatData = await _chatService.GetChatTop(area, 2, teamId, groupId);
//NPC信息
var npcData = await _mapService.GetMapNpc(mapInfo.mapId);
var npcData = await _mapService.GetMapNpc(mapInfo.mapId); //NPC信息
npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId)); npcData = npcData.FindAll(it => GameTool.AreaVerify(StateHelper.areaId, it.areaId));
//城市信息 var nearUser =
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); await _mapService.GetMapUser(mapInfo.mapId, area, (int)mapInfo.lookArea, new List<string> { userId },
var cityShow = await _mapService.GetMapCity(cityInfo.cityId); 3); //获取附近的人
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); //城市信息
var cityShow = await _mapService.GetMapCity(cityInfo.cityId); //城内地图
#region 线 #region 线
string ip = ComHelper.GetClientUserIp(HttpContext); string ip = ComHelper.GetClientUserIp(HttpContext);
@@ -61,8 +65,34 @@ public class MapController : ControllerBase
#endregion #endregion
object ret = new { mapInfo, cityInfo, npcData, chatData,cityShow }; object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser };
return PoAction.Ok(ret); return PoAction.Ok(ret);
} }
/// <summary>
/// 获取地图在线玩家
/// </summary>
/// <param name="map"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetMapUser(int page)
{
RefAsync<int> Total = 0;
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
var onMap = await _mapService.GetUserOnMap(userId);
var mapInfo = await _mapService.GetMapInfo(onMap.mapId);
if (mapInfo == null)
{
return PoAction.Message("地图不存在!");
}
var data = await _mapService.GetMapUser(onMap.mapId, areaId, (int)mapInfo.lookArea, new List<string> { userId }, page,
10, Total);
return PoAction.Ok(new { data, total = Total.Value});
}
} }

View File

@@ -52,7 +52,7 @@ namespace Application.Web.Controllers.Pub
var notice = await _noticeService.GetNoticeDataByTake(5); var notice = await _noticeService.GetNoticeDataByTake(5);
int OnCount = 100; int OnCount = await _userService.GetOnlineCount();
return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount, account,userData }); return PoAction.Ok(new { area = areaData, notice, isOnline, onCount = OnCount, account,userData });
} }

View File

@@ -0,0 +1,38 @@
namespace Application.Web.Controllers.User;
/// <summary>
/// 用户背包信息
/// </summary>
[ApiExplorerSettings(GroupName = "User")]
[Route("User/[controller]/[action]")]
[ApiController]
[Authorize]
public class BagController : ControllerBase
{
private readonly IUnitUserWeight _weightService;
public BagController(IUnitUserWeight weightService)
{
_weightService = weightService;
}
/// <summary>
/// 获取背包信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetUserBagData()
{
string userId = StateHelper.userId;
int onWeight = 0;
int maxWeight = 0;
int gold = 0;
int cowry = 0;
long copper = 0;
var userWeight = await _weightService.GetUserWeightInfo(userId);
onWeight = (int)userWeight.onWeight;
maxWeight = (int)userWeight.maxWeight;
return PoAction.Ok(new { onWeight, maxWeight,cowry, gold, copper });
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

View File

@@ -53,4 +53,9 @@ onMounted(() => {
<style> <style>
/* 页面级样式可以在这里定义 */ /* 页面级样式可以在这里定义 */
/* 全局样式已移至 src/assets/css/style.css */ /* 全局样式已移至 src/assets/css/style.css */
:root{
--van-base-font: initial !important;
}
</style> </style>

View File

@@ -120,6 +120,26 @@ a:focus {
height: 20px; height: 20px;
border: none; border: none;
} }
.serch{
display: flex;
align-items: flex-end;
}
.search-ipt{
width: 80px;
font-size: 11px;
padding: 0 ;
}
.ipt-btn{
width: 61px;
height: 21px;
font-size: 13px;
border: none;
margin-top: 5px;
background: url(/css/images/btn_b_gold.gif) no-repeat;
color: #af4c00;
}
.chat { .chat {
word-wrap: break-word; word-wrap: break-word;
} }
@@ -173,4 +193,4 @@ a:focus {
border-color: #d2d2d2; border-color: #d2d2d2;
background: 0 0; background: 0 0;
color: #666; color: #666;
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="common"> <div class="common">
<Abar href="/">状态</Abar>. <Abar href="/">状态</Abar>.
<Abar href="/">物品</Abar>. <Abar href="/bag">物品</Abar>.
<Abar href="/chat">聊天</Abar> <Abar href="/chat">聊天</Abar>
</div> </div>
<div class="common"> <div class="common">

View File

@@ -2,6 +2,7 @@
<div class="main"> <div class="main">
<slot /> <slot />
</div> </div>
<div class="clear"></div>
<div class="content "> <div class="content ">
<button class="btn btn-ret" @click="GoBack">返回</button><br /> <button class="btn btn-ret" @click="GoBack">返回</button><br />
<Abar href="/map">返回游戏</Abar> <Abar href="/map">返回游戏</Abar>

125
Web/src/pages/bag/index.vue Normal file
View File

@@ -0,0 +1,125 @@
<template>
<div class="content">
我的物品.<Abutton @click="Refresh">刷新</Abutton> <br>
金元: {{ bagInfo.gold }}<br />
金贝: {{ bagInfo.cowry }} <br />
负重:{{ bagInfo.onWeight }}/{{ bagInfo.maxWeight }} <br />
{{ bagInfo.copper }}<br />
<Abar href="/">交易记录</Abar><br>
<Abar href="/">赠送记录</Abar>
</div>
<div class="content">
<div class="common">
<Acheak @click="ChangeBag('0')" :on-value="type" on-cheak="0">装备</Acheak>|
<Acheak @click="ChangeBag('1')" :on-value="type" on-cheak="1">药品</Acheak>|
<Acheak @click="ChangeBag('2')" :on-value="type" on-cheak="2">物品</Acheak>|
<Acheak @click="ChangeBag('3')" :on-value="type" on-cheak="3">坐骑</Acheak>
</div>
<div class="common">
</div>
<div class="common serch">
搜索内容<input type="text" class="search-ipt" v-model="serch">&nbsp;
<button class="ipt-btn" name="serch" @click="BindData">搜索</button>
</div>
<div class="common">
<div v-if="type == '0'">
<Acheak @click="ChangeChildBag('0')" :on-value="type_ch" on-cheak="0">全部</Acheak>.
<Acheak @click="ChangeChildBag('1')" :on-value="type_ch" on-cheak="1">穿戴</Acheak>.
<Acheak @click="ChangeChildBag('2')" :on-value="type_ch" on-cheak="2">到期</Acheak>
</div>
<div v-if="type == '2'">
<Acheak @click="ChangeChildBag('0')" :on-value="type_ch" on-cheak="0">全部</Acheak>.<Acheak
@click="ChangeChildBag('1')" :on-value="type_ch" on-cheak="1">宝石</Acheak>.<Acheak
@click="ChangeChildBag('2')" :on-value="type_ch" on-cheak="2">九宫</Acheak>.<Acheak
@click="ChangeChildBag('3')" :on-value="type_ch" on-cheak="3">圣痕</Acheak>.<Acheak
@click="ChangeChildBag('4')" :on-value="type_ch" on-cheak="4">宝箱</Acheak>.<Acheak
@click="ChangeChildBag('5')" :on-value="type_ch" on-cheak="5">材料</Acheak>.<Acheak
@click="ChangeChildBag('6')" :on-value="type_ch" on-cheak="6">图纸</Acheak>.<Acheak
@click="ChangeChildBag('7')" :on-value="type_ch" on-cheak="7">卡片</Acheak>.<Acheak
@click="ChangeChildBag('8')" :on-value="type_ch" on-cheak="8">货物</Acheak>.<Acheak
@click="ChangeChildBag('9')" :on-value="type_ch" on-cheak="9">其他</Acheak>
</div>
</div>
</div>
<div class="content">
暂无道具.
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const currentPage = ref<number>(1);
const total = ref<number>(0);
const bagInfo = ref<any>({});
const data = ref<Array<any>>([]);
const type = ref('0');
const type_ch = ref('0');
const serch = ref('');
onMounted(async () => {
try {
let result = await BagService.GetUserBagData();
if (result.code == 0) {
bagInfo.value = result.data;
await BindData();
}
console.log(result);
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await MapService.GetMapUser(currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
console.log(result);
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
/**切换背包 */
const ChangeBag = async (_type: string): Promise<void> => {
type.value = _type;
await BindData();
}
const ChangeChildBag = async (ch: string): Promise<void> => {
type_ch.value = ch;
await BindData();
}
/**刷新 */
const Refresh = async (): Promise<void> => {
serch.value = '';
MessageExtend.LoadingToast("刷新中...");
currentPage.value = 1;
await BindData();
MessageExtend.LoadingClose();
PageExtend.ScrollToTop();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
</script>

View File

@@ -4,12 +4,12 @@
<Abar href="/news">*更新内容早知道</Abar> <Abar href="/news">*更新内容早知道</Abar>
</div> </div>
<div class="title"> <div class="title">
<Acheak @click="BindData('0')" :on-value="type" on-cheak="0">公共</Acheak>. <Acheak @click="ChangeChat('0')" :on-value="type" on-cheak="0">公共</Acheak>.
<Acheak @click="BindData('1')" :on-value="type" on-cheak="1">队伍</Acheak>. <Acheak @click="ChangeChat('1')" :on-value="type" on-cheak="1">队伍</Acheak>.
<Acheak @click="BindData('2')" :on-value="type" on-cheak="2">帮派</Acheak>. <Acheak @click="ChangeChat('2')" :on-value="type" on-cheak="2">帮派</Acheak>.
<Acheak @click="BindData('3')" :on-value="type" on-cheak="3">全区</Acheak>. <Acheak @click="ChangeChat('3')" :on-value="type" on-cheak="3">全区</Acheak>.
<Acheak @click="BindData('4')" :on-value="type" on-cheak="4">全服</Acheak>. <Acheak @click="ChangeChat('4')" :on-value="type" on-cheak="4">全服</Acheak>.
<Acheak @click="BindData('5')" :on-value="type" on-cheak="5">系统</Acheak> <Acheak @click="ChangeChat('5')" :on-value="type" on-cheak="5">系统</Acheak>
</div> </div>
<div class="content"> <div class="content">
<GameChat :data="data" :show-time="1"></GameChat> <GameChat :data="data" :show-time="1"></GameChat>
@@ -54,18 +54,15 @@ const sign = ref('');
onMounted(async () => { onMounted(async () => {
try { try {
await BindData(type.value); await BindData();
} }
finally { finally {
PageLoading.Close(); PageLoading.Close();
} }
}) })
const BindData = async (typeid: string): Promise<void> => { const BindData = async (): Promise<void> => {
if (type.value != typeid) { let result = await ChatService.GetChatData(Number(type.value), currentPage.value);
type.value = typeid;
}
let result = await ChatService.GetChatData(Number(typeid), currentPage.value);
if (result.code == 0) { if (result.code == 0) {
data.value = result.data.data; data.value = result.data.data;
goodsCount.value = result.data.sendGoodsCount goodsCount.value = result.data.sendGoodsCount
@@ -80,7 +77,7 @@ const BindData = async (typeid: string): Promise<void> => {
/**刷新 */ /**刷新 */
const Refresh = async (): Promise<void> => { const Refresh = async (): Promise<void> => {
MessageExtend.LoadingToast("刷新中..."); MessageExtend.LoadingToast("刷新中...");
await BindData(type.value); await BindData();
MessageExtend.LoadingClose(); MessageExtend.LoadingClose();
PageExtend.ScrollToTop(); PageExtend.ScrollToTop();
} }
@@ -88,7 +85,7 @@ const Refresh = async (): Promise<void> => {
/**翻页 */ /**翻页 */
const handlePageChange = async (page: number): Promise<void> => { const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page; currentPage.value = page;
await BindData(type.value); await BindData();
}; };
/**发送消息 */ /**发送消息 */
@@ -105,7 +102,7 @@ const SendChat = async (): Promise<void> => {
send = true; send = true;
if (result.code == 0) { if (result.code == 0) {
sign.value = ''; sign.value = '';
await BindData(type.value); await BindData();
PageExtend.ScrollToTop(); PageExtend.ScrollToTop();
} }
else { else {
@@ -115,4 +112,13 @@ const SendChat = async (): Promise<void> => {
} }
/**切换频道 */
const ChangeChat = async (typeid: string): Promise<void> => {
if (type.value != typeid) {
type.value = typeid;
}
currentPage.value = 1;
await BindData();
};
</script> </script>

View File

@@ -14,16 +14,16 @@
</div> </div>
<div class="content"> <div class="content">
您看到: 您看到:
<a class="" href="/Map/Index/MapUser/16_27?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">1111 <Abar href="/map/user" v-if="mapUser.length>0">
</a> <span v-for="item in mapUser">{{item.nick}} &nbsp;</span>
</Abar>
</div> </div>
<div class="content"> <div class="content">
<div class="item" v-for="item in npcData"> <div class="item" v-for="item in npcData">
<Abar href="">{{ item.npcName }}{{ item.tips }}</Abar> <Abar href="">{{ item.npcName }}{{ item.tips }}</Abar>
</div> </div>
</div> </div>
<div class="content">
</div>
<div class="content"> <div class="content">
请选择出口:<br /> 请选择出口:<br />
<span v-if="mapDong.mapId != ''">东:<Abutton @click="BindData(mapDong.mapId)">{{ mapDong.name }}</Abutton></span> <span v-if="mapDong.mapId != ''">东:<Abutton @click="BindData(mapDong.mapId)">{{ mapDong.name }}</Abutton></span>
@@ -34,9 +34,7 @@
</div> </div>
<div class="content"> <div class="content">
<Abutton @click="ShowCityProp">城内地图</Abutton>.<a class="" <Abutton @click="ShowCityProp">城内地图</Abutton>.<Abar href="/">寻路</Abar><br />
href="/Business/Help/Index?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">帮助</a>.<a class=""
href="/Privilege/Purdiam/MapTo?sid=W6Wg8iH9gY7wIBNSEdtFcQ3KbI5YiKDo">传送</a><br />
</div> </div>
<div class="content"> <div class="content">
{{ mapInfo.tips }} {{ mapInfo.tips }}
@@ -67,6 +65,7 @@ const cityInfo = ref<any>({});
const npcData = ref<Array<any>>([]); const npcData = ref<Array<any>>([]);
const chatData = ref<Array<any>>([]); const chatData = ref<Array<any>>([]);
const cityShow = ref<Array<any>>([]); const cityShow = ref<Array<any>>([]);
const mapUser = ref<Array<any>>([]);
// 城内地图显示 // 城内地图显示
const showCity = ref(false) const showCity = ref(false)
@@ -88,6 +87,7 @@ const BindData = async (map: string): Promise<void> => {
npcData.value = result.data.npcData; npcData.value = result.data.npcData;
chatData.value = result.data.chatData; chatData.value = result.data.chatData;
cityShow.value = result.data.cityShow; cityShow.value = result.data.cityShow;
mapUser.value = result.data.nearUser;
MapVent(result.data.mapInfo.near); MapVent(result.data.mapInfo.near);
onMap.value = mapInfo.value.mapId; onMap.value = mapInfo.value.mapId;
console.log(result.data); console.log(result.data);

View File

@@ -0,0 +1,61 @@
<template>
<div class="content">
附近的人.<Abutton @click="Refresh">刷新</Abutton>
</div>
<div class="content">
<div class="item" v-for="(item, index) in data" :key="index">
{{ index + 1 }}.<GameUser :data="item" :show-icon="0"></GameUser>
</div>
<span v-if="data.length == 0">暂无玩家.</span>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await MapService.GetMapUser(currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
/**刷新 */
const Refresh = async (): Promise<void> => {
MessageExtend.LoadingToast("刷新中...");
currentPage.value = 1;
await BindData();
MessageExtend.LoadingClose();
PageExtend.ScrollToTop();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
</script>

View File

@@ -6,4 +6,12 @@ export class MapService {
static async GetMapData(map: string) { static async GetMapData(map: string) {
return await ApiService.Request("get", "/Map/Map/GetMapData", { map }); return await ApiService.Request("get", "/Map/Map/GetMapData", { map });
} }
/**
* 获取地图在线玩家
* GET /Map/Map/GetMapUser
*/
static async GetMapUser(page: number) {
return await ApiService.Request("get", "/Map/Map/GetMapUser", { page });
}
} }

View File

@@ -0,0 +1,9 @@
export class BagService {
/**
* 获取背包信息
* GET /User/Bag/GetUserBagData
*/
static async GetUserBagData() {
return await ApiService.Request("get", "/User/Bag/GetUserBagData");
}
}