import { getTodayDownloadCount } from '../../utils/downloadPrint';

Page({
    data: {
        userName: '微信用户',
        avatarUrl: '',
        printCount: 0,
        favoriteCount: 0,
        version: '',
    },

    onLoad() {
        const info = wx.getAccountInfoSync();
        const version = info.miniProgram.version || '开发版';
        this.setData({ version });
    },

    onShow() {
        this.refreshStats();
    },

    refreshStats() {
        const printCount = getTodayDownloadCount();
        // 收藏数待与收藏页数据源打通后接入
        const favoriteCount = 0;
        this.setData({ printCount, favoriteCount });
    },

    onGoToDownloads() {
        wx.setStorageSync('favorites_active_tab', 'downloads');
        wx.switchTab({ url: '/pages/favorites/favorites' });
    },

    onGoToFavorites() {
        wx.setStorageSync('favorites_active_tab', 'favorites');
        wx.switchTab({ url: '/pages/favorites/favorites' });
    },

    onGoToGuide() {
        wx.navigateTo({ url: '/supportPages/guide/guide' });
    },

    onGoToPrintSettings() {
        wx.showToast({ title: '功能开发中', icon: 'none' });
    },

    onGoToSettings() {
        wx.showToast({ title: '功能开发中', icon: 'none' });
    },

    onGoToFeedback() {
        wx.showToast({ title: '功能开发中', icon: 'none' });
    },

    onGoToAbout() {
        wx.showToast({ title: '涂鸦丫练习纸', icon: 'none' });
    },

    onGoToPremium() {
        wx.showToast({ title: '功能开发中', icon: 'none' });
    },
});
