Guest User

Untitled

a guest
Feb 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.26 KB | None | 0 0
  1. <!-- ORDENA POR PREÇO -->
  2. <button class="button button-stable button-block icon-left ion-android-restaurant" modal-select="" ng-model="someModel" options="selectableNames" option-property="role" modal-title="Ordenar por...">Ordenar
  3. <div class="option">
  4. <h1>{{option.name}}</h1>
  5. </div>
  6. </button>
  7.  
  8. // ORDENA POR...
  9. $scope.selectableNames = [
  10. {name : "Por preço: Do Menor para o Maior", role : "+cadastra_oferta_valor_com_desconto"},
  11. { name : "Por preço: Do Maior para o Menor", role : "-cadastra_oferta_valor_com_desconto"},
  12. ];
  13.  
  14.  
  15. $scope.getOpt = function(option){
  16. return option.name + ":" + option.role;
  17. };
  18. // FIM DE ORDENA POR
  19.  
  20. <div class="card" ng-repeat="item in ofertass | orderBy: someModel" ng-init="$last ? fireEvent() : null" href="#/nhaac/ofertas_singles/{{item.cadastra_oferta_cod_oferta}}" >
  21.  
  22. <ion-view view-title="Escolha as Categorias" hide-nav-bar="false" >
  23. <ion-content>
  24.  
  25. <div class="button-bar">
  26. <button class="button button-stable button-block icon-left ion-android-funnel" ng-click="userCategoria(categoria_comida_nome)">Aplicar Filtro</button>
  27. </div>
  28.  
  29. <ion-list>
  30. <ion-checkbox ng-repeat="item in ofertass | unique:'categoria_comida_nome'" ng-model="checkItems[item.categoria_comida_nome]" ng-change="print()">{{item.categoria_comida_nome}}</ion-checkbox>
  31. </ion-list>
  32.  
  33. <div class="button-bar">
  34. <button class="button button-stable button-block icon-left ion-android-funnel" ng-click="userCategoria()">Aplicar Filtro</button>
  35. </div>
  36.  
  37.  
  38. </ion-content>
  39. </ion-view>
  40.  
  41. // PEGA OS ITENS SELECIONADOS NA MODAL E COLOCA NUM ARRAY
  42. $scope.checkItems = { };
  43.  
  44. $scope.print = function() {
  45. console.log($scope.checkItems);
  46.  
  47. }
  48.  
  49. $scope.save = function() {
  50. var array = [];
  51. for(i in $scope.checkItems) {
  52. console.log($scope.checkItems[i]);
  53. if($scope.checkItems[i] == true) {
  54. array.push(i);
  55. }
  56. }
  57. console.log(array);
  58. $state.go("nhaac.promocoes");
  59. }
  60.  
  61.  
  62. // INICIA FILTRO POR CATEGORIA
  63. $ionicModal.fromTemplateUrl('/templates/filters/side-filter.html', {
  64. scope: $scope,
  65. animation: 'slide-in-up'
  66. }).then(function(modal) {
  67. $scope.modal = modal;
  68. });
  69. $scope.abreModal = function() {
  70. $scope.modal.show();
  71. };
  72. $scope.closeModal = function() {
  73. $scope.modal.hide();
  74.  
  75.  
  76. };
  77. // Cleanup the modal when we're done with it!
  78. $scope.$on('$destroy', function() {
  79. $scope.modal.remove();
  80. });
  81. // Execute action on hide modal
  82. $scope.$on('modal.hidden', function() {
  83. // Execute action
  84. });
  85. // Execute action on remove modal
  86. $scope.$on('modal.removed', function() {
  87. // Execute action
  88. });
  89.  
  90. // FIM FILTRO POR CATEGORIA
  91.  
  92. <button class="button button-stable button-block icon-left ion-android-funnel"ng-model="someModel" ng-click="checkItems[item.categoria_comida_nome]" ui-sref="filtroPromo">Filtrar
  93. </button>
  94.  
  95. <div class="card" ng-repeat="item in ofertass | orderBy: someModel" ng-init="$last ? fireEvent() : null" href="#/nhaac/ofertas_singles/{{item.cadastra_oferta_cod_oferta}}" >
  96.  
  97. .controller("promocoesCtrl", function($scope,$rootScope,$state,$ionicScrollDelegate,$http,$httpParamSerializer,$stateParams,$timeout,$ionicLoading,$ionicPopup,$ionicPopover,$ionicSlideBoxDelegate,$ionicHistory,ionicMaterialInk,ionicMaterialMotion,$ionicModal, sharedCartService,sharedFilterService){
  98.  
  99. //put cart after menu
  100. var cart = sharedCartService.cart;
  101.  
  102. // ORDENA POR...
  103. $scope.selectableNames = [
  104. {name : "Por preço: Do Menor para o Maior", role : "+cadastra_oferta_valor_com_desconto"},
  105. { name : "Por preço: Do Maior para o Menor", role : "-cadastra_oferta_valor_com_desconto"},
  106. ];
  107.  
  108.  
  109. $scope.getOpt = function(option){
  110. return option.name + ":" + option.role;
  111. };
  112. // FIM DE ORDENA POR
  113.  
  114. // PEGA OS ITENS SELECIONADOS NA MODAL E COLOCA NUM ARRAY
  115. $scope.checkItems = { };
  116.  
  117. $scope.print = function() {
  118. console.log($scope.checkItems);
  119.  
  120. }
  121.  
  122. // APLICANDO FILTRO CATEGORIA
  123. $scope.userCategoria = function(checkItems) {
  124. console.log("entra na chamada");
  125. // $scope.userCategoria = $scope.checkItems(function(element) {
  126. $scope.checkItems;
  127. console.log("Imprime array");
  128. console.log($scope.checkItems);
  129. // };
  130. // console.log("Imprime array");
  131. // console.log($scope.userCategoria);
  132. $scope.modal.hide();
  133. $state.go("nhaac.ofertas_restaurante");
  134. };
  135.  
  136. $scope.save = function() {
  137. var array = [];
  138. for(i in $scope.checkItems) {
  139. console.log($scope.checkItems[i]);
  140. if($scope.checkItems[i] == true) {
  141. array.push(i);
  142. }
  143. }
  144. console.log(array);
  145. $state.go("nhaac.promocoes");
  146. }
  147.  
  148.  
  149. // INICIA FILTRO POR CATEGORIA
  150. $ionicModal.fromTemplateUrl('/templates/filters/side-filter.html', {
  151. scope: $scope,
  152. animation: 'slide-in-up'
  153. }).then(function(modal) {
  154. $scope.modal = modal;
  155. });
  156. $scope.abreModal = function() {
  157. $scope.modal.show();
  158. };
  159. $scope.closeModal = function() {
  160. $scope.modal.hide();
  161.  
  162.  
  163. };
  164. // Cleanup the modal when we're done with it!
  165. $scope.$on('$destroy', function() {
  166. $scope.modal.remove();
  167. });
  168. // Execute action on hide modal
  169. $scope.$on('modal.hidden', function() {
  170. // Execute action
  171. });
  172. // Execute action on remove modal
  173. $scope.$on('modal.removed', function() {
  174. // Execute action
  175. });
  176.  
  177.  
  178.  
  179.  
  180.  
  181. // FIM FILTRO POR CATEGORIA
  182.  
  183.  
  184. $rootScope.page_id = "promocoes" ;
  185. $scope.scrollTop = function(){
  186. $ionicScrollDelegate.$getByHandle("top").scrollTop();
  187. };
  188. // open external browser
  189. $scope.openURL = function($url){
  190. window.open($url,"_system","location=yes");
  191. };
  192. // open AppBrowser
  193. $scope.openAppBrowser = function($url){
  194. window.open($url,"_blank","closebuttoncaption=Done");
  195. };
  196. // open WebView
  197. $scope.openWebView = function($url){
  198. window.open($url,"_self");
  199. };
  200.  
  201. // Set Motion
  202. $timeout(function(){
  203. ionicMaterialMotion.slideUp({
  204. selector: ".slide-up"
  205. });
  206. }, 300);
  207.  
  208. var targetQuery = ""; //default param
  209. var raplaceWithQuery = "";
  210. // TODO: Dinamics Promoções
  211. targetQuery = "json=promocao"; //default param
  212. raplaceWithQuery = "json=promocao";
  213.  
  214.  
  215. var fetch_per_scroll = 1;
  216. // animation loading
  217. $ionicLoading.show({
  218. template: '<div class="loader"><svg class="circular"><circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/></svg></div>'
  219. });
  220.  
  221.  
  222. $scope.noMoreItemsAvailable = false; //readmore status
  223. var lastPush = 0;
  224. var data_ofertass = [];
  225.  
  226. if(window.localStorage.getItem("data_ofertass") !== "undefined"){
  227. data_ofertass = JSON.parse(window.localStorage.getItem("data_ofertass"));
  228. if (data_ofertass !== null){
  229. $scope.ofertass = [];
  230. for(lastPush = 0; lastPush < 10; lastPush++) {
  231. if (angular.isObject(data_ofertass[lastPush])){
  232. $scope.ofertass.push(data_ofertass[lastPush]);
  233. };
  234. }
  235. $timeout(function() {
  236. $ionicLoading.hide();
  237. }, 500);
  238. }
  239. }
  240. if(!angular.isObject(data_ofertass)){
  241. $timeout(function() {
  242. // retry retrieving data
  243. $http.get("http://vovocooks.com.br/admin/apis/api_listagem/lista_oferta_api.php?json=promocao".replace(targetQuery,raplaceWithQuery)).then(function(response) {
  244. data_ofertass = response.data;
  245. if(typeof(Storage) != "undefined"){
  246. try {
  247. window.localStorage.setItem("data_ofertass",JSON.stringify(data_ofertass));
  248. } catch(e) {
  249. window.localStorage.clear();
  250. window.localStorage.setItem("data_ofertass",JSON.stringify(data_ofertass));
  251. $ionicHistory.clearCache();
  252. $ionicHistory.clearHistory();
  253. $state.reload();
  254. $scope.$state = $state;
  255. }
  256. }
  257. $scope.ofertass = [];
  258. for(lastPush = 0; lastPush < 100; lastPush++) {
  259. if (angular.isObject(data_ofertass[lastPush])){
  260. $scope.ofertass.push(data_ofertass[lastPush]);
  261. };
  262. }
  263. },function(response) {
  264. // error message
  265. var alertPopup = $ionicPopup.alert({
  266. title: "error " + response.status,
  267. template: response.statusText + "<br/>problem: table ofertas",
  268. });
  269. }).finally(function() {
  270. $scope.$broadcast("scroll.refreshComplete");
  271. // event done, hidden animation loading
  272. $timeout(function() {
  273. $ionicLoading.hide();
  274. }, 1000);
  275. });
  276.  
  277. }, 1000);
  278. }
  279.  
  280.  
  281.  
  282. $scope.doRefresh = function(){
  283. // retry retrieving data
  284. window.localStorage.clear();
  285. $http.get( "http://vovocooks.com.br/admin/apis/api_listagem/lista_oferta_api.php?json=promocao".replace(targetQuery,raplaceWithQuery)).then(function(response) {
  286. data_ofertass = response.data;
  287. if(typeof(Storage) != "undefined"){
  288. try {
  289. window.localStorage.setItem("data_ofertass",JSON.stringify(data_ofertass));
  290. } catch(e) {
  291. window.localStorage.clear();
  292. window.localStorage.setItem("data_ofertass",JSON.stringify(data_ofertass));
  293. $ionicHistory.clearCache();
  294. $ionicHistory.clearHistory();
  295. $state.reload();
  296. $scope.$state = $state;
  297. }
  298. }
  299. $scope.ofertass = [];
  300. for(lastPush = 0; lastPush < 100; lastPush++) {
  301. if (angular.isObject(data_ofertass[lastPush])){
  302. $scope.ofertass.push(data_ofertass[lastPush]);
  303. };
  304. }
  305. },function(response) {
  306. // error message
  307. var alertPopup = $ionicPopup.alert({
  308. title: "error " + response.status,
  309. template: response.statusText + "<br/>problem: table ofertas",
  310. });
  311. }).finally(function() {
  312. $scope.$broadcast("scroll.refreshComplete");
  313. // event done, hidden animation loading
  314. $timeout(function() {
  315. $ionicLoading.hide();
  316. }, 500);
  317. });
  318.  
  319.  
  320.  
  321. };
  322.  
  323.  
  324. if (data_ofertass === null){
  325. data_ofertass = [];
  326. };
  327.  
  328.  
  329.  
  330. //add to cart function
  331. $scope.addToCart=function(id,image,name,price){
  332. // CHAMA CART.ADD DE SERVICES
  333. cart.add(id,image,name,price,1);
  334.  
  335. };
  336.  
  337.  
  338.  
  339.  
  340.  
  341. // animation readmore
  342. var fetchItems = function() {
  343. for(var z=0;z<fetch_per_scroll;z++){
  344. if (angular.isObject(data_ofertass[lastPush])){
  345. $scope.ofertass.push(data_ofertass[lastPush]);
  346. lastPush++;
  347. }else{;
  348. $scope.noMoreItemsAvailable = true;
  349. }
  350. }
  351. $scope.$broadcast("scroll.infiniteScrollComplete");
  352. };
  353.  
  354. // event readmore
  355. $scope.onInfinite = function() {
  356. $timeout(fetchItems, 500);
  357. };
  358.  
  359. // create animation fade slide in right (ionic-material)
  360. $scope.fireEvent = function(){
  361. ionicMaterialMotion.fadeSlideInRight();
  362. ionicMaterialInk.displayEffect();
  363. };
  364.  
  365.  
  366. // animation ink (ionic-material)
  367. ionicMaterialInk.displayEffect();
  368. $scope.rating = {};
  369. $scope.rating.max = 5;
  370. })
  371.  
  372. <ion-view view-title="Promoções" hide-nav-bar="false" >
  373. <!-- content -->
  374.  
  375. <!-- BOTÃO CARRINHO DE COMPRAS -->
  376. <ion-nav-buttons side="right" >
  377. <a href="#/nhaac/carrinho" class="button button-icon icon ion-android-cart" > {{total}} </a>
  378. </ion-nav-buttons>
  379.  
  380. <ion-content delegate-handle="top" lazy-scroll id="page-promocoes" class="has-header page-promocoes">
  381.  
  382. <ion-refresher pulling-text="Puxe para atualizar..." on-refresh="doRefresh()"></ion-refresher>
  383. <ion-list class="list card">
  384. <div class="item item-input">
  385. <i class="icon ion-search placeholder-icon"></i>
  386. <input type="search" ng-model="q" placeholder="Procurar" aria-label="filter restaurantess" />
  387. </div>
  388. </ion-list>
  389.  
  390.  
  391. <div class="button-bar">
  392.  
  393. <!-- FILTRA POR... -->
  394. <!-- <button class="button button-stable button-block icon-left ion-android-funnel" ng-click="abreModal()">Filtrar</button> -->
  395.  
  396. <!-- <a class="button button-stable button-block icon-left ion-android-funnel" ng-model="someModel" options="checkItems[item.categoria_comida_nome]" ui-sref="filtroPromo">Filtrar</a> -->
  397.  
  398. <button class="button button-stable button-block icon-left ion-android-funnel"ng-model="someModel" ng-click="checkItems[item.categoria_comida_nome]" ui-sref="filtroPromo">Filtrar
  399. </button>
  400.  
  401. <!-- <button class="button button-stable button-block icon-left ion-android-funnel" >
  402. Filtrar
  403. </button> -->
  404.  
  405.  
  406. <!-- ORDENA POR PREÇO -->
  407. <button class="button button-stable button-block icon-left ion-android-restaurant" modal-select="" ng-model="someModel" options="selectableNames" option-property="role" modal-title="Ordenar por...">Ordenar
  408. <div class="option">
  409. <h1>{{option.name}}</h1>
  410. </div>
  411. </button>
  412.  
  413. </div>
  414.  
  415.  
  416.  
  417.  
  418. <div class="list animate-fade-slide-in-right">
  419.  
  420. <div class="card" ng-repeat="item in ofertass | orderBy: someModel" ng-init="$last ? fireEvent() : null" href="#/nhaac/ofertas_singles/{{item.cadastra_oferta_cod_oferta}}" >
  421.  
  422.  
  423.  
  424. <div class="item item-thumbnail-top item-text-wrap">
  425. <img class="imagemCapa" image-lazy-loader="lines" image-lazy-src="{{item.cadastra_oferta_foto}}"/>
  426. <div class="promocao"><b>{{item.cadastra_oferta_desconto}}% OFF</b></div>
  427. <div class="desconto"><b>Apenas: R$ {{item.cadastra_oferta_valor_com_desconto}}</b></div>
  428.  
  429. <div class="item"><h2><b>{{item.cadastra_oferta_titulo_promocao}}</b></h2></div>
  430.  
  431. <div class="item">
  432. <h3>Categoria: {{item.categoria_comida_nome}}</h3>
  433. <h3>
  434. Preço Normal: <s><small class="preco">R$ {{item.cadastra_oferta_valor_sem_desconto}}</small></s><br>
  435. Preço Promocional <small class="preco">R$ {{item.cadastra_oferta_valor_com_desconto}} </small>
  436. </h3>
  437. <div class="to_trusted" ng-bind-html="item.cadastra_oferta_descricao"></div>
  438. </div>
  439. </div>
  440.  
  441. <div>
  442. <center><p style="position:relative;right:10px;bottom:0px;top:1px">
  443. <a ng-click="addToCart(item.cadastra_oferta_cod_oferta,item.cadastra_oferta_foto, item.cadastra_oferta_titulo_promocao,item.cadastra_oferta_valor_com_desconto)" class="button button-assertive button-clear icon-left ion-android-cart"> Pedir Já </a>
  444. </p></center>
  445. </div>
  446.  
  447.  
  448. <a class="item button button-clear button-dark ink" href="#nhaac/ofertas_singles/{{item.cadastra_oferta_cod_oferta}}">MAIS INFORMAÇÕES</a>
  449. </div>
  450. </div>
  451. <ion-list class="list">
  452. <ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="onInfinite()" distance="5px" ng-if="hasMoreData"></ion-infinite-scroll>
  453. </ion-list>
  454.  
  455. <ion-list class="list">
  456. <div class="item" ng-if="results.length == 0" >
  457. <p>Nenhum resultado encontrado...</p>
  458. </div>
  459. </ion-list>
  460.  
  461.  
  462. <ion-infinite-scroll ng-if="!noMoreItemsAvailable" on-infinite="loadMore()" distance="10%">
  463. <ion-infinite-scroll-content loadingSpinner="bubbles">
  464. </ion-infinite-scroll>
  465.  
  466.  
  467.  
  468. </ion-content>
  469. <!-- ./content -->
  470. </ion-view>
  471.  
  472. ng-repeat="array | orderBy: ['preco', 'categoria']"
  473.  
  474. var array = [
  475. { nome: 'item 1', preco: 1, categoria: 'X' },
  476. { nome: 'item 1', preco: 1, categoria: 'Y' },
  477. { nome: 'item 1', preco: 1, categoria: 'Z' },
  478. { nome: 'item 1', preco: 2, categoria: 'X' },
  479. { nome: 'item 1', preco: 3, categoria: 'Y' },
  480. { nome: 'item 1', preco: 2, categoria: 'X' },
  481. { nome: 'item 1', preco: 5, categoria: 'Z' },
  482. ]
Add Comment
Please, Sign In to add comment