feat(收藏功能): 添加收藏操作时的Toast提示
统一使用Taro.showToast替换原有的showToast方法,并在多个页面和组件中添加收藏/取消收藏时的用户反馈提示
Showing
8 changed files
with
81 additions
and
9 deletions
| ... | @@ -364,8 +364,18 @@ const toggleFavorite = (id) => { | ... | @@ -364,8 +364,18 @@ const toggleFavorite = (id) => { |
| 364 | const index = favoriteIds.value.indexOf(id) | 364 | const index = favoriteIds.value.indexOf(id) |
| 365 | if (index > -1) { | 365 | if (index > -1) { |
| 366 | favoriteIds.value.splice(index, 1) | 366 | favoriteIds.value.splice(index, 1) |
| 367 | + Taro.showToast({ | ||
| 368 | + title: '取消收藏', | ||
| 369 | + icon: 'none', | ||
| 370 | + duration: 2000 | ||
| 371 | + }) | ||
| 367 | } else { | 372 | } else { |
| 368 | favoriteIds.value.push(id) | 373 | favoriteIds.value.push(id) |
| 374 | + Taro.showToast({ | ||
| 375 | + title: '收藏成功', | ||
| 376 | + icon: 'success', | ||
| 377 | + duration: 2000 | ||
| 378 | + }) | ||
| 369 | } | 379 | } |
| 370 | } | 380 | } |
| 371 | 381 | ... | ... |
| ... | @@ -210,10 +210,18 @@ const toggleFavorite = (carId) => { | ... | @@ -210,10 +210,18 @@ const toggleFavorite = (carId) => { |
| 210 | const index = favoriteIds.value.indexOf(carId) | 210 | const index = favoriteIds.value.indexOf(carId) |
| 211 | if (index > -1) { | 211 | if (index > -1) { |
| 212 | favoriteIds.value.splice(index, 1) | 212 | favoriteIds.value.splice(index, 1) |
| 213 | - showToast('取消收藏', 'success') | 213 | + Taro.showToast({ |
| 214 | + title: '取消收藏', | ||
| 215 | + icon: 'none', | ||
| 216 | + duration: 2000 | ||
| 217 | + }) | ||
| 214 | } else { | 218 | } else { |
| 215 | favoriteIds.value.push(carId) | 219 | favoriteIds.value.push(carId) |
| 216 | - showToast('收藏成功', 'success') | 220 | + Taro.showToast({ |
| 221 | + title: '收藏成功', | ||
| 222 | + icon: 'success', | ||
| 223 | + duration: 2000 | ||
| 224 | + }) | ||
| 217 | } | 225 | } |
| 218 | } | 226 | } |
| 219 | 227 | ... | ... |
| ... | @@ -258,10 +258,18 @@ const toggleFavorite = (carId) => { | ... | @@ -258,10 +258,18 @@ const toggleFavorite = (carId) => { |
| 258 | const index = favoriteIds.value.indexOf(carId.toString()) | 258 | const index = favoriteIds.value.indexOf(carId.toString()) |
| 259 | if (index > -1) { | 259 | if (index > -1) { |
| 260 | favoriteIds.value.splice(index, 1) | 260 | favoriteIds.value.splice(index, 1) |
| 261 | - showToast('取消收藏', 'success') | 261 | + Taro.showToast({ |
| 262 | + title: '取消收藏', | ||
| 263 | + icon: 'none', | ||
| 264 | + duration: 2000 | ||
| 265 | + }) | ||
| 262 | } else { | 266 | } else { |
| 263 | favoriteIds.value.push(carId.toString()) | 267 | favoriteIds.value.push(carId.toString()) |
| 264 | - showToast('收藏成功', 'success') | 268 | + Taro.showToast({ |
| 269 | + title: '收藏成功', | ||
| 270 | + icon: 'success', | ||
| 271 | + duration: 2000 | ||
| 272 | + }) | ||
| 265 | } | 273 | } |
| 266 | } | 274 | } |
| 267 | 275 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-06-28 10:33:00 | 2 | * @Date: 2025-06-28 10:33:00 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-07-04 16:26:05 | 4 | + * @LastEditTime: 2025-07-04 16:51:27 |
| 5 | * @FilePath: /jgdl/src/pages/index/index.vue | 5 | * @FilePath: /jgdl/src/pages/index/index.vue |
| 6 | * @Description: 捡个电驴首页 | 6 | * @Description: 捡个电驴首页 |
| 7 | --> | 7 | --> |
| ... | @@ -279,8 +279,18 @@ const toggleFavorite = (scooterId) => { | ... | @@ -279,8 +279,18 @@ const toggleFavorite = (scooterId) => { |
| 279 | const index = favoriteIds.value.indexOf(scooterId) | 279 | const index = favoriteIds.value.indexOf(scooterId) |
| 280 | if (index > -1) { | 280 | if (index > -1) { |
| 281 | favoriteIds.value.splice(index, 1) | 281 | favoriteIds.value.splice(index, 1) |
| 282 | + Taro.showToast({ | ||
| 283 | + title: '取消收藏', | ||
| 284 | + icon: 'none', | ||
| 285 | + duration: 2000 | ||
| 286 | + }) | ||
| 282 | } else { | 287 | } else { |
| 283 | favoriteIds.value.push(scooterId) | 288 | favoriteIds.value.push(scooterId) |
| 289 | + Taro.showToast({ | ||
| 290 | + title: '收藏成功', | ||
| 291 | + icon: 'success', | ||
| 292 | + duration: 2000 | ||
| 293 | + }) | ||
| 284 | } | 294 | } |
| 285 | } | 295 | } |
| 286 | 296 | ... | ... |
| ... | @@ -239,10 +239,18 @@ const toggleFavorite = (carId) => { | ... | @@ -239,10 +239,18 @@ const toggleFavorite = (carId) => { |
| 239 | const index = favoriteIds.value.indexOf(carId) | 239 | const index = favoriteIds.value.indexOf(carId) |
| 240 | if (index > -1) { | 240 | if (index > -1) { |
| 241 | favoriteIds.value.splice(index, 1) | 241 | favoriteIds.value.splice(index, 1) |
| 242 | - showToast('取消收藏', 'success') | 242 | + Taro.showToast({ |
| 243 | + title: '取消收藏', | ||
| 244 | + icon: 'none', | ||
| 245 | + duration: 2000 | ||
| 246 | + }) | ||
| 243 | } else { | 247 | } else { |
| 244 | favoriteIds.value.push(carId) | 248 | favoriteIds.value.push(carId) |
| 245 | - showToast('收藏成功', 'success') | 249 | + Taro.showToast({ |
| 250 | + title: '收藏成功', | ||
| 251 | + icon: 'success', | ||
| 252 | + duration: 2000 | ||
| 253 | + }) | ||
| 246 | } | 254 | } |
| 247 | } | 255 | } |
| 248 | 256 | ... | ... |
| ... | @@ -286,8 +286,18 @@ const toggleFavorite = (scooterId) => { | ... | @@ -286,8 +286,18 @@ const toggleFavorite = (scooterId) => { |
| 286 | const index = favoriteIds.value.indexOf(scooterId) | 286 | const index = favoriteIds.value.indexOf(scooterId) |
| 287 | if (index > -1) { | 287 | if (index > -1) { |
| 288 | favoriteIds.value.splice(index, 1) | 288 | favoriteIds.value.splice(index, 1) |
| 289 | + Taro.showToast({ | ||
| 290 | + title: '取消收藏', | ||
| 291 | + icon: 'none', | ||
| 292 | + duration: 2000 | ||
| 293 | + }) | ||
| 289 | } else { | 294 | } else { |
| 290 | favoriteIds.value.push(scooterId) | 295 | favoriteIds.value.push(scooterId) |
| 296 | + Taro.showToast({ | ||
| 297 | + title: '收藏成功', | ||
| 298 | + icon: 'success', | ||
| 299 | + duration: 2000 | ||
| 300 | + }) | ||
| 291 | } | 301 | } |
| 292 | } | 302 | } |
| 293 | 303 | ... | ... |
| ... | @@ -238,10 +238,18 @@ const toggleFavorite = (carId) => { | ... | @@ -238,10 +238,18 @@ const toggleFavorite = (carId) => { |
| 238 | const index = favoriteIds.value.indexOf(carId) | 238 | const index = favoriteIds.value.indexOf(carId) |
| 239 | if (index > -1) { | 239 | if (index > -1) { |
| 240 | favoriteIds.value.splice(index, 1) | 240 | favoriteIds.value.splice(index, 1) |
| 241 | - showToast('取消收藏', 'success') | 241 | + Taro.showToast({ |
| 242 | + title: '取消收藏', | ||
| 243 | + icon: 'none', | ||
| 244 | + duration: 2000 | ||
| 245 | + }) | ||
| 242 | } else { | 246 | } else { |
| 243 | favoriteIds.value.push(carId) | 247 | favoriteIds.value.push(carId) |
| 244 | - showToast('收藏成功', 'success') | 248 | + Taro.showToast({ |
| 249 | + title: '收藏成功', | ||
| 250 | + icon: 'success', | ||
| 251 | + duration: 2000 | ||
| 252 | + }) | ||
| 245 | } | 253 | } |
| 246 | } | 254 | } |
| 247 | 255 | ... | ... |
| ... | @@ -339,8 +339,18 @@ const toggleFavorite = (id) => { | ... | @@ -339,8 +339,18 @@ const toggleFavorite = (id) => { |
| 339 | const index = favoriteIds.value.indexOf(id) | 339 | const index = favoriteIds.value.indexOf(id) |
| 340 | if (index > -1) { | 340 | if (index > -1) { |
| 341 | favoriteIds.value.splice(index, 1) | 341 | favoriteIds.value.splice(index, 1) |
| 342 | + Taro.showToast({ | ||
| 343 | + title: '取消收藏', | ||
| 344 | + icon: 'none', | ||
| 345 | + duration: 2000 | ||
| 346 | + }) | ||
| 342 | } else { | 347 | } else { |
| 343 | favoriteIds.value.push(id) | 348 | favoriteIds.value.push(id) |
| 349 | + Taro.showToast({ | ||
| 350 | + title: '收藏成功', | ||
| 351 | + icon: 'success', | ||
| 352 | + duration: 2000 | ||
| 353 | + }) | ||
| 344 | } | 354 | } |
| 345 | } | 355 | } |
| 346 | 356 | ... | ... |
-
Please register or login to post a comment