wupengfei 2 yıl önce
ebeveyn
işleme
0b4dac7b89

+ 9 - 4
.idea/workspace.xml

@@ -2,8 +2,12 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
+      <change afterPath="$PROJECT_DIR$/application/nutrition/controller/VideoComment.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/application/nutrition/view/video_comment/form.html" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/application/nutrition/view/video_comment/index.html" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/api/controller/VideoDemand.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/VideoDemand.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/nutrition/view/video_url/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/application/nutrition/view/video_url/index.html" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -121,7 +125,7 @@
     <property name="WebServerToolWindowPanel.toolwindow.show.date" value="false" />
     <property name="WebServerToolWindowPanel.toolwindow.show.permissions" value="false" />
     <property name="WebServerToolWindowPanel.toolwindow.show.size" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/vendor" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/application/nutrition/view" />
     <property name="node.js.detected.package.eslint" value="true" />
     <property name="node.js.detected.package.tslint" value="true" />
     <property name="node.js.path.for.package.eslint" value="project" />
@@ -132,11 +136,11 @@
   </component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\zs\gaoyixia\application\nutrition\view" />
+      <recent name="D:\zs\gaoyixia\application\nutrition\controller" />
       <recent name="D:\zs\gaoyixia\vendor" />
       <recent name="D:\zs\gaoyixia\application\api\controller" />
       <recent name="D:\zs\gaoyixia\public" />
-      <recent name="D:\zs\gaoyixia\application\common\model" />
-      <recent name="D:\zs\gaoyixia\application\nutrition\view\video_cate" />
     </key>
   </component>
   <component name="SvnConfiguration">
@@ -181,7 +185,8 @@
       <workItem from="1660611515701" duration="6983000" />
       <workItem from="1660697982291" duration="9650000" />
       <workItem from="1660730926670" duration="1018000" />
-      <workItem from="1660783282150" duration="14063000" />
+      <workItem from="1660783282150" duration="17421000" />
+      <workItem from="1660870368036" duration="3676000" />
     </task>
     <servers />
   </component>

+ 37 - 36
application/api/controller/VideoDemand.php

@@ -113,6 +113,43 @@ class VideoDemand extends Base
         }
     }
 
+
+
+    /**
+     * @title 获取视频播放凭证[通过视频ID获取]
+     * @desc 获取视频播放凭证[通过视频ID获取]
+     * @author qc
+     * @url /api/Video_demand/getVideoCredentials
+     * @method GET
+     * @tag 视频播放凭证
+     * @header name:Authorization require:1 desc:Token
+     * @param name:ali_vid type:int require:1  default:0 desc:ali_vid
+     * @return name:playAuth type:string default:-- desc:playAuth(时效3000s)
+     * @return name:requestId type:string default:-- desc:requestId
+     */
+    public function getVideoCredentialsByVideoId()
+    {
+        $client = self::createClient($this->access_key, $this->access_secret);
+        $getVideoPlayAuthRequest = new GetVideoPlayAuthRequest([
+            'videoId'=>input('ali_vid'),
+            "authInfoTimeout" => 3000
+        ]);
+        $runtime = new RuntimeOptions([]);
+        try {
+            $res = $client->getVideoPlayAuthWithOptions($getVideoPlayAuthRequest, $runtime);
+            $json_res =  json_encode($res,true);
+            $res_arr = json_decode($json_res,true);
+        }catch (\Exception $error){
+            if (!($error instanceof TeaError)) {
+                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
+            }
+            $this->error($error->message);
+        }
+        // 复制代码运行请自行打印 API 的返回值
+
+        $this->success('ok',$res_arr['body'] );
+    }
+
     /**
      * @title 获取视频上传凭证
      * @desc 获取视频上传凭证
@@ -193,42 +230,6 @@ class VideoDemand extends Base
     }
 
 
-
-    /**
-     * @title 获取视频播放凭证[通过视频ID获取]
-     * @desc 获取视频播放凭证[通过视频ID获取]
-     * @author qc
-     * @url /api/Video_demand/getVideoCredentials
-     * @method GET
-     * @tag 视频播放凭证
-     * @header name:Authorization require:1 desc:Token
-     * @param name:ali_vid type:int require:1  default:0 desc:ali_vid
-     * @return name:playAuth type:string default:-- desc:playAuth(时效3000s)
-     * @return name:requestId type:string default:-- desc:requestId
-     */
-    public function getVideoCredentialsByVideoId()
-    {
-        $client = self::createClient($this->access_key, $this->access_secret);
-        $getVideoPlayAuthRequest = new GetVideoPlayAuthRequest([
-            'videoId'=>input('ali_vid'),
-            "authInfoTimeout" => 3000
-        ]);
-        $runtime = new RuntimeOptions([]);
-        try {
-            $res = $client->getVideoPlayAuthWithOptions($getVideoPlayAuthRequest, $runtime);
-            $json_res =  json_encode($res,true);
-            $res_arr = json_decode($json_res,true);
-        }catch (\Exception $error){
-            if (!($error instanceof TeaError)) {
-                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
-            }
-            $this->error($error->message);
-        }
-        // 复制代码运行请自行打印 API 的返回值
-
-        $this->success('ok',$res_arr['body'] );
-    }
-
     /**
      * @title 获取视频播放地址[通过视频ID获取]
      * @desc 获取视频播放地址[通过视频ID获取]

+ 95 - 0
application/nutrition/controller/VideoComment.php

@@ -0,0 +1,95 @@
+<?php
+namespace app\Nutrition\controller;
+use app\common\model\DatumIntro;
+use app\common\model\VideoIntro;
+use library\Controller;
+use app\common\model\VideoCate;
+use function AlibabaCloud\Client\value;
+
+/**
+ * 视频评论
+ * Class VideoComment
+ * @package app\Nutrition\controller
+ */
+class VideoComment extends Controller
+{
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'VideoComment';
+    /**
+     * 列表
+     * @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 = '视频列表';
+        $this->video_id = input('video_id');
+        $this->url_id = input('url_id');
+        $sel_where = [];
+        $sel_where[] = ['is_deleted','=',0];
+        $sel_where[] = ['video_id','=',$this->video_id];
+        $sel_where[] = ['url_id','=',$this->url_id];
+        $query = $this->_query($this->table)->alias('c')
+            ->field('c.*,u.name,u.headimg')
+            ->leftJoin("User u",'u.id = c.user_id')
+            ->where($sel_where)->order('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 del()
+    {
+        $this->_save($this->table, ['is_deleted' => 1]);
+    }
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+
+    }
+
+
+
+
+}

+ 237 - 0
application/nutrition/view/video_comment/form.html

@@ -0,0 +1,237 @@
+<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="video_id" type="hidden" value='{$video_info.id|default=""}' class="layui-input">
+                    <input readonly maxlength="20"  value='{$video_info.title|default=""}' 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="title" maxlength="20"  value='{$vo.title|default=""}' 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="article_id" lay-filter ="article_id">
+                        <option value="0">请选择</option>
+                        {foreach $article_list as $vk=>$vv}
+                        <option  {if isset($vo.article_id) && $vo.article_id == $vv['id'] }selected{/if} data-vl_key="{$vk}" value="{$vv['id']}">{$vv['title']}</option>
+                        {/foreach}
+                    </select>
+                </div>
+
+
+                <div class="layui-input-inline">
+                    <select name="article_item" lay-filter ="article_item">
+                        <option value="0">请选择</option>
+                        {foreach $article_list as $vk=>$vv}
+                        {if isset($vo.article_id) && $vo.article_id == $vv['id'] }
+                        {foreach $vv['item_list'] as $cln}
+                        <option {if isset($vo.article_item) && $vo.article_item == $cln['id']} selected  {/if} value="{$cln['id']}">{$cln['title']}</option>
+                        {/foreach}
+                        {/if}
+                        {/foreach}
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">关联资料</label>
+                <div class="layui-input-inline">
+                    <select name="datum_id" lay-filter ="datum_id">
+                        <option value="0">请选择</option>
+                        {foreach $datum_list as $dk=>$dv}
+                        <option  {if isset($vo.datum_id) && $vo.datum_id == $dv['id'] }selected{/if} data-dl_key="{$dk}" value="{$dv['id']}">{$dv['title']}</option>
+                        {/foreach}
+                    </select>
+                </div>
+
+                <div class="layui-input-inline">
+                    <select name="datum_item" lay-filter ="datum_item">
+                        <option value="0">请选择</option>
+                        {foreach $datum_list as $vk=>$vv}
+                        {if isset($vo.datum_id) && $vo.datum_id == $vv['id'] }
+                        {foreach $vv['url_arr'] as $cln}
+                        <option {if isset($vo.datum_item) && $vo.datum_item == $cln['id']} selected  {/if} value="{$cln['id']}">{$cln['title']}</option>
+                        {/foreach}
+                        {/if}
+                        {/foreach}
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">PPT</label>
+                <label class="layui-col-xs10 relative">
+                    <label class="layui-col-xs9 think-form-group-left">
+                        <input name="ppt" value='{$vo.ppt|default=""}'  readonly placeholder="请上传" class="layui-input">
+                    </label>
+                    <button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>上传PPT</button>
+                </label>
+            </div>
+
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">视频封面</label>
+                <div class="layui-input-block">
+                    <input class="cover" name="cover" type="hidden" class="layui-input"  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="up_type" lay-filter ="up_type">
+                        {foreach ['1'=>'上传','2'=>'路径'] as $ck=>$cv}
+                        {if !empty($vo.up_type) &&  $vo.up_type == $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 up_video">
+                <label class="layui-form-label label-required">视频上传</label>
+                <div class="layui-input-block">
+                    <input class="up_url layui-input" name="up_url" type="hidden"  value="{$vo.url|default=''}">
+                </div>
+            </div>
+
+
+            <div class="layui-form-item path"   style="display: none">
+                <label class="layui-form-label label-required">视频路径</label>
+                <div class="layui-input-block">
+                    <input  name="path" class="layui-input"  value="{$vo.url|default=''}" />
+                </div>
+            </div>
+
+            <div class="layui-form-item"  >
+                <label class="layui-form-label label-required">云点播ID</label>
+                <div class="layui-input-block">
+                    <input  name="ali_vid" class="layui-input"  value="{$vo.ali_vid|default=''}" />
+                </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">
+                        <option    value="0">否</option>
+                        <option   {if !empty($vo.is_vip) &&  $vo.is_vip == 1 }selected{/if}  value="1">是</option>
+                    </select>
+                </div>
+            </div>
+
+            <div class="layui-form-item">
+                <label class="layui-form-label label-required">排序</label>
+                <div class="layui-input-block">
+                    <input name="sort"  maxlength="20"  value='{$vo.sort|default=""}' 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 src="/static/plugs/layui/layui.all.js" charset="utf-8"></script>
+    <script>
+
+        window.form.render();
+        $('[name="cover"]').uploadOneImage()
+        $('[name="up_url"]').uploadOneVideo()
+        $(document).on("click",'.video_player',function () {
+            vUrl = $(".item_url").val(); //获取到播放的url
+            var loadstr = '<video width="100%" height="100%"  controls="controls" autobuffer="autobuffer"  autoplay="autoplay" loop="loop">' +
+                '<source src='+vUrl+' type="video/mp4"></source></video>';
+            layer.open({
+                type: 1,
+                title: false,
+                area: ['730px', '500px'],
+                shade: [0.8, 'rgb(14, 16, 22)'],
+                skin: 'demo-class',
+                content: loadstr
+            });
+            form.render();
+        });
+        // 文章监听
+        form.on('select(article_id)', function(data){
+            var cl_html = '<option value="0">请选择</option>';
+            if(data.value == 0) {
+                $("select[name='article_item']").html(cl_html);
+            }else{
+                var vl_key =  data.elem[data.elem.selectedIndex].dataset.vl_key;
+                var article_list = {:json_encode($article_list)};
+                $.each(article_list[vl_key]['item_list'],function (ck,cv) {
+                    cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
+                })
+                $("select[name='article_item']").html(cl_html);
+            }
+            window.form.render();
+        });
+
+        // 关联资料监听
+        form.on('select(datum_id)', function(data){
+            var cl_html = '<option value="0">请选择</option>';
+            if(data.value == 0) {
+                $("select[name='datum_item']").html(cl_html);
+            }else{
+                var dl_key =  data.elem[data.elem.selectedIndex].dataset.dl_key;
+                var datum_list = {:json_encode($datum_list)};
+                $.each(datum_list[dl_key]['url_arr'],function (ck,cv) {
+                    cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
+                })
+                $("select[name='datum_item']").html(cl_html);
+            }
+            window.form.render();
+        });
+        form.on('select(up_type)', function(data){
+            check_type()
+            window.form.render();
+        })
+
+
+        function check_type() {
+            if( $("select[name='up_type']").val() == 1) {
+                $(".up_video").show();
+                $(".path").hide();
+            }else{
+                $(".up_video").hide();
+                $(".path").show();
+            }
+            window.form.render();
+        }
+        check_type()
+
+
+        layui.use(['upload', 'element', 'layer'], function(){
+            var $ = layui.jquery
+                ,upload = layui.upload
+                ,element = layui.element
+                ,layer = layui.layer;
+            upload.render({
+                elem: '#test3',
+                url: '/api/upload/upload', //此处用的是第三方的 http 请求演示,实际使用时改成您自己的上传接口即可。,accept: 'file', //普通文件,
+                accept: 'file', //普通文件,
+                done: function(res){
+                    console.log(res)
+                    $("input[name='ppt']").val(res.data);
+                    layer.msg(re.msg);
+                }
+            });
+        });
+    </script>
+</div>

+ 74 - 0
application/nutrition/view/video_comment/index.html

@@ -0,0 +1,74 @@
+{extend name='admin@main'}
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-20" lay-skin="line">
+        <thead>
+        <tr>
+            <th class='text-left nowrap' >用户</th>
+            <th class='text-left nowrap' style="width: 60%">评论内容</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.name|default='--'}
+                </div>
+            </td>
+            <td class='text-left nowrap'>{$vo.content|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at|default=''}</td>
+            <td class='text-left' style="width: 20%">
+                <a data-title="回 复" class="layui-btn layui-btn-xs" data-modal='{:url("reply")}?id={$vo.id}'>回 复</a>
+                <span class="layui-btn layui-btn-xs 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/video_comment/"+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)
+                }
+            });
+        });
+    }
+
+    $(document).on("click",'.video_player',function () {
+        vUrl = $(this).data('src');  //获取到播放的url
+        var loadstr = '<video width="100%" height="100%"  controls="controls" autobuffer="autobuffer"  autoplay="autoplay" loop="loop">' +
+            '<source src='+vUrl+' type="video/mp4"></source></video>';
+        layer.open({
+            type: 1,
+            title: false,
+            area: ['730px', '500px'],
+            shade: [0.8, 'rgb(14, 16, 22)'],
+            skin: 'demo-class',
+            content: loadstr
+        });
+        form.render();
+    });
+</script>
+{/block}
+
+
+

+ 1 - 0
application/nutrition/view/video_url/index.html

@@ -25,6 +25,7 @@
             <td class='text-left nowrap'>{$vo.is_vip ? '是':'否'}</td>
             <td class='text-left' style="width: 20%">
                 <a data-title="编辑" class="layui-btn layui-btn-xs" data-modal='{:url("edit")}?id={$vo.id}&video_id={$vo.video_id}'>编 辑</a>
+                <a data-title="评论" class="layui-btn layui-btn-xs" data-modal='{:url("/nutrition/video_comment/index")}?url_id={$vo.id}&video_id={$vo.video_id}'>评 论</a>
                 <span class="layui-btn layui-btn-xs layui-btn-danger" onclick="btn_confirm('删除','del','{$vo.id}');">删 除</span>
             </td>
         </tr>