list.js 1.98 KB
import listModel from '../../models/classroom/list';
import wx from '../../utils/wx';
import config from '../../common/config';
import Yas from '../../common/yas';
import { stringify } from '../../vendors/query-stringify';

let yas;
let app = getApp();

Page({
    data: {
        newList: '',
        oldList: ''
    },
    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: '型人怎么穿?街头怎么玩?来潮流课堂让你轻松变潮人!',
            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); // 首页分享上报
            }
        };
    },
    onLoad: function(qs) {
        wx.showLoading();
        let params = {
            activityType: 1,
            isFront: qs.isFront || 1,
            storeId: qs.storeId || 0,
            trendClassTypeId: 0
        };

        listModel.newList(params).then((result) => {
            this.setData({
                newList: result.list
            });
        });
        listModel.oldList(params).then((result) => {
            this.setData({
                oldList: result.list
            });
        });

        yas = new Yas(app); // 实例化埋点
        yas.pageOpenReport(); // 页面加载完成上报
    },
    goDetail: function(event) {
        global.router.goUrl(`${config.MINI_APP_DOMAIN}/pages/classroom/detail?activityId=${event.currentTarget.id}`);
    },
    onReady: function() {
        wx.hideLoading();
    }
});