提交 03e87395 编写于 作者: Z Zachary

feat: playlist add collection func

* remove some debug info
* add style
上级 a88a1a49
import axios from "axios"; import axios from "axios";
//const BASIC_URL = "http://zacharyzlj.cn:3000/"; const BASIC_URL = "http://zacharyzlj.cn:3000/";
const BASIC_URL = "http://192.168.31.152:3000/"; //const BASIC_URL = "http://192.168.31.152:3000/";
function createBaseInstance() { function createBaseInstance() {
const instance = axios.create({ baseURL: BASIC_URL, withCredentials: true }); const instance = axios.create({ baseURL: BASIC_URL, withCredentials: true });
......
...@@ -24,3 +24,9 @@ export const getCatList = () => requset.get("/playlist/catlist"); ...@@ -24,3 +24,9 @@ export const getCatList = () => requset.get("/playlist/catlist");
/* 登陆后使用 */ /* 登陆后使用 */
export const getUserPlaylists = id => requset.get(`/user/playlist?uid=${id}`); export const getUserPlaylists = id => requset.get(`/user/playlist?uid=${id}`);
/* 收藏/取消收藏歌单
* 登陆后使用
* t : 类型,1:收藏,2:取消收藏 id : 歌单 id */
export const toggleLikePlaylist = params =>
requset.get("/playlist/subscribe", { params: params });
...@@ -118,6 +118,10 @@ $black: #000; ...@@ -118,6 +118,10 @@ $black: #000;
background-position: -40px -100px; background-position: -40px -100px;
vertical-align: -2px; vertical-align: -2px;
} }
.mod_btn__icon_like--like,
.mod_btn_green__icon_like--like {
background-position: 0 -80px;
}
.mod_btn__icon_add, .mod_btn__icon_add,
.mod_btn__icon_batch, .mod_btn__icon_batch,
.mod_btn__icon_comment, .mod_btn__icon_comment,
...@@ -1304,6 +1308,14 @@ img .playlist__pic { ...@@ -1304,6 +1308,14 @@ img .playlist__pic {
background-position: 0 -150px; background-position: 0 -150px;
margin: 0 auto 16px; margin: 0 auto 16px;
} }
.popup_tips__icon_warn {
display: block;
width: 46px;
height: 46px;
margin: 0 auto 16px;
background-position: 0 -220px;
background-image: url(../img/icon_popup.png);
}
.popup_tips__tit { .popup_tips__tit {
font-size: 14px; font-size: 14px;
color: $white; color: $white;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
style="z-index: 2147483647; left: 646px; top: 326px" style="z-index: 2147483647; left: 646px; top: 326px"
:style="{ display: ifShow ? '' : 'none' }" :style="{ display: ifShow ? '' : 'none' }"
> >
<i class="popup_tips__icon"></i> <i :class="processIcon()"></i>
<h2 class="popup_tips__tit">{{ tip }}</h2> <h2 class="popup_tips__tit">{{ tip }}</h2>
</div> </div>
</template> </template>
...@@ -20,6 +20,22 @@ export default { ...@@ -20,6 +20,22 @@ export default {
type: String, type: String,
default: "", default: "",
}, },
// 0: tip, 1: warn
iconType: { default: 0 },
},
methods: {
processIcon() {
switch (this.iconType) {
case 0:
return "popup_tips__icon";
break;
case 1:
return "popup_tips__icon_warn";
break;
default:
return "";
}
},
}, },
}; };
</script> </script>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<div class="data__desc_txt" id="short_desc"> <div class="data__desc_txt" id="short_desc">
{{ obj.desc }} {{ obj.desc }}
</div> </div>
<a href="javascript:;" class="js_desc" @click="moreClick">[更多]</a> <a class="js_desc" @click="moreClick">[更多]</a>
</div> </div>
<!-- Info --> <!-- Info -->
<ul class="data__info" v-if="cardType != 'songer'"> <ul class="data__info" v-if="cardType != 'songer'">
...@@ -110,7 +110,11 @@ ...@@ -110,7 +110,11 @@
{{ cardType == "song" ? "播放" : "播放全部" }} {{ cardType == "song" ? "播放" : "播放全部" }}
</a> </a>
<a class="mod_btn js_fav_taoge" @click="btnClick('collection')"> <a class="mod_btn js_fav_taoge" @click="btnClick('collection')">
<i class="mod_btn__icon_like"></i>收藏 <i
class="mod_btn__icon_like"
:class="obj.subscribed ? 'mod_btn__icon_like--like' : ''"
></i
>收藏
</a> </a>
<a <a
class="mod_btn js_into_comment" class="mod_btn js_into_comment"
...@@ -120,9 +124,9 @@ ...@@ -120,9 +124,9 @@
<i class="mod_btn__icon_comment"></i>评论({{ commentCount }}) <i class="mod_btn__icon_comment"></i>评论({{ commentCount }})
</a> </a>
<a <a
href="javascript:;"
class="mod_btn js_more" class="mod_btn js_more"
@click="btnClick('more')" @click="btnClick('more')"
style="display: none"
> >
<i class="mod_btn__icon_menu"></i>更多 <i class="mod_btn__icon_menu"></i>更多
</a> </a>
......
...@@ -79,7 +79,6 @@ export default { ...@@ -79,7 +79,6 @@ export default {
let trackIds = res.data.playlist.trackIds.map(({ id }) => id); let trackIds = res.data.playlist.trackIds.map(({ id }) => id);
getSongDetail(trackIds).then((res) => { getSongDetail(trackIds).then((res) => {
let songs = createSongs(res.data.songs); let songs = createSongs(res.data.songs);
console.log(songs);
this.toplists.push(songs); this.toplists.push(songs);
}); });
}); });
......
...@@ -81,7 +81,7 @@ export default { ...@@ -81,7 +81,7 @@ export default {
this.id = this.$route.query.id; this.id = this.$route.query.id;
getMvDetail(this.id).then((res) => { getMvDetail(this.id).then((res) => {
this.mv = createMv(res.data.data); this.mv = createMv(res.data.data);
console.log(this.mv); //console.log(this.mv);
}); });
this.updateMv(); this.updateMv();
this.getComment(); this.getComment();
......
...@@ -147,7 +147,6 @@ export default { ...@@ -147,7 +147,6 @@ export default {
); );
} }
} }
console.log(this.currentAlbums);
}, },
selectArea(n) { selectArea(n) {
this.updateAlbum(); this.updateAlbum();
......
...@@ -52,17 +52,20 @@ ...@@ -52,17 +52,20 @@
</div> </div>
</div> </div>
</div> </div>
<black-tip :ifShow="ifShowTip" :iconType="tipType" :tip="tip" />
</template> </template>
<script> <script>
import DetailInfoCard from "components/common/DetailInfoCard"; import DetailInfoCard from "components/common/DetailInfoCard";
import DetailSonglist from "components/common/DetailSonglist"; import DetailSonglist from "components/common/DetailSonglist";
import CommontBox from "components/common/CommontBox"; import CommontBox from "components/common/CommontBox";
import BlackTip from "components/common/BlackTip";
import { import {
getPlayList, getPlayList,
getPlaylistDetial, getPlaylistDetial,
getSongDetail, getSongDetail,
getCommentsNew, getCommentsNew,
toggleLikePlaylist,
} from "api"; } from "api";
import { processCount, createSong, playSonglist } from "common/utils"; import { processCount, createSong, playSonglist } from "common/utils";
...@@ -76,6 +79,9 @@ export default { ...@@ -76,6 +79,9 @@ export default {
commentPage: 1, commentPage: 1,
commentCount: 0, commentCount: 0,
comments: [], comments: [],
ifShowTip: false,
tip: "",
tipType: 1,
}; };
}, },
created() { created() {
...@@ -84,7 +90,6 @@ export default { ...@@ -84,7 +90,6 @@ export default {
methods: { methods: {
init() { init() {
getPlaylistDetial(this.id).then((res) => { getPlaylistDetial(this.id).then((res) => {
console.log(res);
let d = res.data.playlist; let d = res.data.playlist;
this.playlist = { this.playlist = {
id: d.id, id: d.id,
...@@ -97,12 +102,11 @@ export default { ...@@ -97,12 +102,11 @@ export default {
playCount: processCount(d.playCount), playCount: processCount(d.playCount),
subscribedCount: processCount(d.subscribedCount), subscribedCount: processCount(d.subscribedCount),
shareCount: processCount(d.shareCount), shareCount: processCount(d.shareCount),
subscribed: d.subscribed,
}; };
console.log(this.playlist);
let trackIds = res.data.playlist.trackIds.map(({ id }) => id); let trackIds = res.data.playlist.trackIds.map(({ id }) => id);
let songDetails = getSongDetail(trackIds.slice(0, 500)).then((res) => { let songDetails = getSongDetail(trackIds.slice(0, 500)).then((res) => {
console.log(res.data.songs);
let songs = res.data.songs.map(({ id, name, al, ar, mv, dt }) => { let songs = res.data.songs.map(({ id, name, al, ar, mv, dt }) => {
return createSong({ return createSong({
id, id,
...@@ -122,6 +126,30 @@ export default { ...@@ -122,6 +126,30 @@ export default {
}, },
cardClick(v) { cardClick(v) {
if (v == "all") playSonglist(this.songs); if (v == "all") playSonglist(this.songs);
else if (v == "collection") {
if (this.$store.state.user.isLogged) {
if (!this.playlist.subscribed) {
toggleLikePlaylist({ t: 1, id: this.playlist.id }).then((res) => {
this.playlist.subscribed = true;
this.showTip("收藏成功,已添加到收藏歌单", 0);
});
} else {
toggleLikePlaylist({ t: 2, id: this.playlist.id }).then((res) => {
this.playlist.subscribed = false;
this.showTip("取消收藏成功", 0);
});
}
} else this.showTip("请先登陆", 1);
}
},
showTip(tip, type) {
this.tipType = type;
this.tip = tip;
this.ifShowTip = true;
if (this.tipTimer) clearTimeout(this.tipTimer);
setTimeout(() => {
this.ifShowTip = false;
}, 1300);
}, },
getComment() { getComment() {
let params = { let params = {
...@@ -150,6 +178,7 @@ export default { ...@@ -150,6 +178,7 @@ export default {
DetailInfoCard, DetailInfoCard,
DetailSonglist, DetailSonglist,
CommontBox, CommontBox,
BlackTip,
}, },
}; };
</script> </script>
......
...@@ -159,7 +159,7 @@ export default { ...@@ -159,7 +159,7 @@ export default {
// 获取歌曲信息 // 获取歌曲信息
getSongDetail(this.songId).then((res) => { getSongDetail(this.songId).then((res) => {
let d = res.data.songs[0]; let d = res.data.songs[0];
//console.log(d); //console.log(res);
this.song = createSong({ this.song = createSong({
id: d.id, id: d.id,
name: d.name, name: d.name,
......
...@@ -228,9 +228,7 @@ export default { ...@@ -228,9 +228,7 @@ export default {
// Get songer album // Get songer album
const res4 = await getSongerAlbums({ id: this.id, limit: 5, offset: 0 }); const res4 = await getSongerAlbums({ id: this.id, limit: 5, offset: 0 });
console.log(res4);
this.albums = createAlbums(res4.data.hotAlbums); this.albums = createAlbums(res4.data.hotAlbums);
console.log(this.albums);
// Get songer mv // Get songer mv
const res5 = await getSongerMvs(this.id); const res5 = await getSongerMvs(this.id);
......
...@@ -68,7 +68,6 @@ export default { ...@@ -68,7 +68,6 @@ export default {
updateArtists() { updateArtists() {
getSongers(this.initial, this.type, this.area, this.page) getSongers(this.initial, this.type, this.area, this.page)
.then((res) => { .then((res) => {
console.log(res);
this.artists = res.data.artists; this.artists = res.data.artists;
this.more = res.data.more; this.more = res.data.more;
this.loading = false; this.loading = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册