Commit 4b80a764 authored by xiabin's avatar xiabin

修改utils

parent 41c08c63
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div class="v-teacher-list clearfix"> <div class="v-teacher-list clearfix">
<span class="pull-left">发布时间:{{transcateTimeUnSecs(item.updated_at)}}</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,6 +65,9 @@ ...@@ -64,6 +65,9 @@
{ {
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');
......
...@@ -6,6 +6,30 @@ var Utils = { ...@@ -6,6 +6,30 @@ var Utils = {
isWeixin: function () { isWeixin: function () {
var ua = navigator.userAgent.toLowerCase(); var ua = navigator.userAgent.toLowerCase();
return ua.indexOf('micromessenger') != -1; 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; 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