Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
52c528c1
Commit
52c528c1
authored
Oct 10, 2016
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simditor
parent
eb9e0113
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
152 additions
and
89 deletions
+152
-89
Teacher.php
src/common/models/Teacher.php
+22
-4
m161010_075253_upload_attachments_init.php
...ole/migrations/m161010_075253_upload_attachments_init.php
+40
-0
publish.php
src/frontend/views/my-course/publish.php
+3
-1
reset.css
src/frontend/web/css/reset.css
+0
-1
thumb-upload.vue
src/frontend/web/js/components/uploader/thumb-upload.vue
+61
-64
video-upload.vue
src/frontend/web/js/components/uploader/video-upload.vue
+2
-2
publish.js
src/frontend/web/js/my-course/publish.js
+22
-16
package.json
src/frontend/web/package.json
+1
-0
webpack.config.js
src/frontend/web/webpack.config.js
+1
-1
No files found.
src/common/models/Teacher.php
View file @
52c528c1
...
...
@@ -3,6 +3,8 @@
namespace
common\models
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\db\ActiveRecord
;
/**
* This is the model class for table "teacher".
...
...
@@ -15,7 +17,7 @@ use Yii;
* @property integer $created_at
* @property integer $updated_at
*/
class
Teacher
extends
\yii\db\
ActiveRecord
class
Teacher
extends
ActiveRecord
{
public
static
$lastErrors
;
...
...
@@ -34,7 +36,7 @@ class Teacher extends \yii\db\ActiveRecord
public
function
rules
()
{
return
[
[[
'user_id'
,
'name'
,
'avatar'
,
'intro'
,
'created_at'
,
'updated_at'
],
'required'
],
[[
'user_id'
,
'name'
,
'avatar'
,
'intro'
],
'required'
],
[[
'user_id'
,
'created_at'
,
'updated_at'
],
'integer'
],
[[
'intro'
],
'string'
],
[[
'name'
],
'string'
,
'min'
=>
2
,
'max'
=>
64
],
...
...
@@ -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
*/
...
...
@@ -65,8 +85,6 @@ class Teacher extends \yii\db\ActiveRecord
$model
->
name
=
$name
;
$model
->
avatar
=
'avatar/f6/98/c6/_tjy7DgC0641.jpg'
;
$model
->
intro
=
'这个家伙很懒,什么也没有写。'
;
$model
->
created_at
=
time
();
$model
->
updated_at
=
time
();
if
(
$model
->
save
())
{
return
$model
->
toArray
();
...
...
src/console/migrations/m161010_075253_upload_attachments_init.php
0 → 100644
View file @
52c528c1
<?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()
{
}
*/
}
src/frontend/views/my-course/publish.php
View file @
52c528c1
...
...
@@ -11,6 +11,7 @@ $this->title = '发布课程';
//AppAsset::addScript($this, '@web/assets/single-lib/plupload/plupload.full.min.js');
AppAsset
::
addScript
(
$this
,
'@web/assets/course_publish.js'
);
AppAsset
::
addCss
(
$this
,
'@web/assets/css/course_publish.css'
);
$this
->
registerCss
(
'[v-cloak] {display:none;}'
);
?>
<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;}');
<input
type=
"hidden"
name=
"vuid"
value=
"{{vuid}}"
/>
<input
type=
"hidden"
name=
"preview_pic"
value=
"{{previewKey}}"
/>
<input
type=
"hidden"
name=
"attachs"
value=
"{{attachs}}"
/>
<div
class=
"cls-part"
>
<div
class=
"tit"
>
课程介绍
</div>
<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>
...
...
src/frontend/web/css/reset.css
View file @
52c528c1
...
...
@@ -181,7 +181,6 @@ ul,
ol
,
li
{
list-style
:
none
;
float
:
left
;
}
i
,
em
{
...
...
src/frontend/web/js/components/uploader/thumb-upload.vue
View file @
52c528c1
...
...
@@ -9,6 +9,7 @@
<
script
>
import
layer
from
"layer-js"
;
import
str
from
"../../utils/string"
;
import
qiniu
from
"../../utils/qiniu"
;
var
defaultText
=
"上传缩略图"
;
...
...
@@ -28,82 +29,78 @@ export default{
var
self
=
this
;
require
.
ensure
([
"../../utils/qiniu"
],
function
()
{
var
qiniu
=
require
(
"../../utils/qiniu"
);
var
uploader
=
new
qiniu
.
Uploader
({
browse_button
:
self
.
uploaderId
,
drop_element
:
self
.
uploaderId
,
upload_token
:
self
.
uptoken
,
filters
:
{
max_file_size
:
'5mb'
,
mime_types
:
[
{
title
:
"图片文件"
,
extensions
:
"jpg,jpeg,gif,png"
}
]
},
flash_swf_url
:
__CDN_URL__
+
'assets/plupload/Moxie.swf'
,
dragdrop
:
true
,
multi_selection
:
false
,
auto_start
:
true
,
init
:
{
'FilesAdded'
:
function
(
up
,
files
)
{
plupload
.
each
(
files
,
function
(
file
)
{
var
uploader
=
new
qiniu
.
Uploader
({
browse_button
:
self
.
uploaderId
,
drop_element
:
self
.
uploaderId
,
upload_token
:
self
.
uptoken
,
filters
:
{
max_file_size
:
'5mb'
,
mime_types
:
[
{
title
:
"图片文件"
,
extensions
:
"jpg,jpeg,gif,png"
}
]
},
flash_swf_url
:
__CDN_URL__
+
'assets/plupload/Moxie.swf'
,
dragdrop
:
true
,
multi_selection
:
false
,
auto_start
:
true
,
init
:
{
'FilesAdded'
:
function
(
up
,
files
)
{
plupload
.
each
(
files
,
function
(
file
)
{
// self.videoSize = filesize(file.origSize, {fixed:2, spacer:' '}).human('si');
// self.videoName = file.name;
});
self
.
state
=
'uploading'
;
up
.
start
();
self
.
text
=
"上传中.."
;
},
//每个文件上传前
'BeforeUpload'
:
function
(
up
,
file
)
{
},
'UploadProgress'
:
function
(
up
,
file
)
{
self
.
text
=
"上传中.."
+
file
.
percent
+
"%"
;
},
//每个文件上传成功后
'FileUploaded'
:
function
(
up
,
file
,
info
)
{
self
.
text
=
"上传完成"
;
});
setTimeout
(
function
()
{
self
.
text
=
file
.
name
;
},
1000
);
self
.
state
=
'uploading'
;
up
.
start
();
self
.
text
=
"上传中.."
;
},
//每个文件上传前
'BeforeUpload'
:
function
(
up
,
file
)
{
},
'UploadProgress'
:
function
(
up
,
file
)
{
self
.
text
=
"上传中.."
+
file
.
percent
+
"%"
;
},
//每个文件上传成功后
'FileUploaded'
:
function
(
up
,
file
,
info
)
{
self
.
text
=
"上传完成"
;
var
response
=
$
.
parseJSON
(
info
.
response
);
self
.
$dispatch
(
"thumb-uploaded"
,
file
.
name
,
response
);
},
'Error'
:
function
(
up
,
err
)
{
var
msg
=
""
;
setTimeout
(
function
()
{
self
.
text
=
file
.
name
;
},
1000
);
if
(
err
.
response
)
{
var
data
=
$
.
parseJSON
(
err
.
response
);
msg
+=
"<br>"
+
data
.
error
;
}
var
response
=
$
.
parseJSON
(
info
.
response
);
self
.
$dispatch
(
"thumb-uploaded"
,
file
.
name
,
response
);
},
'Error'
:
function
(
up
,
err
)
{
var
msg
=
""
;
layer
.
alert
(
"图片 "
+
err
.
file
.
name
+
" 上传失败!"
+
msg
,
{
icon
:
5
,
title
:
"上传失败"
});
self
.
state
=
"error"
;
},
//队列文件处理完毕后
'UploadComplete'
:
function
()
{
self
.
state
=
'completed'
;
if
(
err
.
response
)
{
var
data
=
$
.
parseJSON
(
err
.
response
);
msg
+=
"<br>"
+
data
.
error
;
}
}
});
//上传中禁止重选文件
self
.
$watch
(
"state"
,
function
(
val
,
old
)
{
if
(
val
==
"uploading"
)
{
uploader
.
disableBrowse
();
}
else
{
uploader
.
disableBrowse
(
false
)
;
layer
.
alert
(
"图片 "
+
err
.
file
.
name
+
" 上传失败!"
+
msg
,
{
icon
:
5
,
title
:
"上传失败"
});
self
.
state
=
"error"
;
},
//队列文件处理完毕后
'UploadComplete'
:
function
()
{
self
.
state
=
'completed'
;
}
}
});
self
.
$dispatch
(
"thumb-upload-state-change"
,
val
,
old
);
});
//上传中禁止重选文件
self
.
$watch
(
"state"
,
function
(
val
,
old
)
{
if
(
val
==
"uploading"
)
{
uploader
.
disableBrowse
();
}
else
{
uploader
.
disableBrowse
(
false
);
}
uploader
.
init
(
);
self
.
$dispatch
(
"thumb-upload-state-change"
,
val
,
old
);
});
uploader
.
init
();
}
}
</
script
>
src/frontend/web/js/components/uploader/video-upload.vue
View file @
52c528c1
...
...
@@ -28,6 +28,7 @@
import
filesize
from
"file-size"
;
import
layer
from
"layer-js"
;
import
str
from
"../../utils/string"
;
import
qiniu
from
"../../utils/qiniu"
;
export
default
{
data
()
{
...
...
@@ -52,8 +53,7 @@ export default {
var
self
=
this
,
startTime
;
require
.
ensure
([
"../../utils/qiniu"
,
"moment"
],
function
()
{
var
qiniu
=
require
(
"../../utils/qiniu"
);
require
.
ensure
([
"moment"
],
function
()
{
var
moment
=
require
(
"moment"
);
moment
.
locale
(
'zh-cn'
,
{
...
...
src/frontend/web/js/my-course/publish.js
View file @
52c528c1
...
...
@@ -5,8 +5,9 @@ var Vue = require('vue');
var
videoUpload
=
require
(
'../components/uploader/video-upload.vue'
);
var
thumbUpload
=
require
(
'../components/uploader/thumb-upload.vue'
);
var
form
=
document
.
forms
[
"coursePublish"
];
var
layer
=
require
(
"layer-js"
);
var
Simditor
=
require
(
"../utils/simditor"
);
require
(
'jquery-validation'
);
//$.ajaxSetup({
// beforeSend: function() {
...
...
@@ -16,6 +17,8 @@ var layer = require("layer-js");
// }
//});
var
form
=
document
.
forms
[
"coursePublish"
];
var
vm
=
new
Vue
({
el
:
"#publishMain"
,
data
:
{
...
...
@@ -76,21 +79,24 @@ var vm = new Vue({
this
.
$on
(
"thumb-uploaded"
,
function
(
name
,
data
)
{
self
.
previewKey
=
data
.
key
;
});
}
});
require
.
ensure
(
"jquery-validation"
,
function
()
{
require
(
'jquery-validation'
);
$
(
form
).
validate
({
debug
:
true
,
rules
:
{
name
:
{
required
:
true
$
(
form
).
validate
({
debug
:
true
,
rules
:
{
name
:
{
required
:
true
}
},
submitHandler
:
function
()
{
return
false
;
}
},
submitHandler
:
function
()
{
return
false
;
}
});
});
var
editor
=
new
Simditor
({
textarea
:
$
(
"#introEditor"
),
toolbarFloat
:
false
,
defaultImage
:
"http://simditor.tower.im/assets/images/image.png"
});
}
});
src/frontend/web/package.json
View file @
52c528c1
...
...
@@ -43,6 +43,7 @@
"jquery"
:
"~2.2.2"
,
"jquery-validation"
:
"^1.15.1"
,
"moment"
:
"^2.13.0"
,
"simditor"
:
"^2.3.6"
,
"video.js"
:
"^5.11.7"
,
"vue"
:
"^1.0.8"
}
...
...
src/frontend/web/webpack.config.js
View file @
52c528c1
...
...
@@ -44,7 +44,7 @@ var config = {
loader
:
'vue'
},
{
test
:
/
\.(
ttf|eot|svg|woff
(
2
)?)(\?[
a-z0-9
=&.
]
+
)?
$/
,
test
:
/
\.(
ttf|eot|svg|woff
(
2
)?)(\?[
\w\-
_#
=&.
]
+
)?
$/
,
loader
:
'file-loader'
},
{
test
:
require
.
resolve
(
"jquery"
),
loader
:
"expose?$!expose?jQuery"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment