my.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. (function (app) {
  2. app.controller('myCtrl', ["$scope", "$state", "$http", "storage", "myService", "common", "config", "msg"
  3. , function ($scope, $state, $http, storage, myService, common, config, msg) {
  4. $scope.$on('$ionicView.beforeEnter', function (viewResult) {
  5. });
  6. $scope.testuploadFile = function(files) { //单次提交图片的函数
  7. console.log(files[0]);
  8. var formData = new FormData();
  9. formData.append('file', files[0]);
  10. formData.append('tag', 'avatar');
  11. $http({
  12. method: 'POST',
  13. url: config.server + 'api/attachment/upload',
  14. transformRequest: angular.identity,
  15. data: formData,
  16. // headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }
  17. headers: {'Content-Type': undefined}
  18. }).then(function (result) {
  19. // alert(JSON.stringify(result));
  20. console.log("attachment upload result:"+JSON.stringify(result));
  21. }, function (erro) {
  22. console.log("attachment upload erro:"+JSON.stringify(erro));
  23. })
  24. }
  25. $scope.setAvator = function () {
  26. common.setAvator().then(function (result) {
  27. var response = JSON.parse(result.response);
  28. $timeout(function () {
  29. $scope.vm.user.avatar = response.data.md5;
  30. });
  31. }, function (erro) {
  32. msg.erro(JSON.stringify(erro));
  33. });
  34. };
  35. $scope.toprofile = function () {
  36. $state.go('app.my_profile');
  37. }
  38. }]);
  39. app.controller('profileCtrl', ["$scope", "$state", "storage", "myService", "msg"
  40. , function ($scope, $state, storage, myService, msg) {
  41. $scope.$on('$ionicView.beforeEnter', function () {
  42. });
  43. }]);
  44. app.controller('settingCtrl', ["$scope", "$state", "myService", "msg"
  45. , function ($scope, $state,myService, msg) {
  46. $scope.$on('$ionicView.beforeEnter', function () {
  47. });
  48. }]);
  49. app.controller('rechargeCtrl', ["$scope", "$state", "myService", "msg"
  50. , function ($scope, $state, myService, msg) {
  51. $scope.$on('$ionicView.beforeEnter', function () {
  52. });
  53. }]);
  54. app.controller('messageCtrl', ["$scope", "$state", "myService", "msg"
  55. , function ($scope, $state, myService, msg) {
  56. $scope.$on('$ionicView.beforeEnter', function () {
  57. });
  58. }]);
  59. app.controller('dreamCtrl', ["$scope", "$state", "myService", "msg"
  60. , function ($scope, $state, myService, msg) {
  61. $scope.$on('$ionicView.beforeEnter', function () {
  62. });
  63. }]);
  64. app.controller('collectCtrl', ["$scope", "$state", "myService", "msg"
  65. , function ($scope, $state, myService, msg) {
  66. $scope.$on('$ionicView.beforeEnter', function () {
  67. });
  68. }]);
  69. app.controller('messageSysCtrl', ["$scope", "$state", "myService", "msg"
  70. , function ($scope, $state, myService, msg) {
  71. $scope.$on('$ionicView.beforeEnter', function () {
  72. });
  73. }]);
  74. app.controller('messageReplyCtrl', ["$scope", "$state", "myService", "msg", "$ionicModal"
  75. , function ($scope, $state, myService, msg, $ionicModal) {
  76. $ionicModal.fromTemplateUrl('my-modal.html', {
  77. scope: $scope,
  78. animation: 'slide-in-up'
  79. }).then(function (modal) {
  80. $scope.modal = modal;
  81. });
  82. $scope.openModal = function () {
  83. $scope.modal.show();
  84. };
  85. $scope.closeModal = function () {
  86. $scope.modal.hide();
  87. };
  88. $scope.$on('$ionicView.beforeEnter', function () {
  89. });
  90. }]);
  91. })(angular.module('app.controllers'));