站内消息完善:增加标签和收件箱等处 消息数量的绑定
This commit is contained in:
parent
a845699333
commit
c218fb812e
|
@ -262,6 +262,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Models\ContentModel.cs" />
|
||||
<Compile Include="Models\LockModel.cs" />
|
||||
<Compile Include="Models\MessageCountModel.cs" />
|
||||
<Compile Include="Models\QueryDictOption.cs" />
|
||||
<Compile Include="Models\QueryExceptionOption.cs" />
|
||||
<Compile Include="Models\QueryGroupOption.cs" />
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Admin.Models;
|
||||
using Bootstrap.DataAccess;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
|
||||
|
||||
namespace Bootstrap.Admin.Controllers
|
||||
{
|
||||
public class MessagesController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 根据Id返回不同的消息列表
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -16,8 +18,8 @@ namespace Bootstrap.Admin.Controllers
|
|||
public IEnumerable<Message> Get(string id)
|
||||
{
|
||||
var ret = new List<Message>();
|
||||
switch(id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case "inbox": ret = MessageHelper.Inbox(User.Identity.Name).ToList();
|
||||
break;
|
||||
case "sendmail": ret = MessageHelper.SendMail(User.Identity.Name).ToList();
|
||||
|
@ -26,8 +28,24 @@ namespace Bootstrap.Admin.Controllers
|
|||
break;
|
||||
case "trash": ret = MessageHelper.Trash(User.Identity.Name).ToList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回各个消息列表的文件个数
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public MessageCountModel Get()
|
||||
{
|
||||
MessageCountModel mcm = new MessageCountModel();
|
||||
mcm.inboxCount = MessageHelper.Inbox(User.Identity.Name).Count();
|
||||
mcm.sendmailCount = MessageHelper.SendMail(User.Identity.Name).Count();
|
||||
mcm.markCount = MessageHelper.Mark(User.Identity.Name).Count();
|
||||
mcm.trashCount = MessageHelper.Trash(User.Identity.Name).Count();
|
||||
return mcm;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Bootstrap.Admin.Models
|
||||
{
|
||||
public class MessageCountModel
|
||||
{
|
||||
public int inboxCount { get; set; }
|
||||
public int sendmailCount { get; set; }
|
||||
public int markCount { get; set; }
|
||||
public int trashCount { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,5 +1,20 @@
|
|||
$(function () {
|
||||
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 loadData() {
|
||||
$.bc({
|
||||
url: Messages.url, method: 'GET', swal: false,
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
$('#s_inbox').text(result.inboxCount);
|
||||
$('#s_sendmail').text(result.sendmailCount);
|
||||
$('#s_mark').text(result.markCount);
|
||||
$('#s_trash').text(result.trashCount);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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}<span class="label {3} pull-right">{4}</span></td><td class="view-message dont-show">{5}</td><td class="view-message ">{6}</td><td class="view-message text-right">{7}</td></tr>';
|
||||
|
||||
function listData(options) {
|
||||
|
||||
|
@ -16,7 +31,11 @@
|
|||
mailMark = "inbox-started";
|
||||
else
|
||||
mailMark = " ";
|
||||
return $.format(html, mailStatus, mailMark, mail.FromDisplayName, mail.Title, mail.Content, mail.SendTime);
|
||||
if (mail.Label == '0')
|
||||
mailLabel = 'label-success';
|
||||
else
|
||||
mailLabel = 'label-warning';
|
||||
return $.format(html, mailStatus, mailMark, mail.FromDisplayName, mailLabel, mail.LabelName, mail.Title, mail.Content, mail.SendTime);
|
||||
}).join('');
|
||||
$('#tbMsg').html(content);
|
||||
}
|
||||
|
@ -25,6 +44,7 @@
|
|||
}
|
||||
|
||||
listData({ Id: 'inbox' });
|
||||
loadData();
|
||||
|
||||
$('#mailBox').on('click', 'a', function () {
|
||||
listData({ Id: $(this).attr('data-id') });
|
||||
|
|
|
@ -27,16 +27,16 @@
|
|||
</div>
|
||||
<ul id="mailBox" class="inbox-nav inbox-divider">
|
||||
<li class="active">
|
||||
<a href="#" data-id="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" id="s_inbox"></span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-id="sendmail"><i class="fa fa-envelope-o"></i>发信箱</a>
|
||||
<a href="#" data-id="sendmail"><i class="fa fa-envelope-o"></i>发信箱<span class="label label-danger pull-right" id="s_sendmail"></span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-id="mark"><i class="fa fa-bookmark-o"></i>标旗消息</a>
|
||||
<a href="#" data-id="mark"><i class="fa fa-bookmark-o"></i>标旗消息<span class="label label-danger pull-right" id="s_mark"></span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" data-id="trash"><i class=" fa fa-trash-o"></i>垃圾箱</a>
|
||||
<a href="#" data-id="trash"><i class=" fa fa-trash-o"></i>垃圾箱<span class="label label-danger pull-right" id="s_trash"></span></a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
|
Loading…
Reference in New Issue