@@ -11,9 +11,9 @@ export default {
1111 total : 0 ,
1212 page : 0 ,
1313 allPage : 1 ,
14- musicSearch ( str , page ) {
14+ musicSearch ( str , page , limit ) {
1515 if ( searchRequest && searchRequest . cancelHttp ) searchRequest . cancelHttp ( )
16- searchRequest = httpFetch ( `http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=5.6.5.6&method=baidu.ting.search.merge&format=json&query=${ encodeURIComponent ( str ) } &page_no=${ page } &page_size=${ this . limit } &type=0&data_source=0&use_cluster=1` )
16+ searchRequest = httpFetch ( `http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=5.6.5.6&method=baidu.ting.search.merge&format=json&query=${ encodeURIComponent ( str ) } &page_no=${ page } &page_size=${ limit } &type=0&data_source=0&use_cluster=1` )
1717 return searchRequest . promise . then ( ( { body } ) => body )
1818 } ,
1919 handleResult ( rawData ) {
@@ -66,22 +66,22 @@ export default {
6666 } ,
6767 search ( str , page = 1 , { limit } = { } , retryNum = 0 ) {
6868 if ( ++ retryNum > 3 ) return Promise . reject ( new Error ( 'try max num' ) )
69- if ( limit != null ) this . limit = limit
69+ if ( limit == null ) limit = this . limit
7070
71- return this . musicSearch ( str , page ) . then ( result => {
71+ return this . musicSearch ( str , page , limit ) . then ( result => {
7272 if ( ! result || result . error_code !== 22000 ) return this . search ( str , page , { limit } , retryNum )
7373 let list = this . handleResult ( result . result . song_info . song_list )
7474
7575 if ( list == null ) return this . search ( str , page , { limit } , retryNum )
7676
7777 this . total = result . result . song_info . total
7878 this . page = page
79- this . allPage = Math . ceil ( this . total / this . limit )
79+ this . allPage = Math . ceil ( this . total / limit )
8080
8181 return Promise . resolve ( {
8282 list,
8383 allPage : this . allPage ,
84- limit : this . limit ,
84+ limit : limit ,
8585 total : this . total ,
8686 source : 'bd' ,
8787 } )
0 commit comments