From c218fb812e723ec9caa8011d358796eddd46bf6e Mon Sep 17 00:00:00 2001 From: "liuchun_0206@163.com" Date: Sat, 19 Nov 2016 14:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E5=86=85=E6=B6=88=E6=81=AF=E5=AE=8C?= =?UTF-8?q?=E5=96=84=EF=BC=9A=E5=A2=9E=E5=8A=A0=E6=A0=87=E7=AD=BE=E5=92=8C?= =?UTF-8?q?=E6=94=B6=E4=BB=B6=E7=AE=B1=E7=AD=89=E5=A4=84=20=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=95=B0=E9=87=8F=E7=9A=84=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Bootstrap.Admin.csproj | 1 + .../Controllers/MessagesController.cs | 28 +++++++++++++++---- Bootstrap.Admin/Models/MessageCountModel.cs | 15 ++++++++++ Bootstrap.Admin/Scripts/message.js | 24 ++++++++++++++-- Bootstrap.Admin/Views/Admin/Messages.cshtml | 8 +++--- 5 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 Bootstrap.Admin/Models/MessageCountModel.cs diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index a03282c9..cd440b69 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -262,6 +262,7 @@ + diff --git a/Bootstrap.Admin/Controllers/MessagesController.cs b/Bootstrap.Admin/Controllers/MessagesController.cs index 16bed46e..b3536fc1 100644 --- a/Bootstrap.Admin/Controllers/MessagesController.cs +++ b/Bootstrap.Admin/Controllers/MessagesController.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 { /// - /// + /// 根据Id返回不同的消息列表 /// /// /// @@ -16,8 +18,8 @@ namespace Bootstrap.Admin.Controllers public IEnumerable Get(string id) { var ret = new List(); - 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; } + + /// + /// 返回各个消息列表的文件个数 + /// + /// + /// + [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; + } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/MessageCountModel.cs b/Bootstrap.Admin/Models/MessageCountModel.cs new file mode 100644 index 00000000..24f1c628 --- /dev/null +++ b/Bootstrap.Admin/Models/MessageCountModel.cs @@ -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; } + } +} \ No newline at end of file diff --git a/Bootstrap.Admin/Scripts/message.js b/Bootstrap.Admin/Scripts/message.js index 2c57e163..1311acaf 100644 --- a/Bootstrap.Admin/Scripts/message.js +++ b/Bootstrap.Admin/Scripts/message.js @@ -1,5 +1,20 @@ $(function () { - var html = '{2}{3}{4}{5}'; + + 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 = '{2}{4}{5}{6}{7}'; 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') }); diff --git a/Bootstrap.Admin/Views/Admin/Messages.cshtml b/Bootstrap.Admin/Views/Admin/Messages.cshtml index 5e084206..4821dd6c 100644 --- a/Bootstrap.Admin/Views/Admin/Messages.cshtml +++ b/Bootstrap.Admin/Views/Admin/Messages.cshtml @@ -27,16 +27,16 @@