站内消息完善:增加标签和收件箱等处 消息数量的绑定

This commit is contained in:
liuchun_0206@163.com 2016-11-19 14:20:25 +08:00
parent a845699333
commit c218fb812e
5 changed files with 65 additions and 11 deletions

View File

@ -262,6 +262,7 @@
</Compile> </Compile>
<Compile Include="Models\ContentModel.cs" /> <Compile Include="Models\ContentModel.cs" />
<Compile Include="Models\LockModel.cs" /> <Compile Include="Models\LockModel.cs" />
<Compile Include="Models\MessageCountModel.cs" />
<Compile Include="Models\QueryDictOption.cs" /> <Compile Include="Models\QueryDictOption.cs" />
<Compile Include="Models\QueryExceptionOption.cs" /> <Compile Include="Models\QueryExceptionOption.cs" />
<Compile Include="Models\QueryGroupOption.cs" /> <Compile Include="Models\QueryGroupOption.cs" />

View File

@ -1,14 +1,16 @@
using Bootstrap.DataAccess; using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web.Http; using System.Web.Http;
namespace Bootstrap.Admin.Controllers namespace Bootstrap.Admin.Controllers
{ {
public class MessagesController : ApiController public class MessagesController : ApiController
{ {
/// <summary> /// <summary>
/// /// 根据Id返回不同的消息列表
/// </summary> /// </summary>
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
@ -16,7 +18,7 @@ namespace Bootstrap.Admin.Controllers
public IEnumerable<Message> Get(string id) public IEnumerable<Message> Get(string id)
{ {
var ret = new List<Message>(); var ret = new List<Message>();
switch(id) switch (id)
{ {
case "inbox": ret = MessageHelper.Inbox(User.Identity.Name).ToList(); case "inbox": ret = MessageHelper.Inbox(User.Identity.Name).ToList();
break; break;
@ -26,8 +28,24 @@ namespace Bootstrap.Admin.Controllers
break; break;
case "trash": ret = MessageHelper.Trash(User.Identity.Name).ToList(); case "trash": ret = MessageHelper.Trash(User.Identity.Name).ToList();
break; break;
} }
return ret; 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;
}
} }
} }

View File

@ -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; }
}
}

View File

@ -1,5 +1,20 @@
$(function () { $(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) { function listData(options) {
@ -16,7 +31,11 @@
mailMark = "inbox-started"; mailMark = "inbox-started";
else else
mailMark = " "; 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(''); }).join('');
$('#tbMsg').html(content); $('#tbMsg').html(content);
} }
@ -25,6 +44,7 @@
} }
listData({ Id: 'inbox' }); listData({ Id: 'inbox' });
loadData();
$('#mailBox').on('click', 'a', function () { $('#mailBox').on('click', 'a', function () {
listData({ Id: $(this).attr('data-id') }); listData({ Id: $(this).attr('data-id') });

View File

@ -27,16 +27,16 @@
</div> </div>
<ul id="mailBox" class="inbox-nav inbox-divider"> <ul id="mailBox" class="inbox-nav inbox-divider">
<li class="active"> <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>
<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>
<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>
<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> </li>
</ul> </ul>
</aside> </aside>