exposure-item.vue 1.65 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
            },
            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>