index.js 1.39 KB
import resource from '../../common/resource';
import Yas from '../../common/yas';
import config from '../../common/config';
import { stringify } from '../../vendors/query-stringify';

let app = getApp();
let yas;

Page({
    data: {
        resource
    },
    onLoad: function() {
        yas = new Yas(app);
        yas.pageOpenReport();
    },
    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: '美国东西海岸流行趋势、欧洲新锐设计师品牌,日韩最新潮品,尽在YOHO!STORE一手掌握!',
            DESC: '',
            PATH: path,
            PAGE_PARAM: pageParams
        };

        return {
            title: params.TITLE, // 分享标题
            desc: params.DESC, // 分享描述
            success: function() {
                yas.report('YB_SHARE_RESULT_L', params); // 首页分享上报
            },
            fail: function() {
                params.SHARE_RESULT = 2;
                yas.report('YB_SHARE_RESULT_L', params); // 首页分享上报
            }
        };
    },
    toSearch: function() {
        global.router.goUrl(`${config.MINI_APP_DOMAIN}/pages/brand/search`);
    }
});