home.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. (function (app) {
  2. app.controller('homeCtrl', ["$scope", 'goodsService', 'carService', 'msg', '$state', '$ionicHistory','config', function ($scope, goodsService, carService, msg, $state, $ionicHistory,config) {
  3. $scope.vm = { showIndex: 1 };
  4. $scope.host = config.server +'/upload/photo/';
  5. $scope.changeTab = function (i) {
  6. $scope.vm.showIndex = i;
  7. }
  8. $scope.goods = [];
  9. goodsService.listGoods({ type: 1, pageIndex: 1 }).then(function (result) {
  10. $scope.goods = result.data.data;
  11. }, function (erro) {
  12. // msg.error(erro.data.message);
  13. });
  14. $scope.cars = [];
  15. carService.listCars({ type: 2, pageIndex: 1 }).then(function (result) {
  16. $scope.cars = result.data.data;
  17. }, function (erro) {
  18. // msg.error(erro.data.message);
  19. });
  20. $scope.detail = function (item) {
  21. if ($scope.vm.showIndex == 1) //货源
  22. {
  23. $state.go('wl.goods_detail', {item:item});
  24. }
  25. if ($scope.vm.showIndex == 2) //车源
  26. {
  27. $state.go('wl.car_detail', { item: item });
  28. }
  29. }
  30. $scope.go = function (target) {
  31. $ionicHistory.clearHistory();
  32. $state.go(target);
  33. }
  34. }]);
  35. })(angular.module('app.controllers'));