const app = getApp()

Component({

  properties: {
    background: {
      type: String,
      value: '#F4F5F9'
    },
    color: {
      type: String,
      value: '#000'
    },
    text: {
      type: String,
      value: 'Wechat'
    },
    showLocationIf: {
      type: Boolean,
      value: false
    },
    back: {
      type: Boolean,
      value: false
    },
    home: {
      type: Boolean,
      value: false
    }
  },

  data: {
    array: ['A广场', 'B广场-北京西单'],
    index: 1,
    statusBarHeight: app.statusBarHeight + 'px',
    navigationBarHeight: (app.statusBarHeight + 44) + 'px',
    indexFlaig:null,
  },
  methods: {
    backHome: function () {
      app.globalData.selected = 0
      let tempUrl = '/index/index'
      tt.reLaunch({
        url: tempUrl,
        success(res) {
          console.log(`${res}`);
        },
        fail(err) {
          console.log(`navigateTo调用失败`,err,tempUrl);
        },
      });
    },
    bindPickerChange: function (e) {
      console.log('picker发送选择改变，携带值为', e.detail.value)
      this.setData({
        index: e.detail.value
      })
    },
    back:function() {
      tt.navigateBack({
        delta: 1,
        success(res) {
          console.log(`${res}`);
        },
        fail(err) {
          console.log(`navigateTo调用失败`,err);
        },
      })
    }
  },
  attached: function(){
    this.setData({
      indexFlaig:app.globalData.selected
    })
    console.log(this.properties);
    let pages = getCurrentPages();
    console.log(pages.length);
    if (pages.length <= 1) {
      this.setData({
        back: false
      })
    }
  }
})
