diff --git a/platforms/android/CordovaLib/ant-build/build.prop b/platforms/android/CordovaLib/ant-build/build.prop index 1339082..1fef219 100644 --- a/platforms/android/CordovaLib/ant-build/build.prop +++ b/platforms/android/CordovaLib/ant-build/build.prop @@ -1,5 +1,5 @@ #Last build type -#Sun, 11 May 2014 16:43:16 +0800 +#Wed, 21 May 2014 14:13:08 +0800 build.last.target=debug diff --git a/platforms/android/ant-build/Libr-debug-unaligned.apk b/platforms/android/ant-build/Libr-debug-unaligned.apk index afe5405..c8d259b 100644 Binary files a/platforms/android/ant-build/Libr-debug-unaligned.apk and b/platforms/android/ant-build/Libr-debug-unaligned.apk differ diff --git a/platforms/android/ant-build/Libr-debug.apk b/platforms/android/ant-build/Libr-debug.apk index 7500842..5e98fc5 100644 Binary files a/platforms/android/ant-build/Libr-debug.apk and b/platforms/android/ant-build/Libr-debug.apk differ diff --git a/platforms/android/ant-build/Libr.ap_ b/platforms/android/ant-build/Libr.ap_ index 76cfd5a..b633a11 100644 Binary files a/platforms/android/ant-build/Libr.ap_ and b/platforms/android/ant-build/Libr.ap_ differ diff --git a/platforms/android/ant-build/Libr.ap_.d b/platforms/android/ant-build/Libr.ap_.d index 9008841..31ade90 100644 --- a/platforms/android/ant-build/Libr.ap_.d +++ b/platforms/android/ant-build/Libr.ap_.d @@ -494,31 +494,12 @@ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/css \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/fonts \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/css/all.min.css \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/fonts/ionicons.eot \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/fonts/ionicons.svg \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/fonts/ionicons.ttf \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/fonts/ionicons.woff \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js/all.min.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/authication-service.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/book-service.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/books-controller.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/comments-service.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/constant.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/controllers.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/douban-service.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/error-handler.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/geolocation.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/home-controller.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/ionic-utils.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/localstorage-utils.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/location-controller.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/login-controller.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/main-controller.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/recommend-service.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/scan-service.js \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/dist/js-app/settings-controller.js \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/fonts/ionicons.eot \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/fonts/ionicons.svg \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/fonts/ionicons.ttf \ @@ -526,10 +507,12 @@ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/img/default.jpg \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/img/douban_24.png \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/img/douban_32.png \ +/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/img/social.umeng \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app.js \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/imgcache.js \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/libr.js \ +/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/umeng \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/controllers \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/handler \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/services \ @@ -548,7 +531,6 @@ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/services/douban-service.coffee \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/services/geolocation.coffee \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/services/recommend-service.coffee \ -/Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/services/rest \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/services/scan-service.coffee \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/utils/ionic-utils.coffee \ /Users/twer/gitrepo/libr-mobile/platforms/android/assets/www/js/app/utils/localstorage-utils.coffee \ diff --git a/platforms/android/ant-build/build.prop b/platforms/android/ant-build/build.prop index 6538dbc..18ac771 100644 --- a/platforms/android/ant-build/build.prop +++ b/platforms/android/ant-build/build.prop @@ -1,5 +1,5 @@ #Last build type -#Sun, 11 May 2014 16:43:39 +0800 +#Wed, 21 May 2014 14:13:14 +0800 build.last.target=debug diff --git a/platforms/android/assets/www/dist/js/all.min.js b/platforms/android/assets/www/dist/js/all.min.js index 6c71a75..74ad34c 100644 --- a/platforms/android/assets/www/dist/js/all.min.js +++ b/platforms/android/assets/www/dist/js/all.min.js @@ -1,1304 +1,18 @@ -(function() { - var IonicUtils, libr; - - libr = angular.module('libr.services.utils', []); - - IonicUtils = (function() { - IonicUtils.$inject = ['$timeout']; - - function IonicUtils($timeout) { - this.$timeout = $timeout; - } - - IonicUtils.prototype.initCustomLoading = function(scope) { - return scope.data = { - isLoading: false, - text: null - }; - }; - - IonicUtils.prototype.showLoading = function(scope, text, timing) { - if (timing == null) { - timing = 3000; - } - scope.data = { - isLoading: true, - text: text - }; - return this.$timeout((function(_this) { - return function() { - return _this.initCustomLoading(scope); - }; - })(this), timing); - }; - - IonicUtils.prototype.cacheImage = function(imageUrl) { - if (!ImgCache.isCached(imageUrl)) { - return ImgCache.cacheFile(imageUrl, null); - } - }; - - return IonicUtils; - - })(); - - libr.service('IonicUtils', IonicUtils); - -}).call(this); - -(function() { - var LocalStorageUtils, libr; - - libr = angular.module('libr.services.localstorage', []); - - LocalStorageUtils = (function() { - function LocalStorageUtils() {} - - LocalStorageUtils.prototype.getUser = function() { - return JSON.parse(localStorage.getItem('user')); - }; - - LocalStorageUtils.prototype.getUserId = function() { - var user; - user = this.getUser(); - return user.id; - }; - - LocalStorageUtils.prototype.getUserName = function() { - var user; - user = this.getUser(); - return user.name; - }; - - LocalStorageUtils.prototype.getUserToken = function() { - var user; - user = this.getUser(); - return user.token; - }; - - LocalStorageUtils.prototype.getUserAvatar = function() { - var user; - user = this.getUser(); - return user.avatar; - }; - - LocalStorageUtils.prototype.getUserEmail = function() { - var user; - user = this.getUser(); - return user.email; - }; - - LocalStorageUtils.prototype.isUserLogedIn = function() { - var user; - user = this.getUser(); - return user !== null && this.getUserEmail() !== null && this.getUserToken() !== null; - }; - - LocalStorageUtils.prototype.storeDoubanUser = function(name) { - return localStorage.setItem('doubanUser', name); - }; - - LocalStorageUtils.prototype.getDoubanUser = function() { - var user; - user = this.getUser(); - if (user.douban_user !== null) { - return user.douban_user; - } else if (localStorage.getItem('doubanUser') !== null) { - return localStorage.getItem('doubanUser'); - } else { - return null; - } - }; - - return LocalStorageUtils; - - })(); - - libr.service('LocalStorageUtils', LocalStorageUtils); - -}).call(this); - -(function() { - var ErrorHandler, libr; - - libr = angular.module('libr.handlers.errorHandler', []); - - ErrorHandler = (function() { - function ErrorHandler() {} - - ErrorHandler.prototype.loadingHandler = function($scope, callback) { - var message; - $scope.loading.hide(); - message = '加载失败,请确认有良好网络连接,并重试'; - return navigator.notification.confirm(message, (function(_this) { - return function() { - return callback(); - }; - })(this), '加载失败', ['确定', '取消']); - }; - - ErrorHandler.prototype.whenError = function(callback) { - var message; - message = '加载失败,请确认有良好网络连接,并重试'; - return navigator.notification.confirm(message, (function(_this) { - return function() { - return callback(); - }; - })(this), '加载失败', ['确定', '取消']); - }; - - return ErrorHandler; - - })(); - - libr.service('ErrorHandler', ErrorHandler); - -}).call(this); - -(function() { - var AuthicationService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.auth', []); - - AuthicationService = (function() { - AuthicationService.$inject = ['$http', 'Constant']; - - function AuthicationService($http, Constant) { - this.$http = $http; - this.Constant = Constant; - this.register = __bind(this.register, this); - this.login = __bind(this.login, this); - console.log('init auth service'); - } - - AuthicationService.prototype.login = function(user, callback, errorCallback) { - var baseUrl; - baseUrl = this.Constant.baseUrl + '/sessions'; - return this.$http({ - method: 'POST', - url: baseUrl, - data: "user[email]=" + user.email + "&user[password]=" + user.password, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(result) { - if (result.success) { - return callback(result); - } else { - return errorCallback('登录失败,请输入正确的用户名和密码'); - } - }).error(function(data) { - return errorCallback('登录失败,请输入正确的用户名和密码'); - }); - }; - - AuthicationService.prototype.register = function(user, callback, onError) { - var url; - url = this.Constant.baseUrl + '/registrations'; - return this.$http({ - method: 'POST', - url: url, - data: "user[email]=" + user.email + "&user[password]=" + user.password, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(result, status) { - return callback(result, status); - }).error(function(data, status) { - return onError(data); - }); - }; - - return AuthicationService; - - })(); - - libr.service('AuthService', AuthicationService); - -}).call(this); - -(function() { - var Books, libr; - - libr = angular.module('libr.services.books', ['ngResource']); - - Books = (function() { - Books.$inject = ['$http', '$resource', 'Constant', 'LocalStorageUtils']; - - function Books($resource, Constant, LocalStorageUtils) { - var url; - this.$resource = $resource; - this.Constant = Constant; - this.LocalStorageUtils = LocalStorageUtils; - url = this.Constant.baseUrl + '/users/:user_id/books/:book_id'; - return this.$resource(url, { - user_email: this.LocalStorageUtils.getUserEmail(), - user_token: this.LocalStorageUtils.getUserToken(), - user_id: this.LocalStorageUtils.getUserId(), - book_id: '@bookId' - }, { - 'get': { - cache: true, - method: 'GET' - }, - 'query': { - method: 'GET', - isArray: false, - cache: false - }, - 'fetchNew': { - method: 'GET', - isArray: false, - cache: true, - url: this.Constant.baseUrl + '/books/newbooks/:afterId' - } - }); - } - - return Books; - - })(); - - libr.factory('Books', ['$resource', 'Constant', 'LocalStorageUtils', Books]); - -}).call(this); - -(function() { - var CommentService, libr; - - libr = angular.module('libr.services.comment', ['ngResource']); - - CommentService = (function() { - CommentService.$inject = ['$http', '$resource', 'Constant']; - - function CommentService($resource, Constant) { - var baseUrl; - this.$resource = $resource; - this.Constant = Constant; - baseUrl = this.Constant.baseUrl + '/books/:book_id/comments/:comment_id'; - return this.$resource(baseUrl, { - user_email: localStorage.getItem('email'), - user_token: localStorage.getItem('token'), - book_id: '@bookId', - comment_id: '@commentId' - }, { - 'query': { - method: 'GET', - isArray: true, - cache: false - } - }, { - 'save': { - params: { - comment_id: '@commentId' - } - } - }); - } - - return CommentService; - - })(); - - libr.factory('Comments', ['$resource', 'Constant', CommentService]); - -}).call(this); - -(function() { - var DoubanService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.douban', []); - - DoubanService = (function() { - DoubanService.$inject = ['$http', 'Constant', 'LocalStorageUtils']; - - function DoubanService($http, Constant, LocalStorageUtils) { - this.$http = $http; - this.Constant = Constant; - this.LocalStorageUtils = LocalStorageUtils; - this.submitUser = __bind(this.submitUser, this); - } - - DoubanService.prototype.userInfo = function(user, callback, error) { - return this.$http({ - url: "http://api.douban.com/v2/user/" + user, - method: 'GET', - timeout: 10000, - cache: true - }).success(function(data, status, headers, config) { - if (status === 200) { - return callback(data); - } else { - return error(data); - } - }).error(function(data) { - return error(data); - }); - }; - - DoubanService.prototype.submitUser = function(user, callback, error) { - var email, token, userId; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - userId = this.LocalStorageUtils.getUserId(); - return this.$http({ - url: "" + this.Constant.baseUrl + "/users/" + userId + "/link/douban/" + user + "?user_email=" + email + "&user_token=" + token, - method: 'POST', - timeout: 10000 - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - return DoubanService; - - })(); - - libr.service('DoubanService', DoubanService); - -}).call(this); - -(function() { - var GeolocationService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.geolocation', []); - - GeolocationService = (function() { - var getLocation, onError, onSuccess; - - GeolocationService.$inject = ['$http', 'Constant']; - - function GeolocationService($http, Constant) { - this.$http = $http; - this.Constant = Constant; - this.getDetailAddress = __bind(this.getDetailAddress, this); - } - - onSuccess = function(position) { - alert('lat' + position.coords.latitude); - return { - "Latitude": position.coords.latitude, - "Longitude": position.coords.longitude, - "Altitude": position.coords.altitude, - "Accuracy": position.coords.accuracy, - "Altitude Accuracy": position.coords.altitudeAccuracy, - "Heading": position.coords.heading, - "Speed": position.coords.speed, - "Timestamp": position.timestamp - }; - }; - - onError = function(error) { - throw "code: " + error.code + " \n message: " + error.message; - }; - - GeolocationService.prototype.getCurrentLocation = function(callback, error) { - return navigator.geolocation.getCurrentPosition(callback, error); - }; - - GeolocationService.prototype.getDetailAddress = function(callback, error) { - var baseUrl; - baseUrl = this.Constant.baseUrl + '/locations/detail'; - return this.getCurrentLocation((function(_this) { - return function(position) { - return _this.$http({ - url: "" + baseUrl + "?lat=" + position.coords.latitude + "&lng=" + position.coords.longitude, - cache: true, - method: 'GET' - }).success(function(data, status, headers, config) { - return callback(data); - }); - }; - })(this), function(error) { - throw Error(error); - }); - }; - - GeolocationService.prototype.getLocations = function(callback, error) { - var baseUrl, email, token; - baseUrl = this.Constant.baseUrl + '/locations'; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: "" + baseUrl + "?user_email=" + email + "&user_token=" + token, - method: 'GET', - cache: false - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - throw Error(error); - }); - }; - - GeolocationService.prototype.createLocation = function(callback) { - var baseUrl, email, location, token; - baseUrl = this.Constant.baseUrl + '/locations'; - location = getLocation(); - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - method: 'POST', - url: baseUrl + ("?user_email=" + email + "&user_token=" + token), - data: "address=" + location.address + "&lat=" + location.lat + "&lng=" + location.lng, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(data) { - return callback(data); - }); - }; - - GeolocationService.prototype.deleteLocation = function(item, callback) { - var baseUrl, email, token; - baseUrl = this.Constant.baseUrl + '/locations'; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - method: 'DELETE', - url: baseUrl + ("?user_email=" + email + "&user_token=" + token + "&id=" + item.id), - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(data) { - console.log("=====", data); - return callback(data); - }); - }; - - getLocation = function() { - var location; - location = {}; - location.address = localStorage.getItem('cur_address_detail'); - location.lat = localStorage.getItem('cur_lat'); - location.lng = localStorage.getItem('cur_lng'); - return location; - }; - - return GeolocationService; - - })(); - - libr.service('GeolocationService', GeolocationService); - -}).call(this); - -(function() { - var RecommendService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.recommend', []); - - RecommendService = (function() { - RecommendService.$injector = ['GeolocationService', '$http', 'Constant']; - - function RecommendService(GeolocationService, $http, Constant) { - this.GeolocationService = GeolocationService; - this.$http = $http; - this.Constant = Constant; - this.changeRecommendAction = __bind(this.changeRecommendAction, this); - this.popularBooksAroundMe = __bind(this.popularBooksAroundMe, this); - } - - RecommendService.prototype.getActionSheetList = function() { - var actionList; - actionList = []; - actionList.push({ - text: '随机找几本书看看' - }); - actionList.push({ - text: "你可能喜欢的书" - }); - this.GeolocationService.getLocations((function(_this) { - return function(locations) { - var locationIds; - locationIds = []; - locations.map(function(location) { - locationIds.push(location.id); - location = { - text: "" + location.address + "附近流行的书" - }; - return actionList.push(location); - }); - localStorage.setItem('recommend_action_sheet_arr', JSON.stringify(locationIds)); - return localStorage.setItem('recommend_action_sheet_full_arr', JSON.stringify(actionList)); - }; - })(this)); - return actionList; - }; - - RecommendService.prototype.popularBooksForMe = function(callback, error) { - var email, token; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: this.Constant.baseUrl + ("/recommend/me?user_email=" + email + "&user_token=" + token), - method: 'GET', - timeout: 15000 - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - RecommendService.prototype.randomBooks = function(callback, error) { - var email, token; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: this.Constant.baseUrl + ("/recommend/random?user_email=" + email + "&user_token=" + token), - method: 'GET', - timeout: 15000, - cache: true - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - RecommendService.prototype.popularBooksAroundMe = function(locationId, callback, error) { - var email, token; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: this.Constant.baseUrl + ("/recommend/locations/" + locationId + "?user_email=" + email + "&user_token=" + token), - method: 'GET', - timeout: 15000, - cache: true - }).success(function(data, status, headers, config) { - console.log('数据', data); - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - RecommendService.prototype.changeRecommendAction = function(index, callback, error) { - var locations; - console.log('index====', index); - if (index === 0) { - return this.randomBooks(callback, error); - } else if (index === 1) { - return this.popularBooksForMe(callback, error); - } else { - locations = JSON.parse(localStorage.getItem('recommend_action_sheet_arr')); - console.log(locations[index - 2], 'index......'); - return this.popularBooksAroundMe(locations[index - 2], function(result) { - console.log('callback....', result); - return callback(result); - }, function(errorMessage) { - return error(errorMessage); - }); - } - }; - - return RecommendService; - - })(); - - libr.service('RecommendService', RecommendService); - -}).call(this); - -(function() { - var ScanService, libr; - - libr = angular.module('libr.services.scan', []); - - ScanService = (function() { - ScanService.$inject = ['Books']; - - function ScanService(Books) { - this.Books = Books; - } - - ScanService.prototype.scan = function(callback, errorCallback) { - navigator.notification.vibrate(50); - return cordova.plugins.barcodeScanner.scan((function(_this) { - return function(result) { - console.log('got scan result', result); - if (result.cancelled === 1) { - return; - } - if (result.format !== 'EAN_13') { - console.log('条码不匹配'); - errorCallback('条形码类型错误,请确认所扫为书籍,并更换角度'); - return; - } - return _this.Books.save({ - isbn: result.text - }, null, function(data) { - console.log('get server response'); - if (data.status === 'error') { - return errorCallback(data.message); - } else { - return callback(data); - } - }, function(error) { - return errorCallback('添加图书失败' + error.data.message); - }); - }; - })(this), function(error) { - return errorCallback("扫描图书失败:" + error + " "); - }); - }; - - return ScanService; - - })(); - - libr.service('ScanService', ScanService); - -}).call(this); - -(function() { - var BooksController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.books', ['ionic']); - - BooksController = (function() { - BooksController.$inject = ['$scope', 'Books', 'ScanService', '$ionicModal', 'DoubanService', 'IonicUtils', 'LocalStorageUtils']; - - function BooksController($scope, Books, ScanService, $ionicModal, DoubanService, IonicUtils, LocalStorageUtils) { - var currentPage; - this.$scope = $scope; - this.Books = Books; - this.ScanService = ScanService; - this.$ionicModal = $ionicModal; - this.DoubanService = DoubanService; - this.IonicUtils = IonicUtils; - this.LocalStorageUtils = LocalStorageUtils; - this.submitDoubanUser = __bind(this.submitDoubanUser, this); - this.scanBooks = __bind(this.scanBooks, this); - this.searchDoubanUser = __bind(this.searchDoubanUser, this); - this.closeDialog = __bind(this.closeDialog, this); - this.loadMore = __bind(this.loadMore, this); - this.refresh = __bind(this.refresh, this); - currentPage = localStorage.setItem('user_books_current_page', 0); - this.$scope.books = []; - this.$scope.moreItemsAvailable = true; - this.$scope.submitAllowed = false; - this.$ionicModal.fromTemplateUrl('templates/modal/import_books.html', (function(_this) { - return function(modal) { - return _this.$scope.modal = modal; - }; - })(this), { - scope: this.$scope, - animation: 'slide-in-up' - }); - this.$scope.data = { - isLoading: false, - text: null - }; - this.IonicUtils.initCustomLoading(this.$scope); - this.$scope.onRefresh = this.refresh; - this.$scope.loadMore = this.loadMore; - this.$scope.closeDialog = this.closeDialog; - this.$scope.searchDoubanUser = this.searchDoubanUser; - this.$scope.scanBooks = this.scanBooks; - this.$scope.submitDoubanUser = this.submitDoubanUser; - this.$scope.doubanInputDisabled = this.LocalStorageUtils.getDoubanUser() !== null; - this.$scope.doubanUsername = this.LocalStorageUtils.getDoubanUser(); - } - - BooksController.prototype.refresh = function() { - var afterBookId; - afterBookId = localStorage.getItem('user_max_book_id'); - return this.Books.fetchNew({ - afterId: afterBookId - }, (function(_this) { - return function(data) { - _this.$scope.$broadcast('scroll.refreshComplete'); - if (data.books.length !== 0) { - localStorage.setItem('user_max_book_id', data.books[0].id); - return data.books.forEach(function(item, index, array) { - return _this.$scope.books.push(item); - }); - } - }; - })(this)); - }; - - BooksController.prototype.loadMore = function() { - var currentPage, maxPage; - currentPage = localStorage.getItem('user_books_current_page'); - maxPage = localStorage.getItem('user_books_max_page'); - maxPage = parseInt(maxPage); - currentPage = parseInt(currentPage); - if (!(currentPage >= maxPage)) { - return this.Books.query({ - page: currentPage + 1 - }, (function(_this) { - return function(data) { - if (data.books.length !== 0) { - localStorage.setItem('user_max_book_id', data.books[0].id); - localStorage.setItem('user_books_current_page', data.current_page); - localStorage.setItem('user_books_max_page', data.total_page); - data.books.forEach(function(item, index, array) { - return _this.$scope.books.push(item); - }); - } else { - _this.$scope.moreItemsAvailable = false; - } - return _this.$scope.$broadcast('scroll.infiniteScrollComplete'); - }; - })(this)); - } else { - this.$scope.$broadcast('scroll.infiniteScrollComplete'); - return this.$scope.moreItemsAvailable = false; - } - }; - - BooksController.prototype.closeDialog = function() { - return this.$scope.modal.hide(); - }; - - BooksController.prototype.searchDoubanUser = function(user) { - console.log(user, '...'); - if (user === void 0 || user.trim() === '') { - return this.IonicUtils.showLoading(this.$scope, '请输入有效昵称'); - } else { - return this.DoubanService.userInfo(user, (function(_this) { - return function(data) { - _this.$scope.resultEnabled = true; - _this.$scope.submitAllowed = true; - return _this.$scope.doubanUser = data; - }; - })(this), (function(_this) { - return function(error) { - _this.IonicUtils.showLoading(_this.$scope, '查找豆瓣用户失败,请稍后再试'); - console.log(error); - _this.$scope.resultEnabled = false; - return _this.$scope.submitAllowed = false; - }; - })(this)); - } - }; - - BooksController.prototype.scanBooks = function() { - return this.ScanService.scan((function(_this) { - return function(result) { - navigator.notification.alert("添加图书《" + result.book.name + "》成功", null, "Libr", "确定"); - return _this.$scope.books.unshift(result.book); - }; - })(this), (function(_this) { - return function(msg) { - console.log('trying to show loading...', msg); - _this.IonicUtils.showLoading(_this.$scope, msg); - _this.$scope.$apply(); - return console.log('applied'); - }; - })(this)); - }; - - BooksController.prototype.submitDoubanUser = function() { - var username; - username = angular.element(document.getElementById('douban-username')); - username = username.val(); - return this.DoubanService.submitUser(username, (function(_this) { - return function(data) { - _this.$scope.doubanInputDisabled = true; - _this.LocalStorageUtils.storeDoubanUser(username); - return alert('成功绑定豆瓣用户,请返回,系统将自动为你导入豆瓣图书'); - }; - })(this), (function(_this) { - return function(data) { - return _this.IonicUtils.showLoading(_this.$scope, '绑定豆瓣用户失败,请稍后再试'); - }; - })(this)); - }; - - return BooksController; - - })(); - - libr.controller('BooksController', BooksController); - -}).call(this); - -(function() { - var BookDetailController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers', ['ionic']); - - BookDetailController = (function() { - BookDetailController.$inject = ['$scope', '$stateParams', 'Books', '$window', '$ionicModal', 'Comments']; - - function BookDetailController($scope, $stateParams, Books, $window, $ionicModal, Comments) { - this.$scope = $scope; - this.$stateParams = $stateParams; - this.Books = Books; - this.$window = $window; - this.$ionicModal = $ionicModal; - this.Comments = Comments; - this.back = __bind(this.back, this); - this.doComment = __bind(this.doComment, this); - this.closeCommentDialog = __bind(this.closeCommentDialog, this); - this.openCommentDialog = __bind(this.openCommentDialog, this); - this.$scope.openDialog = this.openCommentDialog; - this.$scope.closeDialog = this.closeCommentDialog; - this.$scope.doComment = this.doComment; - this.$scope.back = this.back; - this.$ionicModal.fromTemplateUrl('templates/modal/comment.html', (function(_this) { - return function(modal) { - return _this.$scope.modal = modal; - }; - })(this), { - scope: this.$scope, - animation: 'slide-in-up' - }); - console.log('===='); - this.Books.get({ - book_id: this.$stateParams.isbn - }, (function(_this) { - return function(result) { - _this.$scope.book = result; - _this.$scope.usersAccount = result.users.length; - _this.$scope.bookName = _this.$scope.book.name; - return _this.Comments.query({ - book_id: result.id - }, function(data) { - console.log(data, '!!!!!'); - return _this.$scope.comments = data; - }); - }; - })(this)); - this.$scope.$on('$destroy', (function(_this) { - return function() { - return _this.$scope.modal.remove(); - }; - })(this)); - } - - BookDetailController.prototype.openCommentDialog = function() { - return this.$scope.modal.show(); - }; - - BookDetailController.prototype.closeCommentDialog = function() { - return this.$scope.modal.hide(); - }; - - BookDetailController.prototype.doComment = function() { - var text; - text = angular.element(document.getElementById('comment')).val(); - if (text.trim() === '') { - alert('请输入有效字符'); - return false; - } else { - return this.Comments.save({ - book_id: this.$scope.book.id, - content: text - }, null, (function(_this) { - return function(data) { - if (data.id === null) { - return alert('添加图书失败'); - } else { - console.log('成功。。。。。。。'); - _this.$scope.comments.push(data); - return _this.closeCommentDialog(); - } - }; - })(this)); - } - }; - - BookDetailController.prototype.back = function() { - return this.$window.history.back(); - }; - - return BookDetailController; - - })(); - - libr.controller('BookDetailController', BookDetailController); - -}).call(this); - -(function() { - var HomeController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.home', ['ionic']); - - HomeController = (function() { - var showLoading; - - HomeController.$inject = ['$scope', '$location', 'ScanService', '$ionicLoading', '$ionicActionSheet', 'RecommendService', 'ErrorHandler', 'LocalStorageUtils']; - - function HomeController($scope, $location, ScanService, $ionicLoading, $ionicActionSheet, RecommendService, ErrorHandler, LocalStorageUtils) { - this.$scope = $scope; - this.$location = $location; - this.$ionicLoading = $ionicLoading; - this.$ionicActionSheet = $ionicActionSheet; - this.RecommendService = RecommendService; - this.ErrorHandler = ErrorHandler; - this.LocalStorageUtils = LocalStorageUtils; - this.changeRecommend = __bind(this.changeRecommend, this); - this.showRecommendActionSheet = __bind(this.showRecommendActionSheet, this); - this.$scope.showRecommendActionSheet = this.showRecommendActionSheet; - if (this.LocalStorageUtils.isUserLogedIn()) { - showLoading(this.$scope, this.$ionicLoading); - this.$scope.title = '随便看看吧'; - if (localStorage.getItem('home.books') === null) { - this.RecommendService.randomBooks((function(_this) { - return function(result) { - _this.$scope.books = result; - localStorage.setItem('home.books', JSON.stringify(result)); - return _this.$scope.loading.hide(); - }; - })(this), (function(_this) { - return function(error) { - return _this.ErrorHandler.loadingHandler(_this.$scope, null); - }; - })(this)); - } else { - this.$scope.books = JSON.parse(localStorage.getItem('home.books')); - this.$scope.loading.hide(); - } - } else { - this.$location.path('/tab/settings'); - return; - } - } - - showLoading = function($scope, $ionicLoading) { - return $scope.loading = $ionicLoading.show({ - content: '加载中', - animation: 'fade-in', - showBackdrop: true, - maxWidth: 200, - showDelay: 500 - }); - }; - - HomeController.prototype.showRecommendActionSheet = function() { - return this.$ionicActionSheet.show({ - titleText: 'Libr 为你推荐', - buttons: this.RecommendService.getActionSheetList(), - cancelText: '取消', - cancel: function() { - return console.log('CANCELLED'); - }, - buttonClicked: (function(_this) { - return function(index) { - console.log("" + index + " has been taped"); - _this.changeRecommend(index); - return true; - }; - })(this) - }); - }; - - HomeController.prototype.changeRecommend = function(index) { - var msg; - msg = '喔,看来附近还没有好书推荐,快去推荐你的朋友也来使用吧!'; - return this.RecommendService.changeRecommendAction(index, (function(_this) { - return function(result) { - var listArray; - if (result.length === 0) { - return navigator.notification.alert(msg, null, 'libr', '确定'); - } else { - _this.$scope.books = result; - localStorage.setItem('home.books', JSON.stringify(result)); - listArray = JSON.parse(localStorage.getItem('recommend_action_sheet_full_arr')); - return _this.$scope.title = listArray[index].text; - } - }; - })(this), (function(_this) { - return function(error) { - return _this.ErrorHandler.whenError(null); - }; - })(this)); - }; - - return HomeController; - - })(); - - libr.controller('HomeCtrl', HomeController); - -}).call(this); - -(function() { - var LocationController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.location', ['ionic']); - - LocationController = (function() { - LocationController.$inject = ['$scope', '$location', 'GeolocationService', 'IonicUtils']; - - function LocationController($scope, $location, GeolocationService, IonicUtils) { - this.$scope = $scope; - this.$location = $location; - this.GeolocationService = GeolocationService; - this.IonicUtils = IonicUtils; - this.deleteItem = __bind(this.deleteItem, this); - this.addLocation = __bind(this.addLocation, this); - this.$scope.addLocation = this.addLocation; - this.$scope.itemButtons = [ - { - text: '删除', - type: 'button-assertive', - onTap: (function(_this) { - return function(item) { - return _this.GeolocationService.deleteLocation(item, function(result) { - return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item), 1); - }); - }; - })(this) - } - ]; - this.GeolocationService.getLocations((function(_this) { - return function(locations) { - return _this.$scope.locations = locations; - }; - })(this)); - this.GeolocationService.getDetailAddress((function(_this) { - return function(position) { - localStorage.setItem('cur_address_detail', position.result.formatted_address); - localStorage.setItem('cur_lat', position.result.location.lat); - localStorage.setItem('cur_lng', position.result.location.lng); - return _this.$scope.address = position.result.formatted_address; - }; - })(this)); - this.IonicUtils.initCustomLoading(this.$scope); - this.$scope.deleteItem = this.deleteItem; - } - - LocationController.prototype.addLocation = function() { - if (this.$scope.locations.length >= 3) { - return this.IonicUtils.showLoading(this.$scope, '只能创建3个常用的地址,请先删除部分再添加'); - } else if (localStorage.getItem('cur_address_detail') === null) { - return this.IonicUtils.showLoading(this.$scope, '定位成功后方可添加常用地址'); - } else if (this.$scope.address === null || this.$scope.address === '') { - return this.IonicUtils.showLoading(this.$scope, '定位成功后方可添加常用地址'); - } else { - return this.GeolocationService.createLocation((function(_this) { - return function(result) { - return _this.$scope.locations.push(result); - }; - })(this)); - } - }; - - LocationController.prototype.deleteItem = function(item) { - return this.GeolocationService.deleteLocation(item, (function(_this) { - return function(result) { - return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item), 1); - }; - })(this)); - }; - - return LocationController; - - })(); - - libr.controller('LocationController', LocationController); - -}).call(this); - -(function() { - var LoginController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.login', ['ionic']); - - LoginController = (function() { - LoginController.$inject = ['$scope', 'AuthService', '$state', '$ionicModal', 'IonicUtils', 'LocalStorageUtils']; - - function LoginController($scope, AuthService, $state, $ionicModal, IonicUtils, LocalStorageUtils) { - this.$scope = $scope; - this.AuthService = AuthService; - this.$state = $state; - this.$ionicModal = $ionicModal; - this.IonicUtils = IonicUtils; - this.LocalStorageUtils = LocalStorageUtils; - this.closeDialog = __bind(this.closeDialog, this); - this.registerUser = __bind(this.registerUser, this); - this.registerForm = __bind(this.registerForm, this); - this.login = __bind(this.login, this); - if (this.LocalStorageUtils.isUserLogedIn()) { - this.$state.go('tab.home'); - } - this.$scope.login = this.login; - this.$scope.registerForm = this.registerForm; - this.$scope.registerUser = this.registerUser; - this.$scope.closeDialog = this.closeDialog; - this.$ionicModal.fromTemplateUrl('templates/modal/registration.html', (function(_this) { - return function(modal) { - return _this.$scope.modal = modal; - }; - })(this), { - scope: this.$scope, - animation: 'slide-in-up' - }); - this.IonicUtils.initCustomLoading(this.$scope); - } - - LoginController.prototype.login = function(user) { - if (!user || user.email === '' || user.password === '' || user.email === void 0 || user.password === void 0) { - this.IonicUtils.showLoading(this.$scope, '请输入有效的用户名和密码'); - return; - } - return this.AuthService.login(user, (function(_this) { - return function(result) { - localStorage.setItem('token', result.user.token); - localStorage.setItem('avatar', result.user.avatar); - localStorage.setItem('username', result.user.name); - localStorage.setItem('email', user.email); - localStorage.setItem('user', JSON.stringify(result.user)); - return _this.$state.go('tab.home'); - }; - })(this), (function(_this) { - return function(data) { - return _this.IonicUtils.showLoading(_this.$scope, data); - }; - })(this)); - }; - - LoginController.prototype.registerForm = function() { - return this.$scope.modal.show(); - }; - - LoginController.prototype.registerUser = function(user) { - if (!user || user.email === '' || user.password === '' || user.email === void 0 || user.password === void 0) { - this.IonicUtils.showLoading(this.$scope, '用户名或密码错误,请重试'); - } else { - return this.AuthService.register(user, (function(_this) { - return function(result, status) { - if (status === 201) { - alert('注册成功,请返回登录'); - return _this.$scope.modal.hide(); - } else { - return _this.IonicUtils.showLoading(_this.$scope, '注册失败,请确认是否输入正确,并重试'); - } - }; - })(this), (function(_this) { - return function(error) { - _this.IonicUtils.showLoading(_this.$scope, '注册失败,请确认是否输入正确,并重试'); - return console.log("registerError", error); - }; - })(this)); - } - }; - - LoginController.prototype.closeDialog = function() { - return this.$scope.modal.hide(); - }; - - return LoginController; - - })(); - - libr.controller('LoginController', LoginController); - -}).call(this); - -(function() { - var MainController, libr; - - libr = angular.module('libr.controllers.main', ['ionic']); - - MainController = (function() { - MainController.$inject = ['$scope', '$location', '$ionicModal', '$state']; - - function MainController($scope, $location, $ionicModal, $state) { - this.$scope = $scope; - this.$location = $location; - this.$ionicModal = $ionicModal; - this.$state = $state; - } - - return MainController; - - })(); - - libr.controller('MainCtrl', MainController); - -}).call(this); - -(function() { - var SettingsController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.settings', ['ionic']); - - SettingsController = (function() { - var isUserLogedIn; - - SettingsController.$inject = ['$scope', '$ionicModal', 'AuthService', '$state', '$cacheFactory', 'LocalStorageUtils']; - - function SettingsController($scope, $ionicModal, AuthService, $state, $cacheFactory, LocalStorageUtils) { - this.$scope = $scope; - this.$ionicModal = $ionicModal; - this.AuthService = AuthService; - this.$state = $state; - this.$cacheFactory = $cacheFactory; - this.LocalStorageUtils = LocalStorageUtils; - this.logout = __bind(this.logout, this); - this.$scope.logout = this.logout; - this.$scope.feedback = this.feedback; - this.$scope.showMe = this.showMe; - if (isUserLogedIn(this.LocalStorageUtils)) { - this.$scope.isLogedIn = true; - } else { - this.$scope.isLogedIn = false; - } - this.$scope.avatar = this.LocalStorageUtils.getUserAvatar(); - this.$scope.username = this.LocalStorageUtils.getUserName(); - } - - SettingsController.prototype.logout = function() { - var httpDefaultCache; - localStorage.clear(); - httpDefaultCache = this.$cacheFactory.get('$http'); - console.log('cacheFactory', httpDefaultCache); - httpDefaultCache.removeAll(); - return this.$state.go('login'); - }; - - SettingsController.prototype.feedback = function() { - return window.open('https://jinshuju.net/f/F96z3s', '_blank', 'location=no'); - }; - - SettingsController.prototype.showMe = function() { - return window.open('http://librme.com', '_blank', 'location=no'); - }; - - isUserLogedIn = function(localStorageUtils) { - if (localStorageUtils.getUserToken() !== null && localStorageUtils.getUserEmail() !== null) { - return true; - } else { - return false; - } - }; - - return SettingsController; - - })(); - - libr.controller('SettingsController', SettingsController); - -}).call(this); - -(function() { - var Constant, libr; - - libr = angular.module('libr.constant', []); - - Constant = {}; - - Constant.baseUrl = "http://192.168.0.100:3000/api/v1"; - - libr.constant('Constant', Constant); - -}).call(this); +(function(){var IonicUtils,libr;libr=angular.module("libr.services.utils",[]),IonicUtils=function(){function IonicUtils($timeout){this.$timeout=$timeout}return IonicUtils.$inject=["$timeout"],IonicUtils.prototype.initCustomLoading=function(scope){return scope.data={isLoading:!1,text:null}},IonicUtils.prototype.showLoading=function(scope,text,timing){return null==timing&&(timing=3e3),scope.data={isLoading:!0,text:text},this.$timeout(function(_this){return function(){return _this.initCustomLoading(scope)}}(this),timing)},IonicUtils.prototype.cacheImage=function(imageUrl){return ImgCache.isCached(imageUrl)?void 0:ImgCache.cacheFile(imageUrl,null)},IonicUtils}(),libr.service("IonicUtils",IonicUtils)}).call(this); +(function(){var LocalStorageUtils,libr;libr=angular.module("libr.services.localstorage",[]),LocalStorageUtils=function(){function LocalStorageUtils(){}return LocalStorageUtils.prototype.getUser=function(){return JSON.parse(localStorage.getItem("user"))},LocalStorageUtils.prototype.getUserId=function(){var user;return user=this.getUser(),user.id},LocalStorageUtils.prototype.getUserName=function(){var user;return user=this.getUser(),user.name},LocalStorageUtils.prototype.getUserToken=function(){var user;return user=this.getUser(),user.token},LocalStorageUtils.prototype.getUserAvatar=function(){var user;return user=this.getUser(),user.avatar},LocalStorageUtils.prototype.getUserEmail=function(){var user;return user=this.getUser(),user.email},LocalStorageUtils.prototype.isUserLogedIn=function(){var user;return user=this.getUser(),null!==user&&null!==this.getUserEmail()&&null!==this.getUserToken()},LocalStorageUtils.prototype.storeDoubanUser=function(name){return localStorage.setItem("doubanUser",name)},LocalStorageUtils.prototype.getDoubanUser=function(){var user;return user=this.getUser(),null!==user.douban_user?user.douban_user:null!==localStorage.getItem("doubanUser")?localStorage.getItem("doubanUser"):null},LocalStorageUtils}(),libr.service("LocalStorageUtils",LocalStorageUtils)}).call(this); +(function(){var ErrorHandler,libr;libr=angular.module("libr.handlers.errorHandler",[]),ErrorHandler=function(){function ErrorHandler(){}return ErrorHandler.prototype.loadingHandler=function($scope,callback){var message;return $scope.loading.hide(),message="加载失败,请确认有良好网络连接,并重试",navigator.notification.confirm(message,function(){return function(){return callback()}}(this),"加载失败",["确定","取消"])},ErrorHandler.prototype.whenError=function(callback){var message;return message="加载失败,请确认有良好网络连接,并重试",navigator.notification.confirm(message,function(){return function(){return callback()}}(this),"加载失败",["确定","取消"])},ErrorHandler}(),libr.service("ErrorHandler",ErrorHandler)}).call(this); +(function(){var AuthicationService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.auth",[]),AuthicationService=function(){function AuthicationService($http,Constant){this.$http=$http,this.Constant=Constant,this.register=__bind(this.register,this),this.login=__bind(this.login,this),console.log("init auth service")}return AuthicationService.$inject=["$http","Constant"],AuthicationService.prototype.login=function(user,callback,errorCallback){var baseUrl;return baseUrl=this.Constant.baseUrl+"/sessions",this.$http({method:"POST",url:baseUrl,data:"user[email]="+user.email+"&user[password]="+user.password,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(result){return result.success?callback(result):errorCallback("登录失败,请输入正确的用户名和密码")}).error(function(){return errorCallback("登录失败,请输入正确的用户名和密码")})},AuthicationService.prototype.register=function(user,callback,onError){var url;return url=this.Constant.baseUrl+"/registrations",this.$http({method:"POST",url:url,data:"user[email]="+user.email+"&user[password]="+user.password,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(result,status){return callback(result,status)}).error(function(data){return onError(data)})},AuthicationService}(),libr.service("AuthService",AuthicationService)}).call(this); +(function(){var Books,libr;libr=angular.module("libr.services.books",["ngResource"]),Books=function(){function Books($resource,Constant,LocalStorageUtils){var url;return this.$resource=$resource,this.Constant=Constant,this.LocalStorageUtils=LocalStorageUtils,url=this.Constant.baseUrl+"/users/:user_id/books/:book_id",this.$resource(url,{user_email:this.LocalStorageUtils.getUserEmail(),user_token:this.LocalStorageUtils.getUserToken(),user_id:this.LocalStorageUtils.getUserId(),book_id:"@bookId"},{get:{cache:!0,method:"GET"},query:{method:"GET",isArray:!1,cache:!1},fetchNew:{method:"GET",isArray:!1,cache:!0,url:this.Constant.baseUrl+"/books/newbooks/:afterId"}})}return Books.$inject=["$http","$resource","Constant","LocalStorageUtils"],Books}(),libr.factory("Books",["$resource","Constant","LocalStorageUtils",Books])}).call(this); +(function(){var CommentService,libr;libr=angular.module("libr.services.comment",["ngResource"]),CommentService=function(){function CommentService($resource,Constant){var baseUrl;return this.$resource=$resource,this.Constant=Constant,baseUrl=this.Constant.baseUrl+"/books/:book_id/comments/:comment_id",this.$resource(baseUrl,{user_email:localStorage.getItem("email"),user_token:localStorage.getItem("token"),book_id:"@bookId",comment_id:"@commentId"},{query:{method:"GET",isArray:!0,cache:!1}},{save:{params:{comment_id:"@commentId"}}})}return CommentService.$inject=["$http","$resource","Constant"],CommentService}(),libr.factory("Comments",["$resource","Constant",CommentService])}).call(this); +(function(){var DoubanService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.douban",[]),DoubanService=function(){function DoubanService($http,Constant,LocalStorageUtils){this.$http=$http,this.Constant=Constant,this.LocalStorageUtils=LocalStorageUtils,this.submitUser=__bind(this.submitUser,this)}return DoubanService.$inject=["$http","Constant","LocalStorageUtils"],DoubanService.prototype.userInfo=function(user,callback,error){return this.$http({url:"http://api.douban.com/v2/user/"+user,method:"GET",timeout:1e4,cache:!0}).success(function(data,status){return 200===status?callback(data):error(data)}).error(function(data){return error(data)})},DoubanService.prototype.bookDetail=function(isbn,callback,error){return this.$http({url:"https://api.douban.com/v2/book/isbn/"+isbn,method:"GET",timeout:1e4,cache:!0}).success(function(data,status){return 200===status?callback(data):error(data)}).error(function(data){return error(data)})},DoubanService.prototype.submitUser=function(user,callback,error){var email,token,userId;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),userId=this.LocalStorageUtils.getUserId(),this.$http({url:""+this.Constant.baseUrl+"/users/"+userId+"/link/douban/"+user+"?user_email="+email+"&user_token="+token,method:"POST",timeout:1e4}).success(function(data){return callback(data)}).error(function(data){return error(data)})},DoubanService}(),libr.service("DoubanService",DoubanService)}).call(this); +(function(){var GeolocationService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.geolocation",[]),GeolocationService=function(){function GeolocationService($http,Constant){this.$http=$http,this.Constant=Constant,this.getDetailAddress=__bind(this.getDetailAddress,this)}var getLocation,onError,onSuccess;return GeolocationService.$inject=["$http","Constant"],onSuccess=function(position){return alert("lat"+position.coords.latitude),{Latitude:position.coords.latitude,Longitude:position.coords.longitude,Altitude:position.coords.altitude,Accuracy:position.coords.accuracy,"Altitude Accuracy":position.coords.altitudeAccuracy,Heading:position.coords.heading,Speed:position.coords.speed,Timestamp:position.timestamp}},onError=function(error){throw"code: "+error.code+" \n message: "+error.message},GeolocationService.prototype.getCurrentLocation=function(callback,error){return navigator.geolocation.getCurrentPosition(callback,error)},GeolocationService.prototype.getDetailAddress=function(callback){var baseUrl;return baseUrl=this.Constant.baseUrl+"/locations/detail",this.getCurrentLocation(function(_this){return function(position){return _this.$http({url:""+baseUrl+"?lat="+position.coords.latitude+"&lng="+position.coords.longitude,cache:!0,method:"GET"}).success(function(data){return callback(data)})}}(this),function(error){throw Error(error)})},GeolocationService.prototype.getLocations=function(callback,error){var baseUrl,email,token;return baseUrl=this.Constant.baseUrl+"/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"?user_email="+email+"&user_token="+token,method:"GET",cache:!1}).success(function(data){return callback(data)}).error(function(){throw Error(error)})},GeolocationService.prototype.createLocation=function(callback){var baseUrl,email,location,token;return baseUrl=this.Constant.baseUrl+"/locations",location=getLocation(),email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"POST",url:baseUrl+("?user_email="+email+"&user_token="+token),data:"address="+location.address+"&lat="+location.lat+"&lng="+location.lng,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return callback(data)})},GeolocationService.prototype.deleteLocation=function(item,callback){var baseUrl,email,token;return baseUrl=this.Constant.baseUrl+"/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"DELETE",url:baseUrl+("?user_email="+email+"&user_token="+token+"&id="+item.id),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return console.log("=====",data),callback(data)})},getLocation=function(){var location;return location={},location.address=localStorage.getItem("cur_address_detail"),location.lat=localStorage.getItem("cur_lat"),location.lng=localStorage.getItem("cur_lng"),location},GeolocationService}(),libr.service("GeolocationService",GeolocationService)}).call(this); +(function(){var RecommendService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.recommend",[]),RecommendService=function(){function RecommendService(GeolocationService,$http,Constant){this.GeolocationService=GeolocationService,this.$http=$http,this.Constant=Constant,this.changeRecommendAction=__bind(this.changeRecommendAction,this),this.popularBooksAroundMe=__bind(this.popularBooksAroundMe,this)}return RecommendService.$injector=["GeolocationService","$http","Constant"],RecommendService.prototype.getActionSheetList=function(){var actionList;return actionList=[],actionList.push({text:"随便看看吧"}),actionList.push({text:"你可能喜欢的书"}),this.GeolocationService.getLocations(function(){return function(locations){var locationIds;return locationIds=[],locations.map(function(location){return locationIds.push(location.id),location={text:""+location.address+"附近流行的书"},actionList.push(location)}),localStorage.setItem("recommend_action_sheet_arr",JSON.stringify(locationIds)),localStorage.setItem("recommend_action_sheet_full_arr",JSON.stringify(actionList))}}(this)),actionList},RecommendService.prototype.popularBooksForMe=function(callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:this.Constant.baseUrl+("/recommend/me?user_email="+email+"&user_token="+token),method:"GET",timeout:15e3}).success(function(data){return callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.randomBooks=function(callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:this.Constant.baseUrl+("/recommend/random?user_email="+email+"&user_token="+token),method:"GET",timeout:15e3,cache:!1}).success(function(data){return callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.popularBooksAroundMe=function(locationId,callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:this.Constant.baseUrl+("/recommend/locations/"+locationId+"?user_email="+email+"&user_token="+token),method:"GET",timeout:15e3,cache:!0}).success(function(data){return console.log("数据",data),callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.changeRecommendAction=function(index,callback,error){var locations;return console.log("index====",index),0===index?this.randomBooks(callback,error):1===index?this.popularBooksForMe(callback,error):(locations=JSON.parse(localStorage.getItem("recommend_action_sheet_arr")),console.log(locations[index-2],"index......"),this.popularBooksAroundMe(locations[index-2],function(result){return console.log("callback....",result),callback(result)},function(errorMessage){return error(errorMessage)}))},RecommendService}(),libr.service("RecommendService",RecommendService)}).call(this); +(function(){var ScanService,libr;libr=angular.module("libr.services.scan",[]),ScanService=function(){function ScanService(Books){this.Books=Books}return ScanService.$inject=["Books"],ScanService.prototype.scan=function(callback,errorCallback){return navigator.notification.vibrate(50),cordova.plugins.barcodeScanner.scan(function(_this){return function(result){return console.log("got scan result",result),1!==result.cancelled?"EAN_13"!==result.format?(console.log("条码不匹配"),void errorCallback("条形码类型错误,请确认所扫为书籍,并更换角度")):_this.Books.save({isbn:result.text},null,function(data){return console.log("get server response"),"error"===data.status?errorCallback(data.message):callback(data)},function(error){return errorCallback("添加图书失败"+error.data.message)}):void 0}}(this),function(error){return errorCallback("扫描图书失败:"+error+" ")})},ScanService}(),libr.service("ScanService",ScanService)}).call(this); +(function(){var BooksController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.books",["ionic"]),BooksController=function(){function BooksController($scope,Books,ScanService,$ionicModal,DoubanService,IonicUtils,LocalStorageUtils){var currentPage;this.$scope=$scope,this.Books=Books,this.ScanService=ScanService,this.$ionicModal=$ionicModal,this.DoubanService=DoubanService,this.IonicUtils=IonicUtils,this.LocalStorageUtils=LocalStorageUtils,this.submitDoubanUser=__bind(this.submitDoubanUser,this),this.scanBooks=__bind(this.scanBooks,this),this.searchDoubanUser=__bind(this.searchDoubanUser,this),this.closeDialog=__bind(this.closeDialog,this),this.loadMore=__bind(this.loadMore,this),this.refresh=__bind(this.refresh,this),currentPage=localStorage.setItem("user_books_current_page",0),this.$scope.books=[],this.$scope.moreItemsAvailable=!0,this.$scope.submitAllowed=!1,this.$ionicModal.fromTemplateUrl("templates/modal/import_books.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.$scope.data={isLoading:!1,text:null},this.IonicUtils.initCustomLoading(this.$scope),this.$scope.onRefresh=this.refresh,this.$scope.loadMore=this.loadMore,this.$scope.closeDialog=this.closeDialog,this.$scope.searchDoubanUser=this.searchDoubanUser,this.$scope.scanBooks=this.scanBooks,this.$scope.submitDoubanUser=this.submitDoubanUser,this.$scope.doubanInputDisabled=null!==this.LocalStorageUtils.getDoubanUser(),this.$scope.doubanUsername=this.LocalStorageUtils.getDoubanUser()}return BooksController.$inject=["$scope","Books","ScanService","$ionicModal","DoubanService","IonicUtils","LocalStorageUtils"],BooksController.prototype.refresh=function(){var afterBookId;return afterBookId=localStorage.getItem("user_max_book_id"),this.Books.fetchNew({afterId:afterBookId},function(_this){return function(data){return _this.$scope.$broadcast("scroll.refreshComplete"),0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),data.books.forEach(function(item){return _this.$scope.books.push(item)})):void 0}}(this))},BooksController.prototype.loadMore=function(){var currentPage,maxPage;return currentPage=localStorage.getItem("user_books_current_page"),maxPage=localStorage.getItem("user_books_max_page"),maxPage=parseInt(maxPage),currentPage=parseInt(currentPage),currentPage>=maxPage?(this.$scope.$broadcast("scroll.infiniteScrollComplete"),this.$scope.moreItemsAvailable=!1):this.Books.query({page:currentPage+1},function(_this){return function(data){return 0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),localStorage.setItem("user_books_current_page",data.current_page),localStorage.setItem("user_books_max_page",data.total_page),data.books.forEach(function(item){return _this.$scope.books.push(item)})):_this.$scope.moreItemsAvailable=!1,_this.$scope.$broadcast("scroll.infiniteScrollComplete")}}(this))},BooksController.prototype.closeDialog=function(){return this.$scope.modal.hide()},BooksController.prototype.searchDoubanUser=function(user){return console.log(user,"..."),void 0===user||""===user.trim()?this.IonicUtils.showLoading(this.$scope,"请输入有效昵称"):this.DoubanService.userInfo(user,function(_this){return function(data){return _this.$scope.resultEnabled=!0,_this.$scope.submitAllowed=!0,_this.$scope.doubanUser=data}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,"查找豆瓣用户失败,请稍后再试"),console.log(error),_this.$scope.resultEnabled=!1,_this.$scope.submitAllowed=!1}}(this))},BooksController.prototype.scanBooks=function(){return this.ScanService.scan(function(_this){return function(result){return navigator.notification.alert("添加图书《"+result.book.name+"》成功",null,"Libr","确定"),_this.$scope.books.unshift(result.book)}}(this),function(_this){return function(msg){return console.log("trying to show loading...",msg),_this.IonicUtils.showLoading(_this.$scope,msg),_this.$scope.$apply(),console.log("applied")}}(this))},BooksController.prototype.submitDoubanUser=function(){var username;return username=angular.element(document.getElementById("douban-username")),username=username.val(),this.DoubanService.submitUser(username,function(_this){return function(){return _this.$scope.doubanInputDisabled=!0,_this.LocalStorageUtils.storeDoubanUser(username),alert("成功绑定豆瓣用户,请返回,系统将自动为你导入豆瓣图书")}}(this),function(_this){return function(){return _this.IonicUtils.showLoading(_this.$scope,"绑定豆瓣用户失败,请稍后再试")}}(this))},BooksController}(),libr.controller("BooksController",BooksController)}).call(this); +(function(){var BookDetailController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers",["ionic"]),BookDetailController=function(){function BookDetailController($scope,$stateParams,Books,$window,$ionicModal,Comments,DoubanService){this.$scope=$scope,this.$stateParams=$stateParams,this.Books=Books,this.$window=$window,this.$ionicModal=$ionicModal,this.Comments=Comments,this.DoubanService=DoubanService,this.back=__bind(this.back,this),this.doComment=__bind(this.doComment,this),this.closeCommentDialog=__bind(this.closeCommentDialog,this),this.openCommentDialog=__bind(this.openCommentDialog,this),this.$scope.openDialog=this.openCommentDialog,this.$scope.closeDialog=this.closeCommentDialog,this.$scope.doComment=this.doComment,this.$scope.back=this.back,this.$ionicModal.fromTemplateUrl("templates/modal/comment.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.Books.get({book_id:this.$stateParams.isbn},function(_this){return function(result){return _this.$scope.book=result,_this.$scope.usersAccount=result.users.length,_this.$scope.bookName=_this.$scope.book.name,_this.Comments.query({book_id:result.id},function(data){return console.log(data,"!!!!!"),_this.$scope.comments=data}),_this.DoubanService.bookDetail(result.isbn,function(data){return console.log(data),_this.$scope.bookDetail=data},function(error){return console.log("error",error)})}}(this)),this.$scope.$on("$destroy",function(_this){return function(){return _this.$scope.modal.remove()}}(this))}return BookDetailController.$inject=["$scope","$stateParams","Books","$window","$ionicModal","Comments","DoubanService"],BookDetailController.prototype.openCommentDialog=function(){return this.$scope.modal.show()},BookDetailController.prototype.closeCommentDialog=function(){return this.$scope.modal.hide()},BookDetailController.prototype.doComment=function(){var text;return text=angular.element(document.getElementById("comment")).val(),""===text.trim()?(alert("请输入有效字符"),!1):this.Comments.save({book_id:this.$scope.book.id,content:text},null,function(_this){return function(data){return null===data.id?alert("添加图书失败"):(console.log("成功。。。。。。。"),_this.$scope.comments.push(data),_this.closeCommentDialog())}}(this))},BookDetailController.prototype.back=function(){return this.$window.history.back()},BookDetailController}(),libr.controller("BookDetailController",BookDetailController)}).call(this); +(function(){var HomeController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.home",["ionic"]),HomeController=function(){function HomeController($scope,$location,ScanService,$ionicLoading,$ionicActionSheet,RecommendService,ErrorHandler,LocalStorageUtils){return this.$scope=$scope,this.$location=$location,this.$ionicLoading=$ionicLoading,this.$ionicActionSheet=$ionicActionSheet,this.RecommendService=RecommendService,this.ErrorHandler=ErrorHandler,this.LocalStorageUtils=LocalStorageUtils,this.changeRecommend=__bind(this.changeRecommend,this),this.showRecommendActionSheet=__bind(this.showRecommendActionSheet,this),console.log(this.$scope,"!!!!!!!"),this.$scope.showRecommendActionSheet=this.showRecommendActionSheet,this.LocalStorageUtils.isUserLogedIn()?(showLoading(this.$scope,this.$ionicLoading),this.$scope.title={name:"Libr-随便看看吧"},null===localStorage.getItem("home.books")?this.RecommendService.randomBooks(function(_this){return function(result){return _this.$scope.books=result,localStorage.setItem("home.books",JSON.stringify(result)),_this.$ionicLoading.hide()}}(this),function(_this){return function(){return _this.ErrorHandler.loadingHandler(_this.$scope,null)}}(this)):(this.$scope.books=JSON.parse(localStorage.getItem("home.books")),this.$ionicLoading.hide()),void(this.$scope.changeRecommend=this.changeRecommend)):void this.$location.path("/tab/settings")}var showLoading;return HomeController.$inject=["$scope","$location","ScanService","$ionicLoading","$ionicActionSheet","RecommendService","ErrorHandler","LocalStorageUtils"],showLoading=function($scope,$ionicLoading){return $scope.loading=$ionicLoading.show({content:"加载中",animation:"fade-in",showBackdrop:!0,maxWidth:200,showDelay:500})},HomeController.prototype.showRecommendActionSheet=function(){return this.$ionicActionSheet.show({titleText:"Libr 为你推荐",buttons:this.RecommendService.getActionSheetList(),cancelText:"取消",cancel:function(){return console.log("CANCELLED")},buttonClicked:function(_this){return function(index){return console.log(""+index+" has been taped"),_this.changeRecommend(index),!0}}(this)})},HomeController.prototype.changeRecommend=function(index){var msg;return msg="喔,看来附近还没有好书推荐,快去推荐你的朋友也来使用吧!",this.RecommendService.changeRecommendAction(index,function(_this){return function(result){var listArray;return 0===result.length?navigator.notification.alert(msg,null,"libr","确定"):(_this.$scope.books=result,localStorage.setItem("home.books",JSON.stringify(result)),listArray=JSON.parse(localStorage.getItem("recommend_action_sheet_full_arr")),_this.$scope.title.name=listArray[index].text,console.log(_this.$scope,"========"))}}(this),function(_this){return function(){return _this.ErrorHandler.whenError(null)}}(this))},HomeController}(),libr.controller("HomeCtrl",HomeController)}).call(this); +(function(){var LocationController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.location",["ionic"]),LocationController=function(){function LocationController($scope,$location,GeolocationService,IonicUtils){this.$scope=$scope,this.$location=$location,this.GeolocationService=GeolocationService,this.IonicUtils=IonicUtils,this.deleteItem=__bind(this.deleteItem,this),this.addLocation=__bind(this.addLocation,this),this.$scope.addLocation=this.addLocation,this.$scope.itemButtons=[{text:"删除",type:"button-assertive",onTap:function(_this){return function(item){return _this.GeolocationService.deleteLocation(item,function(){return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item),1)})}}(this)}],this.GeolocationService.getLocations(function(_this){return function(locations){return _this.$scope.locations=locations}}(this)),this.GeolocationService.getDetailAddress(function(_this){return function(position){return localStorage.setItem("cur_address_detail",position.result.formatted_address),localStorage.setItem("cur_lat",position.result.location.lat),localStorage.setItem("cur_lng",position.result.location.lng),_this.$scope.address=position.result.formatted_address}}(this)),this.IonicUtils.initCustomLoading(this.$scope),this.$scope.deleteItem=this.deleteItem}return LocationController.$inject=["$scope","$location","GeolocationService","IonicUtils"],LocationController.prototype.addLocation=function(){return this.$scope.locations.length>=3?this.IonicUtils.showLoading(this.$scope,"只能创建3个常用的地址,请先删除部分再添加"):null===localStorage.getItem("cur_address_detail")||void 0===localStorage.getItem("cur_address_detail")?this.IonicUtils.showLoading(this.$scope,"定位成功后方可添加常用地址"):null===this.$scope.address||""===this.$scope.address?this.IonicUtils.showLoading(this.$scope,"定位成功后方可添加常用地址"):this.GeolocationService.createLocation(function(_this){return function(result){return _this.$scope.locations.push(result)}}(this))},LocationController.prototype.deleteItem=function(item){return this.GeolocationService.deleteLocation(item,function(_this){return function(){return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item),1)}}(this))},LocationController}(),libr.controller("LocationController",LocationController)}).call(this); +(function(){var LoginController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.login",["ionic"]),LoginController=function(){function LoginController($scope,AuthService,$state,$ionicModal,IonicUtils,LocalStorageUtils){this.$scope=$scope,this.AuthService=AuthService,this.$state=$state,this.$ionicModal=$ionicModal,this.IonicUtils=IonicUtils,this.LocalStorageUtils=LocalStorageUtils,this.closeDialog=__bind(this.closeDialog,this),this.registerUser=__bind(this.registerUser,this),this.registerForm=__bind(this.registerForm,this),this.login=__bind(this.login,this),this.LocalStorageUtils.isUserLogedIn()&&this.$state.go("tab.home"),this.$scope.login=this.login,this.$scope.registerForm=this.registerForm,this.$scope.registerUser=this.registerUser,this.$scope.closeDialog=this.closeDialog,this.$ionicModal.fromTemplateUrl("templates/modal/registration.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.IonicUtils.initCustomLoading(this.$scope)}return LoginController.$inject=["$scope","AuthService","$state","$ionicModal","IonicUtils","LocalStorageUtils"],LoginController.prototype.login=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.login(user,function(_this){return function(result){return localStorage.setItem("token",result.user.token),localStorage.setItem("avatar",result.user.avatar),localStorage.setItem("username",result.user.name),localStorage.setItem("email",user.email),localStorage.setItem("user",JSON.stringify(result.user)),_this.$state.go("tab.home")}}(this),function(_this){return function(data){return _this.IonicUtils.showLoading(_this.$scope,data)}}(this)):void this.IonicUtils.showLoading(this.$scope,"请输入有效的用户名和密码")},LoginController.prototype.registerForm=function(){return this.$scope.modal.show()},LoginController.prototype.registerUser=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.register(user,function(_this){return function(result,status){return 201===status?(alert("注册成功,请返回登录"),_this.$scope.modal.hide()):_this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试")}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试"),console.log("registerError",error)}}(this)):void this.IonicUtils.showLoading(this.$scope,"用户名或密码错误,请重试")},LoginController.prototype.closeDialog=function(){return this.$scope.modal.hide()},LoginController}(),libr.controller("LoginController",LoginController)}).call(this); +(function(){var MainController,libr;libr=angular.module("libr.controllers.main",["ionic"]),MainController=function(){function MainController($scope,$location,$ionicModal,$state){this.$scope=$scope,this.$location=$location,this.$ionicModal=$ionicModal,this.$state=$state}return MainController.$inject=["$scope","$location","$ionicModal","$state"],MainController}(),libr.controller("MainCtrl",MainController)}).call(this); +(function(){var SettingsController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.settings",["ionic"]),SettingsController=function(){function SettingsController($scope,$ionicModal,AuthService,$state,$cacheFactory,LocalStorageUtils){this.$scope=$scope,this.$ionicModal=$ionicModal,this.AuthService=AuthService,this.$state=$state,this.$cacheFactory=$cacheFactory,this.LocalStorageUtils=LocalStorageUtils,this.logout=__bind(this.logout,this),this.$scope.logout=this.logout,this.$scope.feedback=this.feedback,this.$scope.showMe=this.showMe,this.$scope.isLogedIn=isUserLogedIn(this.LocalStorageUtils)?!0:!1,this.$scope.avatar=this.LocalStorageUtils.getUserAvatar(),this.$scope.username=this.LocalStorageUtils.getUserName()}var isUserLogedIn;return SettingsController.$inject=["$scope","$ionicModal","AuthService","$state","$cacheFactory","LocalStorageUtils"],SettingsController.prototype.logout=function(){var httpDefaultCache;return localStorage.clear(),httpDefaultCache=this.$cacheFactory.get("$http"),console.log("cacheFactory",httpDefaultCache),httpDefaultCache.removeAll(),this.$state.go("login")},SettingsController.prototype.feedback=function(){return window.open("https://jinshuju.net/f/F96z3s","_blank","location=no")},SettingsController.prototype.showMe=function(){return window.open("http://librme.com","_blank","location=no")},isUserLogedIn=function(localStorageUtils){return null!==localStorageUtils.getUserToken()&&null!==localStorageUtils.getUserEmail()?!0:!1},SettingsController}(),libr.controller("SettingsController",SettingsController)}).call(this); +(function(){var Constant,libr;libr=angular.module("libr.constant",[]),Constant={},Constant.baseUrl="http://librme.com/api/v1",libr.constant("Constant",Constant)}).call(this); \ No newline at end of file diff --git a/platforms/android/assets/www/js/app/controllers/controllers.coffee b/platforms/android/assets/www/js/app/controllers/controllers.coffee index a345dce..30f48db 100644 --- a/platforms/android/assets/www/js/app/controllers/controllers.coffee +++ b/platforms/android/assets/www/js/app/controllers/controllers.coffee @@ -1,9 +1,8 @@ libr = angular.module('libr.controllers', ['ionic']) class BookDetailController - @$inject: ['$scope', '$stateParams', 'Books', '$window', '$ionicModal', 'Comments'] - - constructor: (@$scope, @$stateParams, @Books, @$window, @$ionicModal, @Comments) -> + @$inject: ['$scope', '$stateParams', 'Books', '$window', '$ionicModal', 'Comments', 'DoubanService'] + constructor: (@$scope, @$stateParams, @Books, @$window, @$ionicModal, @Comments, @DoubanService) -> @$scope.openDialog = @openCommentDialog @$scope.closeDialog = @closeCommentDialog @$scope.doComment = @doComment @@ -15,15 +14,19 @@ class BookDetailController scope: @$scope, animation: 'slide-in-up' } - console.log '====' @Books.get {book_id: @$stateParams.isbn}, (result) => @$scope.book = result @$scope.usersAccount = result.users.length @$scope.bookName = @$scope.book.name @Comments.query {book_id: result.id}, (data)=> - console.log data,'!!!!!' + console.log data, '!!!!!' @$scope.comments = data + @DoubanService.bookDetail result.isbn, (data)=> + console.log data + @$scope.bookDetail = data + , (error)-> + console.log 'error', error @$scope.$on '$destroy', ()=> @$scope.modal.remove() @@ -54,5 +57,4 @@ class BookDetailController @$window.history.back() - libr.controller 'BookDetailController', BookDetailController diff --git a/platforms/android/assets/www/js/app/controllers/home-controller.coffee b/platforms/android/assets/www/js/app/controllers/home-controller.coffee index 3ffa5e5..6e883d4 100644 --- a/platforms/android/assets/www/js/app/controllers/home-controller.coffee +++ b/platforms/android/assets/www/js/app/controllers/home-controller.coffee @@ -4,24 +4,26 @@ class HomeController @$inject: ['$scope', '$location', 'ScanService', '$ionicLoading', '$ionicActionSheet', 'RecommendService', 'ErrorHandler', 'LocalStorageUtils'] constructor: (@$scope, @$location, ScanService, @$ionicLoading, @$ionicActionSheet, @RecommendService, @ErrorHandler, @LocalStorageUtils)-> + console.log @$scope, '!!!!!!!' @$scope.showRecommendActionSheet = @showRecommendActionSheet if @LocalStorageUtils.isUserLogedIn() showLoading(@$scope, @$ionicLoading) - @$scope.title = '随便看看吧' + @$scope.title = {'name': 'Libr-随便看看吧'} if localStorage.getItem('home.books') is null @RecommendService.randomBooks (result)=> @$scope.books = result localStorage.setItem 'home.books', JSON.stringify(result) - @$scope.loading.hide() + @$ionicLoading.hide() , (error)=> @ErrorHandler.loadingHandler @$scope, null else @$scope.books = JSON.parse(localStorage.getItem('home.books')) - @$scope.loading.hide() + @$ionicLoading.hide() else @$location.path '/tab/settings' return + @$scope.changeRecommend = @changeRecommend showLoading = ($scope, $ionicLoading)-> $scope.loading = $ionicLoading.show { @@ -54,7 +56,9 @@ class HomeController @$scope.books = result localStorage.setItem 'home.books', JSON.stringify(result) listArray = JSON.parse(localStorage.getItem 'recommend_action_sheet_full_arr') - @$scope.title = listArray[index].text + @$scope.title.name = listArray[index].text + + console.log @$scope, '========' , (error)=> @ErrorHandler.whenError null libr.controller 'HomeCtrl', HomeController diff --git a/platforms/android/assets/www/js/app/controllers/location-controller.coffee b/platforms/android/assets/www/js/app/controllers/location-controller.coffee index 51098da..4e9ac6b 100644 --- a/platforms/android/assets/www/js/app/controllers/location-controller.coffee +++ b/platforms/android/assets/www/js/app/controllers/location-controller.coffee @@ -30,7 +30,7 @@ class LocationController addLocation: () => if @$scope.locations.length >= 3 @IonicUtils.showLoading(@$scope, '只能创建3个常用的地址,请先删除部分再添加') - else if localStorage.getItem('cur_address_detail') is null + else if (localStorage.getItem('cur_address_detail') is null) || (localStorage.getItem('cur_address_detail') is undefined) @IonicUtils.showLoading(@$scope, '定位成功后方可添加常用地址') else if (@$scope.address is null or @$scope.address is '') @IonicUtils.showLoading(@$scope, '定位成功后方可添加常用地址') diff --git a/platforms/android/assets/www/js/app/services/douban-service.coffee b/platforms/android/assets/www/js/app/services/douban-service.coffee index 645f30e..7baff6e 100644 --- a/platforms/android/assets/www/js/app/services/douban-service.coffee +++ b/platforms/android/assets/www/js/app/services/douban-service.coffee @@ -22,6 +22,21 @@ class DoubanService .error (data)-> error data + bookDetail: (isbn, callback, error)-> + @$http( + url: "https://api.douban.com/v2/book/isbn/#{isbn}" + method: 'GET' + timeout: 10000 + cache: true + ) + .success (data, status, headers, config)-> + if status is 200 + callback data + else + error data + .error (data)-> + error data + submitUser: (user, callback, error)=> email = localStorage.getItem 'email' token = localStorage.getItem 'token' diff --git a/platforms/android/assets/www/js/app/services/recommend-service.coffee b/platforms/android/assets/www/js/app/services/recommend-service.coffee index dde399a..f270522 100644 --- a/platforms/android/assets/www/js/app/services/recommend-service.coffee +++ b/platforms/android/assets/www/js/app/services/recommend-service.coffee @@ -7,7 +7,7 @@ class RecommendService getActionSheetList: ()-> actionList = [] - actionList.push {text: '随机找几本书看看'} + actionList.push {text: '随便看看吧'} actionList.push {text: "你可能喜欢的书"} @GeolocationService.getLocations (locations)=> locationIds = [] @@ -40,7 +40,7 @@ class RecommendService url: @Constant.baseUrl + "/recommend/random?user_email=#{email}&user_token=#{token}" method: 'GET' timeout: 15000 - cache: true + cache: false ) .success (data, status, headers, config)-> callback data diff --git a/platforms/android/assets/www/templates/book-detail.html b/platforms/android/assets/www/templates/book-detail.html index 96d2d1e..5a23c1f 100644 --- a/platforms/android/assets/www/templates/book-detail.html +++ b/platforms/android/assets/www/templates/book-detail.html @@ -28,6 +28,11 @@ 评论 + +
图书简介:
+
+ {{bookDetail.summary}} +
评论:
diff --git a/platforms/android/assets/www/templates/libr-index.html b/platforms/android/assets/www/templates/libr-index.html index 23e369d..0caec4d 100644 --- a/platforms/android/assets/www/templates/libr-index.html +++ b/platforms/android/assets/www/templates/libr-index.html @@ -1,4 +1,9 @@ - + + + + diff --git a/platforms/android/assets/www/templates/modal/import_books.html b/platforms/android/assets/www/templates/modal/import_books.html index 7d57923..884e218 100644 --- a/platforms/android/assets/www/templates/modal/import_books.html +++ b/platforms/android/assets/www/templates/modal/import_books.html @@ -6,17 +6,20 @@
{{data.text}}
- +
-

已成功绑定豆瓣用户,你的豆瓣用户名为:{{doubanUsername}}

+

已成功绑定豆瓣用户:{{doubanUsername}}

- -
diff --git a/platforms/android/assets/www/templates/settings.html b/platforms/android/assets/www/templates/settings.html index db01612..49398a7 100644 --- a/platforms/android/assets/www/templates/settings.html +++ b/platforms/android/assets/www/templates/settings.html @@ -12,20 +12,10 @@ 注销登录
- - - 系统消息 - 0 - 请给我们提供反馈吧 - - - 关于 - - diff --git a/platforms/android/res/xml/config.xml b/platforms/android/res/xml/config.xml index 83e6e7d..2625be9 100644 --- a/platforms/android/res/xml/config.xml +++ b/platforms/android/res/xml/config.xml @@ -26,6 +26,9 @@ + + + Libr A sample Apache Cordova application that responds to the deviceready event. @@ -52,7 +55,4 @@ - - - diff --git a/platforms/ios/Libr.xcodeproj/project.pbxproj b/platforms/ios/Libr.xcodeproj/project.pbxproj index 9fa1224..570e862 100644 --- a/platforms/ios/Libr.xcodeproj/project.pbxproj +++ b/platforms/ios/Libr.xcodeproj/project.pbxproj @@ -5,6 +5,7 @@ }; objectVersion = 46; objects = { + /* Begin PBXBuildFile section */ 1407A44D22484B4395C72B89 /* scannerOverlay.xib in Resources */ = {isa = PBXBuildFile; fileRef = E12B99CB376A490BA963436B /* scannerOverlay.xib */; }; 1A60A167A53E41DC9AB3A5B5 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = CB86B589F04E43CD95185886 /* CDVReachability.m */; }; diff --git a/platforms/ios/Libr.xcodeproj/project.xcworkspace/xcuserdata/twer.xcuserdatad/UserInterfaceState.xcuserstate b/platforms/ios/Libr.xcodeproj/project.xcworkspace/xcuserdata/twer.xcuserdatad/UserInterfaceState.xcuserstate index 042fba9..84dab9d 100644 Binary files a/platforms/ios/Libr.xcodeproj/project.xcworkspace/xcuserdata/twer.xcuserdatad/UserInterfaceState.xcuserstate and b/platforms/ios/Libr.xcodeproj/project.xcworkspace/xcuserdata/twer.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/platforms/ios/Libr/Libr-Info.plist b/platforms/ios/Libr/Libr-Info.plist index 4347c4b..bcabdc8 100644 --- a/platforms/ios/Libr/Libr-Info.plist +++ b/platforms/ios/Libr/Libr-Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.0.1 + 1.0.0 CFBundleSignature ???? CFBundleVersion diff --git a/platforms/ios/www/dist/js/all.min.js b/platforms/ios/www/dist/js/all.min.js index d577a1a..74ad34c 100644 --- a/platforms/ios/www/dist/js/all.min.js +++ b/platforms/ios/www/dist/js/all.min.js @@ -1,1328 +1,18 @@ -(function() { - var IonicUtils, libr; - - libr = angular.module('libr.services.utils', []); - - IonicUtils = (function() { - IonicUtils.$inject = ['$timeout']; - - function IonicUtils($timeout) { - this.$timeout = $timeout; - } - - IonicUtils.prototype.initCustomLoading = function(scope) { - return scope.data = { - isLoading: false, - text: null - }; - }; - - IonicUtils.prototype.showLoading = function(scope, text, timing) { - if (timing == null) { - timing = 3000; - } - scope.data = { - isLoading: true, - text: text - }; - return this.$timeout((function(_this) { - return function() { - return _this.initCustomLoading(scope); - }; - })(this), timing); - }; - - IonicUtils.prototype.cacheImage = function(imageUrl) { - if (!ImgCache.isCached(imageUrl)) { - return ImgCache.cacheFile(imageUrl, null); - } - }; - - return IonicUtils; - - })(); - - libr.service('IonicUtils', IonicUtils); - -}).call(this); - -(function() { - var LocalStorageUtils, libr; - - libr = angular.module('libr.services.localstorage', []); - - LocalStorageUtils = (function() { - function LocalStorageUtils() {} - - LocalStorageUtils.prototype.getUser = function() { - return JSON.parse(localStorage.getItem('user')); - }; - - LocalStorageUtils.prototype.getUserId = function() { - var user; - user = this.getUser(); - return user.id; - }; - - LocalStorageUtils.prototype.getUserName = function() { - var user; - user = this.getUser(); - return user.name; - }; - - LocalStorageUtils.prototype.getUserToken = function() { - var user; - user = this.getUser(); - return user.token; - }; - - LocalStorageUtils.prototype.getUserAvatar = function() { - var user; - user = this.getUser(); - return user.avatar; - }; - - LocalStorageUtils.prototype.getUserEmail = function() { - var user; - user = this.getUser(); - return user.email; - }; - - LocalStorageUtils.prototype.isUserLogedIn = function() { - var user; - user = this.getUser(); - return user !== null && this.getUserEmail() !== null && this.getUserToken() !== null; - }; - - LocalStorageUtils.prototype.storeDoubanUser = function(name) { - return localStorage.setItem('doubanUser', name); - }; - - LocalStorageUtils.prototype.getDoubanUser = function() { - var user; - user = this.getUser(); - if (user.douban_user !== null) { - return user.douban_user; - } else if (localStorage.getItem('doubanUser') !== null) { - return localStorage.getItem('doubanUser'); - } else { - return null; - } - }; - - return LocalStorageUtils; - - })(); - - libr.service('LocalStorageUtils', LocalStorageUtils); - -}).call(this); - -(function() { - var ErrorHandler, libr; - - libr = angular.module('libr.handlers.errorHandler', []); - - ErrorHandler = (function() { - function ErrorHandler() {} - - ErrorHandler.prototype.loadingHandler = function($scope, callback) { - var message; - $scope.loading.hide(); - message = '加载失败,请确认有良好网络连接,并重试'; - return navigator.notification.confirm(message, (function(_this) { - return function() { - return callback(); - }; - })(this), '加载失败', ['确定', '取消']); - }; - - ErrorHandler.prototype.whenError = function(callback) { - var message; - message = '加载失败,请确认有良好网络连接,并重试'; - return navigator.notification.confirm(message, (function(_this) { - return function() { - return callback(); - }; - })(this), '加载失败', ['确定', '取消']); - }; - - return ErrorHandler; - - })(); - - libr.service('ErrorHandler', ErrorHandler); - -}).call(this); - -(function() { - var AuthicationService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.auth', []); - - AuthicationService = (function() { - AuthicationService.$inject = ['$http', 'Constant']; - - function AuthicationService($http, Constant) { - this.$http = $http; - this.Constant = Constant; - this.register = __bind(this.register, this); - this.login = __bind(this.login, this); - console.log('init auth service'); - } - - AuthicationService.prototype.login = function(user, callback, errorCallback) { - var baseUrl; - baseUrl = this.Constant.baseUrl + '/sessions'; - return this.$http({ - method: 'POST', - url: baseUrl, - data: "user[email]=" + user.email + "&user[password]=" + user.password, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(result) { - if (result.success) { - return callback(result); - } else { - return errorCallback('登录失败,请输入正确的用户名和密码'); - } - }).error(function(data) { - return errorCallback('登录失败,请输入正确的用户名和密码'); - }); - }; - - AuthicationService.prototype.register = function(user, callback, onError) { - var url; - url = this.Constant.baseUrl + '/registrations'; - return this.$http({ - method: 'POST', - url: url, - data: "user[email]=" + user.email + "&user[password]=" + user.password, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(result, status) { - return callback(result, status); - }).error(function(data, status) { - return onError(data); - }); - }; - - return AuthicationService; - - })(); - - libr.service('AuthService', AuthicationService); - -}).call(this); - -(function() { - var Books, libr; - - libr = angular.module('libr.services.books', ['ngResource']); - - Books = (function() { - Books.$inject = ['$http', '$resource', 'Constant', 'LocalStorageUtils']; - - function Books($resource, Constant, LocalStorageUtils) { - var url; - this.$resource = $resource; - this.Constant = Constant; - this.LocalStorageUtils = LocalStorageUtils; - url = this.Constant.baseUrl + '/users/:user_id/books/:book_id'; - return this.$resource(url, { - user_email: this.LocalStorageUtils.getUserEmail(), - user_token: this.LocalStorageUtils.getUserToken(), - user_id: this.LocalStorageUtils.getUserId(), - book_id: '@bookId' - }, { - 'get': { - cache: true, - method: 'GET' - }, - 'query': { - method: 'GET', - isArray: false, - cache: false - }, - 'fetchNew': { - method: 'GET', - isArray: false, - cache: true, - url: this.Constant.baseUrl + '/books/newbooks/:afterId' - } - }); - } - - return Books; - - })(); - - libr.factory('Books', ['$resource', 'Constant', 'LocalStorageUtils', Books]); - -}).call(this); - -(function() { - var CommentService, libr; - - libr = angular.module('libr.services.comment', ['ngResource']); - - CommentService = (function() { - CommentService.$inject = ['$http', '$resource', 'Constant']; - - function CommentService($resource, Constant) { - var baseUrl; - this.$resource = $resource; - this.Constant = Constant; - baseUrl = this.Constant.baseUrl + '/books/:book_id/comments/:comment_id'; - return this.$resource(baseUrl, { - user_email: localStorage.getItem('email'), - user_token: localStorage.getItem('token'), - book_id: '@bookId', - comment_id: '@commentId' - }, { - 'query': { - method: 'GET', - isArray: true, - cache: false - } - }, { - 'save': { - params: { - comment_id: '@commentId' - } - } - }); - } - - return CommentService; - - })(); - - libr.factory('Comments', ['$resource', 'Constant', CommentService]); - -}).call(this); - -(function() { - var DoubanService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.douban', []); - - DoubanService = (function() { - DoubanService.$inject = ['$http', 'Constant', 'LocalStorageUtils']; - - function DoubanService($http, Constant, LocalStorageUtils) { - this.$http = $http; - this.Constant = Constant; - this.LocalStorageUtils = LocalStorageUtils; - this.submitUser = __bind(this.submitUser, this); - } - - DoubanService.prototype.userInfo = function(user, callback, error) { - return this.$http({ - url: "http://api.douban.com/v2/user/" + user, - method: 'GET', - timeout: 10000, - cache: true - }).success(function(data, status, headers, config) { - if (status === 200) { - return callback(data); - } else { - return error(data); - } - }).error(function(data) { - return error(data); - }); - }; - - DoubanService.prototype.bookDetail = function(isbn, callback, error) { - return this.$http({ - url: "https://api.douban.com/v2/book/isbn/" + isbn, - method: 'GET', - timeout: 10000, - cache: true - }).success(function(data, status, headers, config) { - if (status === 200) { - return callback(data); - } else { - return error(data); - } - }).error(function(data) { - return error(data); - }); - }; - - DoubanService.prototype.submitUser = function(user, callback, error) { - var email, token, userId; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - userId = this.LocalStorageUtils.getUserId(); - return this.$http({ - url: "" + this.Constant.baseUrl + "/users/" + userId + "/link/douban/" + user + "?user_email=" + email + "&user_token=" + token, - method: 'POST', - timeout: 10000 - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - return DoubanService; - - })(); - - libr.service('DoubanService', DoubanService); - -}).call(this); - -(function() { - var GeolocationService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.geolocation', []); - - GeolocationService = (function() { - var getLocation, onError, onSuccess; - - GeolocationService.$inject = ['$http', 'Constant']; - - function GeolocationService($http, Constant) { - this.$http = $http; - this.Constant = Constant; - this.getDetailAddress = __bind(this.getDetailAddress, this); - } - - onSuccess = function(position) { - alert('lat' + position.coords.latitude); - return { - "Latitude": position.coords.latitude, - "Longitude": position.coords.longitude, - "Altitude": position.coords.altitude, - "Accuracy": position.coords.accuracy, - "Altitude Accuracy": position.coords.altitudeAccuracy, - "Heading": position.coords.heading, - "Speed": position.coords.speed, - "Timestamp": position.timestamp - }; - }; - - onError = function(error) { - throw "code: " + error.code + " \n message: " + error.message; - }; - - GeolocationService.prototype.getCurrentLocation = function(callback, error) { - return navigator.geolocation.getCurrentPosition(callback, error); - }; - - GeolocationService.prototype.getDetailAddress = function(callback, error) { - var baseUrl; - baseUrl = this.Constant.baseUrl + '/locations/detail'; - return this.getCurrentLocation((function(_this) { - return function(position) { - return _this.$http({ - url: "" + baseUrl + "?lat=" + position.coords.latitude + "&lng=" + position.coords.longitude, - cache: true, - method: 'GET' - }).success(function(data, status, headers, config) { - return callback(data); - }); - }; - })(this), function(error) { - throw Error(error); - }); - }; - - GeolocationService.prototype.getLocations = function(callback, error) { - var baseUrl, email, token; - baseUrl = this.Constant.baseUrl + '/locations'; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: "" + baseUrl + "?user_email=" + email + "&user_token=" + token, - method: 'GET', - cache: false - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - throw Error(error); - }); - }; - - GeolocationService.prototype.createLocation = function(callback) { - var baseUrl, email, location, token; - baseUrl = this.Constant.baseUrl + '/locations'; - location = getLocation(); - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - method: 'POST', - url: baseUrl + ("?user_email=" + email + "&user_token=" + token), - data: "address=" + location.address + "&lat=" + location.lat + "&lng=" + location.lng, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(data) { - return callback(data); - }); - }; - - GeolocationService.prototype.deleteLocation = function(item, callback) { - var baseUrl, email, token; - baseUrl = this.Constant.baseUrl + '/locations'; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - method: 'DELETE', - url: baseUrl + ("?user_email=" + email + "&user_token=" + token + "&id=" + item.id), - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } - }).success(function(data) { - console.log("=====", data); - return callback(data); - }); - }; - - getLocation = function() { - var location; - location = {}; - location.address = localStorage.getItem('cur_address_detail'); - location.lat = localStorage.getItem('cur_lat'); - location.lng = localStorage.getItem('cur_lng'); - return location; - }; - - return GeolocationService; - - })(); - - libr.service('GeolocationService', GeolocationService); - -}).call(this); - -(function() { - var RecommendService, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.services.recommend', []); - - RecommendService = (function() { - RecommendService.$injector = ['GeolocationService', '$http', 'Constant']; - - function RecommendService(GeolocationService, $http, Constant) { - this.GeolocationService = GeolocationService; - this.$http = $http; - this.Constant = Constant; - this.changeRecommendAction = __bind(this.changeRecommendAction, this); - this.popularBooksAroundMe = __bind(this.popularBooksAroundMe, this); - } - - RecommendService.prototype.getActionSheetList = function() { - var actionList; - actionList = []; - actionList.push({ - text: '随便看看吧' - }); - actionList.push({ - text: "你可能喜欢的书" - }); - this.GeolocationService.getLocations((function(_this) { - return function(locations) { - var locationIds; - locationIds = []; - locations.map(function(location) { - locationIds.push(location.id); - location = { - text: "" + location.address + "附近流行的书" - }; - return actionList.push(location); - }); - localStorage.setItem('recommend_action_sheet_arr', JSON.stringify(locationIds)); - return localStorage.setItem('recommend_action_sheet_full_arr', JSON.stringify(actionList)); - }; - })(this)); - return actionList; - }; - - RecommendService.prototype.popularBooksForMe = function(callback, error) { - var email, token; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: this.Constant.baseUrl + ("/recommend/me?user_email=" + email + "&user_token=" + token), - method: 'GET', - timeout: 15000 - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - RecommendService.prototype.randomBooks = function(callback, error) { - var email, token; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: this.Constant.baseUrl + ("/recommend/random?user_email=" + email + "&user_token=" + token), - method: 'GET', - timeout: 15000, - cache: false - }).success(function(data, status, headers, config) { - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - RecommendService.prototype.popularBooksAroundMe = function(locationId, callback, error) { - var email, token; - email = localStorage.getItem('email'); - token = localStorage.getItem('token'); - return this.$http({ - url: this.Constant.baseUrl + ("/recommend/locations/" + locationId + "?user_email=" + email + "&user_token=" + token), - method: 'GET', - timeout: 15000, - cache: true - }).success(function(data, status, headers, config) { - console.log('数据', data); - return callback(data); - }).error(function(data) { - return error(data); - }); - }; - - RecommendService.prototype.changeRecommendAction = function(index, callback, error) { - var locations; - console.log('index====', index); - if (index === 0) { - return this.randomBooks(callback, error); - } else if (index === 1) { - return this.popularBooksForMe(callback, error); - } else { - locations = JSON.parse(localStorage.getItem('recommend_action_sheet_arr')); - console.log(locations[index - 2], 'index......'); - return this.popularBooksAroundMe(locations[index - 2], function(result) { - console.log('callback....', result); - return callback(result); - }, function(errorMessage) { - return error(errorMessage); - }); - } - }; - - return RecommendService; - - })(); - - libr.service('RecommendService', RecommendService); - -}).call(this); - -(function() { - var ScanService, libr; - - libr = angular.module('libr.services.scan', []); - - ScanService = (function() { - ScanService.$inject = ['Books']; - - function ScanService(Books) { - this.Books = Books; - } - - ScanService.prototype.scan = function(callback, errorCallback) { - navigator.notification.vibrate(50); - return cordova.plugins.barcodeScanner.scan((function(_this) { - return function(result) { - console.log('got scan result', result); - if (result.cancelled === 1) { - return; - } - if (result.format !== 'EAN_13') { - console.log('条码不匹配'); - errorCallback('条形码类型错误,请确认所扫为书籍,并更换角度'); - return; - } - return _this.Books.save({ - isbn: result.text - }, null, function(data) { - console.log('get server response'); - if (data.status === 'error') { - return errorCallback(data.message); - } else { - return callback(data); - } - }, function(error) { - return errorCallback('添加图书失败' + error.data.message); - }); - }; - })(this), function(error) { - return errorCallback("扫描图书失败:" + error + " "); - }); - }; - - return ScanService; - - })(); - - libr.service('ScanService', ScanService); - -}).call(this); - -(function() { - var BooksController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.books', ['ionic']); - - BooksController = (function() { - BooksController.$inject = ['$scope', 'Books', 'ScanService', '$ionicModal', 'DoubanService', 'IonicUtils', 'LocalStorageUtils']; - - function BooksController($scope, Books, ScanService, $ionicModal, DoubanService, IonicUtils, LocalStorageUtils) { - var currentPage; - this.$scope = $scope; - this.Books = Books; - this.ScanService = ScanService; - this.$ionicModal = $ionicModal; - this.DoubanService = DoubanService; - this.IonicUtils = IonicUtils; - this.LocalStorageUtils = LocalStorageUtils; - this.submitDoubanUser = __bind(this.submitDoubanUser, this); - this.scanBooks = __bind(this.scanBooks, this); - this.searchDoubanUser = __bind(this.searchDoubanUser, this); - this.closeDialog = __bind(this.closeDialog, this); - this.loadMore = __bind(this.loadMore, this); - this.refresh = __bind(this.refresh, this); - currentPage = localStorage.setItem('user_books_current_page', 0); - this.$scope.books = []; - this.$scope.moreItemsAvailable = true; - this.$scope.submitAllowed = false; - this.$ionicModal.fromTemplateUrl('templates/modal/import_books.html', (function(_this) { - return function(modal) { - return _this.$scope.modal = modal; - }; - })(this), { - scope: this.$scope, - animation: 'slide-in-up' - }); - this.$scope.data = { - isLoading: false, - text: null - }; - this.IonicUtils.initCustomLoading(this.$scope); - this.$scope.onRefresh = this.refresh; - this.$scope.loadMore = this.loadMore; - this.$scope.closeDialog = this.closeDialog; - this.$scope.searchDoubanUser = this.searchDoubanUser; - this.$scope.scanBooks = this.scanBooks; - this.$scope.submitDoubanUser = this.submitDoubanUser; - this.$scope.doubanInputDisabled = this.LocalStorageUtils.getDoubanUser() !== null; - this.$scope.doubanUsername = this.LocalStorageUtils.getDoubanUser(); - } - - BooksController.prototype.refresh = function() { - var afterBookId; - afterBookId = localStorage.getItem('user_max_book_id'); - return this.Books.fetchNew({ - afterId: afterBookId - }, (function(_this) { - return function(data) { - _this.$scope.$broadcast('scroll.refreshComplete'); - if (data.books.length !== 0) { - localStorage.setItem('user_max_book_id', data.books[0].id); - return data.books.forEach(function(item, index, array) { - return _this.$scope.books.push(item); - }); - } - }; - })(this)); - }; - - BooksController.prototype.loadMore = function() { - var currentPage, maxPage; - currentPage = localStorage.getItem('user_books_current_page'); - maxPage = localStorage.getItem('user_books_max_page'); - maxPage = parseInt(maxPage); - currentPage = parseInt(currentPage); - if (!(currentPage >= maxPage)) { - return this.Books.query({ - page: currentPage + 1 - }, (function(_this) { - return function(data) { - if (data.books.length !== 0) { - localStorage.setItem('user_max_book_id', data.books[0].id); - localStorage.setItem('user_books_current_page', data.current_page); - localStorage.setItem('user_books_max_page', data.total_page); - data.books.forEach(function(item, index, array) { - return _this.$scope.books.push(item); - }); - } else { - _this.$scope.moreItemsAvailable = false; - } - return _this.$scope.$broadcast('scroll.infiniteScrollComplete'); - }; - })(this)); - } else { - this.$scope.$broadcast('scroll.infiniteScrollComplete'); - return this.$scope.moreItemsAvailable = false; - } - }; - - BooksController.prototype.closeDialog = function() { - return this.$scope.modal.hide(); - }; - - BooksController.prototype.searchDoubanUser = function(user) { - console.log(user, '...'); - if (user === void 0 || user.trim() === '') { - return this.IonicUtils.showLoading(this.$scope, '请输入有效昵称'); - } else { - return this.DoubanService.userInfo(user, (function(_this) { - return function(data) { - _this.$scope.resultEnabled = true; - _this.$scope.submitAllowed = true; - return _this.$scope.doubanUser = data; - }; - })(this), (function(_this) { - return function(error) { - _this.IonicUtils.showLoading(_this.$scope, '查找豆瓣用户失败,请稍后再试'); - console.log(error); - _this.$scope.resultEnabled = false; - return _this.$scope.submitAllowed = false; - }; - })(this)); - } - }; - - BooksController.prototype.scanBooks = function() { - return this.ScanService.scan((function(_this) { - return function(result) { - navigator.notification.alert("添加图书《" + result.book.name + "》成功", null, "Libr", "确定"); - return _this.$scope.books.unshift(result.book); - }; - })(this), (function(_this) { - return function(msg) { - console.log('trying to show loading...', msg); - _this.IonicUtils.showLoading(_this.$scope, msg); - _this.$scope.$apply(); - return console.log('applied'); - }; - })(this)); - }; - - BooksController.prototype.submitDoubanUser = function() { - var username; - username = angular.element(document.getElementById('douban-username')); - username = username.val(); - return this.DoubanService.submitUser(username, (function(_this) { - return function(data) { - _this.$scope.doubanInputDisabled = true; - _this.LocalStorageUtils.storeDoubanUser(username); - return alert('成功绑定豆瓣用户,请返回,系统将自动为你导入豆瓣图书'); - }; - })(this), (function(_this) { - return function(data) { - return _this.IonicUtils.showLoading(_this.$scope, '绑定豆瓣用户失败,请稍后再试'); - }; - })(this)); - }; - - return BooksController; - - })(); - - libr.controller('BooksController', BooksController); - -}).call(this); - -(function() { - var BookDetailController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers', ['ionic']); - - BookDetailController = (function() { - BookDetailController.$inject = ['$scope', '$stateParams', 'Books', '$window', '$ionicModal', 'Comments', 'DoubanService']; - - function BookDetailController($scope, $stateParams, Books, $window, $ionicModal, Comments, DoubanService) { - this.$scope = $scope; - this.$stateParams = $stateParams; - this.Books = Books; - this.$window = $window; - this.$ionicModal = $ionicModal; - this.Comments = Comments; - this.DoubanService = DoubanService; - this.back = __bind(this.back, this); - this.doComment = __bind(this.doComment, this); - this.closeCommentDialog = __bind(this.closeCommentDialog, this); - this.openCommentDialog = __bind(this.openCommentDialog, this); - this.$scope.openDialog = this.openCommentDialog; - this.$scope.closeDialog = this.closeCommentDialog; - this.$scope.doComment = this.doComment; - this.$scope.back = this.back; - this.$ionicModal.fromTemplateUrl('templates/modal/comment.html', (function(_this) { - return function(modal) { - return _this.$scope.modal = modal; - }; - })(this), { - scope: this.$scope, - animation: 'slide-in-up' - }); - this.Books.get({ - book_id: this.$stateParams.isbn - }, (function(_this) { - return function(result) { - _this.$scope.book = result; - _this.$scope.usersAccount = result.users.length; - _this.$scope.bookName = _this.$scope.book.name; - _this.Comments.query({ - book_id: result.id - }, function(data) { - console.log(data, '!!!!!'); - return _this.$scope.comments = data; - }); - return _this.DoubanService.bookDetail(result.isbn, function(data) { - console.log(data); - return _this.$scope.bookDetail = data; - }, function(error) { - return console.log('error', error); - }); - }; - })(this)); - this.$scope.$on('$destroy', (function(_this) { - return function() { - return _this.$scope.modal.remove(); - }; - })(this)); - } - - BookDetailController.prototype.openCommentDialog = function() { - return this.$scope.modal.show(); - }; - - BookDetailController.prototype.closeCommentDialog = function() { - return this.$scope.modal.hide(); - }; - - BookDetailController.prototype.doComment = function() { - var text; - text = angular.element(document.getElementById('comment')).val(); - if (text.trim() === '') { - alert('请输入有效字符'); - return false; - } else { - return this.Comments.save({ - book_id: this.$scope.book.id, - content: text - }, null, (function(_this) { - return function(data) { - if (data.id === null) { - return alert('添加图书失败'); - } else { - console.log('成功。。。。。。。'); - _this.$scope.comments.push(data); - return _this.closeCommentDialog(); - } - }; - })(this)); - } - }; - - BookDetailController.prototype.back = function() { - return this.$window.history.back(); - }; - - return BookDetailController; - - })(); - - libr.controller('BookDetailController', BookDetailController); - -}).call(this); - -(function() { - var HomeController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.home', ['ionic']); - - HomeController = (function() { - var showLoading; - - HomeController.$inject = ['$scope', '$location', 'ScanService', '$ionicLoading', '$ionicActionSheet', 'RecommendService', 'ErrorHandler', 'LocalStorageUtils']; - - function HomeController($scope, $location, ScanService, $ionicLoading, $ionicActionSheet, RecommendService, ErrorHandler, LocalStorageUtils) { - this.$scope = $scope; - this.$location = $location; - this.$ionicLoading = $ionicLoading; - this.$ionicActionSheet = $ionicActionSheet; - this.RecommendService = RecommendService; - this.ErrorHandler = ErrorHandler; - this.LocalStorageUtils = LocalStorageUtils; - this.changeRecommend = __bind(this.changeRecommend, this); - this.showRecommendActionSheet = __bind(this.showRecommendActionSheet, this); - this.$scope.showRecommendActionSheet = this.showRecommendActionSheet; - if (this.LocalStorageUtils.isUserLogedIn()) { - showLoading(this.$scope, this.$ionicLoading); - this.$scope.title = '随便看看吧'; - if (localStorage.getItem('home.books') === null) { - this.RecommendService.randomBooks((function(_this) { - return function(result) { - _this.$scope.books = result; - localStorage.setItem('home.books', JSON.stringify(result)); - return _this.$ionicLoading.hide(); - }; - })(this), (function(_this) { - return function(error) { - return _this.ErrorHandler.loadingHandler(_this.$scope, null); - }; - })(this)); - } else { - this.$scope.books = JSON.parse(localStorage.getItem('home.books')); - this.$ionicLoading.hide(); - } - } else { - this.$location.path('/tab/settings'); - return; - } - this.$scope.changeRecommend = this.changeRecommend; - } - - showLoading = function($scope, $ionicLoading) { - return $scope.loading = $ionicLoading.show({ - content: '加载中', - animation: 'fade-in', - showBackdrop: true, - maxWidth: 200, - showDelay: 500 - }); - }; - - HomeController.prototype.showRecommendActionSheet = function() { - return this.$ionicActionSheet.show({ - titleText: 'Libr 为你推荐', - buttons: this.RecommendService.getActionSheetList(), - cancelText: '取消', - cancel: function() { - return console.log('CANCELLED'); - }, - buttonClicked: (function(_this) { - return function(index) { - console.log("" + index + " has been taped"); - _this.changeRecommend(index); - return true; - }; - })(this) - }); - }; - - HomeController.prototype.changeRecommend = function(index) { - var msg; - msg = '喔,看来附近还没有好书推荐,快去推荐你的朋友也来使用吧!'; - return this.RecommendService.changeRecommendAction(index, (function(_this) { - return function(result) { - var listArray; - if (result.length === 0) { - return navigator.notification.alert(msg, null, 'libr', '确定'); - } else { - _this.$scope.books = result; - localStorage.setItem('home.books', JSON.stringify(result)); - listArray = JSON.parse(localStorage.getItem('recommend_action_sheet_full_arr')); - return _this.$scope.title = listArray[index].text; - } - }; - })(this), (function(_this) { - return function(error) { - return _this.ErrorHandler.whenError(null); - }; - })(this)); - }; - - return HomeController; - - })(); - - libr.controller('HomeCtrl', HomeController); - -}).call(this); - -(function() { - var LocationController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.location', ['ionic']); - - LocationController = (function() { - LocationController.$inject = ['$scope', '$location', 'GeolocationService', 'IonicUtils']; - - function LocationController($scope, $location, GeolocationService, IonicUtils) { - this.$scope = $scope; - this.$location = $location; - this.GeolocationService = GeolocationService; - this.IonicUtils = IonicUtils; - this.deleteItem = __bind(this.deleteItem, this); - this.addLocation = __bind(this.addLocation, this); - this.$scope.addLocation = this.addLocation; - this.$scope.itemButtons = [ - { - text: '删除', - type: 'button-assertive', - onTap: (function(_this) { - return function(item) { - return _this.GeolocationService.deleteLocation(item, function(result) { - return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item), 1); - }); - }; - })(this) - } - ]; - this.GeolocationService.getLocations((function(_this) { - return function(locations) { - return _this.$scope.locations = locations; - }; - })(this)); - this.GeolocationService.getDetailAddress((function(_this) { - return function(position) { - localStorage.setItem('cur_address_detail', position.result.formatted_address); - localStorage.setItem('cur_lat', position.result.location.lat); - localStorage.setItem('cur_lng', position.result.location.lng); - return _this.$scope.address = position.result.formatted_address; - }; - })(this)); - this.IonicUtils.initCustomLoading(this.$scope); - this.$scope.deleteItem = this.deleteItem; - } - - LocationController.prototype.addLocation = function() { - if (this.$scope.locations.length >= 3) { - return this.IonicUtils.showLoading(this.$scope, '只能创建3个常用的地址,请先删除部分再添加'); - } else if ((localStorage.getItem('cur_address_detail') === null) || (localStorage.getItem('cur_address_detail') === void 0)) { - return this.IonicUtils.showLoading(this.$scope, '定位成功后方可添加常用地址'); - } else if (this.$scope.address === null || this.$scope.address === '') { - return this.IonicUtils.showLoading(this.$scope, '定位成功后方可添加常用地址'); - } else { - return this.GeolocationService.createLocation((function(_this) { - return function(result) { - return _this.$scope.locations.push(result); - }; - })(this)); - } - }; - - LocationController.prototype.deleteItem = function(item) { - return this.GeolocationService.deleteLocation(item, (function(_this) { - return function(result) { - return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item), 1); - }; - })(this)); - }; - - return LocationController; - - })(); - - libr.controller('LocationController', LocationController); - -}).call(this); - -(function() { - var LoginController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.login', ['ionic']); - - LoginController = (function() { - LoginController.$inject = ['$scope', 'AuthService', '$state', '$ionicModal', 'IonicUtils', 'LocalStorageUtils']; - - function LoginController($scope, AuthService, $state, $ionicModal, IonicUtils, LocalStorageUtils) { - this.$scope = $scope; - this.AuthService = AuthService; - this.$state = $state; - this.$ionicModal = $ionicModal; - this.IonicUtils = IonicUtils; - this.LocalStorageUtils = LocalStorageUtils; - this.closeDialog = __bind(this.closeDialog, this); - this.registerUser = __bind(this.registerUser, this); - this.registerForm = __bind(this.registerForm, this); - this.login = __bind(this.login, this); - if (this.LocalStorageUtils.isUserLogedIn()) { - this.$state.go('tab.home'); - } - this.$scope.login = this.login; - this.$scope.registerForm = this.registerForm; - this.$scope.registerUser = this.registerUser; - this.$scope.closeDialog = this.closeDialog; - this.$ionicModal.fromTemplateUrl('templates/modal/registration.html', (function(_this) { - return function(modal) { - return _this.$scope.modal = modal; - }; - })(this), { - scope: this.$scope, - animation: 'slide-in-up' - }); - this.IonicUtils.initCustomLoading(this.$scope); - } - - LoginController.prototype.login = function(user) { - if (!user || user.email === '' || user.password === '' || user.email === void 0 || user.password === void 0) { - this.IonicUtils.showLoading(this.$scope, '请输入有效的用户名和密码'); - return; - } - return this.AuthService.login(user, (function(_this) { - return function(result) { - localStorage.setItem('token', result.user.token); - localStorage.setItem('avatar', result.user.avatar); - localStorage.setItem('username', result.user.name); - localStorage.setItem('email', user.email); - localStorage.setItem('user', JSON.stringify(result.user)); - return _this.$state.go('tab.home'); - }; - })(this), (function(_this) { - return function(data) { - return _this.IonicUtils.showLoading(_this.$scope, data); - }; - })(this)); - }; - - LoginController.prototype.registerForm = function() { - return this.$scope.modal.show(); - }; - - LoginController.prototype.registerUser = function(user) { - if (!user || user.email === '' || user.password === '' || user.email === void 0 || user.password === void 0) { - this.IonicUtils.showLoading(this.$scope, '用户名或密码错误,请重试'); - } else { - return this.AuthService.register(user, (function(_this) { - return function(result, status) { - if (status === 201) { - alert('注册成功,请返回登录'); - return _this.$scope.modal.hide(); - } else { - return _this.IonicUtils.showLoading(_this.$scope, '注册失败,请确认是否输入正确,并重试'); - } - }; - })(this), (function(_this) { - return function(error) { - _this.IonicUtils.showLoading(_this.$scope, '注册失败,请确认是否输入正确,并重试'); - return console.log("registerError", error); - }; - })(this)); - } - }; - - LoginController.prototype.closeDialog = function() { - return this.$scope.modal.hide(); - }; - - return LoginController; - - })(); - - libr.controller('LoginController', LoginController); - -}).call(this); - -(function() { - var MainController, libr; - - libr = angular.module('libr.controllers.main', ['ionic']); - - MainController = (function() { - MainController.$inject = ['$scope', '$location', '$ionicModal', '$state']; - - function MainController($scope, $location, $ionicModal, $state) { - this.$scope = $scope; - this.$location = $location; - this.$ionicModal = $ionicModal; - this.$state = $state; - } - - return MainController; - - })(); - - libr.controller('MainCtrl', MainController); - -}).call(this); - -(function() { - var SettingsController, libr, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; - - libr = angular.module('libr.controllers.settings', ['ionic']); - - SettingsController = (function() { - var isUserLogedIn; - - SettingsController.$inject = ['$scope', '$ionicModal', 'AuthService', '$state', '$cacheFactory', 'LocalStorageUtils']; - - function SettingsController($scope, $ionicModal, AuthService, $state, $cacheFactory, LocalStorageUtils) { - this.$scope = $scope; - this.$ionicModal = $ionicModal; - this.AuthService = AuthService; - this.$state = $state; - this.$cacheFactory = $cacheFactory; - this.LocalStorageUtils = LocalStorageUtils; - this.logout = __bind(this.logout, this); - this.$scope.logout = this.logout; - this.$scope.feedback = this.feedback; - this.$scope.showMe = this.showMe; - if (isUserLogedIn(this.LocalStorageUtils)) { - this.$scope.isLogedIn = true; - } else { - this.$scope.isLogedIn = false; - } - this.$scope.avatar = this.LocalStorageUtils.getUserAvatar(); - this.$scope.username = this.LocalStorageUtils.getUserName(); - } - - SettingsController.prototype.logout = function() { - var httpDefaultCache; - localStorage.clear(); - httpDefaultCache = this.$cacheFactory.get('$http'); - console.log('cacheFactory', httpDefaultCache); - httpDefaultCache.removeAll(); - return this.$state.go('login'); - }; - - SettingsController.prototype.feedback = function() { - return window.open('https://jinshuju.net/f/F96z3s', '_blank', 'location=no'); - }; - - SettingsController.prototype.showMe = function() { - return window.open('http://librme.com', '_blank', 'location=no'); - }; - - isUserLogedIn = function(localStorageUtils) { - if (localStorageUtils.getUserToken() !== null && localStorageUtils.getUserEmail() !== null) { - return true; - } else { - return false; - } - }; - - return SettingsController; - - })(); - - libr.controller('SettingsController', SettingsController); - -}).call(this); - -(function() { - var Constant, libr; - - libr = angular.module('libr.constant', []); - - Constant = {}; - - Constant.baseUrl = "http://10.17.2.147:3000/api/v1"; - - libr.constant('Constant', Constant); - -}).call(this); +(function(){var IonicUtils,libr;libr=angular.module("libr.services.utils",[]),IonicUtils=function(){function IonicUtils($timeout){this.$timeout=$timeout}return IonicUtils.$inject=["$timeout"],IonicUtils.prototype.initCustomLoading=function(scope){return scope.data={isLoading:!1,text:null}},IonicUtils.prototype.showLoading=function(scope,text,timing){return null==timing&&(timing=3e3),scope.data={isLoading:!0,text:text},this.$timeout(function(_this){return function(){return _this.initCustomLoading(scope)}}(this),timing)},IonicUtils.prototype.cacheImage=function(imageUrl){return ImgCache.isCached(imageUrl)?void 0:ImgCache.cacheFile(imageUrl,null)},IonicUtils}(),libr.service("IonicUtils",IonicUtils)}).call(this); +(function(){var LocalStorageUtils,libr;libr=angular.module("libr.services.localstorage",[]),LocalStorageUtils=function(){function LocalStorageUtils(){}return LocalStorageUtils.prototype.getUser=function(){return JSON.parse(localStorage.getItem("user"))},LocalStorageUtils.prototype.getUserId=function(){var user;return user=this.getUser(),user.id},LocalStorageUtils.prototype.getUserName=function(){var user;return user=this.getUser(),user.name},LocalStorageUtils.prototype.getUserToken=function(){var user;return user=this.getUser(),user.token},LocalStorageUtils.prototype.getUserAvatar=function(){var user;return user=this.getUser(),user.avatar},LocalStorageUtils.prototype.getUserEmail=function(){var user;return user=this.getUser(),user.email},LocalStorageUtils.prototype.isUserLogedIn=function(){var user;return user=this.getUser(),null!==user&&null!==this.getUserEmail()&&null!==this.getUserToken()},LocalStorageUtils.prototype.storeDoubanUser=function(name){return localStorage.setItem("doubanUser",name)},LocalStorageUtils.prototype.getDoubanUser=function(){var user;return user=this.getUser(),null!==user.douban_user?user.douban_user:null!==localStorage.getItem("doubanUser")?localStorage.getItem("doubanUser"):null},LocalStorageUtils}(),libr.service("LocalStorageUtils",LocalStorageUtils)}).call(this); +(function(){var ErrorHandler,libr;libr=angular.module("libr.handlers.errorHandler",[]),ErrorHandler=function(){function ErrorHandler(){}return ErrorHandler.prototype.loadingHandler=function($scope,callback){var message;return $scope.loading.hide(),message="加载失败,请确认有良好网络连接,并重试",navigator.notification.confirm(message,function(){return function(){return callback()}}(this),"加载失败",["确定","取消"])},ErrorHandler.prototype.whenError=function(callback){var message;return message="加载失败,请确认有良好网络连接,并重试",navigator.notification.confirm(message,function(){return function(){return callback()}}(this),"加载失败",["确定","取消"])},ErrorHandler}(),libr.service("ErrorHandler",ErrorHandler)}).call(this); +(function(){var AuthicationService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.auth",[]),AuthicationService=function(){function AuthicationService($http,Constant){this.$http=$http,this.Constant=Constant,this.register=__bind(this.register,this),this.login=__bind(this.login,this),console.log("init auth service")}return AuthicationService.$inject=["$http","Constant"],AuthicationService.prototype.login=function(user,callback,errorCallback){var baseUrl;return baseUrl=this.Constant.baseUrl+"/sessions",this.$http({method:"POST",url:baseUrl,data:"user[email]="+user.email+"&user[password]="+user.password,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(result){return result.success?callback(result):errorCallback("登录失败,请输入正确的用户名和密码")}).error(function(){return errorCallback("登录失败,请输入正确的用户名和密码")})},AuthicationService.prototype.register=function(user,callback,onError){var url;return url=this.Constant.baseUrl+"/registrations",this.$http({method:"POST",url:url,data:"user[email]="+user.email+"&user[password]="+user.password,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(result,status){return callback(result,status)}).error(function(data){return onError(data)})},AuthicationService}(),libr.service("AuthService",AuthicationService)}).call(this); +(function(){var Books,libr;libr=angular.module("libr.services.books",["ngResource"]),Books=function(){function Books($resource,Constant,LocalStorageUtils){var url;return this.$resource=$resource,this.Constant=Constant,this.LocalStorageUtils=LocalStorageUtils,url=this.Constant.baseUrl+"/users/:user_id/books/:book_id",this.$resource(url,{user_email:this.LocalStorageUtils.getUserEmail(),user_token:this.LocalStorageUtils.getUserToken(),user_id:this.LocalStorageUtils.getUserId(),book_id:"@bookId"},{get:{cache:!0,method:"GET"},query:{method:"GET",isArray:!1,cache:!1},fetchNew:{method:"GET",isArray:!1,cache:!0,url:this.Constant.baseUrl+"/books/newbooks/:afterId"}})}return Books.$inject=["$http","$resource","Constant","LocalStorageUtils"],Books}(),libr.factory("Books",["$resource","Constant","LocalStorageUtils",Books])}).call(this); +(function(){var CommentService,libr;libr=angular.module("libr.services.comment",["ngResource"]),CommentService=function(){function CommentService($resource,Constant){var baseUrl;return this.$resource=$resource,this.Constant=Constant,baseUrl=this.Constant.baseUrl+"/books/:book_id/comments/:comment_id",this.$resource(baseUrl,{user_email:localStorage.getItem("email"),user_token:localStorage.getItem("token"),book_id:"@bookId",comment_id:"@commentId"},{query:{method:"GET",isArray:!0,cache:!1}},{save:{params:{comment_id:"@commentId"}}})}return CommentService.$inject=["$http","$resource","Constant"],CommentService}(),libr.factory("Comments",["$resource","Constant",CommentService])}).call(this); +(function(){var DoubanService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.douban",[]),DoubanService=function(){function DoubanService($http,Constant,LocalStorageUtils){this.$http=$http,this.Constant=Constant,this.LocalStorageUtils=LocalStorageUtils,this.submitUser=__bind(this.submitUser,this)}return DoubanService.$inject=["$http","Constant","LocalStorageUtils"],DoubanService.prototype.userInfo=function(user,callback,error){return this.$http({url:"http://api.douban.com/v2/user/"+user,method:"GET",timeout:1e4,cache:!0}).success(function(data,status){return 200===status?callback(data):error(data)}).error(function(data){return error(data)})},DoubanService.prototype.bookDetail=function(isbn,callback,error){return this.$http({url:"https://api.douban.com/v2/book/isbn/"+isbn,method:"GET",timeout:1e4,cache:!0}).success(function(data,status){return 200===status?callback(data):error(data)}).error(function(data){return error(data)})},DoubanService.prototype.submitUser=function(user,callback,error){var email,token,userId;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),userId=this.LocalStorageUtils.getUserId(),this.$http({url:""+this.Constant.baseUrl+"/users/"+userId+"/link/douban/"+user+"?user_email="+email+"&user_token="+token,method:"POST",timeout:1e4}).success(function(data){return callback(data)}).error(function(data){return error(data)})},DoubanService}(),libr.service("DoubanService",DoubanService)}).call(this); +(function(){var GeolocationService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.geolocation",[]),GeolocationService=function(){function GeolocationService($http,Constant){this.$http=$http,this.Constant=Constant,this.getDetailAddress=__bind(this.getDetailAddress,this)}var getLocation,onError,onSuccess;return GeolocationService.$inject=["$http","Constant"],onSuccess=function(position){return alert("lat"+position.coords.latitude),{Latitude:position.coords.latitude,Longitude:position.coords.longitude,Altitude:position.coords.altitude,Accuracy:position.coords.accuracy,"Altitude Accuracy":position.coords.altitudeAccuracy,Heading:position.coords.heading,Speed:position.coords.speed,Timestamp:position.timestamp}},onError=function(error){throw"code: "+error.code+" \n message: "+error.message},GeolocationService.prototype.getCurrentLocation=function(callback,error){return navigator.geolocation.getCurrentPosition(callback,error)},GeolocationService.prototype.getDetailAddress=function(callback){var baseUrl;return baseUrl=this.Constant.baseUrl+"/locations/detail",this.getCurrentLocation(function(_this){return function(position){return _this.$http({url:""+baseUrl+"?lat="+position.coords.latitude+"&lng="+position.coords.longitude,cache:!0,method:"GET"}).success(function(data){return callback(data)})}}(this),function(error){throw Error(error)})},GeolocationService.prototype.getLocations=function(callback,error){var baseUrl,email,token;return baseUrl=this.Constant.baseUrl+"/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:""+baseUrl+"?user_email="+email+"&user_token="+token,method:"GET",cache:!1}).success(function(data){return callback(data)}).error(function(){throw Error(error)})},GeolocationService.prototype.createLocation=function(callback){var baseUrl,email,location,token;return baseUrl=this.Constant.baseUrl+"/locations",location=getLocation(),email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"POST",url:baseUrl+("?user_email="+email+"&user_token="+token),data:"address="+location.address+"&lat="+location.lat+"&lng="+location.lng,headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return callback(data)})},GeolocationService.prototype.deleteLocation=function(item,callback){var baseUrl,email,token;return baseUrl=this.Constant.baseUrl+"/locations",email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({method:"DELETE",url:baseUrl+("?user_email="+email+"&user_token="+token+"&id="+item.id),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(data){return console.log("=====",data),callback(data)})},getLocation=function(){var location;return location={},location.address=localStorage.getItem("cur_address_detail"),location.lat=localStorage.getItem("cur_lat"),location.lng=localStorage.getItem("cur_lng"),location},GeolocationService}(),libr.service("GeolocationService",GeolocationService)}).call(this); +(function(){var RecommendService,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.services.recommend",[]),RecommendService=function(){function RecommendService(GeolocationService,$http,Constant){this.GeolocationService=GeolocationService,this.$http=$http,this.Constant=Constant,this.changeRecommendAction=__bind(this.changeRecommendAction,this),this.popularBooksAroundMe=__bind(this.popularBooksAroundMe,this)}return RecommendService.$injector=["GeolocationService","$http","Constant"],RecommendService.prototype.getActionSheetList=function(){var actionList;return actionList=[],actionList.push({text:"随便看看吧"}),actionList.push({text:"你可能喜欢的书"}),this.GeolocationService.getLocations(function(){return function(locations){var locationIds;return locationIds=[],locations.map(function(location){return locationIds.push(location.id),location={text:""+location.address+"附近流行的书"},actionList.push(location)}),localStorage.setItem("recommend_action_sheet_arr",JSON.stringify(locationIds)),localStorage.setItem("recommend_action_sheet_full_arr",JSON.stringify(actionList))}}(this)),actionList},RecommendService.prototype.popularBooksForMe=function(callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:this.Constant.baseUrl+("/recommend/me?user_email="+email+"&user_token="+token),method:"GET",timeout:15e3}).success(function(data){return callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.randomBooks=function(callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:this.Constant.baseUrl+("/recommend/random?user_email="+email+"&user_token="+token),method:"GET",timeout:15e3,cache:!1}).success(function(data){return callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.popularBooksAroundMe=function(locationId,callback,error){var email,token;return email=localStorage.getItem("email"),token=localStorage.getItem("token"),this.$http({url:this.Constant.baseUrl+("/recommend/locations/"+locationId+"?user_email="+email+"&user_token="+token),method:"GET",timeout:15e3,cache:!0}).success(function(data){return console.log("数据",data),callback(data)}).error(function(data){return error(data)})},RecommendService.prototype.changeRecommendAction=function(index,callback,error){var locations;return console.log("index====",index),0===index?this.randomBooks(callback,error):1===index?this.popularBooksForMe(callback,error):(locations=JSON.parse(localStorage.getItem("recommend_action_sheet_arr")),console.log(locations[index-2],"index......"),this.popularBooksAroundMe(locations[index-2],function(result){return console.log("callback....",result),callback(result)},function(errorMessage){return error(errorMessage)}))},RecommendService}(),libr.service("RecommendService",RecommendService)}).call(this); +(function(){var ScanService,libr;libr=angular.module("libr.services.scan",[]),ScanService=function(){function ScanService(Books){this.Books=Books}return ScanService.$inject=["Books"],ScanService.prototype.scan=function(callback,errorCallback){return navigator.notification.vibrate(50),cordova.plugins.barcodeScanner.scan(function(_this){return function(result){return console.log("got scan result",result),1!==result.cancelled?"EAN_13"!==result.format?(console.log("条码不匹配"),void errorCallback("条形码类型错误,请确认所扫为书籍,并更换角度")):_this.Books.save({isbn:result.text},null,function(data){return console.log("get server response"),"error"===data.status?errorCallback(data.message):callback(data)},function(error){return errorCallback("添加图书失败"+error.data.message)}):void 0}}(this),function(error){return errorCallback("扫描图书失败:"+error+" ")})},ScanService}(),libr.service("ScanService",ScanService)}).call(this); +(function(){var BooksController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.books",["ionic"]),BooksController=function(){function BooksController($scope,Books,ScanService,$ionicModal,DoubanService,IonicUtils,LocalStorageUtils){var currentPage;this.$scope=$scope,this.Books=Books,this.ScanService=ScanService,this.$ionicModal=$ionicModal,this.DoubanService=DoubanService,this.IonicUtils=IonicUtils,this.LocalStorageUtils=LocalStorageUtils,this.submitDoubanUser=__bind(this.submitDoubanUser,this),this.scanBooks=__bind(this.scanBooks,this),this.searchDoubanUser=__bind(this.searchDoubanUser,this),this.closeDialog=__bind(this.closeDialog,this),this.loadMore=__bind(this.loadMore,this),this.refresh=__bind(this.refresh,this),currentPage=localStorage.setItem("user_books_current_page",0),this.$scope.books=[],this.$scope.moreItemsAvailable=!0,this.$scope.submitAllowed=!1,this.$ionicModal.fromTemplateUrl("templates/modal/import_books.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.$scope.data={isLoading:!1,text:null},this.IonicUtils.initCustomLoading(this.$scope),this.$scope.onRefresh=this.refresh,this.$scope.loadMore=this.loadMore,this.$scope.closeDialog=this.closeDialog,this.$scope.searchDoubanUser=this.searchDoubanUser,this.$scope.scanBooks=this.scanBooks,this.$scope.submitDoubanUser=this.submitDoubanUser,this.$scope.doubanInputDisabled=null!==this.LocalStorageUtils.getDoubanUser(),this.$scope.doubanUsername=this.LocalStorageUtils.getDoubanUser()}return BooksController.$inject=["$scope","Books","ScanService","$ionicModal","DoubanService","IonicUtils","LocalStorageUtils"],BooksController.prototype.refresh=function(){var afterBookId;return afterBookId=localStorage.getItem("user_max_book_id"),this.Books.fetchNew({afterId:afterBookId},function(_this){return function(data){return _this.$scope.$broadcast("scroll.refreshComplete"),0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),data.books.forEach(function(item){return _this.$scope.books.push(item)})):void 0}}(this))},BooksController.prototype.loadMore=function(){var currentPage,maxPage;return currentPage=localStorage.getItem("user_books_current_page"),maxPage=localStorage.getItem("user_books_max_page"),maxPage=parseInt(maxPage),currentPage=parseInt(currentPage),currentPage>=maxPage?(this.$scope.$broadcast("scroll.infiniteScrollComplete"),this.$scope.moreItemsAvailable=!1):this.Books.query({page:currentPage+1},function(_this){return function(data){return 0!==data.books.length?(localStorage.setItem("user_max_book_id",data.books[0].id),localStorage.setItem("user_books_current_page",data.current_page),localStorage.setItem("user_books_max_page",data.total_page),data.books.forEach(function(item){return _this.$scope.books.push(item)})):_this.$scope.moreItemsAvailable=!1,_this.$scope.$broadcast("scroll.infiniteScrollComplete")}}(this))},BooksController.prototype.closeDialog=function(){return this.$scope.modal.hide()},BooksController.prototype.searchDoubanUser=function(user){return console.log(user,"..."),void 0===user||""===user.trim()?this.IonicUtils.showLoading(this.$scope,"请输入有效昵称"):this.DoubanService.userInfo(user,function(_this){return function(data){return _this.$scope.resultEnabled=!0,_this.$scope.submitAllowed=!0,_this.$scope.doubanUser=data}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,"查找豆瓣用户失败,请稍后再试"),console.log(error),_this.$scope.resultEnabled=!1,_this.$scope.submitAllowed=!1}}(this))},BooksController.prototype.scanBooks=function(){return this.ScanService.scan(function(_this){return function(result){return navigator.notification.alert("添加图书《"+result.book.name+"》成功",null,"Libr","确定"),_this.$scope.books.unshift(result.book)}}(this),function(_this){return function(msg){return console.log("trying to show loading...",msg),_this.IonicUtils.showLoading(_this.$scope,msg),_this.$scope.$apply(),console.log("applied")}}(this))},BooksController.prototype.submitDoubanUser=function(){var username;return username=angular.element(document.getElementById("douban-username")),username=username.val(),this.DoubanService.submitUser(username,function(_this){return function(){return _this.$scope.doubanInputDisabled=!0,_this.LocalStorageUtils.storeDoubanUser(username),alert("成功绑定豆瓣用户,请返回,系统将自动为你导入豆瓣图书")}}(this),function(_this){return function(){return _this.IonicUtils.showLoading(_this.$scope,"绑定豆瓣用户失败,请稍后再试")}}(this))},BooksController}(),libr.controller("BooksController",BooksController)}).call(this); +(function(){var BookDetailController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers",["ionic"]),BookDetailController=function(){function BookDetailController($scope,$stateParams,Books,$window,$ionicModal,Comments,DoubanService){this.$scope=$scope,this.$stateParams=$stateParams,this.Books=Books,this.$window=$window,this.$ionicModal=$ionicModal,this.Comments=Comments,this.DoubanService=DoubanService,this.back=__bind(this.back,this),this.doComment=__bind(this.doComment,this),this.closeCommentDialog=__bind(this.closeCommentDialog,this),this.openCommentDialog=__bind(this.openCommentDialog,this),this.$scope.openDialog=this.openCommentDialog,this.$scope.closeDialog=this.closeCommentDialog,this.$scope.doComment=this.doComment,this.$scope.back=this.back,this.$ionicModal.fromTemplateUrl("templates/modal/comment.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.Books.get({book_id:this.$stateParams.isbn},function(_this){return function(result){return _this.$scope.book=result,_this.$scope.usersAccount=result.users.length,_this.$scope.bookName=_this.$scope.book.name,_this.Comments.query({book_id:result.id},function(data){return console.log(data,"!!!!!"),_this.$scope.comments=data}),_this.DoubanService.bookDetail(result.isbn,function(data){return console.log(data),_this.$scope.bookDetail=data},function(error){return console.log("error",error)})}}(this)),this.$scope.$on("$destroy",function(_this){return function(){return _this.$scope.modal.remove()}}(this))}return BookDetailController.$inject=["$scope","$stateParams","Books","$window","$ionicModal","Comments","DoubanService"],BookDetailController.prototype.openCommentDialog=function(){return this.$scope.modal.show()},BookDetailController.prototype.closeCommentDialog=function(){return this.$scope.modal.hide()},BookDetailController.prototype.doComment=function(){var text;return text=angular.element(document.getElementById("comment")).val(),""===text.trim()?(alert("请输入有效字符"),!1):this.Comments.save({book_id:this.$scope.book.id,content:text},null,function(_this){return function(data){return null===data.id?alert("添加图书失败"):(console.log("成功。。。。。。。"),_this.$scope.comments.push(data),_this.closeCommentDialog())}}(this))},BookDetailController.prototype.back=function(){return this.$window.history.back()},BookDetailController}(),libr.controller("BookDetailController",BookDetailController)}).call(this); +(function(){var HomeController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.home",["ionic"]),HomeController=function(){function HomeController($scope,$location,ScanService,$ionicLoading,$ionicActionSheet,RecommendService,ErrorHandler,LocalStorageUtils){return this.$scope=$scope,this.$location=$location,this.$ionicLoading=$ionicLoading,this.$ionicActionSheet=$ionicActionSheet,this.RecommendService=RecommendService,this.ErrorHandler=ErrorHandler,this.LocalStorageUtils=LocalStorageUtils,this.changeRecommend=__bind(this.changeRecommend,this),this.showRecommendActionSheet=__bind(this.showRecommendActionSheet,this),console.log(this.$scope,"!!!!!!!"),this.$scope.showRecommendActionSheet=this.showRecommendActionSheet,this.LocalStorageUtils.isUserLogedIn()?(showLoading(this.$scope,this.$ionicLoading),this.$scope.title={name:"Libr-随便看看吧"},null===localStorage.getItem("home.books")?this.RecommendService.randomBooks(function(_this){return function(result){return _this.$scope.books=result,localStorage.setItem("home.books",JSON.stringify(result)),_this.$ionicLoading.hide()}}(this),function(_this){return function(){return _this.ErrorHandler.loadingHandler(_this.$scope,null)}}(this)):(this.$scope.books=JSON.parse(localStorage.getItem("home.books")),this.$ionicLoading.hide()),void(this.$scope.changeRecommend=this.changeRecommend)):void this.$location.path("/tab/settings")}var showLoading;return HomeController.$inject=["$scope","$location","ScanService","$ionicLoading","$ionicActionSheet","RecommendService","ErrorHandler","LocalStorageUtils"],showLoading=function($scope,$ionicLoading){return $scope.loading=$ionicLoading.show({content:"加载中",animation:"fade-in",showBackdrop:!0,maxWidth:200,showDelay:500})},HomeController.prototype.showRecommendActionSheet=function(){return this.$ionicActionSheet.show({titleText:"Libr 为你推荐",buttons:this.RecommendService.getActionSheetList(),cancelText:"取消",cancel:function(){return console.log("CANCELLED")},buttonClicked:function(_this){return function(index){return console.log(""+index+" has been taped"),_this.changeRecommend(index),!0}}(this)})},HomeController.prototype.changeRecommend=function(index){var msg;return msg="喔,看来附近还没有好书推荐,快去推荐你的朋友也来使用吧!",this.RecommendService.changeRecommendAction(index,function(_this){return function(result){var listArray;return 0===result.length?navigator.notification.alert(msg,null,"libr","确定"):(_this.$scope.books=result,localStorage.setItem("home.books",JSON.stringify(result)),listArray=JSON.parse(localStorage.getItem("recommend_action_sheet_full_arr")),_this.$scope.title.name=listArray[index].text,console.log(_this.$scope,"========"))}}(this),function(_this){return function(){return _this.ErrorHandler.whenError(null)}}(this))},HomeController}(),libr.controller("HomeCtrl",HomeController)}).call(this); +(function(){var LocationController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.location",["ionic"]),LocationController=function(){function LocationController($scope,$location,GeolocationService,IonicUtils){this.$scope=$scope,this.$location=$location,this.GeolocationService=GeolocationService,this.IonicUtils=IonicUtils,this.deleteItem=__bind(this.deleteItem,this),this.addLocation=__bind(this.addLocation,this),this.$scope.addLocation=this.addLocation,this.$scope.itemButtons=[{text:"删除",type:"button-assertive",onTap:function(_this){return function(item){return _this.GeolocationService.deleteLocation(item,function(){return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item),1)})}}(this)}],this.GeolocationService.getLocations(function(_this){return function(locations){return _this.$scope.locations=locations}}(this)),this.GeolocationService.getDetailAddress(function(_this){return function(position){return localStorage.setItem("cur_address_detail",position.result.formatted_address),localStorage.setItem("cur_lat",position.result.location.lat),localStorage.setItem("cur_lng",position.result.location.lng),_this.$scope.address=position.result.formatted_address}}(this)),this.IonicUtils.initCustomLoading(this.$scope),this.$scope.deleteItem=this.deleteItem}return LocationController.$inject=["$scope","$location","GeolocationService","IonicUtils"],LocationController.prototype.addLocation=function(){return this.$scope.locations.length>=3?this.IonicUtils.showLoading(this.$scope,"只能创建3个常用的地址,请先删除部分再添加"):null===localStorage.getItem("cur_address_detail")||void 0===localStorage.getItem("cur_address_detail")?this.IonicUtils.showLoading(this.$scope,"定位成功后方可添加常用地址"):null===this.$scope.address||""===this.$scope.address?this.IonicUtils.showLoading(this.$scope,"定位成功后方可添加常用地址"):this.GeolocationService.createLocation(function(_this){return function(result){return _this.$scope.locations.push(result)}}(this))},LocationController.prototype.deleteItem=function(item){return this.GeolocationService.deleteLocation(item,function(_this){return function(){return _this.$scope.locations.splice(_this.$scope.locations.indexOf(item),1)}}(this))},LocationController}(),libr.controller("LocationController",LocationController)}).call(this); +(function(){var LoginController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.login",["ionic"]),LoginController=function(){function LoginController($scope,AuthService,$state,$ionicModal,IonicUtils,LocalStorageUtils){this.$scope=$scope,this.AuthService=AuthService,this.$state=$state,this.$ionicModal=$ionicModal,this.IonicUtils=IonicUtils,this.LocalStorageUtils=LocalStorageUtils,this.closeDialog=__bind(this.closeDialog,this),this.registerUser=__bind(this.registerUser,this),this.registerForm=__bind(this.registerForm,this),this.login=__bind(this.login,this),this.LocalStorageUtils.isUserLogedIn()&&this.$state.go("tab.home"),this.$scope.login=this.login,this.$scope.registerForm=this.registerForm,this.$scope.registerUser=this.registerUser,this.$scope.closeDialog=this.closeDialog,this.$ionicModal.fromTemplateUrl("templates/modal/registration.html",function(_this){return function(modal){return _this.$scope.modal=modal}}(this),{scope:this.$scope,animation:"slide-in-up"}),this.IonicUtils.initCustomLoading(this.$scope)}return LoginController.$inject=["$scope","AuthService","$state","$ionicModal","IonicUtils","LocalStorageUtils"],LoginController.prototype.login=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.login(user,function(_this){return function(result){return localStorage.setItem("token",result.user.token),localStorage.setItem("avatar",result.user.avatar),localStorage.setItem("username",result.user.name),localStorage.setItem("email",user.email),localStorage.setItem("user",JSON.stringify(result.user)),_this.$state.go("tab.home")}}(this),function(_this){return function(data){return _this.IonicUtils.showLoading(_this.$scope,data)}}(this)):void this.IonicUtils.showLoading(this.$scope,"请输入有效的用户名和密码")},LoginController.prototype.registerForm=function(){return this.$scope.modal.show()},LoginController.prototype.registerUser=function(user){return user&&""!==user.email&&""!==user.password&&void 0!==user.email&&void 0!==user.password?this.AuthService.register(user,function(_this){return function(result,status){return 201===status?(alert("注册成功,请返回登录"),_this.$scope.modal.hide()):_this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试")}}(this),function(_this){return function(error){return _this.IonicUtils.showLoading(_this.$scope,"注册失败,请确认是否输入正确,并重试"),console.log("registerError",error)}}(this)):void this.IonicUtils.showLoading(this.$scope,"用户名或密码错误,请重试")},LoginController.prototype.closeDialog=function(){return this.$scope.modal.hide()},LoginController}(),libr.controller("LoginController",LoginController)}).call(this); +(function(){var MainController,libr;libr=angular.module("libr.controllers.main",["ionic"]),MainController=function(){function MainController($scope,$location,$ionicModal,$state){this.$scope=$scope,this.$location=$location,this.$ionicModal=$ionicModal,this.$state=$state}return MainController.$inject=["$scope","$location","$ionicModal","$state"],MainController}(),libr.controller("MainCtrl",MainController)}).call(this); +(function(){var SettingsController,libr,__bind=function(fn,me){return function(){return fn.apply(me,arguments)}};libr=angular.module("libr.controllers.settings",["ionic"]),SettingsController=function(){function SettingsController($scope,$ionicModal,AuthService,$state,$cacheFactory,LocalStorageUtils){this.$scope=$scope,this.$ionicModal=$ionicModal,this.AuthService=AuthService,this.$state=$state,this.$cacheFactory=$cacheFactory,this.LocalStorageUtils=LocalStorageUtils,this.logout=__bind(this.logout,this),this.$scope.logout=this.logout,this.$scope.feedback=this.feedback,this.$scope.showMe=this.showMe,this.$scope.isLogedIn=isUserLogedIn(this.LocalStorageUtils)?!0:!1,this.$scope.avatar=this.LocalStorageUtils.getUserAvatar(),this.$scope.username=this.LocalStorageUtils.getUserName()}var isUserLogedIn;return SettingsController.$inject=["$scope","$ionicModal","AuthService","$state","$cacheFactory","LocalStorageUtils"],SettingsController.prototype.logout=function(){var httpDefaultCache;return localStorage.clear(),httpDefaultCache=this.$cacheFactory.get("$http"),console.log("cacheFactory",httpDefaultCache),httpDefaultCache.removeAll(),this.$state.go("login")},SettingsController.prototype.feedback=function(){return window.open("https://jinshuju.net/f/F96z3s","_blank","location=no")},SettingsController.prototype.showMe=function(){return window.open("http://librme.com","_blank","location=no")},isUserLogedIn=function(localStorageUtils){return null!==localStorageUtils.getUserToken()&&null!==localStorageUtils.getUserEmail()?!0:!1},SettingsController}(),libr.controller("SettingsController",SettingsController)}).call(this); +(function(){var Constant,libr;libr=angular.module("libr.constant",[]),Constant={},Constant.baseUrl="http://librme.com/api/v1",libr.constant("Constant",Constant)}).call(this); \ No newline at end of file diff --git a/platforms/ios/www/js/app/controllers/home-controller.coffee b/platforms/ios/www/js/app/controllers/home-controller.coffee index 091b833..6e883d4 100644 --- a/platforms/ios/www/js/app/controllers/home-controller.coffee +++ b/platforms/ios/www/js/app/controllers/home-controller.coffee @@ -4,10 +4,11 @@ class HomeController @$inject: ['$scope', '$location', 'ScanService', '$ionicLoading', '$ionicActionSheet', 'RecommendService', 'ErrorHandler', 'LocalStorageUtils'] constructor: (@$scope, @$location, ScanService, @$ionicLoading, @$ionicActionSheet, @RecommendService, @ErrorHandler, @LocalStorageUtils)-> + console.log @$scope, '!!!!!!!' @$scope.showRecommendActionSheet = @showRecommendActionSheet if @LocalStorageUtils.isUserLogedIn() showLoading(@$scope, @$ionicLoading) - @$scope.title = '随便看看吧' + @$scope.title = {'name': 'Libr-随便看看吧'} if localStorage.getItem('home.books') is null @RecommendService.randomBooks (result)=> @$scope.books = result @@ -55,7 +56,9 @@ class HomeController @$scope.books = result localStorage.setItem 'home.books', JSON.stringify(result) listArray = JSON.parse(localStorage.getItem 'recommend_action_sheet_full_arr') - @$scope.title = listArray[index].text + @$scope.title.name = listArray[index].text + + console.log @$scope, '========' , (error)=> @ErrorHandler.whenError null libr.controller 'HomeCtrl', HomeController diff --git a/platforms/ios/www/templates/libr-index.html b/platforms/ios/www/templates/libr-index.html index 3798baf..0caec4d 100644 --- a/platforms/ios/www/templates/libr-index.html +++ b/platforms/ios/www/templates/libr-index.html @@ -1,6 +1,7 @@ - + - diff --git a/www/js/app/controllers/home-controller.coffee b/www/js/app/controllers/home-controller.coffee index 091b833..6e883d4 100644 --- a/www/js/app/controllers/home-controller.coffee +++ b/www/js/app/controllers/home-controller.coffee @@ -4,10 +4,11 @@ class HomeController @$inject: ['$scope', '$location', 'ScanService', '$ionicLoading', '$ionicActionSheet', 'RecommendService', 'ErrorHandler', 'LocalStorageUtils'] constructor: (@$scope, @$location, ScanService, @$ionicLoading, @$ionicActionSheet, @RecommendService, @ErrorHandler, @LocalStorageUtils)-> + console.log @$scope, '!!!!!!!' @$scope.showRecommendActionSheet = @showRecommendActionSheet if @LocalStorageUtils.isUserLogedIn() showLoading(@$scope, @$ionicLoading) - @$scope.title = '随便看看吧' + @$scope.title = {'name': 'Libr-随便看看吧'} if localStorage.getItem('home.books') is null @RecommendService.randomBooks (result)=> @$scope.books = result @@ -55,7 +56,9 @@ class HomeController @$scope.books = result localStorage.setItem 'home.books', JSON.stringify(result) listArray = JSON.parse(localStorage.getItem 'recommend_action_sheet_full_arr') - @$scope.title = listArray[index].text + @$scope.title.name = listArray[index].text + + console.log @$scope, '========' , (error)=> @ErrorHandler.whenError null libr.controller 'HomeCtrl', HomeController diff --git a/www/templates/libr-index.html b/www/templates/libr-index.html index 3798baf..0caec4d 100644 --- a/www/templates/libr-index.html +++ b/www/templates/libr-index.html @@ -1,6 +1,7 @@ - + -