import common from '../../utils/util';
import main from '../../utils/main';

const app = getApp();

Page({
  data: {
  },
  onLoad: function () {
    var that = this;

    that.setData({
      Containnerheight: main.getWindowHeight(),
    });
    
  },
  onShow: function () {
    var that = this;
    common.getStorageValue(that, "CardType", 0, function () {});
  },
  setColorPlan: function () {
    wx.navigateTo({
      url: './colorplan',
    })
  },
  setPattern: function () {
    wx.navigateTo({
      url: './pattern',
    })
  },
  setClickType: function () {
    wx.navigateTo({
      url: './clicktype',
    })
  },
  goto: function (e) {
    var url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url,
    });
  },
  resetTodayTask:function(){
    wx.showModal({
      title: '提醒',
      content: '此操作无法撤销。确认重置今天的任务量吗？',
      showCancel:true,
      cancelText:"确定",
      confirmColor:"#000000",
      confirmText:"取消",
      success (res) {
        if (res.confirm) {
          //console.log('用户点击取消');
        } else if (res.cancel) {
          //console.log('用户点击确定')
          var url = "ResetMiaoguoCardTask?UserID=" + app.globalData.userInfo.UserID;
          main.getData(url, function (data) {
            if (data) {
              wx.showModal({
                title: '提醒',
                content: '重置已完成。请重新开始今天的练习吧。',
                showCancel:false,
                confirmColor:"#000000",
                confirmText:"返回首页",
                success (res) {
                  wx.navigateBack({
                    delta: 2,
                  });
                }
              });
            }
          });
        }
      }
    });
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
});