Browse Source

课程区分普通课与私教课

lizhen_gitee 7 months ago
parent
commit
5e7b780ee6

+ 1 - 0
application/admin/controller/Lesson.php

@@ -23,6 +23,7 @@ class Lesson extends Backend
         parent::_initialize();
         $this->model = new \app\admin\model\Lesson;
         $this->view->assign("isShowList", $this->model->getIsShowList());
+        $this->view->assign("typeList", $this->model->getTypeList());
     }
 
 

+ 6 - 3
application/admin/lang/en/lesson.php

@@ -8,9 +8,12 @@ return [
     'Price'         => 'Price',
     'Oldprice'      => 'Old price',
     'Lessoncate_id' => 'Lesson cate',
-    'Is_show'       => 'Is show',
-    'Is_show 1'     => 'up',
-    'Is_show 0'     => 'down',
+    'Is_show'       => 'show or not',
+    'Is_show 1'     => 'show',
+    'Is_show 0'     => 'hidden',
+    'Type'          => 'class type',
+    'Type 1'        => 'default',
+    'Type 2'        => 'private',
     'Weigh'         => 'Weigh',
     'Title'            => 'Title',
     'Title_en'         => 'Title(en)',

+ 3 - 0
application/admin/lang/zh-cn/lesson.php

@@ -11,6 +11,9 @@ return [
     'Is_show'          => '是否显示',
     'Is_show 1'        => '上架',
     'Is_show 0'        => '下架',
+    'Type'             => '课程类型',
+    'Type 1'           => '普通课',
+    'Type 2'           => '私教课',
     'Weigh'            => '排序',
     'Title'            => '长标题',
     'Title_en'         => '长标题en',

+ 14 - 1
application/admin/model/Lesson.php

@@ -25,7 +25,8 @@ class Lesson extends Model
 
     // 追加属性
     protected $append = [
-        'is_show_text'
+        'is_show_text',
+        'type_text'
     ];
     
 
@@ -44,6 +45,12 @@ class Lesson extends Model
     }
 
 
+    public function getTypeList()
+    {
+        return ['1' => __('Type 1'), '2' => __('Type 2')];
+    }
+
+
     public function getIsShowTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['is_show']) ? $data['is_show'] : '');
@@ -52,6 +59,12 @@ class Lesson extends Model
     }
 
 
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
 
 
     public function cate()

+ 12 - 0
application/admin/view/lesson/add.html

@@ -45,6 +45,18 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Is_show')}:</label>
         <div class="col-xs-12 col-sm-8">
                         

+ 12 - 0
application/admin/view/lesson/edit.html

@@ -45,6 +45,18 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Is_show')}:</label>
         <div class="col-xs-12 col-sm-8">
                         

+ 1 - 0
public/assets/js/backend/lesson.js

@@ -34,6 +34,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'price', title: __('Price'), operate:'BETWEEN'},
                         {field: 'oldprice', title: __('Oldprice'), operate:'BETWEEN'},
                         {field: 'lessoncate_id', title: __('Lessoncate_id')},
+                        {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
                         {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
                         {field: 'weigh', title: __('Weigh'), operate: false},
 //                        {field: 'title', title: __('Title'), operate: 'LIKE'},