wupengfei 3 年之前
父節點
當前提交
19dc7026c0

+ 151 - 0
application/store/controller/LiveBanner.php

@@ -0,0 +1,151 @@
+<?php
+namespace app\store\controller;
+use library\Controller;
+use think\Db;
+
+/**
+ * 轮播图
+ * Class Goods
+ * @package app\store\controller
+ */
+class LiveBanner extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'LiveBanner';
+
+    /**
+     * 直播商品列表
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        $this->title = '轮播图列表';
+        $query = $this->_query($this->table)->where('is_deleted',0);
+        $query->like('name');
+        $query->order(' sort desc , id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+
+    }
+
+
+
+
+
+
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加商品';
+        $this->goods_cate = Db::table('store_live_cate')
+            ->field('id,title')
+            ->where('status',1)
+            ->where('is_deleted',0)
+            ->order('sort desc , id desc')
+            ->select();
+        $this->_form($this->table, 'form');
+    }
+
+
+    /**
+     * 编辑商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function edit()
+    {
+        $this->title = '编辑商品';
+        $this->goods_cate = Db::table('store_live_cate')
+            ->field('id,title')
+            ->where('status',1)
+            ->where('is_deleted',0)
+            ->order('sort desc , id desc')
+            ->select();
+        $this->_form($this->table, 'form');
+    }
+
+    /**
+     * 禁用
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function forbidden()
+    {
+        $this->_save($this->table, ['status' => '0']);
+    }
+
+    /**
+     * 启用
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function enable()
+    {
+        $this->_save($this->table, ['status' => 1]);
+    }
+
+    /**
+     * 删除
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function del()
+    {
+        $this->_save($this->table, ['is_deleted' => 1]);
+    }
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        $data['create_at'] = date('Y-m-d H:i:s');
+    }
+
+}

+ 4 - 0
application/store/controller/LiveGoods.php

@@ -60,6 +60,10 @@ class LiveGoods extends Controller
 
 
 
+
+
+
+
     /**
      * 添加商品
      * @auth true

+ 53 - 0
application/store/view/live_banner/form.html

@@ -0,0 +1,53 @@
+<div class="think-box-shadow">
+<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
+    <div class="layui-card-body">
+
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">商品名称</label>
+            <div class="layui-input-block">
+                <input name="name" maxlength="20"  value='{$vo.name|default=""}' placeholder="请输入商品名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">商品封面</label>
+            <div class="layui-input-block">
+                <input name="cover" type="hidden" value="{$vo.cover|default=''}">
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">商品分类</label>
+            <div class="layui-input-inline">
+                <select name="cate_id" lay-filter ="cate_id">
+                    <option value="0">请选择</option>
+                    {foreach $goods_cate as $ck=>$cv}
+                        {if isset($vo.cate_id) && $vo.cate_id == $cv.id}
+                        <option selected value="{$cv.id}">{$cv.title}</option>
+                        {else}
+                        <option value="{$cv.id}">{$cv.title}</option>
+                        {/if}
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+
+        <div class="layui-form-item">
+            <label class="layui-form-label label-required">排序</label>
+            <div class="layui-input-block">
+                <input type="number" name="sort"  value='{$vo.sort|default=""}' placeholder="请输入排序号" class="layui-input">
+            </div>
+        </div>
+        {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+        <div class="layui-form-item text-center">
+            <button class="layui-btn" type='submit'>保 存</button>
+            <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定取消编辑吗?" data-close>取消编辑</button>
+        </div>
+    </div>
+</form>
+    <script>
+        window.form.render();
+        $('[name="cover"]').uploadOneImage();
+    </script>
+</div>

+ 67 - 0
application/store/view/live_banner/index.html

@@ -0,0 +1,67 @@
+{extend name='admin@main'}
+
+{block name="button"}
+    <button data-modal='{:url("add")}' data-title="添加轮播图" class='layui-btn layui-btn-sm layui-btn-primary'>添加轮播图</button>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-20" lay-skin="line">
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'><input data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
+            <th class='list-table-sort-td'><button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button></th>
+            <th class='text-left nowrap'>名称</th>
+            <th class='text-left nowrap'>轮播图</th>
+            <th class="text-left" style="width: 20%">操作</th>
+        </tr>
+        </thead>
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class='list-table-sort-td'><input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input"></td>
+            <td class='text-left nowrap'>{$vo.name|default=''}</td>
+            <td class='text-left nowrap'><img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px"></td>
+            <td class='text-left' style="width: 20%">
+                <a data-title="编辑轮播图" class="layui-btn layui-btn-sm" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {if $vo.status == 1}
+                <span class="layui-btn layui-btn-sm layui-btn-warm"  onclick="btn_confirm('禁用','forbidden','{$vo.id}');" >禁 用</span>
+                {else}
+                <span class="layui-btn layui-btn-sm layui-btn-sm"  onclick="btn_confirm('启用','enable','{$vo.id}');">启 用</span>
+                {/if}
+                <span class="layui-btn layui-btn-sm layui-btn-danger" onclick="btn_confirm('删除','del','{$vo.id}');">删 除</span>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/live_cate/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+
+</script>
+{/block}
+
+
+

+ 15 - 0
application/store/view/live_banner/index_search.html

@@ -0,0 +1,15 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">商品名称</label>
+            <div class="layui-input-inline">
+                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入分类名称" class="layui-input">
+            </div>
+        </div>
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>