const app = getApp()
// let app = null;
Component({
  data: {
    labelColor: ["#c41d7f", "#096dd9", "#531dab", "#d46b08", "#389e0d", "#08979c", "#cf1322"],
    bgColor: ["#fff0f6", "#e6f7ff", "#f9f0ff", "#fff7e6", "#f6ffed", "#e6fffb", "#fff1f0"],
    corpUserFlag: false,
  },
  properties: {
    // 抽屉高度
    recordList: {
      type: Array,
      value: [],
    },
    isLogin: {
      type: Boolean,
      value: true
    },
    storeJobListSearchForm: {
      type: Object,
      value: {},
    },
    agencyStatus: {
      type: Boolean,
      value: true
    },
    hasUserInfo: {
      type: Number,
      value: 0
    },
    selectJob: {
      type: Boolean,
      value: false
    },
    loginUserInfo: {
      type: Object,
      value: {}
    },
    type: {
      type: String,
      value: ''
    }


  },
  lifetimes: {
    attached: function () {
      app.getLoginUserTokenInfo().then(() => {
        this.setData({
          corpUserFlag: this.properties.loginUserInfo.corpUserFlag
        })
      });

      // 在组件实例进入页面节点树时执行
    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  ready () {
    // console.log('app.globalData.loginUserInfo.corpUserFlag', app.globalData.loginUserInfo.corpUserFlag);
    console.log('this.properties.loginUserInfo', this.properties.loginUserInfo);
    // app.getLoginUserTokenInfo().then(() => {

    // });

  },
  methods: {

    goLogin () {
      wx.setStorageSync("comeFromPage", "firstBill");
      wx.navigateTo({
        url: "/pages/login/index",
      });
    },
    stoptap (e) {
      return false;
    },
    getPhoneNumber (e) {
      let that = this
      that.triggerEvent("getPhoneNumber", e.detail);
    },
    collectPaste (e) {
      let that = this
      console.log('collectPaste', e);
      that.triggerEvent("collectPaste", e.currentTarget);

    },
    getUserInfoBtn (e) {
      let that = this
      console.log('getUserInfoBtn', e);
      that.triggerEvent("getUserInfoBtn", e.currentTarget);

    },
    goDetail (e) {
      console.log(e);
      var that = this;
      if (!that.data.isLogin) {
        wx.navigateTo({
          url: `../login/index`
        });
      }
      if (that.data.selectJob) {
        that.triggerEvent("getDetail", e.currentTarget);

      } else {
        wx.navigateTo({
          url: `../detail/index?storeJobId=${e.currentTarget.dataset.id}&jobClassify=${e.currentTarget.dataset.info.jobClassify}`,
        });
      }

    },
  }
})