fashionplay.js 2.15 KB
import resource from '../../common/resource';
import event from '../../common/event';
import wx from '../../utils/wx';
import Yas from '../../common/yas';
import { stringify } from '../../vendors/query-stringify';

let yas;
let app = getApp();

Page({
    data: {
        refresh: true,
        resource
    },
    onLoad: function(option) {
        this.setData({
            from: option.from || '普通小程序码'
        });
        yas = new Yas(app);

        event.on('anchor-click', params => { // anchor组件中点击时上报楼层点击事件
            yas.report('YB_MAIN_EVENT', params);
        });

        event.on('scan-success', params => {
            yas.report('YB_SCAN_CODE_SUCCESS_L', params); // 扫码成功后上报
        });

        global.fashionFloors = { // 用户潮流资讯部分的埋点
            F_ID: '0',
            F_NAME: '',
            F_INDEX: 1
        };
    },
    onShow: function() {
        yas.pageOpenReport(); // 进入页面后 上报
    },
    onPageScroll: function(e) {
        event.emit('pageScroll', e);
    },
    onPullDownRefresh: function() {
        this.setData({
            refresh: !this.data.refresh,
            resource
        });

        setTimeout(() => {
            wx.stopPullDownRefresh();
        }, 600);
    },
    onShareAppMessage: function(res) {
        let pages = getCurrentPages();
        let path = pages[pages.length - 1].route || '/pages/index/index';
        let pageParams = stringify(pages[pages.length - 1].options) || '';
        let params = {
            FROM: res.from,
            SHARE_RESULT: 1,
            TITLE: '「生鲜」市集、潮流「便利」,你的潮流生活社区!上海K11艺术购物中心有货MKT',
            DESC: '',
            PATH: path,
            PAGE_PARAM: pageParams
        };

        return {
            title: params.TITLE,
            success: function() {
                yas.report('YB_SHARE_RESULT_L', params); // 首页分享上报
            },
            fail: function() {
                params.SHARE_RESULT = 2;
                yas.report('YB_SHARE_RESULT_L', params); // 首页分享上报
            }
        };
    }
});