wupengfei 2 anos atrás
pai
commit
29b191d954

+ 198 - 0
application/nutrition/controller/UserDatum.php

@@ -0,0 +1,198 @@
+<?php
+namespace app\Nutrition\controller;
+use app\common\model\VideoIntro;
+use app\common\model\VideoUrl;
+use library\Controller;
+use library\tools\Data;
+use think\Db;
+use app\common\model\VideoCate as VCM;
+/**
+ * 资料管理
+ * Class VideoManage
+ * @package app\Nutrition\controller
+ */
+class UserDatum extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'UserDatum';
+
+    /**
+     * 列表
+     * @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 = '资料列表';
+        $video_cate = VCM::field('id,title')->select()->toArray();
+        $this->video_cate = array_column($video_cate,null,'id');
+        $sel_where = [];
+        $sel_where[] = ['v.is_deleted','=',0];
+        if($title = $this->request->get('title')) $sel_where[] = ['v.title','like','%'.$title.'%'];
+        if($phone = $this->request->get('phone')) $sel_where[] = ['m.phone','like','%'.$phone.'%'];
+        $this->status = $this->request->get('status',-1);
+        if( $this->status  >= 0 ) $sel_where[] = ['v.status','=', $this->status ];
+        $query = $this->_query($this->table)->field('v.*,m.phone,m.name user_name, m.headimg')->alias('v')
+            ->leftJoin('StoreMember m','m.id = v.user_id');
+        $query->where($sel_where)->order('v.status desc ,v.is_top desc ,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)
+    {
+
+
+    }
+
+
+
+
+    /**
+     * 编辑
+     * @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->_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 forbidden()
+    {
+        $this->_save($this->table, ['status' => '0']);
+    }
+
+    /**
+     * 启用
+     * @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 enable()
+    {
+        $this->_save($this->table, ['status' => 1]);
+    }
+
+
+
+
+    /**
+     * 删除资料
+     * @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()
+    {
+        $this->_save($this->table, ['is_deleted' => 1]);
+    }
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if($this->request->isGet() && in_array($this->request->action(),['add','edit'])){
+            $all_cate  = VCM::where(['is_deleted'=>0])->order('sort desc ,id desc')->select();
+            $this->cate_tree = make_tree($all_cate);
+        }
+
+        if($this->request->isPost() && in_array($this->request->action(),['add','edit'])) {
+            $select_label = [];
+            if(isset($data['serve_label']) && !empty($data['serve_label'])){
+                foreach ($data['serve_label'] as $key=>$value){
+                    if($value) $select_label[] = $key;
+                }
+            }
+           if(!empty($select_label)) $data['label'] = ','.implode(',',$select_label);
+        }
+    }
+
+    protected function  _form_result($result){
+
+    }
+
+
+    /**
+     * 资料添加到系列
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function series()
+    {
+        if ($this->request->isGet()) {
+            $id = $this->request->get('id');
+            $has_series = VideoUrl::where('rel_id',$id)->column('video_id');
+            $user_video = \app\common\model\UserVideo::where(['id' => $id])->find()->toArray();
+            $series_list = VideoIntro::where(['is_deleted'=>0,'type'=>2])->where('id','not in',$has_series)->column('title','id');
+            $this->fetch('', ['vo' => $user_video,'series_list'=>$series_list]);
+        } else {
+            $id = input('post.id');
+            $series_id = input('post.series_id');
+            $sort = input('post.sort');
+            $is_vip = input('post.is_vip');
+            $user_video = \app\common\model\UserVideo::where(['id' => $id])->find()->toArray();
+            VideoUrl::create([
+                'video_id'=>$series_id,
+                'cover'=>$user_video['cover'],
+                'url'=>$user_video['video_url'],
+                'sort'=>$sort,
+                'is_vip'=>$is_vip,
+                'source'=>2,
+                'rel_id'=>$id,
+                'title'=>$user_video['title'],
+            ]);
+            $this->success('添加成功!');
+        }
+    }
+
+}

+ 6 - 0
application/nutrition/view/one_datum/form.html

@@ -19,6 +19,12 @@
                     <button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>上传文件</button>
                 </label>
             </div>
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">标签</label>
+                <div class="layui-input-block">
+                    <input name="label" maxlength="20"  value='{$vo.label|default=""}' placeholder="请输入标签" class="layui-input">
+                </div>
+            </div>
 
             <div class="layui-form-item">
                 <label class="layui-form-label label-required">是否VIP</label>

+ 7 - 0
application/nutrition/view/series_datum/form.html

@@ -25,6 +25,13 @@
                 </div>
             </div>
 
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">标签</label>
+                <div class="layui-input-block">
+                    <input name="label" maxlength="20"  value='{$vo.label|default=""}' placeholder="请输入标签" class="layui-input">
+                </div>
+            </div>
+
             <input type="hidden" name="type" value="{$type}">
             <div class="layui-form-item">
                 <label class="layui-form-label label-required">是否VIP</label>

+ 151 - 0
application/nutrition/view/user_datum/form.html

@@ -0,0 +1,151 @@
+
+<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">
+                    {foreach $label_item as $key=>$value}
+                    <input type="checkbox" name="serve_label[{$key}]" title="{$value}" {if isset($label_id_arr) && in_array($key,$label_id_arr)} checked = "checked" {/if}>
+                    {/foreach}
+                </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="status" lay-filter ="status">
+                        {foreach ['暂不审核','审核通过','审核拒绝'] as $ck=>$cv}
+                            <option  {if $vo.status == $ck } selected {/if} value="{$ck}">{$cv}</option>
+                        {/foreach}
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">审核备注</label>
+                <div class="layui-input-block">
+                    <input name="remark" maxlength="20"  value='{$vo.remark|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="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(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>

+ 76 - 0
application/nutrition/view/user_datum/index.html

@@ -0,0 +1,76 @@
+{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">
+    {include file='user_datum/index_search'}
+    <table class="layui-table margin-top-20" lay-skin="line">
+        <thead>
+        <tr>
+            <th class='text-left nowrap' >用户</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>
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+            <td class='text-left nowrap'>
+                <img data-tips-image style="width:50px;height:50px" src="{$vo.headimg|default=''}" class="margin-right-5 text-top">
+                <div class="inline-block">
+                    用户ID:{$vo.user_id|default='--'}<br>
+                    手机号:{$vo.phone|default='--'}<br>
+                    用户昵称:{$vo.user_name|default='--'}
+                </div>
+            </td>
+            <td class='text-left nowrap'>{$vo.title|default=''}</td>
+            <td class='text-left nowrap'>{$vo.datum_url|default=''}</td>
+            <td class='text-left nowrap'>{$vo.status == 0 ?'待审核' : ($vo.status == 1?'审核通过':'审核拒绝')}</td>
+            <td class='text-left nowrap' >
+                {if $vo.status == 0}
+                <a data-title="审核" class="layui-btn layui-btn-sm layui-btn-warm" data-modal='{:url("edit")}?id={$vo.id}'>审 核</a>
+                {else}
+                <a data-title="查看" class="layui-btn layui-btn-sm" data-modal='{:url("edit")}?id={$vo.id}'>查 看</a>
+                {eq name='vo.status' value='1'} <a data-title="加入系列" class="layui-btn layui-btn-sm layui-btn-warm" data-modal='{:url("series")}?id={$vo.id}'>加入系列</a>{/eq}
+                {/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 = "/nutrition/user_datum/"+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}
+
+
+

+ 39 - 0
application/nutrition/view/user_datum/index_search.html

@@ -0,0 +1,39 @@
+<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">
+            <label class="layui-form-label">手机号</label>
+            <div class="layui-input-inline">
+                <input name="phone" value="{$Think.get.phone|default=''}" placeholder="请输入手机号" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">状态</label>
+            <div class="layui-input-inline">
+                <select class="layui-select" name="status">
+                    <option  value="-1" {if $status eq -1 } selected {/if} >全部</option>
+                    {foreach ['暂不审核','审核通过','审核拒绝'] as $ck=>$cv}
+                    <option  {if $status eq $ck } selected {/if} value="{$ck}">{$cv}</option>
+                    {/foreach}
+                </select>
+            </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>

+ 49 - 0
application/nutrition/view/user_datum/series.html

@@ -0,0 +1,49 @@
+
+<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">
+                    <select   class="layui-select" name="series_id" lay-filter ="series_id" >
+                        {foreach $series_list as $ck=>$cv}
+                            <option  {if $vo.status == $ck } selected {/if} value="{$ck}">{$cv}</option>
+                        {/foreach}
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">是否VIP</label>
+                <div class="layui-input-block">
+                    <select  class="layui-select"  name="is_vip" lay-filter ="is_vip">
+                        {foreach ['否','是'] as $ck=>$cv}
+                        {if !empty($video_url.is_vip) &&  $video_url.is_vip == $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();
+
+
+    </script>
+</div>