列表下拉刷新,上拉加载更多
<ion-view can-swipe-back="false" cache-view="false"> <div class="bar bar-header bar-positive"> <button ng-click="vm.goBack()" class="button button-clear icon icon ion-ios-arrow-left"></button> <h1 class="title">{{searchType == '1'?'Search Product':'Physical Count'}}</h1> <button ng-click="scrollTop()" class="button button-positive icon ion-ios-arrow-up"></button> </div> <ion-content class="has-header"> <ion-refresher pulling-text="Pull to refresh..." on-refresh="vm.searchProduct('1')"> </ion-refresher> <div style="width: 100%; margin: 0 auto"> <div ng-if="vm.errormsg1 != ''" style="padding: 0px;"> <a class="button button-block icon-right ion-ios-close-outline button-assertive" style="font-size: 9px; border-radius: 0px; margin-top: 0px; margin-bottom: 0px;" ng-click="Clean1()">{{vm.errormsg1}}</a> </div> <div class="list"> <div class="item item-input-inset" style="background-color:#F5F5F5"> <label class="item-input-wrapper" style="background-color:#ffffff"> <i class="icon ion-ios-search placeholder-icon"></i> <input type="text" ng-model="vm.search" placeholder="Barcode/UPC/Description" style="width: 100%;"> </label> <button class="button button-small button-positive" ng-click="vm.searchProduct('0')"> Search </button> </div> <div class="item item-input-inset" style="background-color:#F5F5F5"> <label class="item item-input" style="width: 100%; background-color:#F5F5F5;"> <input type="text" ng-model="warehouseName" ng-click="vm.selectWarehouse()" readonly style="background-color:#F5F5F5; color:#8A8A8A;"> <i class="icon ion-ios-arrow-down icon-right placeholder-icon" style="margin-right: 10px"></i> </label> </div> <a ng-repeat="item in vm.list" ng-click="vm.selectItem(item)" class="item item-icon-right"> <h2 ng-if="item.plu != ''">{{item.upc}} / {{item.plu}}</h2> <h2 ng-if="item.plu == ''">{{item.upc}}</h2> <p>{{item.description}}</p> <p>Price $ {{item.price1}}</p> <p ng-if="item.onhand != '' && item.kitchen == false">Quantity: {{item.onhand}}</p> <p ng-if="item.onhand == '' && item.kitchen == false">Quantity: 0.00</p> <i class="icon ion-ios-arrow-right" style="font-size: 15px;"></i> </a> <div ng-if="vm.nextpage==0 && vm.list.length>0" class="item" align="center" style="color:#FF0000"> --last page-- </div> </div> <ion-infinite-scroll on-infinite="vm.next({{vm.nextpage}})" distance="5%"> </ion-infinite-scroll> </div> </ion-content> </ion-view>
vm.searchProduct = function(refreshyn) { $rootScope.photo = ""; if (vm.search == "") { vm.errormsg1 = "Please enter Barcode/UPC/Description."; return; } $rootScope.search = vm.search; vm.errormsg1 = ""; vm.warningmsg1 = ""; if (refreshyn=='1') { $scope.$broadcast('scroll.refreshComplete'); } if (refreshyn!='-1') { $ionicLoading.show({template: 'Searching...'}); } //if ($rootScope.isAndroid==true || $rootScope.isIOS==true) // cordova.plugins.Keyboard.close(); $ionicLoading.show({template: 'Searching Product...'}); var params = { token : $rootScope.loginInfo.token, tokensecret : $rootScope.loginInfo.tokensecret, ciaid: $rootScope.ciaid, username: $rootScope.loginInfo.username, upc: vm.search, idwarehouse: $rootScope.idwarehouse, type: $rootScope.searchType, nextpage: '0' }; vm.doSearch(params, false); } vm.next=function(xnextpage){ if ( xnextpage == 0 ) { $scope.$broadcast('scroll.infiniteScrollComplete'); } else { var params = { token : $rootScope.loginInfo.token, tokensecret : $rootScope.loginInfo.tokensecret, ciaid: $rootScope.ciaid, username: $rootScope.loginInfo.username, upc: vm.search, idwarehouse: $rootScope.idwarehouse, type: $rootScope.searchType, nextpage : xnextpage }; vm.doSearch(params, true); } } vm.doSearch = function(params, next) { $rootScope.productSearchResult = null; $http.post($rootScope.ws_url + "/SearchProduct.json", params, {timeout:5000}).then( function(Json) { $ionicLoading.hide(); $scope.$broadcast('scroll.infiniteScrollComplete'); if (Json.status == 200) { if (Json.data.validtoken == "0") { vm.logout($rootScope.error2); return; } if (Json.data.list != null && Json.data.list.length > 0) { $rootScope.productSearchResult = Json.data; if (params.nextpage > 0) { for (var i = 0; i < Json.data.list.length; i++) { vm.list.push(Json.data.list[i]); } } else { vm.list = $rootScope.productSearchResult.list; } vm.nextpage = $rootScope.productSearchResult.nextpage; if (next == false) { if (vm.list.length == 1) vm.getProduct(vm.list[0].upc, $rootScope.searchType); } } else { if (next == false) { vm.list = {}; vm.nextpage = 0; vm.errormsg1 = "Data not found."; $ionicScrollDelegate.scrollTop(); } else { vm.nextpage = 0; } } } }, function(err) { $ionicLoading.hide(); $scope.$broadcast('scroll.infiniteScrollComplete'); vm.errormsg1 = $rootScope.error1; $ionicScrollDelegate.scrollTop(); } ); }
Jack Fan
Email: juan850311@163.com
QQ: 441935503
Email: juan850311@163.com
QQ: 441935503