(function (app) {
    app.controller('myCtrl', ["$scope", function ($scope) {

    }]);
    app.controller('mySettingCtrl', ['$scope', 'data', '$state', function ($scope, data, $state) {
        $scope.logout = function () {
            data.remove('user');
            data.remove('token');
            $state.go('login');
        }
    }]);
    app.controller('mySetPasswordCtrl', ['$scope', '$state', function ($scope,$state) {
        $scope.vm = {
            password: '',
            password2: '',
            isloading: false,

        };
        $scope.submit = function () {

        }
    }]);
    
    app.controller('myProfileCtrl', ['$scope', 'userService', 'msg', 'util','data', function ($scope, userService, msg, util,data) {
        $scope.user = data.getObject('user');
        $scope.vm = {};
        $scope.genderOpt = [
              { name: "男", value: 1 },
              { name: "女", value: 0 }
        ];
        userService.getApplyProfile().then(function (result) {
            $scope.vm = result;
        }, function (erro) {
            msg.error(erro);
        });
        $scope.setAvator = function (type) {
            var wx = window.wx;
            wx.chooseImage({
                count: 1, // 默认9
                sizeType: ['compressed'], // ['original', 'compressed']可以指定是原图还是压缩图，默认二者都有
                sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                success: function (res) {
                    //var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                    if (res.localIds.length > 0) {
                        switch (type) {
                            case 1:  //证件照正面
                                $scope.vm.CardImgFront = res.localIds[0];
                                break;
                            case 2:   //证件照反面
                                $scope.vm.vm.CardImgBack = res.localIds[0];
                                break;  
                            case 3:  //自拍照
                                $scope.vm.vm.CardImgSelf = res.localIds[0];
                                break;
                            default:
                                break;
                        }
                    } else {
                        msg.text('未选中图片');
                    }
                }
            });
        }
         
        $scope.save = function () {

            msg.loading('保存中...')
            userService.saveApplyProfile($scope.vm).then(function (result) {
                msg.hide();
                $state.go('uf7.my_apply');
            }, function (erro) {
                msg.hide();
                msg.error(erro);
            });
        }
       
    }]);
    
    app.controller('myTruckCtrl', ['$scope', function ($scope) {

    }]);
    app.controller('myTruckAddCtrl', ['$scope', function ($scope) {

    }]);
    app.controller('myTruckDetailCtrl', ['$scope', function ($scope) {

    }]);
    
})(angular.module('app.controllers'));