menu.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="menu-content">
  3. <uv-vtabs :chain="chain" :list="list" :height="height">
  4. <template v-for="(item,index) in list">
  5. <uv-vtabs-item :index="index" :key="index">
  6. <view class="menu-box">
  7. <view class="menu-title">{{item.name}}</view>
  8. <view class="menu-list">
  9. <view class="menu-item" @click="toCategory(item)">
  10. <image class="item-menu-image" :src="shopImage(item.icon)" mode="scaleToFill"></image>
  11. <view class="item-menu-name">{{item.name}}</view>
  12. </view>
  13. <view class="menu-item" v-for="(item1, index1) in item.children" :key="index1"
  14. @click="toCategory(item1)">
  15. <image class="item-menu-image" :src="shopImage(item.icon)" mode=""></image>
  16. <view class="item-menu-name">{{item.name}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </uv-vtabs-item>
  21. </template>
  22. </uv-vtabs>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. getCategoryList
  28. } from '@/request/api/shop.js'
  29. export default {
  30. data() {
  31. return {
  32. list: [],
  33. chain: true
  34. }
  35. },
  36. computed: {
  37. height() {
  38. return uni.getWindowInfo().windowHeight - uni.upx2px(100);
  39. }
  40. },
  41. onLoad() {
  42. this.init();
  43. },
  44. methods: {
  45. async init() {
  46. let categoryData = await getCategoryList();
  47. if (categoryData.state) this.list = categoryData.data;
  48. },
  49. toCategory(item) {
  50. this.$navigateTo('/subPages/shopPage/menuShop/menuShop?idCategory=' + item.id);
  51. }
  52. }
  53. }
  54. </script>
  55. <style scoped lang="scss">
  56. .menu-content {
  57. padding-top: 30rpx;
  58. }
  59. .menu-box {
  60. padding: 20rpx;
  61. .menu-title {
  62. font-size: 36rpx;
  63. font-weight: bold;
  64. padding-bottom: 20rpx;
  65. }
  66. }
  67. .item-menu-image {
  68. width: 120rpx;
  69. height: 120rpx;
  70. }
  71. .item-menu-name {
  72. font-weight: normal;
  73. font-size: 24rpx;
  74. }
  75. .menu-list {
  76. display: flex;
  77. flex-wrap: wrap;
  78. .menu-item {
  79. width: 33.33%;
  80. text-align: center;
  81. }
  82. }
  83. </style>