index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <u-index-list :index-list="indexList" :sticky="false" activeColor="#ffbc00">
  3. <view :slot="header" class="list">
  4. <view class="text">热门品牌</view>
  5. <view class="one">
  6. <view class="list" v-for="(item, index) in list" :key="index" @tap="toCommon(item)">
  7. <view class="icon">
  8. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:'/static/logo.png'">
  9. </image>
  10. </view>
  11. <view class="title">{{item.title}}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <template :key="index" v-for="(item, index) in itemArr">
  16. <!-- #ifdef APP-NVUE -->
  17. <u-index-anchor color="#333333" bg-color="#f9f9f9" :text="indexList[index]"></u-index-anchor>
  18. <!-- #endif -->
  19. <u-index-item>
  20. <!-- #ifndef APP-NVUE -->
  21. <u-index-anchor color="#333333" bg-color="#f9f9f9" :text="indexList[index]"></u-index-anchor>
  22. <!-- #endif -->
  23. <view class="list-cell" v-for="(cell, index) in item" @tap="toCommon(cell)">
  24. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:'/static/logo.png'">
  25. </image>
  26. <view class="title">{{cell.title}}</view>
  27. </view>
  28. </u-index-item>
  29. </template>
  30. </u-index-list>
  31. </template>
  32. <script setup lang="ts">
  33. import { getCurrentInstance, ref } from 'vue';
  34. //该依赖已内置不需要单独安装
  35. import { onLoad } from "@dcloudio/uni-app";
  36. // 请求接口
  37. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  38. // 基本信息
  39. const config = ref({ logoUrl: [] });
  40. const indexList = ref(["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]);
  41. const itemArr = ref([
  42. [{ title: '奥迪', url: [], type: '0' }, { title: '爱驰', url: [], type: '0' }, { title: '阿斯顿·马丁', url: [], type: '0' }],
  43. [{ title: '宝马', url: [], type: '0' }, { title: '本田', url: [], type: '0' }, { title: '比亚迪', url: [], type: '0' }, { title: '奔腾', url: [], type: '0' }],
  44. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  45. [{ title: '大众', url: [], type: '0' }, { title: '东风', url: [], type: '0' }, { title: '大运', url: [], type: '0' }],
  46. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  47. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  48. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  49. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  50. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  51. [{ title: '长安', url: [], type: '0' }, { title: '长城', url: [], type: '0' }, { title: '创维', url: [], type: '0' }],
  52. ]);
  53. const list = ref([{ title: '奥迪', url: [], type: '0' }, { title: '本田', url: [], type: '0' }, { title: '别克', url: [], type: '0' },
  54. { title: '奥迪', url: [], type: '0' }, { title: '大众', url: [], type: '0' }, { title: '长城', url: [], type: '0' },
  55. { title: '福特', url: [], type: '0' }, { title: '丰田', url: [], type: '0' }, { title: '长安', url: [], type: '0' },
  56. { title: '日产', url: [], type: '0' }]);
  57. onLoad(async () => {
  58. await searchConfig();
  59. await search();
  60. })
  61. // config信息
  62. const searchConfig = async () => {
  63. config.value = uni.getStorageSync('config');
  64. };
  65. // 查询
  66. const search = async () => {
  67. };
  68. const toCommon = (item) => {
  69. uni.$emit('toRoute', item)
  70. // 4. 返回上一页面
  71. uni.navigateBack({
  72. delta: 1 // 返回的页面数
  73. })
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. .list {
  78. .text {
  79. margin: 2vw;
  80. font-weight: bold;
  81. font-size: var(--font16Size);
  82. }
  83. .one {
  84. display: flex;
  85. justify-content: space-between;
  86. flex-wrap: wrap;
  87. align-items: center;
  88. padding: 2vw 4vw;
  89. .list {
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. width: 18vw;
  94. margin: 0 0 1vw 0;
  95. .image {
  96. width: 40px;
  97. height: 40px;
  98. border-radius: 40px;
  99. }
  100. .title {
  101. margin: 0 0 1vw 0;
  102. font-size: var(--font14Size);
  103. }
  104. }
  105. }
  106. }
  107. .list-cell {
  108. display: flex;
  109. align-items: center;
  110. box-sizing: border-box;
  111. width: 100%;
  112. padding: 10px 24rpx;
  113. overflow: hidden;
  114. color: #323233;
  115. font-size: 14px;
  116. line-height: 24px;
  117. background-color: #fff;
  118. .image {
  119. width: 40px;
  120. height: 40px;
  121. border-radius: 40px;
  122. }
  123. .title {
  124. margin: 0 0 0 1vw;
  125. }
  126. }
  127. </style>