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

const app = getApp();

Page({
  data: {
    ImagePath: app.globalData.uploadImageUrl,
    List: [
      {
        Name: "使用专属按钮",
        Image: "help_picture_clickshow_02",
        Remark: "通过点击界面底部黑色按钮显示段落2、段落3（如果有的话）和“记忆评价”。所有步进操作均集中于界面底端，不易误操作，适合入门阶段使用。",
        SelectedCSS:"",
      },
      {
        Name: "点击空白区域",
        Image: "help_picture_clickshow_03",
        Remark: "通过点击界面底部黑色按钮显示段落2、段落3（如果有的话）和“记忆评价”。所有步进操作均集中于界面底端，不易误操作，适合入门阶段使用。",
        SelectedCSS: "",
      },
      {
        Name: "同时启用以上两种方式",
        Image: "",
        Remark: "",
        SelectedCSS: "",
      },
    ],
  },
  onLoad: function (options) {
    var that = this;
    that.setData({
      Containnerheight: main.getWindowHeight(),
    });

    that.init();
  },
  init: function () {
    var that = this;
    var clickType = wx.getStorageSync("ClickType");
    if (!clickType)
      clickType = 0;

    for(var i=0;i<that.data.List.length;i++){
      if (i==clickType)
        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("ClickType", index);
    main.UploadUserConfig();
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
})
