index.js
3.38 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* @Description: huyue
* @Author: huyue
* @Date: 2022-12-15 17:13:19
* @LastEditors: huyue
* @LastEditTime: 2023-02-06 15:28:18
*/
Component({
externalClasses: ['custom-class', 'novideo-img', 'sub-menu-active-custom', 'sidebar-active-custom'],
/**
* 组件的属性列表
*/
properties: {
// 顶部菜单
hasMenu: {
type: Boolean,
value: false,
},
// 增值转化Data
list: {
type: Array,
observer: function (n) {
this.init(n)
}
},
// banner下活动轮播数据
activityList: {
type: Array,
value: [],
},
// currentScenIndex: {
// type: Number,
// observer(n) {
// this.setData({
// currentScen: n,
// });
// },
// },
// 选中活动tab下标,默认第一个
discoverIndex: {
type: Number,
value: 0
},
},
/**
* 组件的初始数据
*/
data: {
currentScen: 0,
scrollLeft: 0,
bannerSrc: '',
defaultBannerSrc: 'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/banner/banner_default.png',
sceneCode: '',
listData: []
},
/**
* 组件的方法列表
*/
methods: {
// 初始化数据,新增数字化转型案例视频
init(n) {
if (n.length === 0) return
let operationVideoList = []
let videoList = []
// 递归算出得到所有视频
n.forEach(item => {
operationVideoList = operationVideoList.concat(item.operationVideoList)
videoList = videoList.concat(item.videoList)
if (item.subList.length) {
item.subList.forEach(itm => {
operationVideoList = operationVideoList.concat(itm.operationVideoList)
videoList = videoList.concat(itm.videoList)
})
}
})
n.push({
name: '数字化转型案例',
videoList: videoList,
operationVideoList: operationVideoList
})
this.setData({
listData: n
})
},
// 点击特色产品
proClick(e) {
const sceneCode = this.data.sceneCode || this.data.listData[this.data.discoverIndex].sceneCode
console.log(e.detail, sceneCode);
this.triggerEvent('proClick', {info: e.detail, sceneCode});
},
// 点击案例视频
videoClick(e) {
const sceneCode = this.data.sceneCode || this.data.listData[this.data.discoverIndex].sceneCode
console.log(sceneCode);
this.triggerEvent('videoClick', {info: e.detail, sceneCode});
},
// 活动点击
activityClick(e) {
this.triggerEvent('activityClick', e.detail);
},
// 点击场景banner
senceClick() {
const info = this.data.listData.find(
(item) => item.sceneCode === this.data.sceneCode
);
console.log(info);
this.triggerEvent('senceClick', info);
},
// 点击切换菜单
menuClick(e) {
const menuInfo = this.data.listData.find(
(item) => item.sceneCode === e.detail.info.sceneCode
);
const bannerSrc = menuInfo.banner;
const sceneCode = menuInfo.sceneCode
this.setData({
discoverIndex: e.detail.id,
bannerSrc,
sceneCode
});
},
// 初始化
initMenu(e) {
const menuInfo = e.detail
const bannerSrc = menuInfo.banner;
const sceneCode = menuInfo.sceneCode
this.setData({
bannerSrc,
sceneCode
})
},
},
});