technicalBrokerAddMainSponsorCtrl.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. angular.module('push')
  2. .controller('technicalBrokerAddMainSponsorCtrl', function ($scope,AccountService,$ionicActionSheet,UtilService) {
  3. // 编辑头像
  4. $scope.show_header = function () {
  5. // 弹出头像选择框
  6. $ionicActionSheet.show({
  7. cancelOnStateChange: true,
  8. cssClass: 'action_s',
  9. cancelText: '取消',
  10. buttons: [
  11. {text: "拍照"},
  12. {text: "从相册上传"}
  13. ],
  14. buttonClicked: function (index) {
  15. if (index == 0) {
  16. openCamera(1);
  17. } else {
  18. openCamera(0);
  19. }
  20. return true;
  21. },
  22. destructiveButtonClicked: function () {
  23. return true;
  24. }
  25. });
  26. };
  27. var openCamera = function (srcType) {
  28. var options = {
  29. // Some common settings are 20, 50, and 100
  30. quality: 50,
  31. destinationType: Camera.DestinationType.FILE_URI,
  32. // In this app, dynamically set the picture source, Camera or photo gallery
  33. sourceType: srcType,
  34. encodingType: Camera.EncodingType.JPEG,
  35. mediaType: Camera.MediaType.PICTURE,
  36. allowEdit: false,
  37. correctOrientation: true //Corrects Android orientation quirks
  38. };
  39. navigator.camera.getPicture(function (imageData) {
  40. $scope.imgurl = imageData;
  41. $scope.showLoadingToast();
  42. UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
  43. AccountService.setuserName(response[0].userPhoto, 3).then(function (res) {
  44. $scope.userInfo.photo = res.photo;
  45. UserService.user.user.photo = res.photo;
  46. }, function () {
  47. });
  48. $scope.hideLoadingToast();
  49. }, function () {
  50. $scope.hideLoadingToast();
  51. });
  52. }, function (message) {
  53. }, options);
  54. };
  55. });