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

const app = getApp();

Page({
  data: {
    IsSelect: true,
  },
  onLoad: function (options) {
    var that = this;
    that.setData({
      Containnerheight: main.getWindowHeight(),
      ShowType:options.type,
    });

    var words=[];
    var unitsName="";
    var arr =[];
    if (options.type=="CHN")
      arr= wx.getStorageSync("HanziAll");
    else
      arr= wx.getStorageSync("EnglishAll");
    
    arr = JSON.parse(arr);
    var unitsid = Number(options.unitsid);
    var id = Number(options.id);
    for (var i = 0; i < arr.length; i++) {
      if (arr[i].ID == unitsid) {
        var list = arr[i].Units;
        for (var j = 0; j < list.length; j++) {
          if (list[j].ID==id){
            unitsName = list[j].Name;
            words = list[j].Words;
          }
        }
        that.setData({
          UnitsName: unitsName,
          Words: words,
        });
      }
    }
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
})
