import axios from "axios"

// axios({
//   method: 'post',
//   url: `${config.backendDir}visit/saveType`,
//   headers: {
//     appId: "CA02F83A5FA162B930AA2F962D202F43B0F6DE0B51AD79FEDB03FA8202BB4909330105B3B347510D87C97060C4288280D4A744E00565A4EC",
//     "Content-Type": "application/json",
//   },
//   data: {
//     moduleType,
//     type: 'visit',
//   },
// })

export default {
  reportVisit(idx) {
    return axios({
      method: 'post',
      url: `${process.env.VUE_APP_API_PREFIX}addVisit`,
      headers: {
        "Content-Type": "application/json",
      },
      data: {
        id: idx,
        type: 'visit',
      },
    })
  },
  like(idx) {
    return axios({
      method: 'post',
      url: `${process.env.VUE_APP_API_PREFIX}addVisit`,
      headers: {
        "Content-Type": "application/json",
      },
      data: {
        id: idx,
        type: 'star',
      },
    })
  },
  getLikeCount(idx) {
    return axios({
      method: 'get',
      url: `${process.env.VUE_APP_API_PREFIX}visit/detail/${idx}`,
      headers: {
        "Content-Type": "application/json",
      },
      data: {
        // id: idx,
      },
    }).then((res) => {
      return res.data.data.pcsStar
    })
  },
  getAllLikeCount() {
    return axios({
      method: 'get',
      url: `${process.env.VUE_APP_API_PREFIX}visit/count`,
      headers: {
        "Content-Type": "application/json",
      },
      data: {
        // id: idx,
      },
    }).then((res) => {
      return res.data.data.pcsStar
    })
  }
}