Commit 52c528c1 authored by 杨培's avatar 杨培

simditor

parent eb9e0113
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/** /**
* This is the model class for table "teacher". * This is the model class for table "teacher".
...@@ -15,7 +17,7 @@ use Yii; ...@@ -15,7 +17,7 @@ use Yii;
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
*/ */
class Teacher extends \yii\db\ActiveRecord class Teacher extends ActiveRecord
{ {
public static $lastErrors; public static $lastErrors;
...@@ -34,7 +36,7 @@ class Teacher extends \yii\db\ActiveRecord ...@@ -34,7 +36,7 @@ class Teacher extends \yii\db\ActiveRecord
public function rules() public function rules()
{ {
return [ return [
[['user_id', 'name', 'avatar', 'intro', 'created_at', 'updated_at'], 'required'], [['user_id', 'name', 'avatar', 'intro'], 'required'],
[['user_id', 'created_at', 'updated_at'], 'integer'], [['user_id', 'created_at', 'updated_at'], 'integer'],
[['intro'], 'string'], [['intro'], 'string'],
[['name'], 'string', 'min'=>2, 'max' => 64], [['name'], 'string', 'min'=>2, 'max' => 64],
...@@ -42,6 +44,24 @@ class Teacher extends \yii\db\ActiveRecord ...@@ -42,6 +44,24 @@ class Teacher extends \yii\db\ActiveRecord
]; ];
} }
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
]
// if you're using datetime instead of UNIX timestamp:
// 'value' => new Expression('NOW()'),
]
];
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -65,8 +85,6 @@ class Teacher extends \yii\db\ActiveRecord ...@@ -65,8 +85,6 @@ class Teacher extends \yii\db\ActiveRecord
$model->name = $name; $model->name = $name;
$model->avatar = 'avatar/f6/98/c6/_tjy7DgC0641.jpg'; $model->avatar = 'avatar/f6/98/c6/_tjy7DgC0641.jpg';
$model->intro = '这个家伙很懒,什么也没有写。'; $model->intro = '这个家伙很懒,什么也没有写。';
$model->created_at = time();
$model->updated_at = time();
if ($model->save()) { if ($model->save()) {
return $model->toArray(); return $model->toArray();
......
<?php
use yii\db\Migration;
class m161010_075253_upload_attachments_init extends Migration
{
public $table = 'upload_attachments';
public function up()
{
$this->createTable($this->table, [
'`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT',
'bind' => $this->string(50)->notNull()->comment('绑定归属'),
'key' => $this->string(255)->notNull()->comment('文件key,如"content/fc/abc.jpg"'),
'filesize' => $this->integer(10)->unsigned()->notNull(),
'w' => $this->smallInteger(5)->unsigned()->defaultValue(0)->comment('图片宽'),
'h' => $this->smallInteger(5)->unsigned()->defaultValue(0)->comment('图片高'),
'`status` tinyint(1) NOT NULL DEFAULT \'0\' COMMENT \'文件状态: 0未认领,1已认领,2已删除(弃用)\'',
'upload_time' => $this->integer(10)->unsigned()->notNull()->comment('上传时间'),
'PRIMARY KEY (`id`)',
'KEY `bind` (`bind`)',
], 'ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=\'上传文件状态标记表\'');
}
public function down()
{
$this->dropTable($this->table);
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}
...@@ -11,6 +11,7 @@ $this->title = '发布课程'; ...@@ -11,6 +11,7 @@ $this->title = '发布课程';
//AppAsset::addScript($this, '@web/assets/single-lib/plupload/plupload.full.min.js'); //AppAsset::addScript($this, '@web/assets/single-lib/plupload/plupload.full.min.js');
AppAsset::addScript($this, '@web/assets/course_publish.js'); AppAsset::addScript($this, '@web/assets/course_publish.js');
AppAsset::addCss($this, '@web/assets/css/course_publish.css');
$this->registerCss('[v-cloak] {display:none;}'); $this->registerCss('[v-cloak] {display:none;}');
?> ?>
<div class="send-class" id="publishMain" xmlns:v-el="http://www.w3.org/1999/xhtml"> <div class="send-class" id="publishMain" xmlns:v-el="http://www.w3.org/1999/xhtml">
...@@ -63,10 +64,11 @@ $this->registerCss('[v-cloak] {display:none;}'); ...@@ -63,10 +64,11 @@ $this->registerCss('[v-cloak] {display:none;}');
<input type="hidden" name="vuid" value="{{vuid}}" /> <input type="hidden" name="vuid" value="{{vuid}}" />
<input type="hidden" name="preview_pic" value="{{previewKey}}" /> <input type="hidden" name="preview_pic" value="{{previewKey}}" />
<input type="hidden" name="attachs" value="{{attachs}}" />
<div class="cls-part"> <div class="cls-part">
<div class="tit">课程介绍</div> <div class="tit">课程介绍</div>
<div class="cls-intro-textarea"> <div class="cls-intro-textarea">
<textarea name="intro" class="input-r-control" placeholder="请输入课程介绍..."></textarea> <textarea name="intro" class="input-r-control" placeholder="请输入课程介绍..." id="introEditor"></textarea>
</div> </div>
</div> </div>
......
...@@ -181,7 +181,6 @@ ul, ...@@ -181,7 +181,6 @@ ul,
ol, ol,
li { li {
list-style: none; list-style: none;
float: left;
} }
i, em { i, em {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<script> <script>
import layer from "layer-js"; import layer from "layer-js";
import str from "../../utils/string"; import str from "../../utils/string";
import qiniu from "../../utils/qiniu";
var defaultText = "上传缩略图"; var defaultText = "上传缩略图";
...@@ -28,9 +29,6 @@ export default{ ...@@ -28,9 +29,6 @@ export default{
var self = this; var self = this;
require.ensure(["../../utils/qiniu"], function() {
var qiniu = require("../../utils/qiniu");
var uploader = new qiniu.Uploader({ var uploader = new qiniu.Uploader({
browse_button: self.uploaderId, browse_button: self.uploaderId,
drop_element: self.uploaderId, drop_element: self.uploaderId,
...@@ -103,7 +101,6 @@ export default{ ...@@ -103,7 +101,6 @@ export default{
}); });
uploader.init(); uploader.init();
});
} }
} }
</script> </script>
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import filesize from "file-size"; import filesize from "file-size";
import layer from "layer-js"; import layer from "layer-js";
import str from "../../utils/string"; import str from "../../utils/string";
import qiniu from "../../utils/qiniu";
export default { export default {
data() { data() {
...@@ -52,8 +53,7 @@ export default { ...@@ -52,8 +53,7 @@ export default {
var self = this, var self = this,
startTime; startTime;
require.ensure(["../../utils/qiniu", "moment"], function() { require.ensure(["moment"], function() {
var qiniu = require("../../utils/qiniu");
var moment = require("moment"); var moment = require("moment");
moment.locale('zh-cn', { moment.locale('zh-cn', {
......
...@@ -5,8 +5,9 @@ var Vue = require('vue'); ...@@ -5,8 +5,9 @@ var Vue = require('vue');
var videoUpload = require('../components/uploader/video-upload.vue'); var videoUpload = require('../components/uploader/video-upload.vue');
var thumbUpload = require('../components/uploader/thumb-upload.vue'); var thumbUpload = require('../components/uploader/thumb-upload.vue');
var form = document.forms["coursePublish"];
var layer = require("layer-js"); var layer = require("layer-js");
var Simditor = require("../utils/simditor");
require('jquery-validation');
//$.ajaxSetup({ //$.ajaxSetup({
// beforeSend: function() { // beforeSend: function() {
...@@ -16,6 +17,8 @@ var layer = require("layer-js"); ...@@ -16,6 +17,8 @@ var layer = require("layer-js");
// } // }
//}); //});
var form = document.forms["coursePublish"];
var vm = new Vue({ var vm = new Vue({
el: "#publishMain", el: "#publishMain",
data: { data: {
...@@ -76,11 +79,6 @@ var vm = new Vue({ ...@@ -76,11 +79,6 @@ var vm = new Vue({
this.$on("thumb-uploaded", function(name, data) { this.$on("thumb-uploaded", function(name, data) {
self.previewKey = data.key; self.previewKey = data.key;
}); });
}
});
require.ensure("jquery-validation", function() {
require('jquery-validation');
$(form).validate({ $(form).validate({
debug: true, debug: true,
...@@ -93,4 +91,12 @@ require.ensure("jquery-validation", function() { ...@@ -93,4 +91,12 @@ require.ensure("jquery-validation", function() {
return false; return false;
} }
}); });
var editor = new Simditor({
textarea: $("#introEditor"),
toolbarFloat: false,
defaultImage: "http://simditor.tower.im/assets/images/image.png"
});
}
}); });
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
"jquery": "~2.2.2", "jquery": "~2.2.2",
"jquery-validation": "^1.15.1", "jquery-validation": "^1.15.1",
"moment": "^2.13.0", "moment": "^2.13.0",
"simditor": "^2.3.6",
"video.js": "^5.11.7", "video.js": "^5.11.7",
"vue": "^1.0.8" "vue": "^1.0.8"
} }
......
...@@ -44,7 +44,7 @@ var config = { ...@@ -44,7 +44,7 @@ var config = {
loader: 'vue' loader: 'vue'
}, },
{ {
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/, test: /\.(ttf|eot|svg|woff(2)?)(\?[\w\-_#=&.]+)?$/,
loader: 'file-loader' loader: 'file-loader'
}, },
{test: require.resolve("jquery"), loader: "expose?$!expose?jQuery"} {test: require.resolve("jquery"), loader: "expose?$!expose?jQuery"}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment