ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(11)之支付管理及广告管理
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c
本项目属于个人项目,不支持在线支付功能,所有的支付都是扫码支付到个人,再上传到后台进行半自动的充值,所有后台需要一个支付管理功能。
对于需要在线支付的,我们可以使用ASP.NET SignalR的客户端和服务器之间双向通信实现在线支付全自动功能,在这里不多赘述,感兴趣的朋友可以搜搜相关文章。
然后就是我们的广告管理功能,在我们的项目中可能会挂一些广告或者友情链接分类及横幅幻灯等分类的功能,我们都可以在这里用分类来做一个简单的管理,其功能和知识点都跟前面的功能类似,这里就直接上这两块功能的代码:
一、支付管理:
按流程创建一个PayForMangeController控制器和Index.cshtml视图:
(1)PayForMangeController
using Bobo.Utilities;
using IA.Business;
using IA.Entity;
using IA.WebApp.SystemExtension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace IA.WebApp.Areas.BackstageModule.Controllers
{
[LoginAuthorize("~/BackstageModule/Login/Index")]
public class PayForMangeController : PublicController<Com_PayFor>
{
//
// GET: /BackstageModule/PayForMange/ /// <summary>
/// 获取分页数据
/// </summary>
/// <param name="UserAccount"></param>
/// <param name="jgp"></param>
/// <returns></returns>
public ActionResult GetTable(string UserAccount, int? PayForState, JqGridParam jgp)
{
UserAccount = UserAccount.Replace(" ", "");
Com_PayForBll bll = new Com_PayForBll();
DataTable model = bll.GetTablePage(UserAccount, PayForState, ref jgp);
//构建分页数据
var JsonData = new
{
success = true,
pageData = jgp,
message = "",
data = model
};
return Content(JsonData.ToJson());
} /// <summary>
/// 假删方法
/// </summary>
/// <param name="KeyValue"></param>
/// <returns></returns>
public ActionResult DeleteOther(string KeyValue)
{
Com_PayForBll bll = new Com_PayForBll(); try
{
int IsOk = 1;
string Message = "删除成功";
if (!string.IsNullOrEmpty(KeyValue))
{
string[] array = KeyValue.Split(',');
foreach (var item in array)
{
Com_PayFor Oldentity = bll.Factory.FindEntity(item);//获取没更新之前实体对象
Oldentity.DeleteMark = 1;
Oldentity.Modify(item);
IsOk = bll.Factory.Update(Oldentity);
this.WriteLog(IsOk, Oldentity, Oldentity, item, Message);
}
}
else
{
Message = "删除失败";
IsOk = 1; }
return Content(new JsonMessage { Success = true, Code = IsOk.ToString(), Message = Message }.ToString());
}
catch (Exception ex)
{
this.WriteLog(-1, null, null, KeyValue, "操作失败:" + ex.Message);
return Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString());
} }
/// <summary>
/// 状态更改
/// </summary>
/// <param name="KeyValue"></param>
/// <param name="PayForState"></param>
/// <param name="Idea"></param>
/// <returns></returns>
public ActionResult SetPayForState(string KeyValue, int? PayForState, string Idea)
{
Com_PayForBll bll = new Com_PayForBll();
Com_ApproveBll all = new Com_ApproveBll();
Com_MemberBll mll = new Com_MemberBll();
DbTransaction transaction = bll.Factory.BeginTrans();
try
{
string czMsg = "";
switch (PayForState)
{
case 0:
czMsg = "待审核";
break;
case 1:
czMsg = "审核通过";
break;
case -1:
czMsg = "审核不通过";
break;
}
int IsOk = 1;
string Message = "操作成功";
if (!string.IsNullOrEmpty(KeyValue))
{
string[] array = KeyValue.Split(',');
foreach (var item in array)
{
Com_PayFor Oldentity = bll.Factory.FindEntity(item);//获取没更新之前实体对象
Com_Member menity = mll.Factory.FindEntity(Oldentity.CreateUserId);
if (Oldentity.PayForState != 0 || PayForState != -1)
{ //更新会员金币
if (PayForState > 0)
{
menity.Integral = menity.Integral + Oldentity.Integral;
}
else
{
menity.Integral = menity.Integral - Oldentity.Integral;
}
menity.Modify(Oldentity.CreateUserId);
mll.Factory.Update(menity, transaction);
} Oldentity.PayForState = PayForState;
Oldentity.Modify(item);
IsOk = bll.Factory.Update(Oldentity, transaction);
IsOk = all.SubmitApproveData(KeyValue, PayForState.ToString(), czMsg, Idea, transaction);//插入审批记录
string emailTit = "页落素材网支付凭证处理结果";
string emailBody= "<h2>尊敬的" + menity.RealName + ",您好:</h2>您上传的页落素材网支付凭证已进行处理,处理结果为:[" + czMsg + "],详情请前往会员中心 http://www.yealuo.com/MemberCenterModule/MemberSystem/Index【我的充值】查看";
NetHelper.SendMailByWeb(menity.Email, ConfigHelper.ReadAppConfig("FromEmail"), emailTit, emailBody, ConfigHelper.ReadAppConfig("EmailPwd"), ConfigHelper.ReadAppConfig("SmtpServer"));//支付成功发送邮件
bll.Factory.Commit();
this.WriteLog(IsOk, Oldentity, Oldentity, item, Message);
}
}
else
{
Message = "上报失败";
IsOk = 1;
}
return Content(new JsonMessage { Success = true, Code = IsOk.ToString(), Message = Message }.ToString());
}
catch (Exception ex)
{
this.WriteLog(-1, null, null, KeyValue, "操作失败:" + ex.Message);
return Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString());
} } /// <summary>
/// 获取审批记录
/// </summary>
/// <param name="DataId"></param>
/// <returns></returns>
public ActionResult GetApprove(string DataId)
{
Com_ApproveBll bll = new Com_ApproveBll();
if (!StringHelper.IsNullOrEmpty(DataId))
{
List<Com_Approve> List = bll.GetApproveList(DataId, null, null);
return Content(List.ToJson());
}
else
{
return null;
}
}
}
}
(2)Index.cshtml
@{
ViewBag.Title = "支付凭证管理";
Layout = "~/Views/Shared/_LayoutMange.cshtml";
}
<style>
html {
background-color: #f3f4f4;
} .w_header .header-nav .nav-item li a.wzgl {
border-bottom: 2px solid #2D81E0;
background-color: #E8F4FF;
color: #2D81E0;
font-weight: bold;
} .w_center .center-nav-item a.zfgl {
color: #156cd1;
}
</style>
<div class="w_center clear mAuto">
@Html.Partial("_PartialNav")
<div class="center-main R">
<h2 class="center-main-title font-yahei">
<span>支付凭证管理 /</span><i>PayFor Mange</i>
</h2> <div class="center-main-box">
<div class="toolbarBox clear">
<div id="searchForm">
<div class="L attSeach">
<span>数据状态:</span>
<select class="att-txt" id="PayForState" name="PayForState" onchange="getPageData();">
<option value="">==所有==</option>
<option value="0">待审核</option>
<option value="1">已通过</option>
<option value="-1">退回</option>
</select>
</div> <div class="L searchForm" style="width:220px;">
<span class="seachTit">会员账号:</span>
<input type="text" id="UserAccount" class="seachText" value="" style="width:130px;" />
<a id="searchBtn" class="searchBtn" href="javascript:;" title="搜索"></a>
</div>
</div>
<div class="toolbar R">
@*<input type="button" value="通过" class="addBtn greenBtn" onclick="SetPayForState(1)" />
<input type="button" value="退回" class="addBtn yellowBtn" onclick="Return()" />*@
<input type="button" value="删除" class="delBtn redBtn" onclick="delBtn()" />
</div>
</div>
<table class="dataTable" style="width:100%;">
<thead>
<tr>
<td style="width:6%;" class="remElem"><input type="checkbox" class="ckbAll " />选中</td>
<td style="width:20%;" class="tbTit">会员信息</td>
<td style="width:12%;" class="tbTit">支付内容</td>
<td style="width:10%;" class="remElem">支付类型</td>
<td style="width:20%;">支付凭证</td>
<td style="width:12%;">提交时间</td>
<td style="width:10%;">状态</td>
</tr>
</thead>
<tbody id="dataBody"></tbody>
</table>
<div id="listPage" class="m_pageBar com_pageBar" style="padding:0 30px;"></div>
</div>
</div>
</div> @*分页数据模版*@
<script id="tempBody" type="text/template">
{#each data as item}
<tr>
<td style="text-align: center;"><input type="checkbox" class="ckb" data-id="!{item.PayForID}" onclick="change(this)" /></td>
<td>
<div>账号:<span>!{item.RealName}</span></div>
<div>金币:<span>!{item.HasIntegral}</span></div>
<div>
会员类型:
{#if item.MemberType>0}
<span>VIP会员</span>
{#else}
<span>普通会员</span>
{#/if}
</div>
</td>
{#if item.PayForContent==5}
<td style="text-align:center;">5个金币/5元</td>
{#else if item.PayForContent==10}
<td style="text-align:center;">10个金币/10元</td>
{#else if item.PayForContent==22}
<td style="text-align:center;">22个金币/20元</td>
{#else if item.PayForContent==33}
<td style="text-align:center;">33个金币/30元</td>
{#else if item.PayForContent==44}
<td style="text-align:center;">44个金币/40元</td>
{#else if item.PayForContent==55}
<td style="text-align:center;">55个金币/50元</td>
{#else if item.PayForContent==110}
<td style="text-align:center;">110个金币/100元</td>
{#else if item.PayForContent==220}
<td style="text-align:center;">220个金币/200元</td>
{#else if item.PayForContent==330}
<td style="text-align:center;">330个金币/300元</td>
{#else if item.PayForContent==440}
<td style="text-align:center;">440个金币/400元</td>
{#else if item.PayForContent==550}
<td style="text-align:center;">550个金币/500元</td>
{#/if} {#if item.PayForType==1}
<td style="text-align:center;">微信</td>
{#else}
<td style="text-align:center;">支付宝</td>
{#/if}
<td style="text-align:center;">
<a href="javascript:;" onclick="layer.full(layer.open({ content: $(this).html()}));">
<img src="!{item.PayForUrl}" style="width:99%;" />
</a>
</td>
<td style="text-align:center;">!{formatDate(item.CreateDate, "yyyy-MM-dd hh:mm:ss")}</td>
<td style="text-align:center;">
{#if item.PayForState>0}
<span style="color:#00ff21;">通过</span>
<a href="javascript:;" data-id="!{item.PayForID}" onclick="Return($(this))" class="tbBtn tbDel">退回</a>
{#else if item.PayForState==-1}
<span style="color:#999;">退回</span>
<a href="javascript:;" data-id="!{item.PayForID}" onclick="SetPayForState($(this))" class="tbBtn tbPass">通过</a>
{#else}
<span style="color:#ff0000;">待审核 </span>
<a href="javascript:;" data-id="!{item.PayForID}" onclick="Return($(this))" class="tbBtn tbDel">退回</a>
<a href="javascript:;" data-id="!{item.PayForID}" onclick="SetPayForState($(this))" class="tbBtn tbPass">通过</a>
{#/if}
<a href="javascript:;" data-id="!{item.PayForID}" onclick="ApproveDetail($(this))" class="tbBtn tbDetail">记录</a>
</td>
</tr>
{#/each}
</script>
@*隐藏弹窗模版*@
<script id="Return" type="text/template">
<div style="margin:20px 20px;">
<form id="form1" action="/BackstageModule/PayForMange/SetPayForState" method="post" enctype="multipart/form-data" style="margin: 1px">
<input type="hidden" id="PayForState" name="PayForState" value="-1" />
<table class="layer-table-form">
<tr>
<td style="height:100px;"><textarea name="Idea" class="layer-form-content-tarea" id="Idea" datacol="yes" err="意见" checkexpession="NotNull"></textarea> </td>
</tr>
</table>
</form>
</div>
</script>
@*隐藏审批记录模版*@
<script id="DialogApprove" type="text/template">
<div class="Dialog-Box font-yahei">
<div class="Dialog-Com" style="display:block;">
<table class="Dialog-table">
<thead>
<tr>
<td class="Dialog-table-tit" style="text-align:center;">状态</td>
<td class="Dialog-table-tit" style="text-align:center;">操作人</td>
<td class="Dialog-table-tit" style="text-align:center;">操作时间</td>
<td class="Dialog-table-tit" style="text-align:center;">原因</td>
</tr>
</thead>
<tbody id="Approve"></tbody>
</table>
</div>
</div>
</script>
@section scripts{
<script type="text/javascript">
var KeyValue = "";
$(function () {
juicer.register('formatDate', formatDate);
getPageData();
searchEvent();
}); //初始化分页函数
function getPageData() {
var param = {
rows: 10,
url: "/BackstageModule/PayForMange/GetTable",
sidx: "CreateDate",
sord: "DESC",
searchForm: "#searchForm",
infoPanel: '#dataBody',
barPanel: '#listPage',
template: '#tempBody',
callback: handleSuccess
}
Pager.init(param); }
///审核记录详情
function ApproveDetail(elem) {
var dataId = elem.attr("data-id");
layer.open({
title: "审核记录",
type: 1,
skin: 'layui-layer-rim', //加上边框
area: ['700px', '500px'], //宽高
content: $("#DialogApprove").html(),
});
AjaxJson("/BackstageModule/PayForMange/GetApprove", { DataId: dataId }, function (data) {
if (!!data) {
var str = "";
for (var i = 0; i < data.length; i++) {
str += "<tr>"
str += "<td class=\"Dialog-table-tit\" style=\"text-align:center;\">" + data[i].Action + "</td>"
str += "<td class=\"Dialog-table-tit\" style=\"text-align:center;\">" + data[i].CreateUserName + "</td>"
str += "<td class=\"Dialog-table-tit\" style=\"text-align:center;\">" + formatDate(data[i].CreateDate, "yyyy-MM-dd") + "</td>"
str += "<td class=\"Dialog-table-tit\" style=\"text-align:center;\">" + (!data[i].Idea ? '' : data[i].Idea) + "</td>"
str += "</tr>";
}
$("#Approve").html(str);
}
});
}
//业务操作
function SetPayForState(elem) {
var dataId = elem.attr("data-id");
layer.confirm("确定提交这条数据?", { icon: 0 }, function () {
AjaxJson("/BackstageModule/PayForMange/SetPayForState", { KeyValue: dataId, PayForState: 1 }, function (data) {
layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {
if (data.Code > 0) {
Pager.reload();
}
});
});
}); }
//退回
function Return(elem) {
var dataId = elem.attr("data-id");
layer.open({
title: "退回意见",
type: 1,
skin: 'layui-layer-rim', //加上边框
area: ['450px', '300px'], //宽高
content: $("#Return").html(),
btn: ['保存', '取消'], //只是为了演示
yes: function () {
AcceptClick(dataId);
}
});
}
//提交退回意见表单
function AcceptClick(dataId) {
if (!CheckDataValid('#form1', true)) {
return false;
}
$("#form1").ajaxSubmit({
type: 'post',
url: '/BackstageModule/PayForMange/SetPayForState?&KeyValue=' + dataId,
dataType: "json",
beforeSubmit: function () {
layer.msg('正在提交信息,请稍后…', { icon: 16, shade: 0.2, time: 0 });
},
success: function (data) {
layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {
layer.closeAll();
Pager.reload();
});
}
});
}
//查询按钮绑定事件
function searchEvent() {
$("#searchBtn").on("click", function () {
getPageData();
});
} //删除
function delBtn() {
var allVal = "";
$(".dataTable tbody tr").find(".ckb").each(function () {
var ckb = $(this);
var ckbVal = ckb.prop("checked");
var dataId = ckb.attr("data-id");
if (ckbVal == "checked" || ckbVal == true) {
allVal += (allVal == "" ? dataId : "," + dataId);
}
}); if (allVal == "") {
layer.alert("您没有选中任何项,请选中后再进行操作!", { icon: 0 });
return false;
}
layer.confirm("是否删除这" + allVal.split(",").length + "条数据?", { icon: 0 }, function () {
AjaxJson("/BackstageModule/PayForMange/DeleteOther", { KeyValue: allVal }, function (data) {
layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {
Pager.reload();
});
});
}); }
//分页数据加载后绑定的函数
function handleSuccess() {
checkAll();
}
//全选(包括)
function checkAll() {
//全选按钮
$(".dataTable thead").find(".ckbAll").change(function () {
var chkAll = $(this);
var chkVal = chkAll.prop("checked");
if (chkVal == "checked" || chkVal == true) {
$(".dataTable tbody tr").each(function () {
var chk = $(this).find(":checkbox");
chk.prop("checked", "checked");
});
}
else {
$(".dataTable tbody tr").each(function () {
var chk = $(this).find(":checkbox");
chk.removeAttr("checked");
});
}
}); }
</script> }
在处理支付过程中,我们需要邮箱通知用户他们的充值结果,所以需要在配置文件中配置发送邮箱的服务设置,在之前创建的配置文件system.config中,添加节点如下:
<!-- ================== 5:给用户发送邮箱 ================== -->
<!-- 来源邮箱 -->
<add key="FromEmail" value="xxx@qq.com" />
<!-- 邮箱服务密码 -->
<add key="EmailPwd" value="xkkmsms" />
<!-- Smtp服务名称 -->
<add key="SmtpServer" value="smtp.qq.com" />
二、广告管理:
按流程创建一个BannerMangeController控制器和Index.cshtml视图:
(1)BannerMangeController
using Bobo.Utilities;
using IA.Business;
using IA.Entity;
using IA.WebApp.SystemExtension;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace IA.WebApp.Areas.BackstageModule.Controllers
{
[LoginAuthorize("~/BackstageModule/Login/Index")]
/// <summary>
/// 广告控制器
/// </summary>
public class BannerMangeController : PublicController<Com_Banner>
{
//
// GET: /BackstageModule/BannerMange/
/// <summary>
/// 获取分页数据
/// </summary>
/// <param name="ArticleTitle"></param>
/// <param name="jgp"></param>
/// <returns></returns>
public ActionResult GetTable(string BannerTitle, JqGridParam jgp)
{
BannerTitle = BannerTitle.Replace(" ", "");
Com_BannerBll bll = new Com_BannerBll();
DataTable model = bll.GetTablePage(BannerTitle, ref jgp);
//构建分页数据
var JsonData = new
{
success = true,
pageData = jgp,
message = "",
data = model
};
return Content(JsonData.ToJson());
}
[HttpPost]
[ValidateInput(false)]
/// <summary>
/// 添加编辑
/// </summary>
/// <param name="entity"></param>
/// <param name="KeyValue"></param>
/// <returns></returns>
public ActionResult SubmitFormData(Com_Banner entity, string KeyValue)
{
HttpPostedFileBase FileCover = Request.Files["BannerImg"]; Com_BannerBll bll = new Com_BannerBll();
try
{
int IsOk = 0;
string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";
#region 附件处理
bool FileHasCover = FileCover != null && FileCover.ContentLength > 0; List<string> fileType = ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageType").ToLower().Split('|').ToList();
string PicName = "";
if (FileHasCover)
{
PicName = Path.GetFileName(FileCover.FileName);
} if ((FileHasCover && !fileType.Contains(Path.GetExtension(PicName).ToLower())))
{
return Content(new JsonMessage { Code = "-1", Success = false, Message = "图片只能上传" + ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageType").ToLower() + "类型的文件!" }.ToString());
}
if (FileHasCover && CommonHelper.GetInt(SizeHelper.CountSizeNum(FileCover.ContentLength)) > CommonHelper.GetInt(ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageSize")))
{
return Content(new JsonMessage { Code = "-1", Success = false, Message = "文件大小不能超过" + ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "ImageSize") + "M!" }.ToString());
} string AllPath = "";//ConfigHelper.GetSystemConfig("SystemConfig", "fileUploadPath", "AllFilePath"); string PicPath = "/Resource/BannerImg/";
DirFileHelper.CreateDirectory(Server.MapPath(AllPath + PicPath));
//上传广告图
if (FileCover != null && FileCover.ContentLength > 0)
{
string fileName = CommonHelper.GetGuidNotLine() + Path.GetFileName(FileCover.FileName);
FileCover.SaveAs(Server.MapPath(AllPath + PicPath + fileName));
entity.BannerImg = PicPath + fileName;
} #endregion
if (!string.IsNullOrEmpty(KeyValue))
{
Com_Banner Oldentity = bll.Factory.FindEntity(KeyValue);//获取没更新之前实体对象
entity.Modify(KeyValue);
IsOk = bll.Factory.Update(entity);
this.WriteLog(IsOk, entity, Oldentity, KeyValue, Message);
}
else
{
entity.Create();
IsOk = bll.Factory.Insert(entity);
this.WriteLog(IsOk, entity, null, KeyValue, Message);
} return Content(new JsonMessage { Success = true, Code = IsOk.ToString(), Message = Message }.ToString());
}
catch (Exception ex)
{
this.WriteLog(-1, entity, null, KeyValue, "操作失败:" + ex.Message);
return Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString());
}
}
/// <summary>
/// 假删方法(会刊)
/// </summary>
/// <param name="KeyValue"></param>
/// <returns></returns>
public ActionResult DeleteOther(string KeyValue)
{
Com_BannerBll bll = new Com_BannerBll(); try
{
int IsOk = 1;
string Message = "删除成功";
if (!string.IsNullOrEmpty(KeyValue))
{
string[] array = KeyValue.Split(',');
foreach (var item in array)
{
Com_Banner Oldentity = bll.Factory.FindEntity(item);//获取没更新之前实体对象
Oldentity.DeleteMark = 1;
Oldentity.Modify(item);
IsOk = bll.Factory.Update(Oldentity);
this.WriteLog(IsOk, Oldentity, Oldentity, item, Message);
}
}
else
{
Message = "删除失败";
IsOk = 1; }
return Content(new JsonMessage { Success = true, Code = IsOk.ToString(), Message = Message }.ToString());
}
catch (Exception ex)
{
this.WriteLog(-1, null, null, KeyValue, "操作失败:" + ex.Message);
return Content(new JsonMessage { Success = false, Code = "-1", Message = "操作失败:" + ex.Message }.ToString());
} } }
}
(2)Index.cshtml
@{
ViewBag.Title = "广告管理";
Layout = "~/Views/Shared/_LayoutMange.cshtml";
}
<style>
html {
background-color: #f3f4f4;
} .w_header .header-nav .nav-item li a.wzgl {
border-bottom: 2px solid #2D81E0;
background-color: #E8F4FF;
color: #2D81E0;
font-weight: bold;
} .w_center .center-nav-item a.gggl {
color: #156cd1;
}
</style>
<div class="w_center clear mAuto">
@Html.Partial("_PartialNav")
<div class="center-main R">
<h2 class="center-main-title font-yahei">
<span>广告管理 /</span> <i>management of industry trends</i>
</h2> <div class="center-main-box">
<div class="toolbarBox clear">
<div id="searchForm" class="L searchForm">
<span class="seachTit">产品标题:</span>
<input type="text" id="BannerTitle" class="seachText" value="" />
<a id="searchBtn" class="searchBtn" href="javascript:;" title="搜索"></a>
</div> <div class="toolbar R">
<input type="button" value="添加" class="mainBtn addBtn greenBtn" onclick="AddEditBtn(0,$(this))" />
<input type="button" value="删除" class="mainBtn delBtn blueBtn" onclick="delBtn()" />
</div>
</div>
<table class="dataTable" style="width:100%;">
<thead>
<tr>
<td style="width:10%;" class="remElem"><input type="checkbox" class="ckbAll " />选定</td>
<td style="width:15%;">广告图片</td>
<td style="width:20%;">广告标题</td>
<td style="width:15%;">广告状态</td>
<td style="width:15%;">广告地址</td>
<td style="width:15%;">添加时间</td>
<td style="width:10%;">操作</td>
</tr>
</thead>
<tbody id="dataBody"></tbody>
</table>
<div id="listPage" class="m_pageBar com_pageBar" style="padding:0 30px;"></div>
</div>
</div>
</div> @*隐藏弹窗模版*@
<script id="ReplyEdit" type="text/template">
<div style="margin:20px 20px;">
<form id="form1" action="/BackstageModule/BannerMange/SubmitFormData" method="post" enctype="multipart/form-data" style="margin: 1px">
<input type="hidden" id="KeyValue" name="KeyValue" />
<table class="layer-table-form">
<tr>
<td><span class="layer-form-tit">广告标题:</span><input type="text" name="BannerTitle" class="layer-form-txt" id="BannerTitle" datacol="yes" err="标题" checkexpession="NotNull" /></td> </tr>
<tr>
<td>
<span class="layer-form-tit">广告类型:</span>
<select name="BannerType" class="layer-form-select" id="BannerType">
<option value="">==请选择==</option>
<option value="Index">首页横幅</option>
<option value="flink">友情链接</option>
</select>
</td>
</tr>
<tr>
<td><span class="layer-form-tit">广告地址:</span><input type="text" name="BannerLink" class="layer-form-txt" id="BannerLink" /></td>
</tr>
<tr>
<td>
<div class="layer-form-tit L">广告图片:</div>
<input type="text" name="BannerImgSet" id="BannerImgSet" class="layer-form-txt url1 L" readonly="readonly" style="display:none;" placeholder="请上传.JPG|.JPEG|.PNG|.GIF|.BMP格式的图片" datacol="yes" err="广告图片" />
<input type="text" name="BannerImg" id="BannerImg" class="layer-form-txt url2 L" readonly="readonly" placeholder="请上传.JPG|.JPEG|.PNG|.GIF|.BMP格式的图片" datacol="yes" err="广告图片" />
<div class="FileBox L">
<input class="file upFile" type="file" name="BannerImg" value="" onchange="SetFileVal($(this))" />
</div>
</td>
</tr> <tr>
<td>
<div class="layer-form-tit L">广告介绍:</div>
<textarea class="layer-form-txt" id="BannerCenter" name="BannerCenter" maxlength=2147483647 datacol="yes" err="广告介绍" checkexpession="NotNull" style="width:99.9%;"></textarea>
</td>
</tr>
</table> </form>
</div>
</script> @*分页数据模版*@
<script id="tempBody" type="text/template">
{#each data as item}
<tr>
<td style="text-align: center;"><input type="checkbox" class="ckb" data-id="!{item.BannerID}" onclick="change(this)" /></td>
<td style="text-align: center;"><img src="!{item.BannerImg}" width="80" height="100" /> </td>
<td style="text-align: center;">!{item.BannerTitle}</td>
<td style="text-align: center;">!{item.State}</td>
<td style="text-align: center;">!{item.BannerLink}</td>
<td style="text-align: center;">!{formatDate(item.CreateDate, "yyyy-MM-dd")}</td>
<td style="text-align:center;"><a href="javascript:;" onclick="AddEditBtn(1,$(this))" data-id="!{item.BannerID}" class="tbBtn tbEdit">编辑</a></td>
</tr>
{#/each}
</script>
@section scripts{
<script src="~/Content/Scripts/ueditor/ueditor.config.js"></script>
<script src="~/Content/Scripts/ueditor/ueditor.all.js"></script>
<script src="~/Content/Scripts/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
$(function () {
juicer.register('formatDate', formatDate);
searchEvent();
getPageData(); }); //初始化分页函数
function getPageData() {
var param = {
rows: 10,
url: "/BackstageModule/BannerMange/GetTable",
sidx: "CreateDate",
sord: "DESC",
searchForm: "#searchForm",
infoPanel: '#dataBody',
barPanel: '#listPage',
template: '#tempBody',
callback: handleSuccess
}
Pager.init(param); }
//查询按钮绑定事件
function searchEvent() {
$("#searchBtn").on("click", function () {
getPageData();
});
} //文件域选择设置
function SetFileVal(elem) {
var part = elem.parents("td");
if (!!elem.val()) {
part.find(".url1").val(elem.val()).show().attr("checkexpession", "NotNull");
part.find(".url2").hide().removeAttr("checkexpession");
}
else {
part.find(".url1").show().attr("checkexpession", "NotNull");
part.find(".url2").hide().removeAttr("checkexpession");
}
}
//保存按钮
function AcceptClick() { if (!CheckDataValid('#form1', true)) {
return false;
} //提交表单
$("#form1").ajaxSubmit({
dataType: "json",
beforeSubmit: function () {
layer.msg('正在提交信息,请稍后…', { icon: 16, shade: 0.2, time: 0 });
},
success: function (data) {
if (data.Success) {
layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {
layer.closeAll();
getPageData();
}); }
else {
layer.alert(data.Message, { icon: data.Code });
}
}
});
}
//添加编辑弹窗
function AddEditBtn(num, elem) {
var allVal = "";
if (num > 0) {
allVal = elem.attr("data-id");
}
var index = layer.open({
title: "添加/编辑",
type: 1,
skin: 'layui-layer-rim', //加上边框
area: ['650px', '500px'], //宽高
content: $("#ReplyEdit").html(),
btn: ['保存', '取消'], //只是为了演示
maxmin: true,
yes: function () {
AcceptClick();
}
});
layer.full(index);
InitControl(allVal); }
//得到一个对象实体
function InitControl(allVal) {
var ue = UE.getEditor('BannerCenter', { autoFloatEnabled: false, autoHeightEnabled: false });
AjaxJson("/BackstageModule/BannerMange/SetForm", { KeyValue: allVal }, function (data) {
SetWebControls(data, "#form1");
$("#BannerCenter").val(data.BannerCenter);
if (!!data.BannerCenter) {
ue.addListener('ready', function (editor) {
var height = $(window).height(),
tabHeight = $(".form-table").outerHeight();
headHeight = $(".w_header").outerHeight();
footHeight = $(".w_footer").outerHeight();
editToolHeight = $("#edui1_toolbarbox").outerHeight(),
editBottomHeight = $("#edui1_bottombar").outerHeight(),
editHeight = 300;
ue.setHeight(editHeight);
ue.setContent(data.BannerCenter, false);
});
}
$("#KeyValue").val(data.BannerID);
$("#BannerImg").attr("checkexpession", "NotNull");
});
}
//删除
function delBtn() {
var allVal = "";
$(".dataTable tbody tr").find(".ckb").each(function () {
var ckb = $(this);
var ckbVal = ckb.prop("checked");
var dataId = ckb.attr("data-id");
if (ckbVal == "checked" || ckbVal == true) {
allVal += (allVal == "" ? dataId : "," + dataId);
}
}); if (allVal == "") {
layer.alert("您没有选中任何项,请选中后再进行操作!", { icon: 0 });
return false;
}
layer.confirm("是否删除这" + allVal.split(",").length + "条数据?", { icon: 0 }, function () {
AjaxJson("/BackstageModule/BannerMange/DeleteOther", { KeyValue: allVal }, function (data) {
layer.msg(data.Message, { icon: data.Code, time: 1000 }, function () {
Pager.reload();
});
});
}); } //分页数据加载后绑定的函数
function handleSuccess() {
checkAll();
}
//全选(包括)
function checkAll() {
//全选按钮
$(".dataTable thead").find(".ckbAll").change(function () {
var chkAll = $(this);
var chkVal = chkAll.prop("checked");
if (chkVal == "checked" || chkVal == true) {
$(".dataTable tbody tr").each(function () {
var chk = $(this).find(":checkbox");
chk.prop("checked", "checked");
});
}
else {
$(".dataTable tbody tr").each(function () {
var chk = $(this).find(":checkbox");
chk.removeAttr("checked");
});
}
}); }
</script> }
ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(11)之支付管理及广告管理的更多相关文章
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(13)之会员登录注册
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 会员中心,是我们与用户交 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(1)之数据库设计
本文主要讲解本项目网站所应用到的知识点,及数据库的相关设计: 一.知识点 (1)本项目主要采取ASP.NET MVC的编程模式,相信你已经了解到了MVC的具体含义是什么,这里不再赘述,有不了解的朋友, ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(16)之轻博客
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 项目到上面一步其实已经算 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(15)之前台网站页面
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 本项目主要是一个素材的分 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(14)之会员中心管理
源码下载地址:http://www.yealuo.com/Sccnn/Detail?KeyValue=c891ffae-7441-4afb-9a75-c5fe000e3d1c 会员中心,主要包含了会员 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(9)之系统登录
前面我们已经做好了一个文章管理功能模块,接下来,我们回头来做登录窗口,登录不仅涉及到登录验证还涉及到登录日志还有缓存时长等. 对于缓存的相关设置,我们已经写好封装在Bobo.Utilities.dll ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(7)之扩展基类和区域创建以及文本编辑配置
一.扩展基类和区域创建 (1)在应用之前,我们先在表现层创建一个公共的系统扩展文件来(SystemExtension)存放我们需要延伸和扩展的方法类. 在常规的项目系统操作中,我们都需要用到增删查改的 ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(2)之创建项目
我们在创建项目的时候一定要遵循层次和命名的原则,同时也要有统一的规范,无论是多人项目还是单人项目,能够让人看着一目了然并赏析悦目,做一个有追求的程序员. 例如IA.WebApp是视图控制器层(表现层) ...
- ASP.NET MVC 实现页落网资源分享网站+充值管理+后台管理(8)之文章管理
到这一步,我们整个项目的核心搭建已经算是完成了,接下来就是我们业务功能的实际应用,也就是表现层的设计和实现,如果你是一个项目负责人,到这一步,接下来的工作就可以交给下面的兄弟去完成了,在这里我们用文章 ...
随机推荐
- 几种常见的flex布局
1,水平等距排列.俩端对齐.垂直方向居顶对齐 html: <div class="container flex"> <div class="div1&q ...
- Servlet各种接口和类
http://blog.csdn.net/jediael_lu/article/details/25036019
- 如何写JavaScript中的callback回调函数
如何写回调函数? 如果自己在写一个方法或函数,你有可能会遇到需要一个回调函数.下面就是一个简单的常见回调函数例子: function mySandwich(param1, param2, callba ...
- 使用 Windows 10 WSL 搭建 ESP8266 编译环境并使用 VSCODE 编程(一)(2019-08-23)
目录 使用 Windows 10 WSL 搭建 ESP8266 编译环境并使用 VSCODE 编程 安装前准备 安装 ESP8266 工具链 下载 ESP8266 SDK 编译 花絮 使用 Windo ...
- 某input元素值每隔三位添加逗号跟去掉逗号
//每隔三位数字加一个逗号function moneyformat(s) { var reg = /.*\..*/; if (reg.test(s) == true) { n ...
- yum方式安装MySQL【转】
在CentOS7中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 另外至2919年5月4号, 默认安装的my ...
- 读取服务器的windows共享。。
有些windows共享可以直接登录,有些需要帐号密码帐号密码 有些电脑在输入框输入ip没有弹出登录帐号密码的地方 如下方法可以登录 输入:net use \\ip\ipc$ /del 回车.(例如:& ...
- poj1459 最大流Dinic
比较简单. #include<stdio.h> #include<string.h> #include<queue> #define maxn 110 #defin ...
- 冒泡排序&&选择排序 以及时间效率对比
package com.test4; import java.util.*; //Calendar 显示时间 /** * @author qingfeng * 功能:冒泡排序 */ public cl ...
- mysql 中 DATE_ADD函数和 DATE_SUB函数用法
mysql 中 DATE_ADD(date,INTERVAL expr type) 和 DATE_SUB(date,INTERVAL expr type) 这些函数执行日期运算. date 是一个 D ...