Nav apraksta

Tab2Page.vue 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <ion-page>
  3. <ion-header>
  4. <top-bar></top-bar>
  5. </ion-header>
  6. <ion-content class='ion-padding' :fullscreen="true">
  7. <ion-grid>
  8. <ion-row>
  9. <ion-col size="6" v-for="c in cats" @click="gotoCatPage(c.name)">
  10. <ion-img :src="c.image"></ion-img>
  11. </ion-col>
  12. </ion-row>
  13. </ion-grid>
  14. </ion-content>
  15. </ion-page>
  16. </template>
  17. <script setup lang="ts">
  18. import { IonPage, IonHeader, IonToolbar, IonTitle, IonButton, IonContent, IonBackButton, IonButtons, IonRow, IonCol, IonGrid, onIonViewWillEnter, IonLabel, IonImg } from '@ionic/vue';
  19. import ExploreContainer from '@/components/ExploreContainer.vue';
  20. import TopBar from '@/components/TopBar.vue'
  21. import { useRouter } from 'vue-router';
  22. import { ref, onMounted } from 'vue'
  23. import axios from 'axios';
  24. import { API_URL } from '../api_config';
  25. const router = useRouter()
  26. let cats = ref([])
  27. onIonViewWillEnter( async () => {
  28. console.log("get product cat")
  29. const res2 = await axios.get(API_URL+'fn_product_cats/?format=json&is_promote=True')
  30. //cats = res2.data.results
  31. console.log('cats ')
  32. console.log(res2.data.results)
  33. cats.value = res2.data.results
  34. } )
  35. const gotoCatPage = (cat) => {
  36. router.push(`/tabs/tab2/prod_list/${cat}`)
  37. }
  38. </script>