carservice.js 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. (function (app) {
  2. app.factory('carService', ['$http', 'config', "util", 'data', function ($http, config, util, data) {
  3. return {
  4. //发布车源信息
  5. addCar: function (model) {
  6. return $http({
  7. url: config.server + 'api/messages',
  8. method: "post",
  9. data: model
  10. })
  11. },
  12. //车源列表
  13. listCars: function (model) {
  14. var condition = util.format("?include=user,truck&type={0}&begin_address={1}&end_address={2}&midway_address={3}&page={4}"
  15. , model.type, model.begin_address ? model.begin_address : '', model.end_address ? model.end_address : '', model.midway_address ? model.midway_address : '', model.pageIndex);
  16. return $http({
  17. url: config.server + 'api/messages/search' + condition,
  18. method: "get",
  19. data: model
  20. })
  21. },
  22. //我的车辆
  23. listTrucks:function () {
  24. return $http({
  25. url: config.server + 'api/user/trucks',
  26. method: "get"
  27. })
  28. }
  29. };
  30. }]);
  31. })(angular.module('app.services'));