// component/waterFlowLayout/waterFlowLayout.js
const wxService = require('../../utils/wxService')

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    currentHasUserInfo: {
      type: Boolean,
      type: false
    },
    imageData: {
      type: Array,
      value: [],
    },
    type: {
      type: Number,
      value: [],
    }

  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    onTapLike(e) {
      const { memberId } = wx.getStorageSync('_baseUserInfo')
      let params = {
        contentId: e.currentTarget.dataset.id,
        type: e.currentTarget.dataset.type,
        userId: memberId
      }
      this.triggerEvent('updataLike', params)
    },
    onTapShare(e) {
      console.log(e)
      let params = {
        url: e.currentTarget.dataset.url,
        title: e.currentTarget.dataset.title,
        headline: e.currentTarget.dataset.headline,
        describe: e.currentTarget.dataset.describe,
        id: e.currentTarget.dataset.id
      }
      wxService.nextTick(() => {
        this.triggerEvent('_onTapShare', params)
      })
    },

    //详情
    gotoDetail(e) {
      // type 1:内容  2：我的发布
      if (this.data.type == 1) {
        wxService.router(`/pages/wantToBuyDetail/wantToBuyDetail?id=${e.currentTarget.dataset.id}`)
      } else if (this.data.type == 2) {
        wxService.router(`/subPackage/page/pages/myReleaseDetail/myReleaseDetail?id=${e.currentTarget.dataset.id}`)
      }
    }
  }
})
