All files / src/api collectionAPI.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                                                           
import axios from 'axios'
import BACKURL from './backConfig'
 
const host = BACKURL
 
export default {
  /**
   * @msg: 添加收藏的歌曲
   * @param {Number} userId
   * @param {String} type 0 代表歌曲, 1 代表歌单
   * @param {Number} songId
   * @return: {Promise}
   */
  setCollection (userId, type, songId) {
    var params = new URLSearchParams()
    params.append('userId', userId)
    params.append('type', type)
    params.append('songId', songId || '')
    return axios.post(`${host}/collection/add`, params)
  },
  /**
   * @msg: 返回的指定用户ID的收藏列表
   * @param {Number} userId
   * @return: {Promise}
   */
  getCollectionOfUser (userId) {
    return axios.get(`${host}/collection/detail?userId=${userId}`)
  }
}