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

const app = getApp();

Page({
  data: {
    ImageUrl:app.globalData.uploadImageUrl,
    IsIPhoneX:app.globalData.IsIPhoneX,
    GradeArr:[
      {Image:"19",Name:"A1 A2",Name2:"小学",BColor:"#EDBF87"},
      {Image:"20",Name:"A2 B1",Name2:"初中",BColor:"#F2ED83"},
      {Image:"21",Name:"B1 B2",Name2:"高中",BColor:"#84D082"},
      {Image:"22",Name:"B2 C1",Name2:"大学",BColor:"#90C0E2"},
    ]
  },
  onLoad: function (options) {
    let that = this;
    
    let ArticleStyleArr=app.globalData.GenerateConfig.ArticleStyle;
    ArticleStyleArr=common.sort(ArticleStyleArr,"ASC","ID","Number");
    that.setData({
      Containnerheight: main.getWindowHeight(),
      ArticleStyleArr:ArticleStyleArr,
    });
    that.getChoicenessArticle();
    main.checkGenerating();
  },
  goto: function (e) {
    let that=this;
    var url=e.currentTarget.dataset.url;

    if (url=="index"){
      wx.reLaunch({
        url: url,
      });
    }
    else if (url=="guide"){
      wx.setStorageSync('IsShowGuideContainer', true);
      wx.reLaunch({
        url: "index",
      });
    }
    else{
      wx.navigateTo({
        url: url,
      });
    }
  },
  //得到精选文章
  getChoicenessArticle:function(){
    let that=this;
    main.getData('GetYJBDCArticleList?IsFine=1', function (data) {
      if (data) {
        that.setData({
          ChoicenessList:data,
        });
        wx.setStorageSync('ChoicenessList', data);
      }
    });
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?goto=articlefine&UserID=' + app.globalData.userInfo.UserID,
    }
  },
})