index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <u-search shape="square" v-model="value" :show-action="true" action-text="取消" placeholder="想买什么车"
  5. @change="toChange" @custom="toCustom"></u-search>
  6. </view>
  7. <view class="two">
  8. <view class="list" v-for="(item, index) in list" :key="index" @tap="toView(item)">
  9. <view class="left">
  10. <image v-if="item.file" class="image" :src="item.file&&item.file.length>0?item.file[0].url:''">
  11. </image>
  12. <u-icon v-else size="14px" name="search"></u-icon>
  13. </view>
  14. <view class="right">
  15. {{item.name}}
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script setup lang="ts">
  22. import { getCurrentInstance, ref } from 'vue';
  23. // 请求接口
  24. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  25. const value = ref('');
  26. const list = ref([]);
  27. // 查询
  28. const search = async () => {
  29. };
  30. // 搜索
  31. const toChange = async () => {
  32. };
  33. // 取消
  34. const toCustom = async () => {
  35. value.value = ''
  36. };
  37. // 查看详情
  38. const toView = (item) => {
  39. console.log(item);
  40. uni.navigateTo({
  41. url: `/pagesHome/search/index?type=${item.type || ''}`
  42. })
  43. };
  44. </script>
  45. <style lang="scss" scoped>
  46. .content {
  47. display: flex;
  48. flex-direction: column;
  49. width: 100vw;
  50. height: 100vh;
  51. .one {
  52. padding: 2vw;
  53. }
  54. .two {
  55. .list {
  56. display: flex;
  57. align-items: center;
  58. margin: 1vw 0 0 0;
  59. padding: 1vw;
  60. border-bottom: 1px solid var(--f9Color);
  61. }
  62. .left {
  63. .image {
  64. width: 40px;
  65. height: 40px;
  66. border-radius: 40px;
  67. }
  68. }
  69. .right {
  70. margin: 0 0 0 2vw;
  71. font-size: var(--font14Size);
  72. }
  73. }
  74. }
  75. </style>