Commit 1e65a677 authored by 汪波's avatar 汪波

Merge remote-tracking branch 'origin/dev' into dev

parents bc7fcbbd 4b80a764
...@@ -171,7 +171,7 @@ class Course extends \yii\db\ActiveRecord ...@@ -171,7 +171,7 @@ class Course extends \yii\db\ActiveRecord
if ($count > 0) { if ($count > 0) {
$return['data'] = self::find() $return['data'] = self::find()
->select('id,user_id,price,name,intro,preview_pic,recommend,status,play_count,comment_count,favorite_count,created_at,updated_at') ->select('id,user_id,price,name,intro,preview_pic,recommend,status,play_count,comment_count,favorite_count,created_at,updated_at')
->where($cond)->orderBy(['id'=>SORT_DESC])->limit($num)->offset($offset)->with('teachers')->asArray()->all(); ->where($cond)->orderBy(['id'=>SORT_DESC])->limit($num)->offset($offset)->with('teachers')->with('courseware')->asArray()->all();
} }
return $return; return $return;
......
...@@ -135,7 +135,7 @@ class HomeController extends \yii\web\Controller ...@@ -135,7 +135,7 @@ class HomeController extends \yii\web\Controller
throw new HttpException(404, '页面不存在'); throw new HttpException(404, '页面不存在');
} else { } else {
$coursewareInfo = $coursewareInfo->toArray(); $coursewareInfo = $coursewareInfo->toArray();
$coursewareInfo['previewUrl'] = Yii::$app->qiniu->getUrl('public', $course->preview_pic); $coursewareInfo['previewUrl'] = Yii::$app->qiniu->getUrl('public', $course->preview_pic).'-l.preview';
$coursewareInfo['intro'] = $course->intro; $coursewareInfo['intro'] = $course->intro;
$coursewareInfo['courseName'] = $course->name; $coursewareInfo['courseName'] = $course->name;
$coursewareInfo['teachers'] = ArrayHelper::toArray($teachers); $coursewareInfo['teachers'] = ArrayHelper::toArray($teachers);
...@@ -190,7 +190,7 @@ class HomeController extends \yii\web\Controller ...@@ -190,7 +190,7 @@ class HomeController extends \yii\web\Controller
throw new HttpException(404, '页面不存在'); throw new HttpException(404, '页面不存在');
} else { } else {
$coursewareInfo = $coursewareInfo->toArray(); $coursewareInfo = $coursewareInfo->toArray();
$coursewareInfo['previewUrl'] = Yii::$app->qiniu->getUrl('public', $course->preview_pic); $coursewareInfo['previewUrl'] = Yii::$app->qiniu->getUrl('public', $course->preview_pic).'-l.preview';
$coursewareInfo['intro'] = $course->intro; $coursewareInfo['intro'] = $course->intro;
$coursewareInfo['courseName'] = $course->name; $coursewareInfo['courseName'] = $course->name;
$coursewareInfo['teachers'] = ArrayHelper::toArray($teachers); $coursewareInfo['teachers'] = ArrayHelper::toArray($teachers);
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
</div> </div>
<div class="v-teacher-list clearfix"> <div class="v-teacher-list clearfix">
<span class="pull-left">发布时间:2016-08-04</span> <span class="pull-left">发布时间:{{transcateTimeUnSecs(item.updated_at)}}</span>
<span class="pull-right">时长:01:28:21</span> <span class="pull-right">时长:{{transcateSeconds(item.courseware.time)}}</span>
</div> </div>
<div class="v-foot"> <div class="v-foot">
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
</template> </template>
<script> <script>
import moment from 'moment'; import moment from 'moment';
import Utils from '../../utils/utils';
export default{ export default{
data(){ data(){
return { return {
...@@ -64,9 +65,16 @@ ...@@ -64,9 +65,16 @@
{ {
window.location.href = __BASE_URL__ + 'home/video?courseId=' + id; window.location.href = __BASE_URL__ + 'home/video?courseId=' + id;
}, },
transcateSeconds(sec){
return Utils.secondsToHms(sec);
},
transcateTime(time) transcateTime(time)
{ {
return moment(new Date(time * 1000)).format('YYYY-MM-DD HH:mm:ss'); return moment(new Date(time * 1000)).format('YYYY-MM-DD HH:mm:ss');
},
transcateTimeUnSecs(time)
{
return moment(new Date(time * 1000)).format('YYYY-MM-DD HH:mm');
} }
, ,
getFullPreViewPic(pic) getFullPreViewPic(pic)
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
</div> </div>
</template> </template>
<script> <script>
import Utils from '../../libs/utils'; import Utils from '../../utils/utils';
import myvideo from './video.vue'; import myvideo from './video.vue';
export default{ export default{
data(){ data(){
......
/**
* Created by xiabin on 2016/10/19.
*/
var Utils = {
isWeixin: function () {
var ua = navigator.userAgent.toLowerCase();
return ua.indexOf('micromessenger') != -1;
}
};
module.exports = Utils;
\ No newline at end of file
/**
* Created by xiabin on 2016/10/19.
*/
var Utils = {
isWeixin: function () {
var ua = navigator.userAgent.toLowerCase();
return ua.indexOf('micromessenger') != -1;
},
pad: function (num, size) {
var s = num + "";
while (s.length < size) s = "0" + s;
return s;
},
secondsToHms(seconds){
var hour = Math.floor(seconds/3600);
var min = Math.floor(seconds/60);
var sec = Math.floor(seconds % 60);
var result = [];
if(hour > 0){
result.push(this.pad(hour,2));
result.push(this.pad(min,2));
result.push(this.pad(sec,2));
}else if(min > 0){
result.push(this.pad(min,2));
result.push(this.pad(sec,2));
}else{
result.push(this.pad(sec,2));
}
return result.join(':');
}
};
module.exports = Utils;
\ No newline at end of file
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