站内消息页面显示功能完成
This commit is contained in:
parent
15a0261edd
commit
c886277c63
|
@ -16,7 +16,17 @@ namespace Bootstrap.Admin.Controllers
|
|||
public IEnumerable<Message> Get(string id)
|
||||
{
|
||||
var ret = new List<Message>();
|
||||
if (id == "inbox") ret = MessageHelper.Inbox(User.Identity.Name).ToList();
|
||||
switch(id)
|
||||
{
|
||||
case "inbox": ret = MessageHelper.Inbox(User.Identity.Name).ToList();
|
||||
break;
|
||||
case "sendmail": ret = MessageHelper.SendMail(User.Identity.Name).ToList();
|
||||
break;
|
||||
case "mark": ret = MessageHelper.Mark(User.Identity.Name).ToList();
|
||||
break;
|
||||
case "trash": ret = MessageHelper.Trash(User.Identity.Name).ToList();
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,32 @@
|
|||
$(function () {
|
||||
var html = '<tr><td class="inbox-small-cells"><input type="checkbox" class="mail-checkbox"></td><td class="inbox-small-cells"><i class="fa fa-star"></i></td><td class="view-message dont-show">{0}</td><td class="view-message dont-show">{1}</td><td class="view-message ">{2}</td><td class="view-message text-right">{3}</td></tr>';
|
||||
var html = '<tr {0}><td class="inbox-small-cells"><input type="checkbox" class="mail-checkbox"></td><td class="inbox-small-cells"><i class="fa fa-star {1}"></i></td><td class="view-message dont-show">{2}</td><td class="view-message dont-show">{3}</td><td class="view-message ">{4}</td><td class="view-message text-right">{5}</td></tr>';
|
||||
|
||||
function listData(options) {
|
||||
|
||||
function listData() {
|
||||
$.bc({
|
||||
Id: 'inbox', url: Messages.url, method: 'GET', swal: false,
|
||||
Id: options.Id, url: Messages.url, method: 'GET', swal: false,
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
var content = result.map(function (mail) {
|
||||
return $.format(html, mail.FromDisplayName, mail.Title, mail.Content, mail.SendTime);
|
||||
if (mail.Status == '0')
|
||||
mailStatus = 'class="unread"';
|
||||
else
|
||||
mailStatus = " "
|
||||
if (mail.Mark == '1')
|
||||
mailMark = "inbox-started";
|
||||
else
|
||||
mailMark = " ";
|
||||
return $.format(html, mailStatus, mailMark, mail.FromDisplayName, mail.Title, mail.Content, mail.SendTime);
|
||||
}).join('');
|
||||
$('#tbMsg').html(content);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
listData();
|
||||
|
||||
listData({ Id: 'inbox' });
|
||||
|
||||
$('#mailBox').on('click', 'a', function () {
|
||||
listData({ Id: $(this).attr('data-id') });
|
||||
})
|
||||
});
|
|
@ -25,18 +25,18 @@
|
|||
写消息
|
||||
</a>
|
||||
</div>
|
||||
<ul class="inbox-nav inbox-divider">
|
||||
<ul id="mailBox" class="inbox-nav inbox-divider">
|
||||
<li class="active">
|
||||
<a href="~/Admin/Messages/Inbox"><i class="fa fa-inbox"></i>收信箱<span class="label label-danger pull-right">2</span></a>
|
||||
<a href="#" data-id="inbox"><i class="fa fa-inbox"></i>收信箱<span class="label label-danger pull-right">2</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Messages/SendMail"><i class="fa fa-envelope-o"></i>发信箱</a>
|
||||
<a href="#" data-id="sendmail"><i class="fa fa-envelope-o"></i>发信箱</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Messages/Mark"><i class="fa fa-bookmark-o"></i>标旗消息</a>
|
||||
<a href="#" data-id="mark"><i class="fa fa-bookmark-o"></i>标旗消息</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="~/Admin/Messages/Trash"><i class=" fa fa-trash-o"></i>垃圾箱</a>
|
||||
<a href="#" data-id="trash"><i class=" fa fa-trash-o"></i>垃圾箱</a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
|
||||
{
|
||||
string sql = "select m.*, d.Name, isnull(i.Code + u.Icon, '~/Content/images/uploader/default.jpg'), u.DisplayName from[Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息状态' and d.Define = 0 left join Dicts i on i.Category = N'头像地址' and i.Name = N'头像路径' and i.Define = 0 inner join Users u on m.[From] = u.UserName where [To] = @UserName or [From] = @UserName";
|
||||
string sql = "select m.*, d.Name, isnull(i.Code + u.Icon, '~/Content/images/uploader/default.jpg'), u.DisplayName from[Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息标签' and d.Define = 0 left join Dicts i on i.Category = N'头像地址' and i.Name = N'头像路径' and i.Define = 0 inner join Users u on m.[From] = u.UserName where [To] = @UserName or [From] = @UserName";
|
||||
List<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue