refactor(车列表): 统一处理车辆ID类型并添加Taro导入
移除车辆ID的toString()转换,直接使用原始ID进行比较和存储 在多个车列表页面中添加Taro导入以支持相关功能
Showing
4 changed files
with
7 additions
and
4 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-07-04 16:27:02 | 4 | + * @LastEditTime: 2025-07-04 16:58:46 |
| 5 | * @FilePath: /jgdl/src/pages/goodCarList/index.vue | 5 | * @FilePath: /jgdl/src/pages/goodCarList/index.vue |
| 6 | * @Description: 特价好车页面 | 6 | * @Description: 特价好车页面 |
| 7 | --> | 7 | --> |
| ... | @@ -123,6 +123,7 @@ | ... | @@ -123,6 +123,7 @@ |
| 123 | </template> | 123 | </template> |
| 124 | 124 | ||
| 125 | <script setup> | 125 | <script setup> |
| 126 | +import Taro from '@tarojs/taro' | ||
| 126 | import { ref, computed, onMounted } from 'vue' | 127 | import { ref, computed, onMounted } from 'vue' |
| 127 | import { Search2, Addfollow, Follow, Heart1, HeartFill } from '@nutui/icons-vue-taro' | 128 | import { Search2, Addfollow, Follow, Heart1, HeartFill } from '@nutui/icons-vue-taro' |
| 128 | import TabBar from '@/components/TabBar.vue' | 129 | import TabBar from '@/components/TabBar.vue' |
| ... | @@ -255,7 +256,7 @@ const scrollStyle = computed(() => { | ... | @@ -255,7 +256,7 @@ const scrollStyle = computed(() => { |
| 255 | * @param {string} carId - 车辆ID | 256 | * @param {string} carId - 车辆ID |
| 256 | */ | 257 | */ |
| 257 | const toggleFavorite = (carId) => { | 258 | const toggleFavorite = (carId) => { |
| 258 | - const index = favoriteIds.value.indexOf(carId.toString()) | 259 | + const index = favoriteIds.value.indexOf(carId) |
| 259 | if (index > -1) { | 260 | if (index > -1) { |
| 260 | favoriteIds.value.splice(index, 1) | 261 | favoriteIds.value.splice(index, 1) |
| 261 | Taro.showToast({ | 262 | Taro.showToast({ |
| ... | @@ -264,7 +265,7 @@ const toggleFavorite = (carId) => { | ... | @@ -264,7 +265,7 @@ const toggleFavorite = (carId) => { |
| 264 | duration: 2000 | 265 | duration: 2000 |
| 265 | }) | 266 | }) |
| 266 | } else { | 267 | } else { |
| 267 | - favoriteIds.value.push(carId.toString()) | 268 | + favoriteIds.value.push(carId) |
| 268 | Taro.showToast({ | 269 | Taro.showToast({ |
| 269 | title: '收藏成功', | 270 | title: '收藏成功', |
| 270 | icon: 'success', | 271 | icon: 'success', | ... | ... |
| ... | @@ -112,6 +112,7 @@ | ... | @@ -112,6 +112,7 @@ |
| 112 | </template> | 112 | </template> |
| 113 | 113 | ||
| 114 | <script setup> | 114 | <script setup> |
| 115 | +import Taro from '@tarojs/taro' | ||
| 115 | import { ref, computed, onMounted } from 'vue' | 116 | import { ref, computed, onMounted } from 'vue' |
| 116 | import { Search2, Heart1, HeartFill } from '@nutui/icons-vue-taro' | 117 | import { Search2, Heart1, HeartFill } from '@nutui/icons-vue-taro' |
| 117 | import TabBar from '@/components/TabBar.vue' | 118 | import TabBar from '@/components/TabBar.vue' | ... | ... |
| ... | @@ -112,6 +112,7 @@ | ... | @@ -112,6 +112,7 @@ |
| 112 | </template> | 112 | </template> |
| 113 | 113 | ||
| 114 | <script setup> | 114 | <script setup> |
| 115 | +import Taro from '@tarojs/taro' | ||
| 115 | import { ref, computed, onMounted } from 'vue' | 116 | import { ref, computed, onMounted } from 'vue' |
| 116 | import { Search2, Heart1, HeartFill } from '@nutui/icons-vue-taro' | 117 | import { Search2, Heart1, HeartFill } from '@nutui/icons-vue-taro' |
| 117 | import './index.less' | 118 | import './index.less' | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-07-04 15:21:48 | 4 | + * @LastEditTime: 2025-07-04 16:57:31 |
| 5 | * @FilePath: /jgdl/src/pages/search/index.vue | 5 | * @FilePath: /jgdl/src/pages/search/index.vue |
| 6 | * @Description: 搜索页面 | 6 | * @Description: 搜索页面 |
| 7 | --> | 7 | --> | ... | ... |
-
Please register or login to post a comment