Commit cce8706185d759b753edc0a4e0a199a66632e953
1 parent
d354faed
1、添加无搜索结果Toast提示
2、搜索历史修改时出现Bug修复 3、搜索历史UI优化
Showing
2 changed files
with
21 additions
and
8 deletions
src/components/searchHistory/searchHistory.less
| @@ -23,11 +23,11 @@ | @@ -23,11 +23,11 @@ | ||
| 23 | margin-right: 30px; | 23 | margin-right: 30px; |
| 24 | color: #666666; | 24 | color: #666666; |
| 25 | font-size: 26px; | 25 | font-size: 26px; |
| 26 | - width: 150px; | 26 | + width: auto; |
| 27 | height: 58px; | 27 | height: 58px; |
| 28 | border-radius: 10px; | 28 | border-radius: 10px; |
| 29 | float: left; | 29 | float: left; |
| 30 | - &:nth-child(4n) { | 30 | + &:last-child { |
| 31 | margin-right: 0; | 31 | margin-right: 0; |
| 32 | } | 32 | } |
| 33 | .text { | 33 | .text { |
| @@ -35,7 +35,8 @@ | @@ -35,7 +35,8 @@ | ||
| 35 | justify-content: center; | 35 | justify-content: center; |
| 36 | align-items: center; | 36 | align-items: center; |
| 37 | margin: 0 auto; | 37 | margin: 0 auto; |
| 38 | - width: 120px; | 38 | + padding: 0 20px; |
| 39 | + width: auto; | ||
| 39 | height: 58px; | 40 | height: 58px; |
| 40 | white-space: nowrap; | 41 | white-space: nowrap; |
| 41 | text-overflow: ellipsis; | 42 | text-overflow: ellipsis; |
src/pages/search/search.vue
| @@ -143,6 +143,9 @@ | @@ -143,6 +143,9 @@ | ||
| 143 | 143 | ||
| 144 | // 设置标题 | 144 | // 设置标题 |
| 145 | this.$set(this, "title", "搜索"); | 145 | this.$set(this, "title", "搜索"); |
| 146 | + | ||
| 147 | + // 初始化页面 | ||
| 148 | + this.initPage(); | ||
| 146 | }, | 149 | }, |
| 147 | methods: { | 150 | methods: { |
| 148 | 151 | ||
| @@ -314,6 +317,20 @@ | @@ -314,6 +317,20 @@ | ||
| 314 | // 解构数据 | 317 | // 解构数据 |
| 315 | let { data: datas } = res; | 318 | let { data: datas } = res; |
| 316 | 319 | ||
| 320 | + // 设置全部分类搜索 | ||
| 321 | + this.displayPage.value = this.displayPage.status.ALL; | ||
| 322 | + | ||
| 323 | + // 初始化分页页码为0 | ||
| 324 | + this.$set(this.paging, "page", 0); | ||
| 325 | + | ||
| 326 | + // 无搜索结果提示 | ||
| 327 | + if (!datas.goods.length && !datas.shop.length && !datas.foodsShop.length) { | ||
| 328 | + | ||
| 329 | + // 无搜索结果吐司提示 | ||
| 330 | + Toast('未搜索到相关结果'); | ||
| 331 | + return false; | ||
| 332 | + } | ||
| 333 | + | ||
| 317 | /* 获取全局搜索数据 开始 */ | 334 | /* 获取全局搜索数据 开始 */ |
| 318 | 335 | ||
| 319 | // 设置商品数据 | 336 | // 设置商品数据 |
| @@ -355,11 +372,6 @@ | @@ -355,11 +372,6 @@ | ||
| 355 | 372 | ||
| 356 | /* 获取全局搜索数据 结束 */ | 373 | /* 获取全局搜索数据 结束 */ |
| 357 | 374 | ||
| 358 | - // 设置全部分类搜索 | ||
| 359 | - this.displayPage.value = this.displayPage.status.ALL; | ||
| 360 | - | ||
| 361 | - // 初始化分页页码为0 | ||
| 362 | - this.$set(this.paging, "page", 0); | ||
| 363 | } else if (res.code == 400) { | 375 | } else if (res.code == 400) { |
| 364 | 376 | ||
| 365 | // 搜索失败 | 377 | // 搜索失败 |