Kaynağa Gözat

后台不上传视频了,自己在VOD控制台传

lizhen_gitee 4 ay önce
ebeveyn
işleme
ef563cc621

+ 4 - 128
application/admin/controller/Voteplayer.php

@@ -3,15 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
-use Exception;
-use think\Db;
-use think\db\exception\BindParamException;
-use think\db\exception\DataNotFoundException;
-use think\db\exception\ModelNotFoundException;
-use think\exception\DbException;
-use think\exception\PDOException;
-use think\exception\ValidateException;
-use app\common\library\Uploadvideo;
+
 /**
  * 投票选手管理
  *
@@ -36,126 +28,10 @@ class Voteplayer extends Backend
 
 
     /**
-     * 添加
-     *
-     * @return string
-     * @throws \think\Exception
-     */
-    public function add()
-    {
-        if (false === $this->request->isPost()) {
-            return $this->view->fetch();
-        }
-        $params = $this->request->post('row/a');
-        if (empty($params)) {
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        $params = $this->preExcludeFields($params);
-
-        //从oss上传到vod
-        if(!empty($params['video_file'])){
-            $full_filepath = config('upload.cdnurl').$params['video_file'];
-            $uploadvideo = new Uploadvideo();
-            $res = $uploadvideo->testUploadWebVideo($full_filepath,$params['title']);
-            $params['vodid'] = $res;
-        }
-        //从oss上传到vod
-
-        if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
-            $params[$this->dataLimitField] = $this->auth->id;
-        }
-        $result = false;
-        Db::startTrans();
-        try {
-            //是否采用模型验证
-            if ($this->modelValidate) {
-                $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
-                $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
-                $this->model->validateFailException()->validate($validate);
-            }
-            $result = $this->model->allowField(true)->save($params);
-            Db::commit();
-        } catch (ValidateException|PDOException|Exception $e) {
-        Db::rollback();
-        $this->error($e->getMessage());
-    }
-        if ($result === false) {
-            $this->error(__('No rows were inserted'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 编辑
-     *
-     * @param $ids
-     * @return string
-     * @throws DbException
-     * @throws \think\Exception
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
-    public function edit($ids = null)
-    {
-        $row = $this->model->get($ids);
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
-            $this->error(__('You have no permission'));
-        }
-        if (false === $this->request->isPost()) {
-            $this->view->assign('row', $row);
-            return $this->view->fetch();
-        }
-        $params = $this->request->post('row/a');
-        if (empty($params)) {
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        $params = $this->preExcludeFields($params);
 
-        //从oss上传到vod
-        if($row['video_file'] != $params['video_file'] && !empty($params['video_file']) ){
-            $full_filepath = config('upload.cdnurl').$params['video_file'];
-            $uploadvideo = new Uploadvideo();
-            $res = $uploadvideo->testUploadWebVideo($full_filepath,$params['title']);
-            $params['vodid'] = $res;
-        }
-        //从oss上传到vod
 
-        $result = false;
-        Db::startTrans();
-        try {
-            //是否采用模型验证
-            if ($this->modelValidate) {
-                $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
-                $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
-                $row->validateFailException()->validate($validate);
-            }
-            $result = $row->allowField(true)->save($params);
-            Db::commit();
-        } catch (ValidateException|PDOException|Exception $e) {
-        Db::rollback();
-        $this->error($e->getMessage());
-    }
-        if (false === $result) {
-            $this->error(__('No rows were updated'));
-        }
-        $this->success();
-    }
-
-
-    /**
-     * 上传视频
-     */
-    public function editvideo(){
-        $id = input('id');
-        $row = $this->model->get($id);
-
-        if (false === $this->request->isPost()) {
-            $this->view->assign('row', $row);
-            return $this->view->fetch();
-        }
-
-        $this->success();
-    }
 }

+ 3 - 1
application/admin/lang/zh-cn/voteplayer.php

@@ -13,5 +13,7 @@ return [
     'Set status to 0'=> '设为下架',
     'Status 1'       => '上架',
     'Set status to 1'=> '设为上架',
-    'Score'          => '得分数'
+    'Score'          => '得分数',
+    'Thumb_image'    => '视频封面图',
+    'Vodid'          => '云点播id'
 ];

+ 22 - 2
application/admin/view/voteplayer/add.html

@@ -24,7 +24,7 @@
             <input id="c-tuijiangonghui" class="form-control" name="row[tuijiangonghui]" type="text" value="">
         </div>
     </div>
-    <div class="form-group">
+    <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Video_file')}:</label>
         <div class="col-xs-12 col-sm-8">
             <div class="input-group">
@@ -37,7 +37,7 @@
             </div>
             <ul class="row list-inline faupload-preview" id="p-video_file"></ul>
         </div>
-    </div>
+    </div>-->
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Votes')}:</label>
         <div class="col-xs-12 col-sm-8">
@@ -62,6 +62,26 @@
             <input id="c-score" class="form-control" name="row[score]" type="number" value="0">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Thumb_image')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-thumb_image" class="form-control" size="50" name="row[thumb_image]" type="text" value="">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="faupload-thumb_image" class="btn btn-danger faupload" data-input-id="c-thumb_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-thumb_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-thumb_image" class="btn btn-primary fachoose" data-input-id="c-thumb_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-thumb_image"></span>
+            </div>
+            <ul class="row list-inline faupload-preview" id="p-thumb_image"></ul>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Vodid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-vodid" class="form-control" name="row[vodid]" type="text" value="">
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 22 - 2
application/admin/view/voteplayer/edit.html

@@ -24,7 +24,7 @@
             <input id="c-tuijiangonghui" class="form-control" name="row[tuijiangonghui]" type="text" value="{$row.tuijiangonghui|htmlentities}">
         </div>
     </div>
-    <div class="form-group">
+    <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Video_file')}:</label>
         <div class="col-xs-12 col-sm-8">
             <div class="input-group">
@@ -37,7 +37,7 @@
             </div>
             <ul class="row list-inline faupload-preview" id="p-video_file"></ul>
         </div>
-    </div>
+    </div>-->
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Votes')}:</label>
         <div class="col-xs-12 col-sm-8">
@@ -62,6 +62,26 @@
             <input id="c-score" class="form-control" name="row[score]" type="number" value="{$row.score|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Thumb_image')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-thumb_image" class="form-control" size="50" name="row[thumb_image]" type="text" value="{$row.thumb_image|htmlentities}">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="faupload-thumb_image" class="btn btn-danger faupload" data-input-id="c-thumb_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-thumb_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-thumb_image" class="btn btn-primary fachoose" data-input-id="c-thumb_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-thumb_image"></span>
+            </div>
+            <ul class="row list-inline faupload-preview" id="p-thumb_image"></ul>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Vodid')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-vodid" class="form-control" name="row[vodid]" type="text" value="{$row.vodid|htmlentities}">
+        </div>
+    </div>
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 6 - 17
public/assets/js/backend/voteplayer.js

@@ -22,6 +22,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
                 pk: 'id',
                 sortName: 'id',
+                fixedColumns: true,
+                fixedRightNumber: 1,
                 columns: [
                     [
                         {checkbox: true},
@@ -30,23 +32,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'suozaidanwei', title: __('Suozaidanwei'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'tuijiangonghui', title: __('Tuijiangonghui'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
-                        {field: 'video_file', title: __('Video_file'), operate: false, formatter: Table.api.formatter.video},
+//                        {field: 'video_file', title: __('Video_file'), operate: false, formatter: Table.api.formatter.file},
                         {field: 'votes', title: __('Votes')},
                         {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                         {field: 'score', title: __('Score')},
-                        {field: 'operate', title: __('Operate'), table: table,
-                          /*  buttons:[
-                                {
-                                    name:'editvideo',
-                                    text:'上传视频',
-                                    title:'上传视频',
-                                    icon:'fa fa-exclamation-circle',
-                                    classname:'btn btn-xs btn-info btn-dialog btn-selectuser',
-                                    url:'voteplayer/editvideo/id/{ids}?dialog=1',
-                                    target:'_self',
-                                },
-                            ],*/
-                            events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {field: 'thumb_image', title: __('Thumb_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
+                        {field: 'vodid', title: __('Vodid'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]
             });
@@ -57,9 +49,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         add: function () {
             Controller.api.bindevent();
         },
-        editvideo: function () {
-            Controller.api.bindevent();
-        },
         edit: function () {
             Controller.api.bindevent();
         },