k94314517
2024-07-24 a924e3906a3b77f04ac4fedcff9e76ebe0c997a2
wechat_staff/pages/detailDis/case.js
@@ -49,6 +49,42 @@
  //     path: '/pages/index/index?id=' + productDetail.id + '&shareuserid=' + userInfo.id + '&type=0'
  //   }
  // },
  handleEnjoy(e) {
    const enjoyList = wx.getStorageSync('enjoyList') || []
    const { type, flag } = e.detail
    console.log('type', type);
    console.log('flag', flag);
    const info = this.data.info
    if(type == 'enjoy'){
      // 点击了喜欢
      const index = enjoyList.findIndex( i => i.id === info.id )
      if(index === -1){
        info.isEnjoy = true
        this.setData({ info })
        enjoyList.push({
          ...info,
          joinType: 'product',
          timestamp: new Date().getTime()
        })
      }else{
        info.isEnjoy = false
        this.setData({ info })
        enjoyList.splice(index, 1)
      }
      wx.setStorageSync('enjoyList', enjoyList)
    }else{
      actionDo({
        id: info.id,
        actionType: flag ? 'collect' : 'collect_cancel'
      }).then(res => {
        info.isCollection = flag
        wx.showToast({title: flag ? '收藏成功' : '取消收藏'})
        this.setData({
          info
        })
      })
    }
  },
  handleAction(e){
    const actionType = e.currentTarget.dataset.code
    const { info } = this.data