wupengfei %!s(int64=3) %!d(string=hai) anos
pai
achega
a536f123ec

+ 1 - 1
application/mall/controller/Seckill.php

@@ -146,7 +146,7 @@ class Seckill extends Controller
     }
 
     protected function  _form_result($result){
-        $this->success('商品编辑成功!', 'javascript:history.back()');
+        $this->success('编辑成功!', 'javascript:history.back()');
     }
 
 }

+ 153 - 0
application/mall/controller/SeckillGoods.php

@@ -0,0 +1,153 @@
+<?php
+namespace app\mall\controller;
+use library\Controller;
+use think\Db;
+/**
+ * 秒杀商品
+ * Class SeckillGoods
+ * @package app\Nutrition\controller
+ */
+class SeckillGoods extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'SeckillGoods';
+
+    /**
+     * 列表
+     * @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()
+    {
+        $lid = input('id');
+        $search_name = input('search_name','');
+        $this->title =Db::name('information_article')->where(['id'=>$lid])->value('title');
+        $this->lid = $lid;
+        $where = [];
+        $where[]= ['v.act_id','=',$lid];
+        if($search_name) $where[] = ['g.name','like',"%".$search_name."%"];
+        $list = $this->_query($this->table)->alias('v')
+            ->field('v.create_at,v.sort,v.id,v.goods_id,g.name as goods_name,g.cover,g.name,g.low_price,g.status,g.is_deleted')
+            ->where($where)
+            ->join('StoreGoods g','v.goods_id = g.id','LEFT')
+            ->order('v.sort desc ,v.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)
+    {
+        foreach ($data as &$v){
+            $v['goods_num'] = Db::name('SeckillGoods')->where('act_id',$v['id'])->count();
+        }
+
+    }
+
+
+
+    /**
+     * 可添加商品列表
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function goods_list()
+    {
+        $lid = input('id');
+        $live_info = Db::name('VideoIntro')->find($lid);
+        $this->title = $live_info['title'];
+        $this->lid = $lid;
+        $name = input('name');
+        $sel_ids = Db::name('SeckillGoods')->where(['act_id'=>$lid])->column('goods_id');
+        $where = [];
+        $where[]= ['is_deleted','=',0];
+        $where[]= ['status','=',1];
+        if(!empty($sel_ids)) $where[] = ['id','not in',$sel_ids];
+        if($name) $where[] = ['name','like','%'.$name.'%'];
+        $list = $this->_query('StoreGoods')
+            ->field('id,name,cover,low_price')
+            ->where($where)
+            ->order('sort desc ,id desc')->page();
+        return $this->fetch('goods_list');
+    }
+
+
+    /**
+     * ajax添加商品
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function ajax_add()
+    {
+        $sel_goods = input('post.ids');
+        $act_id = input('post.act_id');
+        foreach ($sel_goods as $goods_id){
+            $int_data[]=[
+                'act_id' => $act_id,
+                'goods_id' => $goods_id,
+                'sort' => 0,
+                'create_at' => date("Y-m-d H:i:s")
+            ];
+        }
+        Db::name('SeckillGoods')->insertAll($int_data);
+        return json_encode(['code'=>200]);
+    }
+
+
+    /**
+     * 删除关联商品
+     * @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 del_goods()
+    {
+        $this->_delete($this->table);
+    }
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+
+    }
+    protected function  _form_result($result){
+
+    }
+
+}

+ 147 - 0
application/mall/view/seckill_goods/form.html

@@ -0,0 +1,147 @@
+
+<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="title" maxlength="20"  value='{$vo.title|default=""}' placeholder="请输入标题" class="layui-input">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">分类</label>
+                <div class="layui-input-inline">
+                    <select name="first_classify" lay-filter ="first_classify">
+                        <option value="0">请选择</option>
+                        {if !empty($cate_tree)}
+                        {foreach $cate_tree as $ck=>$cv}
+                        {if  isset($vo.first_classify) && $vo.first_classify == $cv['id'] }
+                        <option selected data-cl_key="{$ck}" value="{$cv['id']}">{$cv['title']}</option>
+                        {else}
+                        <option data-cl_key="{$ck}" value="{$cv['id']}">{$cv['title']}</option>
+                        {/if}
+                        {/foreach}
+                        {/if}
+                    </select>
+                </div>
+                <div class="layui-input-inline">
+                    <select name="second_classify" lay-filter ="second_classify">
+                        <option value="0">请选择</option>
+                        {if !empty($cate_tree)}
+                        {foreach $cate_tree as $ck=>$cv}
+                        {if isset($vo.first_classify) && $vo.first_classify == $cv['id'] }
+                        {if isset($cv['children'])}
+                        {foreach $cv['children'] as $cln}
+                        {if isset($vo.second_classify) && $vo.second_classify == $cln['id'] }
+                        <option selected  value="{$cln['id']}">{$cln['title']}</option>
+                        {else}
+                        <option  value="{$cln['id']}">{$cln['title']}</option>
+                        {/if}
+                        {/foreach}
+                        {/if}
+                        {/if}
+                        {/foreach}
+                        {/if}
+                    </select>
+                </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 video">
+                <label class="layui-form-label label-required">视频</label>
+                <div class="layui-input-block">
+                    <input name="video_url" type="hidden" value="{$vo.video_url|default=''}">
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">是否置顶</label>
+                <div class="layui-input-inline">
+                    <select name="is_top" lay-filter ="is_top">
+                        {foreach ['不置顶','置顶'] as $ck=>$cv}
+                        {if !empty($vo.is_top) &&  $vo.is_top == $ck }
+                        <option selected data-cl_key="{$ck}" value="{$ck}">{$cv}</option>
+                        {else}
+                        <option data-cl_key="{$ck}" value="{$ck}">{$cv}</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();
+        require(['ckeditor', 'angular'], function () {
+            window.createEditor('[name="detail"]', {height: 500,width:1000});
+        })
+
+        $('[name="cover"]').uploadOneImage();
+        $('[name="video_url"]').uploadOneVideo()
+        // 类型选择监听
+        form.on('select(type)', function(data){
+            if(data.value == 1) {
+                $(".video").hide();
+                $(".detail").show();
+            }else{
+                $(".video").show();
+                $(".detail").hide();
+            }
+            window.form.render();
+        })
+        function check_type() {
+            console.log($("select[name='type']").val());
+            if(  $("select[name='type']").val() == 1) {
+                $(".video").hide();
+                $(".detail").show();
+            }else{
+                $(".video").show();
+                $(".detail").hide();
+            }
+            window.form.render();
+        }
+        check_type()
+
+
+        // 分类选择监听
+        form.on('select(first_classify)', function(data){
+            var cl_html = '<option value="0">请选择</option>';
+            if(data.value == 0) {
+                $("select[name='second_classify']").html(cl_html);
+            }else{
+                var cl_key =  data.elem[data.elem.selectedIndex].dataset.cl_key;
+                var goods_spec = {:json_encode($cate_tree)};
+                $.each(goods_spec[cl_key]['children'],function (ck,cv) {
+                    cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
+                })
+                $("select[name='second_classify']").html(cl_html);
+            }
+            window.form.render();
+        })
+
+
+    </script>
+</div>

+ 98 - 0
application/mall/view/seckill_goods/goods_list.html

@@ -0,0 +1,98 @@
+{extend name='admin@main'}
+{block name="button"}
+<a href="javascript:history.go(-1);"  data-title="返 回" class='layui-btn layui-btn-sm layui-btn-primary'>返 回</a>
+{/block}
+{block name="content"}
+<div class="think-box-shadow">
+    <fieldset>
+        <legend>条件搜索</legend>
+        <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+            <input type="hidden" name="id" value="{$lid|default=0}" />
+            <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"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+                <span class="layui-btn" id="add_goods">添 加</span>
+            </div>
+        </form>
+    </fieldset>
+
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'><input id="sel_box" data-auto-none data-check-target='.list-check-box' type='checkbox'></th>
+            <th class='text-left nowrap'>商品ID</th>
+            <th class='text-left nowrap'>商品名称</th>
+            <th class='text-left nowrap'>商品图片</th>
+            <th class='text-left nowrap'>最低价</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <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='text-left nowrap'>{$vo.id|default=''}</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>
+            <th class='text-left nowrap'>{$vo.low_price|default=''}</th>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有可添加商品</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+    form.render();
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/nutrition/information_goods/"+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();
+                    },1500)
+                }
+            });
+        });
+    }
+
+
+    $("#add_goods").click(function () {
+        var sel_goods = new Array();
+        $.each($(".list-check-box"),function (k,v) {
+            if($(".list-check-box").eq(k).is(":checked")) {
+                sel_goods.push($(".list-check-box").eq(k).val());
+            }
+        })
+        if(sel_goods.length == 0){
+            layer.msg('请选择商品');
+            return false;
+        }
+        var news_id = $("input[name='id']").val();
+        $.post('/nutrition/information_goods/ajax_add',{ids:sel_goods,news_id:news_id},function (res) {
+            layer.msg('添加成功');
+            setTimeout(function () {
+                history.go(-1);
+            },1500)
+        })
+    })
+
+</script>
+{/block}
+
+
+

+ 78 - 0
application/mall/view/seckill_goods/index.html

@@ -0,0 +1,78 @@
+{extend name='admin@main'}
+{block name="button"}
+<a data-open='{:url("goods_list")}?id={$lid}'   data-title="添加商品" class='layui-btn layui-btn-sm layui-btn-primary'>添加商品</a>
+{/block}
+{block name="content"}
+<div class="think-box-shadow">
+    <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="search_name" value="{$Think.get.search_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>
+    </fieldset>
+
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <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 nowrap'>最低价</th>
+            <th class="text-left nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <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.goods_name|default=''}</td>
+            <td class='text-left nowrap'><img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px"></td>
+            <th class='text-left nowrap'>{$vo.low_price|default=''}</th>
+            <td class='text-left nowrap'>
+                <span class="layui-btn layui-btn-sm layui-btn-danger" onclick="btn_confirm('删除','del_goods','{$vo.id}');">删 除</span>
+                <span class="layui-btn layui-btn-sm" data-open='{:url("/mall/store_goods/edit")}?id={$vo.goods_id}' >商品详情</span>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+    form.render();
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/nutrition/video_goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg('删除成功');
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 17 - 0
application/mall/view/seckill_goods/index_search.html

@@ -0,0 +1,17 @@
+<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="title" value="{$Think.get.title|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>

+ 77 - 0
application/mall/view/seckill_goods/relate_goods.html

@@ -0,0 +1,77 @@
+{extend name='admin@main'}
+{block name="button"}
+<a data-open='{:url("add_goods")}?id={$lid}'   data-title="添加商品" class='layui-btn layui-btn-sm layui-btn-primary'>添加商品</a>
+{/block}
+{block name="content"}
+<div class="think-box-shadow">
+    <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="search_name" value="{$Think.get.search_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>
+    </fieldset>
+
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <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 nowrap'>最低价</th>
+            <th class="text-left nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <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.goods_name|default=''}</td>
+            <td class='text-left nowrap'><img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px"></td>
+            <th class='text-left nowrap'>{$vo.low_price|default=''}</th>
+            <td class='text-left nowrap'>
+                <span class="layui-btn layui-btn-sm layui-btn-danger" onclick="btn_confirm('删除','del_goods','{$vo.id}');">删 除</span>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+    form.render();
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/mall/video_manage/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg('删除成功');
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 1 - 1
application/nutrition/controller/InformationGoods.php

@@ -76,7 +76,7 @@ class InformationGoods extends Controller
     public function goods_list()
     {
         $lid = input('id');
-        $live_info = Db::name('VideoIntro')->find($lid);
+        $live_info = Db::name('InformationArticle')->find($lid);
         $this->title = $live_info['title'];
         $this->lid = $lid;
         $name = input('name');