第十一课:歌手详情抓取

来源:互联网 发布:java时间相减得到小时 编辑:程序博客网 时间:2024/06/05 23:07

1.api
singer.js

export function getSingerDetail(singerId) {  const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg'  const data = Object.assign({}, commonParams, {    hostUin: 0,    needNewCode: 0,    platform: 'yqq',    order: 'listen',    begin: 0,    num: 80,    songstatus: 1,    singermid: singerId  })  return jsonp(url, data, options)}

2.singer-detail.vue

  import {getSingerDetail} from 'api/singer' created() {      this._getDetail()    },    methods: {      _getDetail() {      //没有id 我们就回退回去        if (!this.singer.id) {          this.$router.push('/singer')          return        }        getSingerDetail(this.singer.id).then((res) => {          if (res.code === ERR_OK) {            this.songs = this._normalizeSongs(res.data.list)          }        })      },
原创粉丝点击