| xqd
@@ -1,14 +1,87 @@
|
|
|
(function (app) {
|
|
|
- app.controller('goodsCtrl', ["$scope","$state", function ($scope,$state) {
|
|
|
+ app.controller('goodsCtrl', ["$scope", "$state", 'goodsService', '$ionicSideMenuDelegate', 'msg', function ($scope, $state, goodsService, $ionicSideMenuDelegate, msg) {
|
|
|
+ $scope.filter = {
|
|
|
+ hasMore: false,
|
|
|
+ pageIndex: 0,
|
|
|
+ pageSize: 10,
|
|
|
+ type:1,
|
|
|
+ begin_address: '',
|
|
|
+ end_address: '',
|
|
|
+ midway_address:''
|
|
|
+ }
|
|
|
+ $scope.items = [];
|
|
|
+ $scope.load = function (init) {
|
|
|
+ if (init) {
|
|
|
+ $scope.filter.pageIndex = 1;
|
|
|
+ $scope.items = [];
|
|
|
+ }
|
|
|
+ goodsService.listGoods($scope.filter).then(function (result) {
|
|
|
+
|
|
|
+ $scope.filter.pageIndex++;
|
|
|
+ var more = (result.data.data.length >= $scope.filter.pageSize);
|
|
|
+ $scope.filter.hasMore = more;
|
|
|
+ $scope.items = $scope.items.concat(result.data.data);
|
|
|
+ if (init) {
|
|
|
+ $scope.$broadcast('scroll.refreshComplete');
|
|
|
+ } else {
|
|
|
+ $scope.$broadcast('scroll.infiniteScrollComplete');
|
|
|
+ }
|
|
|
+ }, function (erro) {
|
|
|
+ msg.error(JSON.stringify(erro.data));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $scope.toggleRight = function () {
|
|
|
+ $scope.load(true);
|
|
|
+ $ionicSideMenuDelegate.toggleRight();
|
|
|
+ };
|
|
|
+ $scope.detail = function (item) {
|
|
|
+ $state.go('wl.goods_detail', {item:item})
|
|
|
+ }
|
|
|
$scope.add = function () {
|
|
|
$state.go('wl.goods_add');
|
|
|
}
|
|
|
+ $scope.load(true);
|
|
|
}]);
|
|
|
- app.controller('goodsAddCtrl', ["$scope", "$state",function ($scope,$state) {
|
|
|
-
|
|
|
+ app.controller('goodsAddCtrl', ["$scope", "$state", "goodsService", "msg", function ($scope, $state, goodsService, msg) {
|
|
|
+ $scope.vm = {type:1};
|
|
|
+ $scope.save = function () {
|
|
|
+ var price=new Number($scope.vm.price);
|
|
|
+ if (!price) {
|
|
|
+ msg.text('输入价格');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$scope.vm.begin_address) {
|
|
|
+ msg.text('请输入出发地址');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$scope.vm.end_address) {
|
|
|
+ msg.text('请输入到达地址');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$scope.vm.midway_address) {
|
|
|
+ msg.text('请输入途经地址');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$scope.vm.detail) {
|
|
|
+ msg.text('请输入详情');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ msg.loading('提交中...');
|
|
|
+ goodsService.addGoods($scope.vm).then(function (result) {
|
|
|
+ $state.go('wl.goods');
|
|
|
+ msg.hide();
|
|
|
+ }, function (erro) {
|
|
|
+ msg.hide();
|
|
|
+ msg.error(JSON.stringify(erro.data));
|
|
|
+ });
|
|
|
+ }
|
|
|
}]);
|
|
|
- app.controller('goodsDetailCtrl', ["$scope", function ($scope) {
|
|
|
+ app.controller('goodsDetailCtrl', ["$scope", '$stateParams', function ($scope, $stateParams) {
|
|
|
+ $scope.vm = $stateParams.item;
|
|
|
+ //下单
|
|
|
+ $scope.bill = function () {
|
|
|
|
|
|
+ }
|
|
|
}]);
|
|
|
|
|
|
})(angular.module('app.controllers'));
|