http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 12249|回复: 1

[小程序系列教程] 【小程序】【在线缴费系统】(七)管理端功能-banner图管理

[复制链接]
发表于 2021-7-5 15:47:33 | 显示全部楼层 |阅读模式
【小程序】【在线缴费系统】(七)管理端功能-banner图管理




导读部分


教程目录http://www.sufeinet.com/thread-40967-1-1.html



教程部分

教程部分


页面效果:
banner-1.jpg
banner-2.jpg


本功能主要用在小程序端, 各个页面上得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图管理 数据库设计+逻辑处理


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-11-22 13:38

© 2014-2021

快速回复 返回顶部 返回列表