unserver-unify
Version:
58 lines (56 loc) • 2.08 kB
JavaScript
angular.module('bamboo.product').controller('MarketListDetailCtrl', function($scope, $state, $stateParams, $rootScope, ApiService, loginService) {
var _self = this;
this.id = $stateParams.id;
this.defaultPhoto = "assets/images/product.png";
this.productpath = ApiService.SHOST + '/product/';
console.log($state.current.name);
this.page = 0;
this.items = [];
_self.currency = (loginService.school.currency&&loginService.school.currency.sign)?loginService.school.currency.sign:'$';
console.log($stateParams.id)
this.quantity = 1;
console.log($stateParams.id)
$rootScope.fullwidthflag = true;
$scope.$on("$destroy", function() {
console.log('-- destroy --');
if ($state.current.name == 'index.advertise' || $state.current.name == 'index.store' || $state.current.name == 'index.store.detail' || $state.current.name.indexOf('index.home') > -1) {
$rootScope.fullwidthflag = true;
} else {
$rootScope.fullwidthflag = false;
}
});
this.plus = function() {
console.log("---");
_self.quantity++;
}
this.minus = function() {
if (_self.quantity <= 0) {
return;
}
_self.quantity--;
}
function showProduct() {
var info = {
action: "getproduct",
id: $stateParams.id
};
ApiService.post("/business", info).then(function(result) {
if (result.data.success) {
$scope.item = result.data.data || {};
$rootScope.ProductName = $scope.item.name;
$scope.releatePhotos = $scope.item.photos|| [];
$scope.productPhotos = $scope.item.rphotos||[];
if($scope.item.photo){
$scope.productPhotos = $scope.productPhotos.concat($scope.item.photo).reverse();
}
console.log($scope.item);
$scope.targetImg = $scope.productPhotos[0];
//_self.imageUrl = _self.item.photo ? _self.productpath + _self.item._id + '/' + _self.item.photo : _self.defaultPhoto;
}
});
}
showProduct();
this.clickImage = function(img){
$scope.targetImg = img;
}
});