exposure-item.vue
1.65 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
<template>
<div class="exposure-item">
<slot></slot>
</div>
</template>
<script>
import _ from 'lodash';
import yoho from 'yoho';
import util from 'common/util';
export default {
name: 'ExposureItem',
props: {
pageName: {
type: String
},
pageParam: {
type: String,
},
index: {
type: [String, Number]
},
productSkn: {
type: [String, Number]
}
},
data() {
return {
isVisible: false,
appPrefix: yoho.isiOS ? 'i' : (yoho.isAndroid ? 'a' : 'h5')
};
},
methods: {
record(visible, init) {
if (init) {
this.isVisiable = false;
}
// 元素由不可见变为可见则记录,否则不记录
if (!this.isVisiable && visible) {
const param = {
P_NAME: `${this.appPrefix}${this.pageName}` || '', // 页面名称
P_PARAM: this.pageParam || '', // 页面参数
I_INDEX: this.index + 1, // 内部item的序号
PRD_SKN: this.productSkn // 商品SKN (可选)
};
if (param.P_PARAM === '') {
delete param.P_PARAM;
}
this.$parent.addIntoWaiting(param);
}
this.isVisiable = visible;
}
}
};
</script>
<style>
</style>