exposure-item.vue 1.79 KB
<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
            },
            pageParams: {
                type: String
            },
            index: {
                type: [String, Number]
            },
            productSkn: {
                type: [String, Number]
            }
        },
        data() {
            return {
                visible: false,
                waitingReport: [],
                isVisible: false
            };
        },
        methods: {
            record(visible) {
                // 元素由不可见变为可见则记录,否则不记录
                if (!this.isVisiable && visible) {
                    const param = {
                        P_NAME: this.pageName,     // 页面名称
                        P_PARAM: this.pageParams,  // 页面参数
                        I_INDEX: this.index,       // 内部item的序号
                        PRD_SKN: this.productSkn   // 商品SKN (可选)
                    };

                    console.log('push')
                    this.waitingReport.push(param);
                }
                this.isVisiable = visible;
            },
            report() {
                if (this.waitingReport.length) {
                    console.log('>>>>>>>>>report<<<<<<<<<', this.waitingReport)
                    this.$yas.event('YB_SHOW_EVENT', this.waitingReport);
                    this.reset();
                }
            },
            reset() {
                this.waitingReport = [];
            }
        }
    };
</script>
<style>
</style>