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

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

  },

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

  },

  /**
   * 组件的方法列表
   */
  methods: {
    onTapLike(e){
      console.log(e)
      const { memberId } = wx.getStorageSync('_baseUserInfo')
      var params = {
        contentId: e.currentTarget.dataset.id,
        type: e.currentTarget.dataset.type,
        userId: memberId
      }
      if (!e.currentTarget.dataset.type){
        wxService.post(`/merchant/contentMobileTerminal/operationSave`, params).then(res => {
          if (!res) return false
          const { result, data } = res.data
          if (result == 0) {
            wx.showToast({
              title: '点赞成功',
              icon: 'none'
            })
          }

        }).finally(() => {
        })

      }else{
        wxService.post(`/merchant/contentMobileTerminal/operationDelete`, {
          contentId: e.currentTarget.dataset.id,
          userId: memberId
        }).then(res => {
          if (!res) return false
          const { result, data } = res.data
          if (result == 0) {
            wx.showToast({
              title: '取消点赞成功',
              icon: 'none'
            })
          }

        }).finally(() => {
        })
      }
    },

    //详情
    gotoDetail(e){
      wxService.router(`/pages/wantToBuyDetail/wantToBuyDetail?id=${e.currentTarget.dataset.id}`)
    }
  }
})
