diff --git a/src/components/Detail.vue b/src/components/Detail.vue index 6c08233..558dea6 100644 --- a/src/components/Detail.vue +++ b/src/components/Detail.vue @@ -181,11 +181,8 @@ export default { ids: this.info.id, site: this.detail.site, name: this.info.name, - type: this.info.type, - year: this.info.year, - note: this.info.note, - last: this.info.last - + detail: this.info, + rate: this.info.rate } star.add(docs).then(res => { this.$message.success('收藏成功') @@ -281,38 +278,9 @@ export default { }) }, getDoubanRate () { - const axios = require('axios') - const cheerio = require('cheerio') const name = this.detail.info.name.trim() - // 豆瓣搜索链接 - var doubanSearchLink = 'https://www.douban.com/search?q=' + name - axios.get(doubanSearchLink).then(res => { - const $ = cheerio.load(res.data) - // 比较第一和第二给豆瓣搜索结果, 看名字是否相符 - var link = '' - var nameInDouban = $($('div.result')[0]).find('div>div>h3>a').first() - if (name.replace(/\s/g, '') === nameInDouban.text().replace(/\s/g, '')) { - link = nameInDouban.attr('href') - } else { - nameInDouban = $($('div.result')[1]).find('div>div>h3>a').first() - if (name.replace(/\s/g, '') === nameInDouban.text().replace(/\s/g, '')) { - link = nameInDouban.attr('href') - } - } - // 如果找到链接,就打开该链接获取评分 - if (link) { - axios.get(link).then(response => { - const parsedHtml = cheerio.load(response.data) - var rating = parsedHtml('body').find('#interest_sectl').first().find('strong').first() - if (rating.text()) { - this.info.rate = rating.text() - } else { - this.info.rate = '暂无评分' - } - }) - } else { - this.info.rate = '暂无评分' - } + zy.doubanRate(name).then(res => { + this.info.rate = res }) }, getDetailInfo () { diff --git a/src/components/Film.vue b/src/components/Film.vue index 0c8e728..3db3368 100644 --- a/src/components/Film.vue +++ b/src/components/Film.vue @@ -327,18 +327,17 @@ export default { if (db) { this.$message.info('已存在') } else { - const docs = { - key: site.key, - ids: e.id, - site: site, - name: e.name, - type: e.type, - year: e.year, - last: e.last, - note: e.note - } - star.add(docs).then(res => { - this.$message.success('收藏成功') + zy.detail(site.key, e.id).then(detailRes => { + const docs = { + key: site.key, + ids: e.id, + site: site, + name: e.name, + detail: detailRes + } + star.add(docs).then(res => { + this.$message.success('收藏成功') + }) }) } }, diff --git a/src/components/Play.vue b/src/components/Play.vue index f06d139..48d9d01 100644 --- a/src/components/Play.vue +++ b/src/components/Play.vue @@ -545,19 +545,18 @@ export default { } }) } else { - const docs = { - key: this.video.key, - ids: info.id, - name: info.name, - type: info.type, - year: info.year, - last: info.last, - note: info.note, - index: info.index - } - star.add(docs).then(res => { - this.$message.success('收藏成功') - this.isStar = true + zy.detail(this.video.key, info.id).then(detailRes => { + const docs = { + key: this.video.key, + ids: info.id, + name: info.name, + detail: detailRes, + index: info.index + } + star.add(docs).then(res => { + this.$message.success('收藏成功') + this.isStar = true + }) }) } }, diff --git a/src/components/Star.vue b/src/components/Star.vue index f75435b..dd5c1fd 100644 --- a/src/components/Star.vue +++ b/src/components/Star.vue @@ -2,12 +2,13 @@