add.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (function (app) {
  2. app.controller('addCtrl', ["$scope", "$state", "storage", "myService", "msg", "$ionicTabsDelegate", "$ionicNavBarDelegate", "$ionicModal", "$ionicHistory", "common"
  3. , function ($scope, $state, storage, myService, msg, $ionicTabsDelegate, $ionicNavBarDelegate, $ionicModal, $ionicHistory, common) {
  4. $ionicModal.fromTemplateUrl('my-modal.html', {
  5. scope: $scope,
  6. animation: 'slide-in-up'
  7. }).then(function (modal) {
  8. $scope.modal = modal;
  9. });
  10. $scope.openModal = function () {
  11. $scope.modal.show();
  12. };
  13. $scope.closeModal = function () {
  14. $scope.modal.hide();
  15. };
  16. $scope.vm={
  17. dream:'',
  18. about:'',
  19. money:""
  20. };
  21. $scope.imgs = [];
  22. $scope.videos = [];
  23. $scope.addpict = function () {
  24. common.chooseImage().then(function (img) {
  25. common.uploadFiles(img,1).then(function (result) {
  26. var response = JSON.parse(result.response);
  27. var file = response.data.file;
  28. $scope.imgs.push(file);
  29. }, function (erro) {
  30. msg.erro('图片上传失败');
  31. });
  32. }, function (erro) {
  33. msg.erro('图片选择失败');
  34. });
  35. }
  36. $scope.addvideo = function () {
  37. var options = { limit: 1, duration:20};
  38. navigator.device.capture.captureVideo(function (videos) {
  39. $scope.videos.push(videos[0].fullPath);
  40. common.uploadFiles(videos[0].fullPath, 2).then(function (result) {
  41. debugger;
  42. var response = JSON.parse(result.response);
  43. var file = response.data.file;
  44. debugger;
  45. }, function (erro) {
  46. debugger;
  47. msg.erro('视频上传失败');
  48. });
  49. }, function (erro) {
  50. debugger;
  51. }, options);
  52. }
  53. $scope.add=function ()
  54. {
  55. var data={
  56. pic:'http://img.taopic.com/uploads/allimg/130103/240435-1301030P33161.jpg',
  57. dream:$scope.vm.dream,
  58. about:$scope.vm.about,
  59. money:$scope.vm.money
  60. };
  61. myService.add(data).then(function(result){
  62. },function(erro){
  63. });
  64. }
  65. $scope.$on('$ionicView.beforeEnter', function (viewResult) {
  66. $ionicTabsDelegate.showBar(false);
  67. $ionicNavBarDelegate.showBackButton(true);
  68. });
  69. $scope.$on('$ionicView.leave', function () {
  70. $ionicTabsDelegate.showBar(true);
  71. });
  72. }]);
  73. })(angular.module('app.controllers'));