(function (app) {
    app.factory('myService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
        return {
            //我的车辆信息
            listTrucks: function (model) {
                return $http({
                    url: config.server + 'api/user/trucks?page='+model.page,
                    method: "get"
                })
            },
            //添加车辆
            addTruck: function (model) {
                return $http({
                    url: config.server + 'api/trucks',
                    method: "post",
                    data: model
                })
            },
            updateTruck: function (model) {
                return $http({
                    url: config.server + 'api/trucks/'+model.id,
                    method: "post",
                    data: model
                })
            },
            deleteTruck:function (id) {
                return $http({
                    url: config.server + 'api/trucks/' + id,
                    method: "delete"
                })
            },
            listMessages: function () {
                return $http({
                    url: config.server + 'api/user/messages',
                    method: "get"
                })
            },
            updateMessage:function (model) {
                return $http({
                    url: config.server + 'api/messages/'+model.id,
                    method: "put",
                    data: model
                })
            },
            listOrders: function (filter) {
                return $http({
                    url: config.server + 'api/user/orders?include=message,user&page=' + filter.page,
                    method: "get"
                })
            },
            setting: function () {
                return $http({
                    url: config.server + 'api/setting',
                    method: "get"
                })
            },
            deleteOrder: function (id) {
                return $http({
                    url: config.server + 'api/orders/' + id,
                    method: "delete"
                })
            },
            resetPassword: function (model) {
                     return $http({
                         url: config.server + 'api/user/password',
                    method: "put",
                    data: model
                })
               
            }
        };
    }]);
})(angular.module('app.services'));