This commit is contained in:
Putoo
2026-05-28 19:06:40 +08:00
parent 0d5443ef36
commit 69ae1e3174
39 changed files with 1742 additions and 31 deletions

View File

@@ -4,7 +4,9 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJwtExtensions_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6b089d08a87d4ddd82371ae63e754ba05000_003F26_003Fd6433acb_003FJwtExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJwtHelper_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6b089d08a87d4ddd82371ae63e754ba05000_003Fe2_003F86047f24_003FJwtHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJwtSecurityTokenHandler_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Ff9d3fc33fd2fba97d4e718534a67f1d3c61e492634cd51c4798ce5621f780f3_003FJwtSecurityTokenHandler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F51505665371d472f8bdbc333fa4d888cf49938_003F0e_003F7279c963_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSetup_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F72993acb059c49dcbba437a858c0b0942000_003F46_003F2e14505d_003FSqlSetup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASqlSugarScopeProvider_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6c0f22f0a47643a3b2a40899acd2044c2e3a00_003Fc5_003F4738d33f_003FSqlSugarScopeProvider_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AString_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F51505665371d472f8bdbc333fa4d888cf49938_003Fdf_003F23ca03dd_003FString_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATimeAssist_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa380d649d5b2495d9bfa0fa24f13662b6400_003Fe6_003F9539602d_003FTimeAssist_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATokenValidationParameters_002Ecs_002Fl_003AC_0021_003FUsers_003F29055_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Ffbb48859ccd84b0d884ab212a4cf9fdb5f820_003F55_003F417754e1_003FTokenValidationParameters_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

View File

@@ -0,0 +1,63 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
public class unit_user_message
{
/// <summary>
/// msgId
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long msgId { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// sendId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? sendId { get; set; }
/// <summary>
/// sign
/// </summary>
[SugarColumn(IsNullable = true)]
public string? sign { get; set; }
/// <summary>
/// isRead
/// </summary>
[SugarColumn(IsNullable = true)]
public int? isRead { get; set; }
/// <summary>
/// status
/// </summary>
[SugarColumn(IsNullable = true)]
public int? status { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? addTime { get; set; }
/// <summary>
/// endTime
/// </summary>
[SugarColumn(IsNullable = true)]
public long? endTime { get; set; }
/// <summary>
/// 会话ID
/// </summary>
[SugarColumn(Length = 100, IsNullable = true)]
public string? talkId { get; set; }
}
}

View File

@@ -0,0 +1,69 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Log")]
public class game_mall_log
{
/// <summary>
/// logId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string logId { get; set; }
/// <summary>
/// mallId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? mallId { get; set; }
/// <summary>
/// type
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? type { get; set; }
/// <summary>
/// pars
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public Int32? pars { get; set; }
/// <summary>
/// count
/// </summary>
[SugarColumn(IsNullable = true)]
public int? count { get; set; }
/// <summary>
/// price
/// </summary>
[SugarColumn(IsNullable = true)]
public long? price { get; set; }
/// <summary>
/// payType
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? payType { get; set; }
/// <summary>
/// userId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? userId { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? addTime { get; set; }
/// <summary>
/// endTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? endTime { get; set; }
}
}

View File

@@ -3,7 +3,7 @@ using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
[Tenant("Kg.SeaTime.Log")]
public class unit_user_acc_log
{
/// <summary>

View File

@@ -3,7 +3,7 @@ using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Game")]
[Tenant("Kg.SeaTime.Log")]
public class unit_user_weight_log
{
/// <summary>

View File

@@ -0,0 +1,69 @@
using SqlSugar;
using System;
namespace Application.Domain.Entity
{
[Tenant("Kg.SeaTime.Resource")]
public class game_mall
{
/// <summary>
/// mallId
/// </summary>
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string mallId { get; set; }
/// <summary>
/// areaId
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? areaId { get; set; }
/// <summary>
/// name
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? name { get; set; }
/// <summary>
/// type
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? type { get; set; }
/// <summary>
/// goodsId
/// </summary>
[SugarColumn(IsNullable = true)]
public int? goodsId { get; set; }
/// <summary>
/// price
/// </summary>
[SugarColumn(IsNullable = true)]
public long? price { get; set; }
/// <summary>
/// payType
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? payType { get; set; }
/// <summary>
/// sort
/// </summary>
[SugarColumn(IsNullable = true)]
public int? sort { get; set; }
/// <summary>
/// addTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? addTime { get; set; }
/// <summary>
/// endTime
/// </summary>
[SugarColumn(IsNullable = true)]
public DateTime? endTime { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace Application.Domain.Entity;
public class MessageView
{
public string sign { get; set; }
public UserModel user { get; set;}
}

View File

@@ -0,0 +1,8 @@
namespace Application.Domain;
public interface IGameMallService
{
Task<List<game_mall>> GetMallData(int area, string type, int page, int limit, RefAsync<int> total);
Task<game_mall> GetMallInfo(string mallId);
Task<bool> AddLog(game_mall mall, string userId, int count);
}

View File

@@ -0,0 +1,22 @@
namespace Application.Domain;
public interface IMessageService
{
Task<int> GetNoReadCount(string userId);
#region
string GetTalkId(string userId, string otId);
Task<List<unit_user_message>> GetUserNoReadData(string talkId);
Task<List<unit_user_message>> GetUserMessageData(string talkId, int page, int limit,
RefAsync<int> total);
Task<List<MessageView>> GetUserMessage(string userId, int type, int page, int limit,
RefAsync<int> total);
Task<bool> SendMsg(string sendId, string toUser, string msg);
Task SetMsgRead(List<long> msgIds, string userId);
Task<bool> DeleteMsgByTalkId(string talkId, string userId);
#endregion
}

View File

@@ -0,0 +1,40 @@
namespace Application.Domain;
public class GameMallService(ISqlSugarClient DbClient, IRedisCache redis) : IGameMallService, ITransient
{
public async Task<List<game_mall>> GetMallData(int area, string type, int page, int limit, RefAsync<int> total)
{
DateTime onTime = DateTime.Now;
string _area = area.ToString();
var db = DbClient.AsTenant().GetConnectionWithAttr<game_mall>();
return await db.Queryable<game_mall>().Where(it =>
it.endTime > onTime && (it.areaId.Contains("0") || it.areaId.Contains(_area)))
.WhereIF(type=="0",it=>it.payType=="cowry")
.WhereIF(type=="1",it=>it.payType=="gold")
.OrderBy(it=>it.sort,OrderByType.Asc)
.ToPageListAsync(page, limit, total);
}
public async Task<game_mall> GetMallInfo(string mallId)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<game_mall>();
return await db.Queryable<game_mall>().Where(it => it.mallId == mallId).SingleAsync();
}
public async Task<bool> AddLog(game_mall mall, string userId, int count)
{
game_mall_log log = new game_mall_log();
log.logId = StringAssist.NewGuid;
log.mallId = mall.mallId;
log.type = mall.type;
log.pars = mall.goodsId;
log.count = count;
log.price = mall.price;
log.payType = mall.payType;
log.userId = userId;
log.addTime = DateTime.Now;
log.endTime = DateTime.Now.AddDays(30);
var db = DbClient.AsTenant().GetConnectionWithAttr<game_mall_log>();
return await db.Insertable(log).ExecuteCommandAsync() > 0;
}
}

View File

@@ -0,0 +1,166 @@
namespace Application.Domain;
public class MessageService(ISqlSugarClient DbClient, IRedisCache redis) : IMessageService, ITransient
{
public async Task<int> GetNoReadCount(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "Message", "Count");
if (await redis.HExistsHashAsync(key, userId))
{
return await redis.GetHashAsync<int>(key, userId);
}
int result = 0;
//普通消息
int noRead = await GetUserNoReadDataCountByUserId(userId);
result += noRead;
//邮件详细
//通知消息
await redis.AddHashAsync(key, userId, result);
return result;
}
private async Task ClearMessageCache(string userId)
{
string key = string.Format(UserCache.BaseCacheKeys, "Message", "Count");
await redis.DelHashAsync(key, userId);
}
#region
public string GetTalkId(string userId, string otId)
{
return $"{userId}_{otId}";
}
private List<string> GetTalkIdToUserId(string talkId)
{
return talkId.Split('_').ToList();
}
private async Task<int> GetUserNoReadDataCountByUserId(string userId)
{
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
return await db.Queryable<unit_user_message>()
.Where(it => it.status == 1 && it.userId == userId && it.isRead == 0).CountAsync();
}
public async Task<List<unit_user_message>> GetUserNoReadData(string talkId)
{
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
return await db.Queryable<unit_user_message>()
.Where(it => it.status == 1 && it.talkId == talkId && it.isRead == 0)
.OrderByDescending(it => it.addTime).ToListAsync();
}
public async Task<List<unit_user_message>> GetUserMessageData(string talkId, int page, int limit,
RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
return await db.Queryable<unit_user_message>()
.Where(it => it.status == 1 && it.talkId == talkId)
.OrderByDescending(it => it.addTime)
.ToPageListAsync(page, limit, total);
}
/// <summary>
/// 获取最新对话列表
/// </summary>
/// <param name="userId"></param>
/// <param name="type"></param>
/// <param name="page"></param>
/// <param name="limit"></param>
/// <param name="total"></param>
/// <returns></returns>
public async Task<List<MessageView>> GetUserMessage(string userId, int type, int page, int limit,
RefAsync<int> total)
{
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
var talkData = await db.Queryable<unit_user_message>()
.GroupBy(it => new { it.talkId })
.Where(it => it.userId == userId && it.status == 1)
.WhereIF(type == 0, it => it.isRead == 0)
.OrderByDescending(it => it.addTime)
.Select(it => new { mgsId = SqlFunc.AggregateMax(it.msgId) })
.ToPageListAsync(page, limit, total);
List<MessageView> result = new List<MessageView>();
foreach (var item in talkData)
{
MessageView temp = new MessageView();
var msgInfo = await db.Queryable<unit_user_message>().Where(it => it.msgId == item.mgsId).SingleAsync();
temp.sign = msgInfo.sign;
var users = GetTalkIdToUserId(msgInfo.talkId);
temp.user = await UserModelTool.GetUserView(users[1]);
result.Add(temp);
}
return result;
}
public async Task<bool> SendMsg(string sendId, string toUser, string msg)
{
List<unit_user_message> adds = new List<unit_user_message>();
unit_user_message message = new unit_user_message();
message.msgId = SnowflakeAssist.NextId();
message.userId = toUser;
message.sendId = sendId;
message.sign = msg;
message.isRead = 0;
message.status = 1;
message.addTime = DateTime.Now;
message.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(90));
message.talkId = GetTalkId(toUser, sendId);
adds.Add(message);
if (sendId != "0")
{
message = new unit_user_message();
message.msgId = SnowflakeAssist.NextId();
message.userId = sendId;
message.sendId = sendId;
message.sign = msg;
message.isRead = 1;
message.status = 1;
message.addTime = DateTime.Now;
message.endTime = TimeExtend.GetTimeStampBySeconds(DateTime.Now.AddDays(90));
message.talkId = GetTalkId(sendId, toUser);
adds.Add(message);
}
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
bool result = await db.Insertable(adds).ExecuteCommandAsync() > 0;
if (result)
{
await ClearMessageCache(toUser);
}
return result;
}
public async Task SetMsgRead(List<long> msgIds, string userId)
{
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
bool result = await db.Updateable<unit_user_message>().SetColumns(it => it.isRead == 1)
.Where(it => msgIds.Contains(it.msgId)).ExecuteCommandAsync() > 0;
if (result)
{
await ClearMessageCache(userId);
}
}
public async Task<bool> DeleteMsgByTalkId(string talkId, string userId)
{
var db = DbClient.AsTenant().GetConnectionScopeWithAttr<unit_user_message>();
bool result = await db.Updateable<unit_user_message>().SetColumns(it => it.status == 0)
.Where(it => it.talkId == talkId && it.status == 1).ExecuteCommandAsync() >
0;
if (result)
{
await ClearMessageCache(userId);
}
return result;
}
#endregion
}

View File

@@ -70,9 +70,9 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
userAccLog.name = name;
userAccLog.amount = count;
userAccLog.addTime = DateTime.Now;
userAccLog.endTime = DateTime.Now.AddDays(3);
userAccLog.endTime = DateTime.Now.AddDays(30);
userAccLog.remark = remark;
await db.Insertable(userAccLog).ExecuteCommandAsync();
await AddLog(userAccLog);
}
await DbClient.AsTenant().CommitTranAsync();
@@ -102,6 +102,11 @@ public class UnitUserAccService(ISqlSugarClient DbClient, IRedisCache redis) : I
return result;
}
private async Task AddLog(unit_user_acc_log log)
{
var db = DbClient.AsTenant().GetConnectionWithAttr<unit_user_acc_log>();
await db.Insertable(log).ExecuteCommandAsync();
}
public async Task<unit_user_copper> GetUserCopperInfo(string userId)
{

View File

@@ -34,8 +34,8 @@ public class GameTool
public static bool AreaVerify(int area, string areas)
{
List<string> onArea = new List<string>() { "0", area.ToString() };
return onArea.Any(it => areas.Contains(it));
List<string> okArea = areas.Split(',').ToList();
return okArea.Any(it => it == "0" || it == area.ToString());
}
public static string GetCurrencyName(string payCode)

View File

@@ -11,6 +11,17 @@ public class UserModelTool
public static async Task<UserModel> GetUserView(string userId,bool addIcon=false)
{
UserModel result = new UserModel();
if (userId == "0")
{
result.userNo = "0";
result.nick = "海精灵";
result.sex = "女";
result.headImg = "";
result.area = 0;
result.icon = "";
}
else
{
var userService = App.GetService<IUnitUserService>();
var userInfo = await userService.GetUserInfoByUserId(userId);
if (userInfo != null)
@@ -26,7 +37,7 @@ public class UserModelTool
result.icon = "";
}
}
}
return result;
}
}

View File

@@ -15,14 +15,16 @@ public class MapController : ControllerBase
private readonly IGameMapService _mapService;
private readonly IGameChatService _chatService;
private readonly IUnitUserAttrService _attrService;
private readonly IMessageService _messageService;
public MapController(IUnitUserService userService, IGameMapService mapService, IGameChatService chatService,
IUnitUserAttrService attrService)
IUnitUserAttrService attrService,IMessageService messageService)
{
_userService = userService;
_mapService = mapService;
_chatService = chatService;
_attrService = attrService;
_messageService = messageService;
}
/// <summary>
@@ -79,6 +81,7 @@ public class MapController : ControllerBase
var cityInfo = await _mapService.GetCityInfo((int)mapInfo.cityId); //城市信息
var cityShow = await _mapService.GetCityShowMap(cityInfo.cityId); //城内地图
int noReadMsg = await _messageService.GetNoReadCount(userId);
#region 线
string ip = ComHelper.GetClientUserIp(HttpContext);
@@ -86,7 +89,7 @@ public class MapController : ControllerBase
#endregion
object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser };
object ret = new { mapInfo, cityInfo, npcData, chatData, cityShow, nearUser,noReadMsg };
return PoAction.Ok(ret);
}

View File

@@ -0,0 +1,86 @@
using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Pub;
/// <summary>
/// 商城接口
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class MallController : ControllerBase
{
private readonly IGameMallService _mallService;
private readonly IUnitUserAccService _accService;
public MallController(IGameMallService mallService, IUnitUserAccService accService)
{
_mallService = mallService;
_accService = accService;
}
/// <summary>
/// 获取商城列表
/// </summary>
/// <param name="type"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetMall(string type, int page)
{
int area = StateHelper.areaId;
string userId = StateHelper.userId;
var accInfo = await _accService.GetUserAccInfo(userId);
RefAsync<int> total = 0;
var data = await _mallService.GetMallData(area, type, page, 10, total);
return PoAction.Ok(new { data, total = total.Value, accInfo.gold, accInfo.cowry });
}
/// <summary>
/// 购买物品
/// </summary>
/// <param name="parms"></param>
/// <returns></returns>
[HttpPost]
public async Task<IPoAction> Buy([FromBody] MallBuyParms parms)
{
string userId = StateHelper.userId;
int area = StateHelper.areaId;
parms.count = parms.count < 1 ? 1 : parms.count;
var mallInfo = await _mallService.GetMallInfo(parms.id);
if (mallInfo == null)
{
return PoAction.Message("商品已下架!");
}
if (mallInfo.endTime < DateTime.Now)
{
return PoAction.Message("商品已下架!");
}
if (GameTool.AreaVerify(area, mallInfo.areaId) == false)
{
return PoAction.Message("商品已下架!");
}
var myAcc = await _accService.GetUserAccInfo(userId, mallInfo.payType);
long need = (long)mallInfo.price * parms.count;
if (myAcc < need)
{
return PoAction.Message($"您的{GameTool.GetCurrencyName(mallInfo.payType)}不足!");
}
if (await _accService.UpdateUserAcc(userId, 0, mallInfo.payType, need, nameof(AccEnum.Name.), "系统商店购买"))
{
if (await _mallService.AddLog(mallInfo, userId, parms.count))
{
await GameBus.UpdateBag(userId, 1, mallInfo.type, mallInfo.goodsId.ToString(), parms.count, "系统商店购买");
}
return PoAction.Ok(true);
}
else
{
return PoAction.Message("购买失败,请稍后尝试!");
}
}
}

View File

@@ -0,0 +1,196 @@
using Microsoft.AspNetCore.Mvc;
namespace Application.Web.Controllers.Pub;
/// <summary>
/// 消息接口
/// </summary>
[Route("[controller]/[action]")]
[ApiController]
[Authorize]
public class MessageController : ControllerBase
{
private readonly IMessageService _messageService;
private readonly IUnitUserService _userService;
public MessageController(IMessageService messageService, IUnitUserService userService)
{
_messageService = messageService;
_userService = userService;
}
/// <summary>
/// 获取消息
/// </summary>
/// <param name="type"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetMessageData(int type, int page)
{
string userId = StateHelper.userId;
RefAsync<int> total = 0;
if (type == 0)
{
var data = await _messageService.GetUserMessage(userId, 0, page, 10, total);
return PoAction.Ok(new { data, total = total.Value });
}
else if (type == 1)
{
var data = await _messageService.GetUserMessage(userId, 1, page, 10, total);
return PoAction.Ok(new { data, total = total.Value });
}
else
{
return PoAction.Ok(new { data = new List<string>(), total = total.Value });
}
}
/// <summary>
/// 获取消息界面
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> GetReadInfo(int no)
{
string userId = StateHelper.userId;
UserModel user = new UserModel();
string talkId = string.Empty;
if (no == 0)
{
user = await UserModelTool.GetUserView("0");
talkId = _messageService.GetTalkId(userId, "0");
}
else
{
var userInfo = await _userService.GetUserInfoByUserNo(no.ToString());
if (userInfo == null)
{
return PoAction.Message("玩家不存在!");
}
talkId = _messageService.GetTalkId(userId, userInfo.userId);
user = await UserModelTool.GetUserView(userInfo.userId);
}
var noRead = await _messageService.GetUserNoReadData(talkId); //未读消息
if (noRead.Count > 0)
{
List<long> msgIds = noRead.Select(it => it.msgId).ToList();
await _messageService.SetMsgRead(msgIds, userId);
}
RefAsync<int> total = 0;
var logs = await _messageService.GetUserMessageData(talkId, 1, 5, total); //消息记录
return PoAction.Ok(new { user, data = noRead, logs });
}
/// <summary>
/// 发送消息
/// </summary>
/// <param name="parms"></param>
/// <returns></returns>
[HttpPost]
public async Task<IPoAction> SendMsg([FromBody] SendMsgParms parms)
{
if (string.IsNullOrEmpty(parms.sign))
{
return PoAction.Message("消息内容不能为空!");
}
string userId = StateHelper.userId;
int areaId = StateHelper.areaId;
var toUser = await _userService.GetUserInfoByUserNo(parms.no.ToString());
if (toUser == null)
{
return PoAction.Message("玩家不存在!", 100);
}
if (toUser.areaId != areaId)
{
return PoAction.Message("暂不支持漫游消息!");
}
parms.sign = StringAssist.NoHTML(parms.sign);
if (await _messageService.SendMsg(userId, toUser.userId, parms.sign))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("发送失败,请稍后尝试");
}
}
/// <summary>
/// 聊天记录
/// </summary>
/// <param name="no"></param>
/// <param name="page"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> MessageLog(int no, int page)
{
string userId = StateHelper.userId;
UserModel user = new UserModel();
string talkId = string.Empty;
if (no == 0)
{
user = await UserModelTool.GetUserView("0");
talkId = _messageService.GetTalkId(userId, "0");
}
else
{
var userInfo = await _userService.GetUserInfoByUserNo(no.ToString());
if (userInfo == null)
{
return PoAction.Message("玩家不存在!");
}
talkId = _messageService.GetTalkId(userId, userInfo.userId);
user = await UserModelTool.GetUserView(userInfo.userId);
}
RefAsync<int> total = 0;
var logs = await _messageService.GetUserMessageData(talkId, page, 10, total); //消息记录
return PoAction.Ok(new { user, data = logs, total = total.Value });
}
/// <summary>
/// 删除对话
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
[HttpGet]
public async Task<IPoAction> DeleteMsg(int no)
{
string userId = StateHelper.userId;
string talkId = string.Empty;
if (no == 0)
{
talkId = _messageService.GetTalkId(userId, "0");
}
else
{
var userInfo = await _userService.GetUserInfoByUserNo(no.ToString());
if (userInfo == null)
{
return PoAction.Message("玩家不存在!");
}
talkId = _messageService.GetTalkId(userId, userInfo.userId);
}
if (await _messageService.DeleteMsgByTalkId(talkId, userId))
{
return PoAction.Ok(true);
}
else
{
return PoAction.Message("删除失败,请稍后尝试!");
}
}
}

View File

@@ -63,6 +63,10 @@ public class UserController : ControllerBase
{
return PoAction.Message("用户本身!", 101);
}
if (userInfo.areaId != StateHelper.areaId)
{
return PoAction.Message("玩家不存在!", 102);
}
object user = new { userInfo.userNo, userInfo.nick, userInfo.sex, userInfo.sign };
var attrInfo = await _attrService.GetUserAttrModel(userInfo.userId); //基础属性

View File

@@ -0,0 +1,7 @@
namespace Application.Web;
public class MallBuyParms
{
public string id { get; set; }
public int count { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace Application.Web;
public class SendMsgParms
{
public int no { get; set; }
public string sign { get; set; }
}

View File

@@ -58,7 +58,7 @@ export default defineNuxtConfig({
},
},
css: ['~/assets/css/style.css'],
css: ['~/assets/css/style.css','~/assets/css/home.css'],
compatibilityDate: '2024-04-03',
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

508
Web/src/assets/css/home.css Normal file
View File

@@ -0,0 +1,508 @@
.tw_icon {
max-width: 20px;
max-height: 20px;
}
.replies_em {
max-height: 30px;
max-width: 30px;
}
.roleitem {
margin-left: 10px;
}
video {
max-height: 211px;
height: 211px;
background-color: black;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
}
audio {
max-width: 680px;
max-height: 350px;
}
.icon_s {
max-width: 30px;
max-height: 30px;
}
.clear {
height: 15px;
}
.site-icon {
width: 16px;
height: 16px;
}
.deep {
background: #E3EEF8;
border: 1px solid #9FC6EC;
border-left: none;
border-right: none;
}
.nick {
color: #0051a4;
font-size: 17px;
}
.ta-border {
font-size: 13px;
width: 98%;
height: 30px;
margin: 0 0 5px 0;
border: 1px solid #9FC6EC;
}
.user-info {
padding: 3px 5px;
}
.user-info a {
font-size: 13px;
padding-right: 1px;
}
.user-info img {
margin-right: 1px;
vertical-align: middle;
}
.user-title img {
margin-bottom: -5px;
}
textarea {
font-size: 13px;
width: 98%;
margin: 0 0 5px 0;
border: 1px solid #9FC6EC;
}
#footer {
padding: 5px;
background: #E3EEF8;
border-top: 1px solid #9FC6EC;
}
#footer a {
font-size: 17px;
color: #0051A4;
}
.ipt-txt {
height: 18px;
margin: 0 3px 0 0;
border: 1px solid #b1d5e5;
}
.ipt-s {
width: 40px;
}
.seperate {
margin: 0 2px;
}
.ipt-btn-gray-s {
width: 40px;
height: 20px;
border: none;
background: url(/css/images/home/btn_s_gray.gif) no-repeat;
}
.ipt-btn-gray-m {
width: 60px;
height: 20px;
border: none;
background: url(/css/images/home/btn_m_gray.gif) no-repeat;
}
.ipt-btn-gray-l {
width: 80px;
height: 20px;
border: none;
background: url(/css/images/home/btn_l_gray.gif) no-repeat;
}
.ipt-btn-gold-b {
width: 61px;
height: 21px;
font-size: 13px;
border: none;
background: url(/css/images/home/btn_b_gold.gif) no-repeat;
color: #af4c00;
margin-top: 5px;
}
.main-nav {
padding: 1px 0 0 12px;
background-color: #4c95e7;
}
.main-nav p {
height: 30px;
line-height: 30px;
}
.main-nav p a {
margin: 0 7px 0 0;
color: #fff;
}
.forum-title {
margin: 8px 0 2px;
padding: 0 5px;
height: 20px,auto;
line-height: 20px;
color: #000;
font-weight: bold;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
overflow: hidden;
}
.module-title {
margin: 9px 0 0px;
padding: 0 5px;
height: 20px;
line-height: 20px;
border-bottom: 4px solid #9FC6EC;
color: #000;
font-weight: bold;
padding-bottom: 3px;
}
.module-title a {
color: #0051A4;
}
.module-title span {
font-weight: normal;
/* font-size: 13px;
margin: 0 0 0 10px;*/
}
.module-title span a {
color: #0051A4;
}
.module-content {
line-height: 1.6;
padding: 3px 5px;
word-wrap: break-word;
}
.module-content a {
color: #0051A4;
}
.module-content img {
margin-right: 2px;
vertical-align: middle;
}
.list {
padding: 0 5px;
line-height: 1.3;
}
.module-page {
padding: 5px;
}
.crumb-nav {
height: 22px;
padding: 0 3px;
background: #71afe3 url(/css/images/home/bar.gif) repeat-x;
line-height: 22px;
color: #fff;
}
.crumb-nav a {
color: #fff;
}
.crumb-nav .current {
color: #98d2ff;
}
.bottom-crumb-nav {
padding: 0 5px;
border-top: 1px solid #eee;
line-height: 1.3;
}
.bottom-crumb-nav-sim {
padding: 0 5px;
line-height: 1.3;
}
.bottom-module {
padding: 5px;
line-height: 1.3;
}
.crumb-nav-large {
height: 25px;
padding: 0 5px;
background: #71afe3 url(/css/images/home/bar.gif) repeat-x;
line-height: 25px;
color: #fff;
}
.crumb-nav-large a {
color: #fff;
}
.crumb-nav-large .current {
color: #98d2ff;
}
.txt-fade {
color: #999;
font-size: 13px;
}
.txt-bold {
font-weight: bold;
}
.txt-slim {
font-weight: 300;
}
.txt-emphasis {
color: #B1761A;
}
.spacing-3 {
padding-top: 3px;
padding-bottom: 3px;
}
.spacing-5 {
padding-top: 5px;
padding-bottom: 5px;
}
.tab-5 {
padding-left: 5px;
padding-right: 5px;
}
.border-btm {
border-bottom: 1px solid #E3E6EB;
}
.tips {
background: #FFF2BD;
border-top: 1px solid #ffd56a;
border-bottom: 1px solid #ffd56a;
line-height: 1.5;
padding: 3px 5px;
color: #738698;
}
.tips p {
padding: 0 0 0 14px;
background: url(/css/images/home/bg_module_content_list_dot_01.gif) 4px 9px no-repeat;
}
.tips img {
padding: 0;
vertical-align: middle;
}
.login-tips {
background: #FFF9B7;
padding: 3px 5px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
line-height: 1.5;
}
.login-tips img {
margin-right: 2px;
vertical-align: middle;
}
.login-tips span {
margin-left: 14px;
}
.annc-border {
border-bottom: 1px solid #ccc;
}
.user-title {
margin-top: 5px;
padding: 5px;
font-weight: bold;
}
.user-stat {
padding: 5px;
background: #e4eff9;
line-height: 1.5;
}
.write-mood {
padding: 5px;
background: #e4eff9;
line-height: 1.5;
border-top: 1px solid #9FC6EC;
border-bottom: 1px solid #9FC6EC;
}
.tool-box {
background-color: #f0f0f0;
border-top: 1px solid #dedede;
border-bottom: 1px solid #dedede;
line-height: 1.3;
padding: 3px 5px;
color: #FFAA22;
}
.ipt-nick {
width: 120px;
}
.ipt-y {
width: 40px;
text-align: center;
}
.ipt-m, .ipt-d {
width: 20px;
text-align: center;
}
.ipt-intro {
width: 180px;
}
.msg_tail {
text-align: right;
}
.note {
background: #FFF9B7;
border-bottom: 1px solid #9FC6EC;
border-top: 1px solid #ffd56a;
line-height: 1.5;
padding: 3px 5px;
}
.note p {
padding: 0 0 0 14px;
background: url(/css/images/home/bg_module_content_list_dot_01.gif) 4px 9px no-repeat;
}
.note img {
padding: 0;
vertical-align: middle;
}
.imgBar60 {
width: 60px;
height: 60px;
}
.imgBarMaxHeight {
max-width: 100%;
max-height: 80px;
}
.guess-tag {
background: coral;
color: #fff;
display: inline-block;
margin-right: 5px;
padding: 4px;
height: initial;
vertical-align: 1px;
text-align: center;
font-size: 12px;
line-height: 10px;
}
.guess-m {
background-color: red;
color: #fff;
display: inline-block;
margin-right: 5px;
padding: 4px;
height: initial;
vertical-align: 1px;
text-align: center;
font-size: 12px;
line-height: 10px;
}
.guess-v {
background-color: dodgerblue;
color: #fff;
display: inline-block;
margin-right: 5px;
padding: 4px;
height: initial;
vertical-align: 1px;
text-align: center;
font-size: 12px;
line-height: 10px;
}
.conter {
width: 100%;
height: 350px;
border: 1px solid #000;
margin: 0px auto;
padding: 0px;
padding-bottom: 30px;
}
.conter h1 {
height: 20px;
font-size: 12px;
background: #CC6600;
line-height: 20px;
text-indent: 5px;
margin-top: 0px;
}
.conter iframe {
width: 100%;
height: 100%;
border: 0;
}
.redBox {
background: url('/css/images/home/unit/bao.jpg') no-repeat;
width: 180px;
height: 65px;
display: inline-block;
}
.redBox_title {
position: relative;
top: 3px;
left: 40px;
font-size: 12px;
color: white
}
.redBox_tips {
position: relative;
top: -3px;
left: 40px;
font-size: 12px;
color: white
}

View File

@@ -97,7 +97,9 @@ a:focus {
margin-right: 2px;
vertical-align: middle;
}
.border-btm {
border-bottom: 1px solid #E3E6EB;
}
.input {
line-height: 30px;
}

View File

@@ -9,4 +9,5 @@ export class LocalStorageHelper {
LocalStorageExtend.Set(this.key, npcId);
}
}

View File

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

View File

@@ -1,3 +1,115 @@
<template>
<div class="content">
商城<br>
金元:{{ gold }}<br>
金贝:{{ cowry }}<br>
</div>
<div class="content">
<Acheak @click="Change('0')" :on-value="type" on-cheak="0">金贝</Acheak> |
<Acheak @click="Change('1')" :on-value="type" on-cheak="1">金元</Acheak>
</div>
<div class="content">
<div class="common">名称|价格</div>
<div class="item" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/prop/equ?id=" + item.parameter' v-if="item.type == 'Equ'">
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
<Abar :href='"/prop/goods?id=" + item.parameter' v-else>
{{ item.name }}({{ GameTool.GetCurrencyNameAll(item.price, item.payType) }})</Abar>
[<Abutton @click="ShopView(item)">购买</Abutton>]
</div>
</div>
<div class="content">
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</div>
<!-- 购买 -->
<GamePopup v-model:show="showBuy" title="【购买】">
<!-- 自定义内容 -->
<div class="common">
物品名称{{ showGoods.name }}<br>
购买价格{{ GameTool.GetCurrencyNameAll(showGoods.price, showGoods.payType) }}<br>
</div>
<div class="common" style="text-align: center;">
购买数量<input type="number" class="search-ipt" v-model="count"><br>
<button class="ipt-btn" name="serch" @click="ShopOk" style="margin-top: 15px;">确认</button>
</div>
</GamePopup>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const type = ref('0');
const gold = ref(0);
const cowry = ref(0);
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
const showBuy = ref(false);
const showGoods = ref<any>({});
const count = ref(1);
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await MallService.GetMall(type.value, currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
gold.value = result.data.gold;
cowry.value = result.data.cowry;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
const Change = async (_type: string): Promise<void> => {
currentPage.value = 1;
type.value = _type;
await BindData();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
//购买
const ShopView = (info: any) => {
showGoods.value = info;
showBuy.value = true;
count.value = 1;
}
const ShopOk = async (): Promise<void> => {
if (count.value < 1 || count.value > 99) {
MessageExtend.ShowToast("每次购买数量在1~99哦.");
return;
}
MessageExtend.LoadingToast("购买中...");
let result = await MallService.Buy(showGoods.value.mallId, count.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
showBuy.value = false;
MessageExtend.Notify(`成功购买${showGoods.value.name}×${count.value}`, "success");
await BindData();
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
</script>

View File

@@ -6,7 +6,7 @@
{{ cityInfo.cityName }}·{{ mapInfo.mapName }}
<Abutton @click="Refresh">刷新</Abutton>
<Abar href="/task/">任务</Abar>
<Abar href="/message/">消息</Abar>
<Abar href="/message/">消息{{ messageCount > 0 ? "(" + messageCount + ")" : "" }}</Abar>
</div>
<div class="notification">
@@ -20,7 +20,7 @@
</div>
<div class="content">
<div class="item" v-for="item in npcData">
<Abar :href='"/npc?npc="+item.npcId'>{{ item.npcName }}{{ item.tips }}</Abar>
<Abar :href='"/npc?npc=" + item.npcId'>{{ item.npcName }}{{ item.tips }}</Abar>
</div>
</div>
@@ -91,8 +91,9 @@ const npcData = ref<Array<any>>([]);
const chatData = ref<Array<any>>([]);
const cityShow = ref<Array<any>>([]);
const mapUser = ref<Array<any>>([]);
const messageCount = ref(0);
// 城内地图显示
const showCity = ref(false)
const showCity = ref(false);
onMounted(async () => {
try {
@@ -113,6 +114,7 @@ const BindData = async (map: string): Promise<void> => {
chatData.value = result.data.chatData;
cityShow.value = result.data.cityShow;
mapUser.value = result.data.nearUser;
messageCount.value = result.data.noReadMsg;
MapVent(result.data.mapInfo.near);
onMap.value = mapInfo.value.mapId;
console.log(result.data);

View File

@@ -1 +1,87 @@
<template></template>
<template>
<div class="crumb-nav-large">
游戏消息
</div>
<div class="module-title">
<Acheak @click="Change('0')" :on-value="type" on-cheak="0">未读</Acheak>|
<Acheak @click="Change('1')" :on-value="type" on-cheak="1">已读</Acheak>|
<Acheak @click="Change('2')" :on-value="type" on-cheak="2">通知</Acheak>|
<Acheak @click="Change('3')" :on-value="type" on-cheak="3">邮件</Acheak>
</div>
<div class="module-content">
<div class="item border-btm" v-for="(item, index) in data" :key="index">
{{ PageExtend.GetPageIndex(currentPage, 10, index + 1) }}.
<Abar :href='"/message/read?id=" + item.user.userNo'>
{{ item.user.nick }}:{{ item.sign }}</Abar>
[<Abutton @click="delTlak(item.user.userNo)">×</Abutton>]
</div>
<span v-if="data.length == 0">暂无消息.</span>
</div>
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const type = ref('0');
const currentPage = ref<number>(1);
const total = ref<number>(0);
const data = ref<Array<any>>([]);
onMounted(async () => {
try {
let local_type = LocalStorageExtend.Get<string>("MsgType");
if (local_type == null || local_type == '') {
LocalStorageExtend.Set("MsgType", type.value);
}
else {
type.value = local_type;
}
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let result = await MessageService.GetMessageData(Number(type.value), 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 Change = async (_type: string): Promise<void> => {
currentPage.value = 1;
type.value = _type;
LocalStorageExtend.Set("MsgType", type.value);
await BindData();
}
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
const delTlak = async (no: number): Promise<void> => {
MessageExtend.LoadingToast("删除中...");
let result = await MessageService.DeleteMsg(no);
MessageExtend.LoadingClose();
if (result.code == 0) {
MessageExtend.Notify("删除成功!", "success");
await BindData();
PageExtend.ScrollToTop();
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
}
</script>

View File

@@ -0,0 +1,60 @@
<template>
<div class="module-title">
消息记录
</div>
<div class="module-content">
<div class="border-btm tab-5 spacing-3" v-for="item in data">
<span v-if="item.sendId == '0'">海精灵:</span>
<span v-else-if="myId == item.sendId">:</span>
<span v-else>
<Abar :href='"/user/user?no=" + user.userNo'>{{ user.nick }}</Abar>:
</span>
<span class="item">
{{ item.sign }}
</span>
<small>[{{ TimeExtend.Format(item.addTime, "yyyy-MM-dd HH:mm:ss") }}]</small><br />
</div>
</div>
<Pagination :currentPage="currentPage" :limit="10" :total="total" @pageChange="handlePageChange" />
</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>>([]);
const user = ref<any>({});
const myId = StateHelper.userId;
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let no = PageExtend.QueryString("no");
let result = await MessageService.MessageLog(Number(no), currentPage.value);
if (result.code == 0) {
data.value = result.data.data;
total.value = result.data.total;
user.value = result.data.user;
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
};
/**翻页 */
const handlePageChange = async (page: number): Promise<void> => {
currentPage.value = page;
await BindData();
};
</script>

View File

@@ -0,0 +1,114 @@
<template>
<div class="crumb-nav-large">
<Abar href="/message">我的消息</Abar>&gt;发送消息
</div>
<div class="module-title" v-if="user.userNo != '0'">
<Abar :href='"/user/user?no=" + user.userNo'>{{ user.nick }}</Abar> ({{ user.userNo }})
</div>
<div class="module-title" v-else>
系统消息
</div>
<div class="module-content">
<div class="tab-5 spacing-3" v-for="item in data">
<span class="data_detail">
{{ item.sign }}</span><br />
<small>[{{ TimeExtend.Format(item.addTime, "yyyy-MM-dd HH:mm:ss") }}]</small><br />
</div>
</div>
<div class="module-content" v-if="user.userNo != '0'">
<input name="u" type="hidden" value="931212" />
<div class="module-content">
<textarea name="content" id="content" class="ta-border emojiTxt" rows="2" maxlength="100"
v-model="msg"></textarea>
</div>
<Abutton @click="Refresh" style="float: left;">刷新</Abutton>
<button class="ipt-btn-gold-b" style="float:right" @click="SendMsg">发送</button>
</div>
<div class="module-title" style="margin-top:35px">消息记录</div>
<div class="module-content">
<div class="border-btm tab-5 spacing-3" v-for="item in logs">
<span v-if="item.sendId == '0'">海精灵:</span>
<span v-else-if="myId == item.sendId">:</span>
<span v-else>
<Abar :href='"/user/user?no=" + user.userNo'>{{ user.nick }}</Abar>:
</span>
<span class="item">
{{ item.sign }}
</span>
<small>[{{ TimeExtend.Format(item.addTime, "yyyy-MM-dd HH:mm:ss") }}]</small><br />
</div>
<Abar :href='"/message/log?no="+user.userNo' v-if="logs.length > 0">查看记录&gt;&gt;</Abar>
</div>
</template>
<script setup lang="ts">
definePageMeta({
layout: layout.default,
middleware: 'page-loading'
})
const data = ref<Array<any>>([]);
const user = ref<any>({});
const logs = ref<Array<any>>([]);
const msg = ref('');
const myId = StateHelper.userId;
onMounted(async () => {
try {
await BindData();
}
finally {
PageLoading.Close();
}
})
const BindData = async (): Promise<void> => {
let no = PageExtend.QueryString("id");
let result = await MessageService.GetReadInfo(Number(no));
if (result.code == 0) {
data.value = result.data.data;
user.value = result.data.user;
logs.value = result.data.logs;
console.log(result);
}
else {
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
return PageExtend.Redirect("/message");
}, "确认");
}
};
/**发送消息 */
const SendMsg = async (): Promise<void> => {
if (msg.value == null || msg.value == '') {
MessageExtend.ShowToast("发送内容不能为空!");
return;
}
MessageExtend.LoadingToast("发送中...");
let no = PageExtend.QueryString("id");
let result = await MessageService.SendMsg(Number(no), msg.value);
MessageExtend.LoadingClose();
if (result.code == 0) {
MessageExtend.Notify("发送成功!", "success");
msg.value = '';
await BindData();
PageExtend.ScrollToTop();
}
else if (result.code == 100) {
MessageExtend.ShowDialogEvent("提示", result.msg, () => {
return PageExtend.Redirect("/message");
}, "确认");
}
else {
MessageExtend.ShowDialog("提示", result.msg);
}
}
/**刷新 */
const Refresh = async (): Promise<void> => {
MessageExtend.LoadingToast("刷新中...");
await BindData();
MessageExtend.LoadingClose();
}
</script>

View File

@@ -1,6 +1,6 @@
<template>
<div class="content">
<Abar>私聊</Abar>. <Abar>送礼物</Abar>. <Abar>逗一下</Abar><br />
<Abar :href='"/message/read?id=" + userData.userNo'>私聊</Abar>. <Abar>送礼物</Abar>. <Abar>逗一下</Abar><br />
<Abar>拜师</Abar>. <Abar>山寨</Abar>. <Abar>送道具</Abar><br>
<Abar>加好友</Abar>. <Abar>加仇人</Abar>
</div>

View File

@@ -0,0 +1,19 @@
export class MallService {
/**
* 获取商城列表
* GET /Mall/GetMall
*/
static async GetMall(type: string, page: number) {
return await ApiService.Request("get", "/Mall/GetMall", { type, page });
}
/**
* 购买物品
* POST /Mall/Buy
* @param id body
* @param count body
*/
static async Buy(id: string, count: number) {
return await ApiService.Request("post", "/Mall/Buy", { id, count });
}
}

View File

@@ -0,0 +1,43 @@
export class MessageService {
/**
* 获取消息
* GET /Message/GetMessageData
*/
static async GetMessageData(type: number, page: number) {
return await ApiService.Request("get", "/Message/GetMessageData", { type, page });
}
/**
* 获取消息界面
* GET /Message/GetReadInfo
*/
static async GetReadInfo(no: number) {
return await ApiService.Request("get", "/Message/GetReadInfo", { no });
}
/**
* 发送消息
* POST /Message/SendMsg
* @param no body
* @param sign body
*/
static async SendMsg(no: number, sign: string) {
return await ApiService.Request("post", "/Message/SendMsg", { no, sign });
}
/**
* 聊天记录
* GET /Message/MessageLog
*/
static async MessageLog(no: number, page: number) {
return await ApiService.Request("get", "/Message/MessageLog", { no, page });
}
/**
* 删除对话
* GET /Message/DeleteMsg
*/
static async DeleteMsg(no: number) {
return await ApiService.Request("get", "/Message/DeleteMsg", { no });
}
}