study.js
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer'], function ($, undefined, Frontend,
Form, Template, Swiper, Layer) {
var Controller = {
index: function () {
var first_swiper = new Swiper ('#first_swiper', {
loop: true, // 循环模式选项
// 如果需要分页器
autoplay:true,
pagination: {
el: '.swiper-pagination',
}
})
var main = new Vue({
el: "#main",
data: function () {
return {
// 公共数据
allData: __data,
// 左侧tab栏active
leftKey: 'course',
// 右侧部分需要的数据
nowData: {},
star: '3',
index: 1,
rightkey:'course',
course_name:'',
thirdkey:'book',
detial:'',
bookname:'',
bookAvator:''
}
},
// 计算属性
computed: {
videoList: function () {
return this.nowData.videoList || []
}
},
// 钩子函数
mounted() {
this.nowData = __data[this.leftKey]
// this.$nextTick(function(){
// })
},
updated() {
if (this.leftKey == 'course') {
this.courses = this.nowData.courseList
this.courses.map(item => {
this.star = item.stars
this.index = item.id
this.showStars(this.star, this.index)
})
}
},
// 监控属性
watch: {
// 监听导航按钮下标改变,使用导航对应的平台数据
leftKey: function (newVal, oldVal) {
this.nowData = __data[newVal]
},
},
methods: {
changeTabIndex: function (key) {
this.leftKey = key;
this.rightkey='course'
this.thirdkey='book'
console.log(this.leftKey)
},
play(url,name){
// this.leftKey = 'direct_seeding';
this.videoUrl = url;
this.rightkey='video'
this.course_name=name
},
showStars: function (value, i) {
layui.use(['rate'], function () {
var rate = layui.rate;
rate.render({
elem: '.stars_' + i,
value: value,
readonly: true
});
})
},
showDetial(detial,img,name){
this.thirdkey='detial'
this.detial=detial
this.bookname=name
this.bookAvator=img
}
},
})
},
}
return Controller;
});