const {
  globalData: {
    util: {
      regeneratorRuntime,
      navigate_auth_native,
      showTip,
      api: {
        delCollect
      },
      request: {
        get_auth
      }
    }
  }
} = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: Object
  },

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

  },
  ready() {
    let img, url, {
      type,
      serviceUnid
    } = this.data.item;
    switch (type) {
      case '1':
        img = 'shixiangImg'
        url = `/pages/handle/serverDetails/serverDetails?unid=${serviceUnid}`
        break
      case '2':
        img = 'yuyueImg'
        url = `/pages/handle/reservation/index?unid=${serviceUnid}`
        break
    }
    this.setData({
      img,
      url
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    navigate_auth_native,
    del() {
      wx.showModal({
        content: '是否取消该收藏',
        success: async ({
          confirm
        }) => {
          if (!confirm) return
          let {
            data: {
              item: {
                type,
                serviceUnid
              }
            }
          } = this, {
            _err
          } = await get_auth(delCollect, {
            type,
            serviceUnid
          })
          if (_err) return _err.status && showTip('取消收藏失败')
          this.triggerEvent("update", {
            type: 'del'
          })
        }
      })
    }
  }
})