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

const app = getApp();

Page({
  data: {
    List: [
      {
        Name: "智能规划",
        Remark: "对时间早晚没有要求，交由系统根据学习情况安排。",
        SelectedCSS: "",
      },
      {
        Name: "最早优先",
        Remark: "想优先做完以往积压的题卡可选此项。从到期时间较早的往较近的安排题卡。",
        SelectedCSS: "",
      },
      {
        Name: "今天优先",
        Remark: "想优先做完近期添加的，和最适合当天回想的知识可选此项。从到期时间较近的（如当日）往积压较早的安排题卡。",
        SelectedCSS: "",
      },
      
    ],
  },
  onLoad: function (options) {
    var that = this;

    that.setData({
      Containnerheight: main.getWindowHeight(),
    });

    that.init();
  },
  init: function () {
    var that = this;
    common.getStorageValue(this, "SortTypeIndex", 0, function () {
      
      for (var i = 0; i < that.data.List.length; i++) {
        if (i == that.data.SortTypeIndex)
          that.data.List[i].SelectedCSS = "panelItemSelected";
      }
      that.setData({
        List: that.data.List,
      });
    });
  },
  selectType: function (e) {
    var that = this;
    var index = e.currentTarget.dataset.index;
    for (var i = 0; i < that.data.List.length; i++) {
      that.data.List[i].SelectedCSS = "";
      if (i == index) {
        if (that.data.List[i].SelectedCSS == "")
          that.data.List[i].SelectedCSS = "panelItemSelected";
        else
          that.data.List[i].SelectedCSS = "";
      }
    }

    that.setData({
      List: that.data.List,
    });

    wx.setStorageSync("SortTypeIndex", index);
    main.UploadUserConfig();
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
})
