const Parse = getApp().Parse;
const company = getApp().globalData.company

Component({

  behaviors: [],

  // 属性定义（详情参见下文）
  properties: {
    options: null,
  },

  data: {
    value: '',
  }, // 私有数据，可用于模板渲染

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached: function () {

      let {
        options
      } = this.data
      console.log('搜索栏', options);
      let {
        data,
        src,
        style,
      } = options
      let {
        className,
        equalTo
      } = data[0]
      console.log(className, equalTo);
      let {
        backgroundColor,
        borderRadius,
        btnBgColor,
        btnBorderRadius,
        btnColor,
        btnFontSize,
        btnHeight,
        btnMargin,
        btnWidth,
        height,
        iconColor,
        iconMargin,
        iconSize,
        inputBgColor,
        inputBorderRadius,
        inputColor,
        inputFontSize,
        inputHeight,
        inputMargin,
        inputPadding,
        inputWidth,
        margin,
        opacity,
        padding,
        placeholder,
        placeholderColor,
        width,
      } = style
      this.setData({
        src,
        backgroundColor,
        borderRadius,
        btnBgColor,
        btnBorderRadius,
        btnColor,
        btnFontSize,
        btnHeight,
        btnMargin,
        btnWidth,
        height,
        iconColor,
        iconMargin,
        iconSize,
        inputBgColor,
        inputBorderRadius,
        inputColor,
        inputFontSize,
        inputHeight,
        inputMargin,
        inputPadding,
        inputWidth,
        margin,
        opacity,
        padding,
        placeholder,
        placeholderColor,
        width,
        className,
        equalTo
      })
    },
    moved: function () {},
    detached: function () {},
  },
  ready: function () {},
  pageLifetimes: {
    // 组件所在页面的生命周期函数
    show: function () {},
    hide: function () {},
    resize: function () {},
  },

  methods: {

    goGoodsLitst() {
      let {
        value,
        className,
        equalTo
      } = this.data
      if(!value) {
        wx.showToast({
          title: '请输入需要搜索的内容',
          icon: 'none'
        })
        return
      }
      wx.navigateTo({
        url: '/nova-shop/pages/search-list/index?value=' + value,
        success: (res) => {
          res.eventChannel.emit('acceptDataFromOpenerPage', {
            value,
            className,
            equalTo,
          })
        },
        fail: () => {},
        complete: () => {}
      });
    },
    onMyButtonTap: function () {
      this.setData({
        // 更新属性和数据的方法与更新页面数据的方法类似
      })
    },
    // 内部方法建议以下划线开头
    _myPrivateMethod: function () {
      // 这里将 data.A[0].B 设为 'myPrivateData'
      this.setData({
        'A[0].B': 'myPrivateData'
      })
    },
    _propertyChange: function (newVal, oldVal) {

    }
  }

})