|
@@ -73,6 +73,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions: channel } = createNamespacedHelpers('channel');
|
|
|
const { mapActions: channelvideo } = createNamespacedHelpers('channelVideo');
|
|
|
var moment = require('moment');
|
|
|
+const _ = require('lodash');
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
props: {},
|
|
@@ -89,7 +90,7 @@ export default {
|
|
|
},
|
|
|
async created() {
|
|
|
await this.search();
|
|
|
- this.show(this.videolist[0], '0');
|
|
|
+ // this.show(this.videolist[0], '0');
|
|
|
},
|
|
|
methods: {
|
|
|
...channel(['query', 'fetch', 'update', 'create', 'delete']),
|
|
@@ -104,12 +105,26 @@ export default {
|
|
|
}
|
|
|
const res = await this.videoquery({ user_id: this.id });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `videolist`, res.data);
|
|
|
+ this.$set(this, `videolist`, _.orderBy(res.data, ['start_time'], ['asc']));
|
|
|
}
|
|
|
},
|
|
|
show(data, index) {
|
|
|
- this.menuIndex = index;
|
|
|
- this.$set(this, `videoUrl`, data.file_path);
|
|
|
+ if (data) {
|
|
|
+ this.menuIndex = index;
|
|
|
+ this.$set(this, `videoUrl`, data.file_path);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ searchvideo() {
|
|
|
+ let data = this.videolist;
|
|
|
+ let adate = moment().format('YYYY-MM-DD HH:mm');
|
|
|
+ // let adate = '2020-11-13 09:50';
|
|
|
+ let arr = data.find(i => i.start_time <= adate && i.end_time >= adate);
|
|
|
+ let index = data.findIndex(i => i.start_time <= adate && i.end_time >= adate);
|
|
|
+ if (arr && index) {
|
|
|
+ this.show(arr, index);
|
|
|
+ } else {
|
|
|
+ this.show(data[0], '0');
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
computed: {
|
|
@@ -118,6 +133,17 @@ export default {
|
|
|
return this.$route.query.id;
|
|
|
},
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ videolist: {
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ handler(val) {
|
|
|
+ if (val) {
|
|
|
+ this.searchvideo();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
|
},
|