angular.module('push') .controller('technicalBrokerAddMainSponsorCtrl', function ($scope,AccountService,$ionicActionSheet,UtilService) { // 编辑头像 $scope.show_header = function () { // 弹出头像选择框 $ionicActionSheet.show({ cancelOnStateChange: true, cssClass: 'action_s', cancelText: '取消', buttons: [ {text: "拍照"}, {text: "从相册上传"} ], buttonClicked: function (index) { if (index == 0) { openCamera(1); } else { openCamera(0); } return true; }, destructiveButtonClicked: function () { return true; } }); }; var openCamera = function (srcType) { var options = { // Some common settings are 20, 50, and 100 quality: 50, destinationType: Camera.DestinationType.FILE_URI, // In this app, dynamically set the picture source, Camera or photo gallery sourceType: srcType, encodingType: Camera.EncodingType.JPEG, mediaType: Camera.MediaType.PICTURE, allowEdit: false, correctOrientation: true //Corrects Android orientation quirks }; navigator.camera.getPicture(function (imageData) { $scope.imgurl = imageData; $scope.showLoadingToast(); UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) { AccountService.setuserName(response[0].userPhoto, 3).then(function (res) { $scope.userInfo.photo = res.photo; UserService.user.user.photo = res.photo; }, function () { }); $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); }); }, function (message) { }, options); }; });