app.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * index
  3. *
  4. */
  5. define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'common/services', 'common/directives', 'angular-toaster', 'ngSanitize', 'common/query/Project'], function(angularAMD) {
  6. 'use strict';
  7. var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'common.services', 'common.directives', 'toaster', 'ProjectService']);
  8. app.init = function() {
  9. angularAMD.bootstrap(app);
  10. };
  11. app.config(['$httpProvider', function ($httpProvider) {
  12. // http拦截
  13. $httpProvider.interceptors.push('httpInterceptor');
  14. }]);
  15. app.factory('httpInterceptor', ['$window', '$q', '$injector', 'BaseService', function ($window, $q, $injector, BaseService) {
  16. var httpInterceptor = {
  17. 'responseError': function (response) {
  18. if (response.status == 401) {// UNAUTHORIZED
  19. window.location.href = response.data.loginUrl || 'index';
  20. return $q.reject(response);
  21. }
  22. return $q.reject(response);
  23. }
  24. }
  25. return httpInterceptor;
  26. }]);
  27. app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
  28. $urlRouterProvider.otherwise("/");
  29. $stateProvider.state("project", angularAMD.route({
  30. url : '/',
  31. title : '项目列表',
  32. templateUrl : 'static/view/project/project_list.html',
  33. controller : 'ProjectListCtrl',
  34. controllerUrl : 'app/controllers/ProjectListCtrl'
  35. })).state("detail", angularAMD.route({
  36. url : '/detail/:id',
  37. title : '项目详情',
  38. templateUrl : 'static/view/project/project_detail.html',
  39. controller : 'ProjectDetailCtrl',
  40. controllerUrl : 'app/controllers/ProjectDetailCtrl'
  41. })).state("organization", angularAMD.route({
  42. url : '/organization/:id',
  43. title : '机构介绍',
  44. templateUrl : 'static/view/project/organization_detail.html',
  45. controller : 'OrganizationDetailCtrl',
  46. controllerUrl : 'app/controllers/OrganizationDetailCtrl'
  47. })).state("paySucccess", {
  48. url : '/donationsOver/:tradeNo',
  49. title : '支付完成',
  50. templateUrl : 'static/view/project/donationsOver.html',
  51. controller : 'donationsOverCtrl'
  52. }).state("wxPayQrcode", {
  53. url : '/donateQrcode',
  54. title : '微信扫码',
  55. templateUrl : 'static/view/project/donateQrcode.html'
  56. // controller : 'donationsOverCtrl'
  57. });
  58. }]);
  59. // app.run(['$rootScope', 'BaseService', 'StoreInfo', function($rootScope, BaseService, StoreInfo) {
  60. // $rootScope.rootPath = BaseService.getRootPath();
  61. //
  62. // }]);
  63. // app.controller('hotNewsCtrl', ['$scope', 'News', function ($scope, News) {
  64. //
  65. // }]);
  66. app.controller('donationsOverCtrl', ['$scope', '$stateParams', '$http', function ($scope, $stateParams, $http) {
  67. var loadData = function () {
  68. var tradeNo = $stateParams.tradeNo;
  69. $http.get('/projectrecode/detail/' + tradeNo, {
  70. }).success(function (data) {
  71. $scope.projectRecode = data;
  72. }).error(function () {
  73. alert("查询支付结果出错");
  74. });
  75. };
  76. loadData();
  77. }]);
  78. return app;
  79. });