This commit is contained in:
2018-12-02 01:20:33 +08:00
parent c88e2b19c6
commit 69c3133e4c
9 changed files with 3830 additions and 608 deletions
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using COMCMS.Common;
using COMCMS.Core;
using COMCMS.Core.Models;
using COMCMS.Web.Common;
using XCode;
namespace COMCMS.Web.Controllers
{
/// <summary>
/// 服务端处理
/// </summary>
public class ServerController : HomeBaseController
{
#region 提交前台底部留言
[HttpPost]
[AutoValidateAntiforgeryToken]
public IActionResult DoPostMessage(string name,string phone,string content)
{
if (string.IsNullOrWhiteSpace(name))
{
tip.Message = "请填写您的姓名!";
return Json(tip);
}
if (!Utils.IsTel(phone))
{
tip.Message = "请填写正确的手机号码!";
return Json(tip);
}
if (string.IsNullOrWhiteSpace(content))
{
tip.Message = "请填写您的留言内容!";
return Json(tip);
}
Guestbook entity = new Guestbook()
{
AddTime = DateTime.Now,
IP = Utils.GetIP(),
KId = 1,
Nickname = name,
Content = Utils.NoHTML(content),
Tel = phone
};
entity.Insert();
tip.Message = "留言成功,感谢您的留言!";
tip.Status = JsonTip.SUCCESS;
return Json(tip);
}
#endregion
}
}
+1 -1
View File
@@ -103,7 +103,7 @@ namespace COMCMS.Web
{
app.Use(async (context, next) =>
{
context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
//context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
await next();
});
@@ -5,7 +5,8 @@
ViewBag.description = Model.Description;
IList<Article> alist = Article.FindAll(Article._.KId == Model.KId, Article._.Sequence.Asc(), null, 0, 0);
int topkid = ViewBag.kind.PId > 0 ? ViewBag.kind.PId : ViewBag.kind.Id;
//获取同级分类
IList<ArticleCategory> sameList = ArticleCategory.FindAll(ArticleCategory._.PId == ViewBag.kind.PId, ArticleCategory._.Rank.Asc(), null, 0, 0);
}
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=VR85PcmdMnsofqPUCk6bD4ay"></script>
<div class="banner normal sec-banner">
@@ -15,9 +16,9 @@
<div class="sec-nav">
<div class="cont">
<ul class="sec-nav-list">
@foreach (Article a in alist)
@foreach (var k in sameList)
{
<li class="@(a.Id == Model.Id?"sec-on":"")"><a asp-controller="Article" asp-action="Detail" asp-route-id="@(a.Id)" title="@a.Title">@a.Title</a></li>
<li class="@(k.Id == Model.KId?"sec-on":"")"><a asp-controller="Article" asp-action="Index" asp-route-id="@(k.Id)" title="@k.KindName">@k.KindName</a></li>
}
</ul>
@@ -104,5 +105,6 @@
<script>
$(function () {
$("#nav_@(topkid)").addClass("nav-on");
map();
})
</script>
@@ -0,0 +1,66 @@
@model COMCMS.Core.ArticleCategory
@{
ViewBag.title = Model.KindName;
ViewBag.keywords = Model.Keyword;
ViewBag.description = Model.Description;
//获取同级分类
IList<ArticleCategory> sameList = ArticleCategory.FindAll(ArticleCategory._.PId == Model.PId, ArticleCategory._.Rank.Asc(), null, 0, 0);
int topkid = Model.PId > 0 ? Model.PId : Model.Id;
}
<div class="banner normal sec-banner">
<em style="background: url('/images/default/slide-1.jpg') center top no-repeat; background-size: 100%;"></em>
</div>
@if (Model.PId > 0)
{
<div class="sec-nav">
<div class="cont">
<ul class="sec-nav-list">
@foreach (var k in sameList)
{
<li class="@(k.Id == Model.Id?"sec-on":"")"><a asp-controller="Article" asp-action="Index" asp-route-id="@(k.Id)" title="@k.KindName">@k.KindName</a></li>
}
</ul>
<script type="text/javascript">
function mbSecNav() {
var num = $('.sec-nav-list li').length;
if (num >= 3) {
$('.sec-nav-list li').css({ 'width': (640 / 3 / 100) + 'rem' });
} else if (num == 2) {
$('.sec-nav-list li').css({ 'width': (640 / 2 / 100) + 'rem' });
} else if (num == 1) {
$('.sec-nav-list li').css({ 'width': (213 / 100) + 'rem' });
}
}
</script>
</div>
</div>
}
<!-- 主体内容 -->
<div class="content msg au">
<div class="cu-bg">
<div class="cont">
<div class="msg-box">
<div class="msg-title">
<span>在线留言</span>
</div>
<form class="msg-form" id="msgForm" onsubmit="return doPostMessage();">
<p><label class="normal">姓 名:</label><input type="text" name="name_txt" id="name_txt" value="" placeholder="姓 名:"></p>
<p><label class="normal">联系电话:</label><input type="text" name="tel_txt" id="tel_txt" value="" placeholder="联系电话:"></p>
<p class="msg-ta"><label class="normal">留言内容:</label><textarea name="content_txt" id="content_txt" rows="8" cols="80" placeholder="留言内容:"></textarea></p>
<p><button type="submit">提交留言</button></p>
</form>
</div>
</div>
</div>
</div>
<script>
$(function () {
$("#nav_@(topkid)").addClass("nav-on");
})
</script>
+7 -5
View File
@@ -12,6 +12,8 @@
<link href="~/images/default/style.css" rel="stylesheet" />
<script src="~/js/html5shiv.min.js"></script>
<script src="~/js/jquery2.min.js"></script>
<script src="~/js/layer/layer.js"></script>
<script src="~/js/jquery.form.js"></script>
<script src="~/js/swpier/swiper.min.js"></script>
<script src="~/js/public.js"></script>
</head>
@@ -150,11 +152,11 @@
<!-- 底部在线留言 -->
<div class="foot-msg">
<span>在线留言</span>
<form class="foot-msg-box" id="msgFormFooter" onsubmit="return PostMsgFooter();">
<p><input type="text" name="name" id="name" value="" placeholder="姓名"></p>
<p><input type="text" name="phone" id="phone" value="" placeholder="电话"></p>
<p class="f-ta"><textarea name="intro" id="intro" rows="8" cols="80" placeholder="留言内容"></textarea></p>
<p><button type="submit" name="submit" id="submit">提 交</button></p>
<form class="foot-msg-box" id="footerMessageForm" name="footerMessageForm" onsubmit="return doPostFooterMessage();" asp-antiforgery="true">
<p><input type="text" name="name" id="name" value="" placeholder="姓名" required></p>
<p><input type="text" name="phone" id="phone" value="" placeholder="电话" required></p>
<p class="f-ta"><textarea name="content" id="content" rows="8" cols="80" placeholder="留言内容" required></textarea></p>
<p><button type="submit">提 交</button></p>
</form>
</div>
<!-- 底部导航栏 PC版下显示-->
Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 KiB

File diff suppressed because it is too large Load Diff
+94 -21
View File
@@ -485,25 +485,98 @@ $(function () {
});
})
function doPostFooterMessage() {
var name = $("#name").val();
var phone = $("#phone").val();
var content = $("#content").val();
if (!name) {
alert('请输入您的姓名!');
return false;
}
if (!phone) {
alert('请输入您的电话号码!');
return false;
}
if (!content) {
alert('请填写您的留言内容!');
return false;
}
var strQueryString = $("#footerMessageForm").formSerialize();
var loading = layer.load(0, { shade: [0.2, '#000'] });
$.ajax({
type: "POST",
url: "/Server/DoPostMessage",
data: strQueryString,
dataType: "JSON",
success: function (data) {
layer.close(loading);
if (data.status == "success") {
layer.msg(data.message, {
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
window.location.href = window.location.href;
});
}
else {
alert(data.message);
}
},
error: function () {
console.log('执行出错!');
layer.close(loading);
alert('执行错误,请联系管理员!');
}
});
return false;
}
function doPostMessage() {
var name = $("#name_txt").val();
var phone = $("#phone_txt").val();
var content = $("#content_txt").val();
var __RequestVerificationToken = $("intput[name='__RequestVerificationToken']").val();
if (!name) {
alert('请输入您的姓名!');
return false;
}
if (!phone) {
alert('请输入您的电话号码!');
return false;
}
if (!content) {
alert('请填写您的留言内容!');
return false;
}
var postData = {
name: name,
phone: phone,
content: content,
__RequestVerificationToken: __RequestVerificationToken
};
var loading = layer.load(0, { shade: [0.2, '#000'] });
$.ajax({
type: "POST",
url: "/Server/DoPostMessage",
data: postData,
dataType: "JSON",
success: function (data) {
layer.close(loading);
if (data.status == "success") {
layer.msg(data.message, {
time: 2000 //2秒关闭(如果不配置,默认是3秒)
}, function () {
window.location.href = window.location.href;
});
}
else {
alert(data.message);
}
},
error: function () {
console.log('执行出错!');
layer.close(loading);
alert('执行错误,请联系管理员!');
}
});
return false;
}