UNPKG

unserver-unify

Version:

57 lines (47 loc) 1.62 kB
'use strict'; angular.module('bamboo.product').controller('ProductSearchCtrl', function($stateParams, ApiService, $scope, loginService) { var _self = this; this.q = $stateParams.key; this.page = 1; this.defaultPhoto = "assets/images/product.png"; this.productpath = ApiService.SHOST + '/product/'; this.inspectorFlag = false; _self.currency = (loginService.school.currency&&loginService.school.currency.sign)?loginService.school.currency.sign:'$'; var page = 0; var limit = 8; this.items = []; this.pageChanged = function(newPage) { _self.page = newPage; _self.getItems(_self.q); }; this.getItems = function(q) { var info = { // id: ApiService.gid, action: "getproducts", // page: page - 1, start: (_self.page -1)* limit, sort: { reverse: true, counter: 'counter' }, limit: limit, search: { searchname: q }, }; // console.log(info); console.log(info); ApiService.post("/business", info).then(function(result) { console.log(result.data.data); if (result.data.success) { $scope.searchCount = result.data.data.counter || 0; $scope.searchName = q; _self.items = result.data.data.items; } }); } if (this.q && this.q.length) { console.log("============="); _self.getItems(_self.q); } });