wupengfei il y a 2 ans
Parent
commit
fbb4817893

+ 9 - 72
application/nutrition/controller/UserDatum.php

@@ -1,10 +1,9 @@
 <?php
 namespace app\Nutrition\controller;
+use app\common\model\DatumIntro;
 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;
 /**
  * 资料管理
@@ -80,54 +79,6 @@ class UserDatum extends Controller
         $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]);
-    }
-
 
     /**
      * 表单数据处理
@@ -137,20 +88,7 @@ class UserDatum extends Controller
      */
     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){
@@ -171,20 +109,19 @@ class UserDatum extends Controller
     {
         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]);
+            $has_series = DatumIntro::where('rel_id',$id)->column('video_id');
+            $user_datum = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray();
+            $series_list = DatumIntro::where(['is_deleted'=>0,'type'=>2])->where('id','not in',$has_series)->column('title','id');
+            $this->fetch('', ['vo' => $user_datum,'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'],
+            $user_video = \app\common\model\UserDatum::where(['id' => $id])->find()->toArray();
+            \app\common\model\DatumUrl::create([
+                'datum_id'=>$series_id,
+                'url'=>$user_video['datum_url'],
                 'sort'=>$sort,
                 'is_vip'=>$is_vip,
                 'source'=>2,

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

@@ -11,46 +11,6 @@
             </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="label" maxlength="20"  value='{$vo.label|default=""}' placeholder="请输入标签" class="layui-input">
@@ -99,23 +59,6 @@
             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>