diff --git a/t/Gruntfile.js b/t/Gruntfile.js index bb25666..47d8d22 100644 --- a/t/Gruntfile.js +++ b/t/Gruntfile.js @@ -11,7 +11,8 @@ module.exports = function(grunt){ './lib/main.js', './lib/directive/**/*.js', './lib/service/**/*.js', - './lib/list/**/*.js' + './lib/list/**/*.js', + './lib/search/**/*.js' ], dest:'./build/main.js' } diff --git a/t/build/main.js b/t/build/main.js index 05fc11e..bb6486f 100644 --- a/t/build/main.js +++ b/t/build/main.js @@ -125,6 +125,24 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url controller: '' } } + }) + + .state('search',{ + url: '/search/:type', + views:{ + header:{ + templateUrl: '../html/views/search.html', + controller: 'Search' + }, + container:{ + templateUrl: '', + controller: '' + }, + footer:{ + templateUrl: '', + controller: '' + } + } }); }]); ; @@ -263,32 +281,51 @@ app.controller('musicListController', ['$rootScope', 'musicList',function($rootS } musicList.getData($rootScope.keywordsObj.music); }]); -;/*搜索*/ -var SearchController = function($scope, $rootScope, $location, bookList, musicList, movieList){ +;/*负责搜索结果的导向*/ +var Search = function($scope, $rootScope, $location, bookList, musicList, movieList){ var path = $location.path(); + $rootScope.isNoLoaded = false; + //跳回列表页 $scope.search = function(){ var keywords = $scope.keywords; - if(path.indexOf('/book') !== -1 || path === '/'){ + if(path.indexOf('/book') !== -1){ if(keywords){ $rootScope.keywordsObj.book = keywords; } - bookList.getData($rootScope.keywordsObj.book); + $location.path('/book'); - }else if(path.indexOf('/music') !== -1 || path === '/music'){ + }else if(path.indexOf('/music') !== -1){ if(keywords){ $rootScope.keywordsObj.music = keywords; } - musicList.getData($rootScope.keywordsObj.music); + $location.path('/music'); - }else if(path.indexOf('/movie') !== -1 || path === '/movie'){ + }else if(path.indexOf('/movie') !== -1){ if(keywords){ $rootScope.keywordsObj.movie = keywords; } - movieList.getData($rootScope.keywordsObj.movie); + $location.path('/movie'); } }; }; +Search.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList']; +app.controller('Search', Search);;/*仅负责搜索页面的打开*/ +var SearchController = function($scope, $rootScope, $location){ + var path = $location.path(); + $scope.goToSearch = function(){ + if(path.indexOf('/book') !== -1 || path === '/'){ + $location.path('/search/book'); + + }else if(path.indexOf('/music') !== -1 || path === '/music'){ + $location.path('/search/music'); + + + }else if(path.indexOf('/movie') !== -1 || path === '/movie'){ + $location.path('/search/movie'); + } + }; + +}; -SearchController.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList']; - +SearchController.$inject = ['$scope', '$rootScope', '$location']; app.controller('SearchController', SearchController); diff --git a/t/build/main.min.js b/t/build/main.min.js index 664fc1e..28478dc 100644 --- a/t/build/main.min.js +++ b/t/build/main.min.js @@ -1,2 +1,2 @@ /*! wlhmyit 2014-12-12 */ -var app=angular.module("app",["ui.router"]);app.run(["$rootScope",function(a){a.version="0.1",a.author="vczero",a.author_alias="鬼谣",a.isNoLoaded=!0,a.bookList=[],a.musicList=[],a.movieList=[],a.keywordsObj={book:"",music:"",movie:""}}]),app.constant("ServiceConfig",{book_search:"https://api.douban.com/v2/book/search",book_search_id:"https://api.douban.com/v2/book/",music_search:"https://api.douban.com/v2/music/search",music_search_id:"https://api.douban.com/v2/music/",movie_search:"https://api.douban.com/v2/movie/search",movie_search_id:"https://api.douban.com/v2/movie/subject/"}),app.config(["$stateProvider","$urlRouterProvider",function(a,b){b.otherwise("/"),a.state("index",{url:"/",views:{header:{templateUrl:"../html/views/list_header.html",controller:"SearchController"},container:{templateUrl:"../html/views/list_book.html",controller:"BookListController"},footer:{templateUrl:"../html/views/list_footer.html",controller:""}}}).state("book_list",{url:"/book",views:{header:{templateUrl:"../html/views/list_header.html",controller:"SearchController"},container:{templateUrl:"../html/views/list_book.html",controller:"BookListController"},footer:{templateUrl:"../html/views/list_footer.html",controller:""}}}).state("book_detail",{url:"/book/:id",views:{header:{templateUrl:"../html/views/list_header.html",controller:"SearchController"},container:{templateUrl:"../html/views/detail_book.html",controller:"BookDetailController"},footer:{templateUrl:"../html/views/list_footer.html",controller:""}}}).state("music_lsit",{url:"/music",views:{header:{templateUrl:"../html/views/list_header.html",controller:"SearchController"},container:{templateUrl:"../html/views/list_music.html",controller:"musicListController"},footer:{templateUrl:"../html/views/list_footer.html",controller:""}}}).state("movie_lsit",{url:"/movie",views:{header:{templateUrl:"../html/views/list_header.html",controller:"SearchController"},container:{templateUrl:"../html/views/list_movie.html",controller:"movieListController"},footer:{templateUrl:"../html/views/list_footer.html",controller:""}}})}]),app.directive("loading",function(){var a='

