const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
const Http = require("../../utils/HttpBasics");
const config = require("../../config/config");
let app = getApp();
const imgurl = require("../../utils/imgurl");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navigationBarHeight,
    src: imgurl.grade.url,
    actUrl: imgurl.act.url,
    gradeUrl: imgurl.grade.url,
    grade1Url: imgurl.grade1.url,
    grade2Url: imgurl.grade2.url,
    grade3Url: imgurl.grade3.url,
    growthbgUrl: imgurl.growthbg.url,
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    Http.get({
      url: config.api.scoreLevelInfo,
      data: {}
    })
      .then(res => {
        let childs = []
        JSON.parse(res.data.score.rules).forEach(item => {
          if (item.id == 2) {
            childs = item.childs
          }
        })
        that.setData({
          flags: 'have',
          rules: JSON.parse(res.data.score.rules),
          rules1: childs || [],
          levelList: res.data.levelList
        })
        console.log(that.data.rules)
        console.log(that.data.rules1)
      })
      .catch(res => {
        that.setData({
          flags: 'nothave'
        })
      })
  },
  // 点击跳转到我的特享优惠
  gotospecialcourtesy: function () {
    wx.navigateTo({
      url: '/pages/specialcourtesy/specialcourtesy',
    })
  }
})