修复歌单无法翻页Bug

pull/96/head
lyswhut 2019-09-04 08:58:29 +08:00
parent d4750f4c6e
commit 9564097f46
3 changed files with 16 additions and 7 deletions

View File

@ -67,7 +67,6 @@ const actions = {
let source = rootState.setting.songList.source
let key = `${source}${id}${page}`
if (state.listDetail.list.length && state.listDetail.key == key) return true
commit('clearListDetail')
return music[source].songList.getListDetail(id, page).then(result => commit('setListDetail', { result, key, page }))
},
}
@ -98,6 +97,7 @@ const mutations = {
state.selectListInfo = info
},
clearListDetail(state) {
console.log('object')
state.listDetail.list = []
},
}

View File

@ -86,7 +86,6 @@ export default {
} else {
id = null
}
console.log(id, type)
this._requestObj_list = httpFatch(this.getListUrl({ sortId, id, type, page }))
return this._requestObj_list.promise.then(({ body }) => {
if (!id || type == '10000') {

View File

@ -27,7 +27,7 @@
p(:title="item.desc") {{item.desc}}
li(:class="$style.item" style="cursor: default;" v-if="listData.list && listData.list.length && listData.list.length % 3 == 2")
div(:class="$style.pagination")
material-pagination(:count="listData.total" :limit="listData.limit" :page="listData.page" @btn-click="handleTogglePage")
material-pagination(:count="listData.total" :limit="listData.limit" :page="listData.page" @btn-click="handleToggleListPage")
material-download-modal(:show="isShowDownload" :musicInfo="musicInfo" @select="handleAddDownload" @close="isShowDownload = false")
material-download-multiple-modal(:show="isShowDownloadMultiple" :list="selectdData" @select="handleAddDownloadMultiple" @close="isShowDownloadMultiple = false")
</template>
@ -118,7 +118,7 @@ export default {
methods: {
...mapMutations(['setSongList']),
...mapActions('songList', ['getTags', 'getList', 'getListDetail']),
...mapMutations('songList', ['setVisibleListDetail', 'setSelectListInfo']),
...mapMutations('songList', ['setVisibleListDetail', 'setSelectListInfo', 'clearListDetail']),
...mapActions('download', ['createDownload', 'createDownloadMultiple']),
...mapMutations('list', ['defaultListAdd', 'defaultListAddMultiple']),
...mapMutations('player', ['setList']),
@ -170,13 +170,20 @@ export default {
},
})
},
handleTogglePage(page) {
handleToggleListPage(page) {
this.getList(page).then(() => {
this.$nextTick(() => {
scrollTo(this.$refs.dom_scrollContent, 0)
})
})
},
handleToggleListDetailPage(page) {
this.getListDetail({ id: this.selectListInfo.id, page }).then(() => {
this.$nextTick(() => {
scrollTo(this.$refs.dom_scrollContent, 0)
})
})
},
handleAddDownload(type) {
this.createDownload({ musicInfo: this.musicInfo, type })
this.isShowDownload = false
@ -194,7 +201,10 @@ export default {
handleItemClick(index) {
this.setSelectListInfo(this.listData.list[index])
this.setVisibleListDetail(true)
this.getListDetail({ id: this.selectListInfo.id, page: 1 })
this.clearListDetail()
this.$nextTick(() => {
this.getListDetail({ id: this.selectListInfo.id, page: 1 })
})
},
handleFlowBtnClick(action) {
switch (action) {
@ -215,7 +225,7 @@ export default {
case 'listBtnClick':
return this.handleListBtnClick(data)
case 'togglePage':
return this.handleTogglePage(data)
return this.handleToggleListDetailPage(data)
case 'flowBtnClick':
return this.handleFlowBtnClick(data)
case 'testPlay':