import { VueLikePage } from '../../utils/page'
import GoodsApi from '../../apis/goods'
import Router from '../../utils/routes'
import { loadCollectHistory } from '../../utils/storage'

VueLikePage([], {
  data: {
    items: [],
    itemsShowList: []
  },
  methods: {
    onShow () {
      this.getGoodsList()
    },
    bindinput (e) {
      const value = e.detail
      this.setData({
        itemsShowList: this.data.items.filter(item => item.title.indexOf(value) > -1)
      })
    },
    getGoodsList () {
      const list = loadCollectHistory()
        this.setData({
          items: list,
          itemsShowList: list
        })
    },
    search (e) {
      const value = e.detail
    },
    toDetail (e) {
      const { id } = e.currentTarget.dataset
      Router.push({
        url: 'goodsDetail',
        query: {
          goods_id: id
        }
      })
    }
  }
})
