|
【小程序】【在线缴费系统】(七)管理端功能-banner图管理
导读部分
教程目录:http://www.sufeinet.com/thread-40967-1-1.html
教程部分
教程部分
页面效果:
本功能主要用在小程序端, 各个页面上得banner图管理, 方便不通得页面,获取不通得banner, 增加小程序得美观性
页面jquery:
[C#] 纯文本查看 复制代码 <script type="text/javascript">
var rs = new Vue({
el: "#grid",
data: {
list: [],
pgsize: 10,
pgindex: 1,
name: "",
model: {},
id: "",
val: "",
checked: false, //多选框
checkedNames: [], //全选框
sortnum: "",
olist: [],
},
methods: {
doInit: function () {
var info = image.list(this.pgindex, this.pgsize);
this.list = info.list;
this.setpage(info.total, info.pgsize, info.pgindex);
},
getpage: function (index) { //分页
this.isinit = 0;
this.pgindex = index;
this.doInit();
},
//新增弹框
newaddlbt: function () {
var info = image.getInfo(0);
this.model = info.info;
var arr = [{ id: 0, name: "请选择" }];
this.olist = arr.concat(info.catelist);
//$("#FileName").parent().siblings(".imglist").html("");
module(['modal'],
function (md, exports) {
md.bind({
target: '#addScroll'
});
});
},
//编辑弹框
addlbt: function (id) {
var info = image.getInfo(id);
this.model = info.info;
var arr = [{ id: 0, name: "请选择" }];
this.olist = arr.concat(info.catelist);
module(['modal'],
function (md, exports) {
md.bind({
target: '#addScroll'
});
});
},
//新增或编辑保存
savetype: function () {
if (!this.model.imgurl || this.model.imgurl == 0) {
layer.msg("请补全信息", { time: 800 });
} else {
var res = image.add(this.model);
if (res == 0) {
layer.msg("保存成功", { time: 800 });
this.doInit();
$("#addScroll").hide();
$(".madal-mask").hide();
}
}
},
//删除列表
delList: function (id) {
this.$confirm('此操作将永久删除该内容, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var res = image.del(id);
if (res == 0) {
this.$message({
type: 'success',
message: '删除成功!'
});
this.doInit()
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
upImgs: function (id, data) {
if (id == "FileName") {
this.model.imgurl = data.info.imgurl;
this.model.imgurlstr = data.info.url;
}
},
},
mounted: function () {
this.doInit();
}
});
function pageSet(pages) {
rs.isinit = 0;
rs.pgindex = 1;
rs.pgsize = pages;
rs.doInit();
}
</script>
程序逻辑:
[C#] 纯文本查看 复制代码
//列表
funlist.TryAdd("imagelist", (context, _handitem) =>
{
JsonResultHelper<dynamic> resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "获取失败" };
try
{
//获取参数
int pageIndex = InputHelper.GetInputInt(context.Request.Params["pgindex"]);
int pageSize = InputHelper.GetInputInt(context.Request.Params["pgsize"]);
if (pageIndex <= 0) { pageIndex = 1; }
if (pageSize <= 0) { pageSize = PAGESIZE; }
//处理类
sys_bannerBLL bll = new sys_bannerBLL();
//列表
List<sys_banner> list = bll.FindListPage(new SufeiDAL.OrmLitePageFactor()
{
Fields = "*",
Conditions = "",
OrderBy = "addtime desc",
PageIndex = pageIndex,
PageSize = pageSize
}, out long total);
// 组织返回数据
dynamic dy = new ExpandoObject();
dy.list = list;
dy.pgindex = pageIndex;
dy.pgsize = pageSize;
dy.total = total;
resultJson.msgCode = 0;
resultJson.msg = "获取成功";
resultJson.info = dy;
return resultJson;
}
catch (Exception ex)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = string.Format("程序出错:{0},{1}", ex.Message, ex.StackTrace), info = "" };
return resultJson;
}
});
//保存
funlist.TryAdd("saveimage", (context, _handitem) =>
{
JsonResultHelper<dynamic> resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "保存失败" };
try
{
sys_banner model = JsonHelper.JsonToObj<sys_banner>(context.Request.Params["info"]);
sys_bannerBLL bll = new sys_bannerBLL();
sys_banner info = bll.FindListOne($"type = {model.type} and id <> {model.id} ");
//修改
if (!string.IsNullOrEmpty(model.imgurl))
{
if (info == null)
{
if (model.id > 0)
{
int result = bll.Update(model);
if (result > 0)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = 0, msg = "修改成功" };
}
}
else //新增
{
int result = (int)bll.insert(model, true);
if (result > 0)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = 0, msg = "保存成功" };
}
}
}
else
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "分类不能重复!!!" };
}
}
else
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "请补全信息!!!" };
}
return resultJson;
}
catch (Exception ex)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = string.Format("程序出错:{0},{1}", ex.Message, ex.StackTrace), info = "" };
return resultJson;
}
});
//实体
funlist.TryAdd("imageinfo", (context, _handitem) =>
{
JsonResultHelper<dynamic> resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "获取失败" };
try
{
int id = InputHelper.GetInputInt(context.Request.Params["id"]);
sys_bannerBLL bll = new sys_bannerBLL();
sys_banner model = new sys_banner();
model = bll.FindListOne($"id = {id}") ?? new sys_banner();
dynamic dy = new ExpandoObject();
dy.info = model;
//父级分类
dy.catelist = bannertype.Dict.Select(c => new { id = c.Key, name = c.Value.Name });
resultJson = new JsonResultHelper<dynamic>() { msgCode = 0, msg = "获取成功", info = dy };
return resultJson;
}
catch (Exception ex)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = string.Format("程序出错:{0},{1}", ex.Message, ex.StackTrace), info = "" };
return resultJson;
}
});
//删除
funlist.TryAdd("delimage", (context, _handitem) =>
{
JsonResultHelper<dynamic> resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = "删除失败" };
try
{
string ids = InputHelper.GetInputString(context.Request.Params["ids"]);
sys_bannerBLL bll = new sys_bannerBLL();
if (ids != null && ids != "")
{
int result = 0;
string sql = $"delete sys_banner where id = {ids}";
result = bll.ExecuteNonQuery(System.Data.CommandType.Text, sql, null);
if (result > 0)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = 0, msg = "删除成功" };
}
}
return resultJson;
}
catch (Exception ex)
{
resultJson = new JsonResultHelper<dynamic>() { msgCode = -1, msg = string.Format("程序出错:{0},{1}", ex.Message, ex.StackTrace), info = "" };
return resultJson;
}
});
点击查看, banner图管理 数据库设计+逻辑处理
|
|